Changeset 167342 in webkit
- Timestamp:
- Apr 15, 2014 8:45:28 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r167340 r167342 1 2014-04-15 Hyowon Kim <hw1008.kim@samsung.com> 2 3 [EFL] Fix problems with the pixel dump. 4 https://bugs.webkit.org/show_bug.cgi?id=131265 5 6 Reviewed by Gyuyoung Kim. 7 8 Painting and compositing paths of WebKit-EFL were totally modified from r166768. 9 However pixel dump codes still call deprecated functions like ewk_view_paint(), 10 which causes that nothing is drawn. 11 12 This patch adds new member functions to AcceleratedCompositingContext to support pixel dump. 13 One of new functions is AcceleratedCompositingContext::extractImageData(), 14 which replaces deprecated function calls. Besides the extractImageData() is invoked by 15 ewk_view_screenshot_contents_get() in order to take the visible content displayed on the EFL webview. 16 17 * platform/graphics/cairo/CairoUtilities.cpp: 18 (WebCore::flipImageSurfaceVertically): Flip pixel data of given cairo_surface_t vertically up/down. 19 Whereas Cairo uses the top-left corner as being 0,0 of the coordinate system, 20 OpenGL uses the bottom-left corner being 0,0. 21 So we need to vertically flip resultant images taken by glReadPixels(). 22 * platform/graphics/cairo/CairoUtilities.h: 23 1 24 2014-04-15 Hyowon Kim <hw1008.kim@samsung.com> 2 25 -
trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
r167195 r167342 260 260 } 261 261 262 void flipImageSurfaceVertically(cairo_surface_t* surface) 263 { 264 ASSERT(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE); 265 266 IntSize size = cairoSurfaceSize(surface); 267 ASSERT(!size.isEmpty()); 268 269 int stride = cairo_image_surface_get_stride(surface); 270 int halfHeight = size.height() / 2; 271 272 uint8_t* source = static_cast<uint8_t*>(cairo_image_surface_get_data(surface)); 273 std::unique_ptr<uint8_t[]> tmp = std::make_unique<uint8_t[]>(stride); 274 275 for (int i = 0; i < halfHeight; ++i) { 276 uint8_t* top = source + (i * stride); 277 uint8_t* bottom = source + ((size.height()-i-1) * stride); 278 279 memcpy(tmp.get(), top, stride); 280 memcpy(top, bottom, stride); 281 memcpy(bottom, tmp.get(), stride); 282 } 283 } 284 262 285 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h
r167195 r167342 57 57 58 58 IntSize cairoSurfaceSize(cairo_surface_t*); 59 void flipImageSurfaceVertically(cairo_surface_t*); 59 60 60 61 } // namespace WebCore -
trunk/Source/WebKit/efl/ChangeLog
r167185 r167342 1 2014-04-15 Hyowon Kim <hw1008.kim@samsung.com> 2 3 [EFL] Fix problems with the pixel dump. 4 https://bugs.webkit.org/show_bug.cgi?id=131265 5 6 Reviewed by Gyuyoung Kim. 7 8 Painting and compositing paths of WebKit-EFL were totally modified from r166768. 9 However pixel dump codes still call deprecated functions like ewk_view_paint(), 10 which causes that nothing is drawn. 11 12 This patch adds new member functions to AcceleratedCompositingContext to support pixel dump. 13 One of new functions is AcceleratedCompositingContext::extractImageData(), 14 which replaces deprecated function calls. Besides the extractImageData() is invoked by 15 ewk_view_screenshot_contents_get() in order to take the visible content displayed on the EFL webview. 16 17 * WebCoreSupport/AcceleratedCompositingContextEfl.cpp: 18 (WebCore::AcceleratedCompositingContext::AcceleratedCompositingContext): 19 Create TextureMapper with a proper backend. 20 (WebCore::AcceleratedCompositingContext::flushPendingLayerChanges): 21 Revise a null check for m_rootLayer. 22 (WebCore::AcceleratedCompositingContext::paintToGraphicsContext): 23 Remove a creation check for TextureMapperGL. 24 (WebCore::AcceleratedCompositingContext::paintToCurrentGLContext): 25 Ditto. 26 (WebCore::AcceleratedCompositingContext::extractImageData): 27 Extract image data from the view and copy it to given Evas_Object. 28 (WebCore::AcceleratedCompositingContext::getImageData): 29 Get image data from the view and return it as cairo_surface_t on software mode. 30 (WebCore::AcceleratedCompositingContext::getImageDataGL): 31 Get image data from the view and return it as cairo_surface_t on GL mode. 32 * WebCoreSupport/AcceleratedCompositingContextEfl.h: 33 * WebCoreSupport/DumpRenderTreeSupportEfl.cpp: 34 (DumpRenderTreeSupportEfl::forcePaint): Repaint the entire webview before pixel dump. 35 * WebCoreSupport/DumpRenderTreeSupportEfl.h: 36 * ewk/ewk_view.cpp: 37 (ewk_view_mark_for_sync): Remove an unnecessary line. 38 (ewk_view_force_paint): Call flushAndRenderLayers(). 39 (ewk_view_screenshot_contents_get): Remove 'scale' parameter and replace ewk_view_paint() 40 with AcceleratedCompositingContext::extractImageData(). 41 * ewk/ewk_view.h: 42 * ewk/ewk_view_private.h: 43 * tests/test_ewk_view.cpp: 44 (TEST_F): 45 1 46 2014-04-12 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 47 -
trunk/Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.cpp
r166768 r167342 23 23 24 24 #include "AcceleratedCompositingContextEfl.h" 25 #include "CairoUtilities.h" 25 26 #include "CairoUtilitiesEfl.h" 26 27 #include "GraphicsLayerTextureMapper.h" … … 54 55 } 55 56 56 if (!m_evasGLContext) 57 if (m_evasGLContext) { 58 m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode); 59 static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true); 60 } else { 61 m_textureMapper = TextureMapper::create(TextureMapper::SoftwareMode); 57 62 m_isAccelerated = false; 63 } 58 64 } 59 65 … … 123 129 bool AcceleratedCompositingContext::flushPendingLayerChanges() 124 130 { 125 if (!m_rootLayer) 126 return false; 127 128 m_rootLayer->flushCompositingStateForThisLayerOnly(); 131 if (m_rootLayer) 132 m_rootLayer->flushCompositingStateForThisLayerOnly(); 129 133 return EWKPrivate::corePage(m_view)->mainFrame().view()->flushCompositingStateIncludingSubframes(); 130 134 } … … 132 136 void AcceleratedCompositingContext::paintToGraphicsContext() 133 137 { 134 if (!m_textureMapper)135 m_textureMapper = TextureMapper::create(TextureMapper::SoftwareMode);136 137 138 RefPtr<cairo_surface_t> surface = createSurfaceForImage(m_compositingObject); 138 139 if (!surface) … … 148 149 void AcceleratedCompositingContext::paintToCurrentGLContext() 149 150 { 150 if (!m_textureMapper) {151 m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);152 static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);153 }154 155 151 if (!evas_gl_make_current(m_evasGL.get(), m_evasGLSurface->surface(), m_evasGLContext->context())) 156 152 return; … … 190 186 } 191 187 188 void AcceleratedCompositingContext::extractImageData(Evas_Object* buffer, const IntRect& rect) 189 { 190 ASSERT(buffer); 191 192 Evas_Coord width, height; 193 evas_object_image_size_get(buffer, &width, &height); 194 195 ASSERT(rect.width() == width); 196 ASSERT(rect.height() == height); 197 198 RefPtr<cairo_surface_t> imageData; 199 if (m_isAccelerated) { 200 imageData = getImageDataGL(rect); 201 flipImageSurfaceVertically(imageData.get()); 202 } else 203 imageData = getImageData(rect); 204 205 evas_object_image_data_copy_set(buffer, static_cast<void*>(cairo_image_surface_get_data(imageData.get()))); 206 } 207 208 PassRefPtr<cairo_surface_t> AcceleratedCompositingContext::getImageData(const IntRect& rect) 209 { 210 RefPtr<cairo_surface_t> source = createSurfaceForImage(m_compositingObject); 211 evas_object_image_data_set(m_compositingObject, static_cast<void*>(cairo_image_surface_get_data(source.get()))); 212 213 if (m_viewSize == rect.size()) 214 return source.release(); 215 216 RefPtr<cairo_surface_t> destination = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, rect.width(), rect.height())); 217 copyRectFromOneSurfaceToAnother(source.get(), destination.get(), -IntSize(rect.x(), rect.y()), IntRect(IntPoint(), rect.size()), IntSize(), CAIRO_OPERATOR_SOURCE); 218 return destination.release(); 219 } 220 221 PassRefPtr<cairo_surface_t> AcceleratedCompositingContext::getImageDataGL(const IntRect& rect) 222 { 223 if (!evas_gl_make_current(m_evasGL.get(), m_evasGLSurface->surface(), m_evasGLContext->context())) 224 return nullptr; 225 226 RefPtr<cairo_surface_t> source = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, rect.width(), rect.height())); 227 uint8_t* sourcePtr = static_cast<uint8_t*>(cairo_image_surface_get_data(source.get())); 228 229 GraphicsContext3D* context3D = static_cast<TextureMapperGL*>(m_textureMapper.get())->graphicsContext3D(); 230 context3D->readPixels(rect.x(), rect.y(), rect.width(), rect.height(), GraphicsContext3D::BGRA, GraphicsContext3D::UNSIGNED_BYTE, sourcePtr); 231 return source.release(); 232 } 233 192 234 } // namespace WebCore 193 235 -
trunk/Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.h
r166889 r167342 46 46 void flushAndRenderLayers(); 47 47 48 void extractImageData(Evas_Object*, const IntRect&); 49 48 50 private: 49 51 void paintToGraphicsContext(); … … 53 55 bool flushPendingLayerChanges(); 54 56 void syncLayers(Timer<AcceleratedCompositingContext>*); 57 58 PassRefPtr<cairo_surface_t> getImageData(const IntRect&); 59 PassRefPtr<cairo_surface_t> getImageDataGL(const IntRect&); 55 60 56 61 Evas_Object* m_view; -
trunk/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp
r165545 r167342 350 350 } 351 351 352 void DumpRenderTreeSupportEfl::forcePaint(Evas_Object* ewkView) 353 { 354 ewk_view_force_paint(ewkView); 355 } 356 352 357 void DumpRenderTreeSupportEfl::setTracksRepaints(Evas_Object* ewkFrame, bool enabled) 353 358 { -
trunk/Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h
r166149 r167342 84 84 85 85 static void forceLayout(Evas_Object* ewkFrame); 86 static void forcePaint(Evas_Object* ewkFrame); 86 87 static void setTracksRepaints(Evas_Object* ewkFrame, bool enabled); 87 88 static void resetTrackedRepaints(Evas_Object* ewkFrame); -
trunk/Source/WebKit/efl/ewk/ewk_view.cpp
r166915 r167342 4413 4413 { 4414 4414 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); 4415 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);4416 4415 4417 4416 // Mark the image as "dirty" meaning it needs an update next time evas renders. 4418 4417 // It will call the pixel get callback then. 4419 4418 evas_object_image_pixels_dirty_set(smartData->image, true); 4419 } 4420 4421 void ewk_view_force_paint(Evas_Object* ewkView) 4422 { 4423 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); 4424 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); 4425 4426 priv->acceleratedCompositingContext->flushAndRenderLayers(); 4420 4427 } 4421 4428 … … 4544 4551 } 4545 4552 4546 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, const Eina_Rectangle* area , float scale)4553 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, const Eina_Rectangle* area) 4547 4554 { 4548 4555 if (!area || !area->w || !area->h) { … … 4551 4558 } 4552 4559 4553 if (scale < std::numeric_limits<float>::epsilon()) {4554 ERR("scale factor should be bigger than zero");4555 return 0;4556 }4557 4558 4560 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); 4559 4561 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); … … 4563 4565 4564 4566 Evas_Object* screenshotImage = evas_object_image_add(canvas); 4565 int surfaceWidth = area->w * scale; 4566 int surfaceHeight = area->h * scale; 4567 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight); 4568 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight); 4569 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight); 4567 evas_object_image_size_set(screenshotImage, area->w, area->h); 4568 evas_object_image_fill_set(screenshotImage, 0, 0, area->w, area->h); 4569 evas_object_resize(screenshotImage, area->w, area->h); 4570 4570 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888); 4571 evas_object_image_smooth_scale_set(screenshotImage, true); 4572 4573 Ewk_Paint_Context* context = ewk_paint_context_from_image_new(screenshotImage); 4574 ewk_paint_context_save(context); 4575 ewk_paint_context_scale(context, scale, scale); 4576 ewk_paint_context_translate(context, -1 * area->x, -1 * area->y); 4577 4578 ewk_view_paint(priv, context, area); 4579 4580 ewk_paint_context_restore(context); 4581 ewk_paint_context_free(context); 4571 4572 priv->acceleratedCompositingContext->extractImageData(screenshotImage, WebCore::IntRect(*area)); 4582 4573 4583 4574 return screenshotImage; -
trunk/Source/WebKit/efl/ewk/ewk_view.h
r166637 r167342 2487 2487 2488 2488 /** 2489 * Gets the image object of the specified area of the page2489 * Gets the image object of the specified area of the view. 2490 2490 * 2491 2491 * The returned image object @b should be freed after use. 2492 2492 * 2493 2493 * @param o view object to be captured 2494 * @param area The area of the page will be captured. 2495 * @param scale scale factor of captured object. 2494 * @param area The area of the view will be captured. 2496 2495 * 2497 2496 * @return newly allocated image object on sucess or @c NULL on failure. 2498 2497 */ 2499 EAPI Evas_Object *ewk_view_screenshot_contents_get(const Evas_Object *o, const Eina_Rectangle *area , float scale);2498 EAPI Evas_Object *ewk_view_screenshot_contents_get(const Evas_Object *o, const Eina_Rectangle *area); 2500 2499 2501 2500 #ifdef __cplusplus -
trunk/Source/WebKit/efl/ewk/ewk_view_private.h
r165428 r167342 153 153 void ewk_view_mark_for_sync(Evas_Object* ewkView); 154 154 155 void ewk_view_force_paint(Evas_Object* ewkView); 156 155 157 #if ENABLE(FULLSCREEN_API) 156 158 void ewk_view_fullscreen_enter(const Evas_Object* ewkView); -
trunk/Source/WebKit/efl/tests/test_ewk_view.cpp
r164168 r167342 133 133 Evas_Coord width, height; 134 134 135 float scale = 2;136 135 Eina_Rectangle area; 137 136 area.x = 10; … … 139 138 area.w = 20; 140 139 area.h = 30; 141 Evas_Object* screenshot = ewk_view_screenshot_contents_get(webView(), &area , scale);140 Evas_Object* screenshot = ewk_view_screenshot_contents_get(webView(), &area); 142 141 evas_object_geometry_get(screenshot, 0, 0, &width, &height); 143 ASSERT_EQ(area.w * scale, width);144 ASSERT_EQ(area.h * scale, height);142 ASSERT_EQ(area.w, width); 143 ASSERT_EQ(area.h, height); 145 144 evas_object_del(screenshot); 146 145 147 screenshot = ewk_view_screenshot_contents_get(webView(), &area, 0); 148 ASSERT_FALSE(screenshot); 149 150 screenshot = ewk_view_screenshot_contents_get(webView(), 0, 1); 146 screenshot = ewk_view_screenshot_contents_get(webView(), 0); 151 147 ASSERT_FALSE(screenshot); 152 148 153 149 area.w = 0; 154 150 area.h = 0; 155 screenshot = ewk_view_screenshot_contents_get(webView(), &area , scale);151 screenshot = ewk_view_screenshot_contents_get(webView(), &area); 156 152 ASSERT_FALSE(screenshot); 157 153 } -
trunk/Tools/ChangeLog
r167334 r167342 1 2014-04-15 Hyowon Kim <hw1008.kim@samsung.com> 2 3 [EFL] Fix problems with the pixel dump. 4 https://bugs.webkit.org/show_bug.cgi?id=131265 5 6 Reviewed by Gyuyoung Kim. 7 8 Painting and compositing paths of WebKit-EFL were totally modified from r166768. 9 However pixel dump codes still call deprecated functions like ewk_view_paint(), 10 which causes that nothing is drawn. 11 12 This patch adds new member functions to AcceleratedCompositingContext to support pixel dump. 13 One of new functions is AcceleratedCompositingContext::extractImageData(), 14 which replaces deprecated function calls. Besides the extractImageData() is invoked by 15 ewk_view_screenshot_contents_get() in order to take the visible content displayed on the EFL webview. 16 17 * DumpRenderTree/efl/PixelDumpSupportEfl.cpp: 18 (createBitmapContextFromWebView): Add to call DumpRenderTreeSupportEfl::forcePaint(). 19 1 20 2014-04-15 Filip Pizlo <fpizlo@apple.com> 2 21 -
trunk/Tools/DumpRenderTree/efl/PixelDumpSupportEfl.cpp
r165676 r167342 48 48 const Evas_Object* mainFrame = browser->mainFrame(); 49 49 50 DumpRenderTreeSupportEfl::forcePaint(browser->mainView()); 51 50 52 int x, y, width, height; 51 53 evas_object_geometry_get(browser->mainFrame(), &x, &y, &width, &height); … … 55 57 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get())); 56 58 57 RefPtr<Evas_Object> screenshot = ewk_view_screenshot_contents_get(browser->mainView(), &rect , 1);59 RefPtr<Evas_Object> screenshot = ewk_view_screenshot_contents_get(browser->mainView(), &rect); 58 60 if (!screenshot) 59 61 return 0;
Note: See TracChangeset
for help on using the changeset viewer.