Diff
Modified: trunk/Source/WebKit2/ChangeLog (138461 => 138462)
--- trunk/Source/WebKit2/ChangeLog 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Source/WebKit2/ChangeLog 2012-12-25 12:28:33 UTC (rev 138462)
@@ -1,3 +1,36 @@
+2012-12-25 Christophe Dumez <[email protected]>
+
+ [EFL][WK2] Refactor snapshot taking code
+ https://bugs.webkit.org/show_bug.cgi?id=105687
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Refactor EFL WK2 snapshot taking code to use
+ smart pointers when possible and follow naming
+ conventions.
+
+ * UIProcess/API/C/efl/WKView.cpp:
+ (WKViewCreateSnapshot):
+ * UIProcess/API/C/efl/WKView.h: Rename WKViewGetSnapshot
+ to WKViewCreateSnapshot to follow C API naming conventions,
+ since the returned value needs to be adopted.
+ * UIProcess/API/efl/EwkViewImpl.cpp:
+ (EwkViewImpl::takeSnapshot):
+ * UIProcess/API/efl/EwkViewImpl.h: Have takeSnapshot() return
+ a cairo_surface_t instead of a WKType. The value should be
+ converted to a WKType at C API level.
+ (EwkViewImpl):
+ * UIProcess/API/efl/SnapshotImageGL.cpp: Use OwnArrayPtr for the
+ buffer to avoid manual memory handling. Remove useless call to
+ glBindTexture() since glReadPixels() reads pixels from the frame
+ buffer, not from the texture.
+ (getImageDataFromFrameBuffer):
+ * UIProcess/API/efl/SnapshotImageGL.h: Rename getImageFromCurrentTexture
+ to getImageDataFromFrameBuffer for consistency since we technically
+ return the pixel data of the image and since glReadPixels does not
+ actually read from the texture. Have the function return a smart
+ pointer instead of a raw one to avoid manual memory handling.
+
2012-12-25 Tim Horton <[email protected]>
PDFPlugin: Find-in-page
Modified: trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp (138461 => 138462)
--- trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp 2012-12-25 12:28:33 UTC (rev 138462)
@@ -23,6 +23,7 @@
#include "EwkViewImpl.h"
#include "WKAPICast.h"
#include "ewk_view_private.h"
+#include <WebKit2/WKImageCairo.h>
using namespace WebKit;
@@ -43,9 +44,9 @@
return viewImpl->wkPage();
}
-WKImageRef WKViewGetSnapshot(WKViewRef viewRef)
+WKImageRef WKViewCreateSnapshot(WKViewRef viewRef)
{
EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(toImpl(viewRef));
- return viewImpl->takeSnapshot();
+ return WKImageCreateFromCairoSurface(viewImpl->takeSnapshot().get(), 0 /* options */);
}
Modified: trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.h (138461 => 138462)
--- trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.h 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.h 2012-12-25 12:28:33 UTC (rev 138462)
@@ -38,7 +38,7 @@
WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
-WK_EXPORT WKImageRef WKViewGetSnapshot(WKViewRef viewRef);
+WK_EXPORT WKImageRef WKViewCreateSnapshot(WKViewRef viewRef);
#ifdef __cplusplus
}
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp (138461 => 138462)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp 2012-12-25 12:28:33 UTC (rev 138462)
@@ -1029,21 +1029,17 @@
viewImpl->informIconChange();
}
-WKImageRef EwkViewImpl::takeSnapshot()
+PassRefPtr<cairo_surface_t> EwkViewImpl::takeSnapshot()
{
Ewk_View_Smart_Data* sd = smartData();
#if USE(ACCELERATED_COMPOSITING)
if (!m_isHardwareAccelerated)
#endif
- return WKImageCreateFromCairoSurface(createSurfaceForImage(sd->image).get(), 0);
+ return createSurfaceForImage(sd->image).get();
#if USE(ACCELERATED_COMPOSITING)
- Evas_Native_Surface* nativeSurface = evas_object_image_native_surface_get(sd->image);
- unsigned char* buffer = getImageFromCurrentTexture(sd->view.w, sd->view.h, nativeSurface->data.opengl.texture_id);
- RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, sd->view.w, sd->view.h, sd->view.w * 4));
- WKImageRef image = WKImageCreateFromCairoSurface(surface.get(), 0);
- delete[] buffer;
+ OwnArrayPtr<unsigned char> buffer = getImageDataFromFrameBuffer(0, 0, sd->view.w, sd->view.h);
- return image;
+ return adoptRef(cairo_image_surface_create_for_data(buffer.get(), CAIRO_FORMAT_ARGB32, sd->view.w, sd->view.h, sd->view.w * 4));
#endif
}
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h (138461 => 138462)
--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h 2012-12-25 12:28:33 UTC (rev 138462)
@@ -31,6 +31,7 @@
#include <Evas.h>
#include <WebCore/FloatPoint.h>
#include <WebCore/IntRect.h>
+#include <WebCore/RefPtrCairo.h>
#include <WebCore/TextDirection.h>
#include <WebCore/Timer.h>
#include <WebKit2/WKBase.h>
@@ -214,7 +215,7 @@
bool isHardwareAccelerated() const { return m_isHardwareAccelerated; }
void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
- WKImageRef takeSnapshot();
+ PassRefPtr<cairo_surface_t> takeSnapshot();
private:
#if USE(ACCELERATED_COMPOSITING)
Modified: trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp (138461 => 138462)
--- trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp 2012-12-25 12:28:33 UTC (rev 138462)
@@ -34,25 +34,23 @@
#include "OpenGLShims.h"
#endif
-unsigned char* getImageFromCurrentTexture(int width, int height, int textureId)
+PassOwnArrayPtr<unsigned char> getImageDataFromFrameBuffer(int x, int y, int width, int height)
{
- glBindTexture(GL_TEXTURE_2D, textureId);
- unsigned char* buffer = new unsigned char[width * height * 4];
- glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
+ OwnArrayPtr<unsigned char> buffer = adoptArrayPtr(new unsigned char[width * height * 4]);
+ glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer.get());
// Textures are flipped on the Y axis, so we need to flip the image back.
- unsigned tmp;
- unsigned* buf = reinterpret_cast<unsigned*>(buffer);
+ unsigned* buf = reinterpret_cast<unsigned*>(buffer.get());
for (int i = 0; i < height / 2; ++i) {
for (int j = 0; j < width; ++j) {
- tmp = buf[i * width + j];
+ unsigned tmp = buf[i * width + j];
buf[i * width + j] = buf[(height - i - 1) * width + j];
buf[(height - i - 1) * width + j] = tmp;
}
}
- return buffer;
+ return buffer.release();
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h (138461 => 138462)
--- trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h 2012-12-25 12:28:33 UTC (rev 138462)
@@ -26,8 +26,10 @@
#ifndef SnapshotImageGL_h
#define SnapshotImageGL_h
+#include <wtf/OwnArrayPtr.h>
+
#if USE(ACCELERATED_COMPOSITING)
-unsigned char* getImageFromCurrentTexture(int width, int height, int textureId);
+PassOwnArrayPtr<unsigned char> getImageDataFromFrameBuffer(int x, int y, int width, int height);
#endif
#endif // SnapshotImageGL_h
Modified: trunk/Tools/ChangeLog (138461 => 138462)
--- trunk/Tools/ChangeLog 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Tools/ChangeLog 2012-12-25 12:28:33 UTC (rev 138462)
@@ -1,3 +1,16 @@
+2012-12-25 Christophe Dumez <[email protected]>
+
+ [EFL][WK2] Refactor snapshot taking code
+ https://bugs.webkit.org/show_bug.cgi?id=105687
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Call WKViewCreateSnapshot() instead of WKViewGetSnapshot()
+ since the function was renamed to follow naming style.
+
+ * WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
+ (WTR::PlatformWebView::windowSnapshotImage):
+
2012-12-24 Ilya Tikhonovsky <[email protected]>
Web Inspector: Native Memory Instrumentation: propagate member type as edge type to the serialized heap graph.
Modified: trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp (138461 => 138462)
--- trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp 2012-12-25 11:08:22 UTC (rev 138461)
+++ trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp 2012-12-25 12:28:33 UTC (rev 138462)
@@ -135,7 +135,7 @@
ecore_evas_geometry_get(ee, 0, 0, &width, &height);
ASSERT(width > 0 && height > 0);
- return adoptWK(WKViewGetSnapshot(toAPI(m_view)));
+ return adoptWK(WKViewCreateSnapshot(toAPI(m_view)));
}
bool PlatformWebView::viewSupportsOptions(WKDictionaryRef options) const