From ee47232fc17f31ef2bd95ca480372216a79def56 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 4 May 2018 12:00:53 -0400 Subject: Use Surface for screen capture in Renderer interface (#551) * Remove serialization of screen captures from a renderer implementation, capture now writes to a Surface. Then client code can decide to serialize (or use as needed). * Improved comment for captureScreenSurface. --- tools/render-test/surface.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tools/render-test/surface.cpp') diff --git a/tools/render-test/surface.cpp b/tools/render-test/surface.cpp index 3f96052ce..4d761389a 100644 --- a/tools/render-test/surface.cpp +++ b/tools/render-test/surface.cpp @@ -188,4 +188,35 @@ void Surface::flipInplaceVertically() } } +SlangResult Surface::set(int width, int height, Format format, int srcRowStride, const void* data, SurfaceAllocator* allocator) +{ + if (hasContents() && m_width == width && m_height == height && m_format == format) + { + // I can just overwrite the contents that is there + } + else + { + SLANG_RETURN_ON_FAIL(allocate(width, height, format, 0, allocator)); + } + + // Okay just need to set the contents + + { + const size_t rowSize = calcRowSize(format, width); + + const uint8_t* srcRow = (const uint8_t*)data; + uint8_t* dstRow = (uint8_t*)m_data; + + for (int i = 0; i < m_numRows; i++) + { + ::memcpy(dstRow, srcRow, rowSize); + + srcRow += srcRowStride; + dstRow += m_rowStrideInBytes; + } + } + + return SLANG_OK; +} + } // renderer_test -- cgit v1.2.3