- Revision
- 138518
- Author
- [email protected]
- Date
- 2012-12-27 18:45:13 -0800 (Thu, 27 Dec 2012)
Log Message
[EFL][WK2] Regression(138462) Sometimes garbage in snapshots
https://bugs.webkit.org/show_bug.cgi?id=105803
Patch by Viatcheslav Ostapenko <[email protected]> on 2012-12-27
Reviewed by Kenneth Rohde Christiansen.
Instead of creating temporary buffer and then creating cairo surface
from it, create cairo surface 1st and use surface image internal buffer
to read pixels from GL buffer.
* UIProcess/API/efl/EwkViewImpl.cpp:
(EwkViewImpl::takeSnapshot):
* UIProcess/API/efl/SnapshotImageGL.cpp:
(getImageSurfaceFromFrameBuffer):
* UIProcess/API/efl/SnapshotImageGL.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (138517 => 138518)
--- trunk/Source/WebKit2/ChangeLog 2012-12-28 00:39:48 UTC (rev 138517)
+++ trunk/Source/WebKit2/ChangeLog 2012-12-28 02:45:13 UTC (rev 138518)
@@ -1,3 +1,20 @@
+2012-12-27 Viatcheslav Ostapenko <[email protected]>
+
+ [EFL][WK2] Regression(138462) Sometimes garbage in snapshots
+ https://bugs.webkit.org/show_bug.cgi?id=105803
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Instead of creating temporary buffer and then creating cairo surface
+ from it, create cairo surface 1st and use surface image internal buffer
+ to read pixels from GL buffer.
+
+ * UIProcess/API/efl/EwkViewImpl.cpp:
+ (EwkViewImpl::takeSnapshot):
+ * UIProcess/API/efl/SnapshotImageGL.cpp:
+ (getImageSurfaceFromFrameBuffer):
+ * UIProcess/API/efl/SnapshotImageGL.h:
+
2012-12-27 Sam Weinig <[email protected]>
Actually make use of the WebProcessSupplements by adding a supplement map to WebProcess
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp (138517 => 138518)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp 2012-12-28 00:39:48 UTC (rev 138517)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp 2012-12-28 02:45:13 UTC (rev 138518)
@@ -1050,8 +1050,7 @@
#if USE(ACCELERATED_COMPOSITING)
}
- OwnArrayPtr<unsigned char> buffer = getImageDataFromFrameBuffer(0, 0, sd->view.w, sd->view.h);
- RefPtr<cairo_surface_t> snapshot = adoptRef(cairo_image_surface_create_for_data(buffer.get(), CAIRO_FORMAT_ARGB32, sd->view.w, sd->view.h, sd->view.w * 4));
+ RefPtr<cairo_surface_t> snapshot = getImageSurfaceFromFrameBuffer(0, 0, sd->view.w, sd->view.h);
// Resume all animations.
m_pageProxy->resumeActiveDOMObjectsAndAnimations();
Modified: trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp (138517 => 138518)
--- trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp 2012-12-28 00:39:48 UTC (rev 138517)
+++ trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp 2012-12-28 02:45:13 UTC (rev 138518)
@@ -34,13 +34,17 @@
#include "OpenGLShims.h"
#endif
-PassOwnArrayPtr<unsigned char> getImageDataFromFrameBuffer(int x, int y, int width, int height)
+#include <WebCore/CairoUtilitiesEfl.h>
+
+PassRefPtr<cairo_surface_t> getImageSurfaceFromFrameBuffer(int x, int y, int width, int height)
{
- OwnArrayPtr<unsigned char> buffer = adoptArrayPtr(new unsigned char[width * height * 4]);
- glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer.get());
+ RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height));
+ unsigned char* data = ""
+ glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, data);
+
// Textures are flipped on the Y axis, so we need to flip the image back.
- unsigned* buf = reinterpret_cast<unsigned*>(buffer.get());
+ unsigned* buf = reinterpret_cast<unsigned*>(data);
for (int i = 0; i < height / 2; ++i) {
for (int j = 0; j < width; ++j) {
@@ -50,7 +54,8 @@
}
}
- return buffer.release();
+ cairo_surface_mark_dirty(newSurface.get());
+ return newSurface;
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h (138517 => 138518)
--- trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h 2012-12-28 00:39:48 UTC (rev 138517)
+++ trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h 2012-12-28 02:45:13 UTC (rev 138518)
@@ -26,10 +26,11 @@
#ifndef SnapshotImageGL_h
#define SnapshotImageGL_h
+#include <RefPtrCairo.h>
#include <wtf/OwnArrayPtr.h>
#if USE(ACCELERATED_COMPOSITING)
-PassOwnArrayPtr<unsigned char> getImageDataFromFrameBuffer(int x, int y, int width, int height);
+PassRefPtr<cairo_surface_t> getImageSurfaceFromFrameBuffer(int x, int y, int width, int height);
#endif
#endif // SnapshotImageGL_h