https://bugs.webkit.org/show_bug.cgi?id=111333
Patch by Kondapally Kalyan <kalyan.kondapally@intel.com> 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
+2013-03-05 Kondapally Kalyan <kalyan.kondapally@intel.com>
+
+ [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 <ggaren@apple.com>
Each web process truncates the disk cache to zero on launch
2013-03-05 Geoffrey Garen <ggaren@apple.com>
Each web process truncates the disk cache to zero on launch
RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height));
unsigned char* data = cairo_image_surface_get_data(newSurface.get());
RefPtr<cairo_surface_t> 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<unsigned*>(data);
// Textures are flipped on the Y axis, so we need to flip the image back.
unsigned* buf = reinterpret_cast<unsigned*>(data);