From 71894fd95a00eda75d56030202b21d0c19b9107d Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Wed, 6 Mar 2013 07:37:08 +0000 Subject: [PATCH] [EFL] Ensure right format is used in SnapshotImageGL. https://bugs.webkit.org/show_bug.cgi?id=111333 Patch by Kondapally Kalyan on 2013-03-05 Reviewed by Benjamin Poulain. GL_BGRA format is not standard for glReadPixels with GLES. This patch ensures that GL_RGBA is used in SnapshotImageGL while using GLES. * UIProcess/API/efl/SnapshotImageGL.cpp: (getImageSurfaceFromFrameBuffer): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144887 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebKit2/ChangeLog | 14 ++++++++++++++ Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index d4ddba1..bc87064 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,17 @@ +2013-03-05 Kondapally Kalyan + + [EFL] Ensure right format is used in SnapshotImageGL. + https://bugs.webkit.org/show_bug.cgi?id=111333 + + Reviewed by Benjamin Poulain. + + GL_BGRA format is not standard for glReadPixels with GLES. + This patch ensures that GL_RGBA is used in SnapshotImageGL + while using GLES. + + * UIProcess/API/efl/SnapshotImageGL.cpp: + (getImageSurfaceFromFrameBuffer): + 2013-03-05 Geoffrey Garen Each web process truncates the disk cache to zero on launch diff --git a/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp b/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp index 9b726cd..efd2619 100644 --- a/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp +++ b/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp @@ -40,7 +40,21 @@ PassRefPtr getImageSurfaceFromFrameBuffer(int x, int y, int wid RefPtr newSurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height)); unsigned char* data = cairo_image_surface_get_data(newSurface.get()); - glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, data); +#if USE(OPENGL_ES_2) + GLenum format = GL_RGBA; +#else + GLenum format = GL_BGRA; +#endif + + glReadPixels(x, y, width, height, format, GL_UNSIGNED_BYTE, data); + +#if USE(OPENGL_ES_2) + // Convert to BGRA. + int totalBytes = width * height * 4; + + for (int i = 0; i < totalBytes; i += 4) + std::swap(data[i], data[i + 2]); +#endif // Textures are flipped on the Y axis, so we need to flip the image back. unsigned* buf = reinterpret_cast(data); -- 1.8.3.1