Commit 5505bdc7 by Geoff Lang Committed by Commit Bot

Fix Win32Window::takeScreenshot.

Several parts of this function were incorrectly checking for errors or passing the wrong parameters. If screenshotting fails, throw an exception in dEQP so that it is converted to a test failure instead of hanging the test. BUG=angleproject:2075 Change-Id: I19b55b273d0d3f1b47c1dac6affca69de8db21e0 Reviewed-on: https://chromium-review.googlesource.com/587300 Commit-Queue: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b5cc1198
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
1662 WIN : dEQP-EGL.functional.render.multi_context.gles2_gles3.other = FAIL 1662 WIN : dEQP-EGL.functional.render.multi_context.gles2_gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.render.multi_thread.gles2.other = FAIL 1662 WIN : dEQP-EGL.functional.render.multi_thread.gles2.other = FAIL
1662 WIN : dEQP-EGL.functional.render.multi_thread.gles3.other = FAIL 1662 WIN : dEQP-EGL.functional.render.multi_thread.gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.swap_buffers.other = FAIL
1662 WIN : dEQP-EGL.functional.native_coord_mapping.native_window.other_clear = FAIL 1662 WIN : dEQP-EGL.functional.native_coord_mapping.native_window.other_clear = FAIL
1662 WIN : dEQP-EGL.functional.native_coord_mapping.native_window.other_render = FAIL 1662 WIN : dEQP-EGL.functional.native_coord_mapping.native_window.other_render = FAIL
1662 WIN : dEQP-EGL.functional.query_context.get_current_context.other = FAIL 1662 WIN : dEQP-EGL.functional.query_context.get_current_context.other = FAIL
...@@ -206,21 +205,6 @@ ...@@ -206,21 +205,6 @@
1340 WIN : dEQP-EGL.functional.negative_api.get_display = FAIL 1340 WIN : dEQP-EGL.functional.negative_api.get_display = FAIL
1340 WIN : dEQP-EGL.functional.negative_api.surface_attrib = SKIP 1340 WIN : dEQP-EGL.functional.negative_api.surface_attrib = SKIP
1340 WIN : dEQP-EGL.functional.negative_api.swap_interval = FAIL 1340 WIN : dEQP-EGL.functional.negative_api.swap_interval = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgb565_no_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgb565_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgb565_depth_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgb888_no_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgb888_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgb888_depth_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba4444_no_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba4444_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba4444_depth_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba5551_no_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba5551_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba5551_depth_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba8888_no_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba8888_depth_no_stencil = FAIL
1340 WIN : dEQP-EGL.functional.swap_buffers.rgba8888_depth_stencil = FAIL
1340 WIN : dEQP-EGL.functional.native_color_mapping.native_window.rgb565_no_depth_no_stencil_clear = FAIL 1340 WIN : dEQP-EGL.functional.native_color_mapping.native_window.rgb565_no_depth_no_stencil_clear = FAIL
1340 WIN : dEQP-EGL.functional.native_color_mapping.native_window.rgb565_no_depth_no_stencil_render = FAIL 1340 WIN : dEQP-EGL.functional.native_color_mapping.native_window.rgb565_no_depth_no_stencil_render = FAIL
1340 WIN : dEQP-EGL.functional.native_color_mapping.native_window.rgb565_depth_no_stencil_clear = FAIL 1340 WIN : dEQP-EGL.functional.native_color_mapping.native_window.rgb565_depth_no_stencil_clear = FAIL
......
...@@ -302,9 +302,10 @@ void NativeWindow::setSurfaceSize(IVec2 size) ...@@ -302,9 +302,10 @@ void NativeWindow::setSurfaceSize(IVec2 size)
void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
{ {
dst->setStorage(TextureFormat(TextureFormat::BGRA, TextureFormat::UNORM_INT8), mWindow->getWidth(), mWindow->getHeight()); dst->setStorage(TextureFormat(TextureFormat::BGRA, TextureFormat::UNORM_INT8), mWindow->getWidth(), mWindow->getHeight());
bool success = mWindow->takeScreenshot(reinterpret_cast<uint8_t*>(dst->getAccess().getDataPtr())); if (!mWindow->takeScreenshot(reinterpret_cast<uint8_t *>(dst->getAccess().getDataPtr())))
DE_ASSERT(success); {
DE_UNREF(success); throw InternalError("Failed to read screen pixels", DE_NULL, __FILE__, __LINE__);
}
} }
} // anonymous } // anonymous
......
...@@ -627,7 +627,7 @@ bool Win32Window::takeScreenshot(uint8_t *pixelData) ...@@ -627,7 +627,7 @@ bool Win32Window::takeScreenshot(uint8_t *pixelData)
if (!error) if (!error)
{ {
screenDC = GetDC(nullptr); screenDC = GetDC(HWND_DESKTOP);
error = screenDC == nullptr; error = screenDC == nullptr;
} }
...@@ -649,18 +649,20 @@ bool Win32Window::takeScreenshot(uint8_t *pixelData) ...@@ -649,18 +649,20 @@ bool Win32Window::takeScreenshot(uint8_t *pixelData)
error = tmpBitmap == nullptr; error = tmpBitmap == nullptr;
} }
RECT rect = {0, 0, 0, 0}; POINT topLeft = {0, 0};
if (!error) if (!error)
{ {
MapWindowPoints(mNativeWindow, nullptr, reinterpret_cast<LPPOINT>(&rect), 0); error = (MapWindowPoints(mNativeWindow, HWND_DESKTOP, &topLeft, 1) == 0);
}
if (!error)
{
error = SelectObject(tmpDC, tmpBitmap) == nullptr; error = SelectObject(tmpDC, tmpBitmap) == nullptr;
} }
if (!error) if (!error)
{ {
error = error = BitBlt(tmpDC, 0, 0, mWidth, mHeight, screenDC, topLeft.x, topLeft.y, SRCCOPY) == 0;
BitBlt(tmpDC, 0, 0, mWidth, mHeight, screenDC, rect.left, rect.top, SRCCOPY) == TRUE;
} }
if (!error) if (!error)
...@@ -679,7 +681,7 @@ bool Win32Window::takeScreenshot(uint8_t *pixelData) ...@@ -679,7 +681,7 @@ bool Win32Window::takeScreenshot(uint8_t *pixelData)
bitmapInfo.biClrImportant = 0; bitmapInfo.biClrImportant = 0;
int getBitsResult = GetDIBits(screenDC, tmpBitmap, 0, mHeight, pixelData, int getBitsResult = GetDIBits(screenDC, tmpBitmap, 0, mHeight, pixelData,
reinterpret_cast<BITMAPINFO *>(&bitmapInfo), DIB_RGB_COLORS); reinterpret_cast<BITMAPINFO *>(&bitmapInfo), DIB_RGB_COLORS);
error = getBitsResult != 0; error = (getBitsResult == 0);
} }
if (tmpBitmap != nullptr) if (tmpBitmap != nullptr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment