Title: [134247] trunk/Source
Revision
134247
Author
[email protected]
Date
2012-11-12 09:34:46 -0800 (Mon, 12 Nov 2012)

Log Message

[EFL][WK2][AC] Black screen when applications use software backend.
https://bugs.webkit.org/show_bug.cgi?id=101659

Patch by Yael Aharon <[email protected]> on 2012-11-12
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Add a utility method to create a cairo_surface_t from a given Evas_Object_Image.

No new tests. Will be covered when running existing tests without enabling openGL.

* platform/graphics/efl/CairoUtilitiesEfl.cpp:
(WebCore::createSurfaceForImage):
(WebCore):
* platform/graphics/efl/CairoUtilitiesEfl.h:
(WebCore):

Source/WebKit2:

If creating openGL context fails, automatically fallback to software rendering.

* UIProcess/API/efl/EwkViewImpl.cpp:
(EwkViewImpl::EwkViewImpl):
(EwkViewImpl::displayTimerFired):
(EwkViewImpl::createGLSurface):
(EwkViewImpl::enterAcceleratedCompositingMode):
* UIProcess/API/efl/EwkViewImpl.h:
(EwkViewImpl::hardwareAccelerationEnabled):
(EwkViewImpl):
* UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
(WebKit::LayerTreeRenderer::LayerTreeRenderer):
(WebKit::LayerTreeRenderer::ensureRootLayer):
* UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
(WebKit::LayerTreeRenderer::setAccelerationMode):
(LayerTreeRenderer):
* UIProcess/efl/PageClientBase.cpp:
(WebKit::PageClientBase::createDrawingAreaProxy):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134246 => 134247)


--- trunk/Source/WebCore/ChangeLog	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebCore/ChangeLog	2012-11-12 17:34:46 UTC (rev 134247)
@@ -1,3 +1,20 @@
+2012-11-12  Yael Aharon  <[email protected]>
+
+        [EFL][WK2][AC] Black screen when applications use software backend.
+        https://bugs.webkit.org/show_bug.cgi?id=101659
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add a utility method to create a cairo_surface_t from a given Evas_Object_Image.
+
+        No new tests. Will be covered when running existing tests without enabling openGL.
+
+        * platform/graphics/efl/CairoUtilitiesEfl.cpp:
+        (WebCore::createSurfaceForImage):
+        (WebCore):
+        * platform/graphics/efl/CairoUtilitiesEfl.h:
+        (WebCore):
+
 2012-11-12  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix make distcheck.

Modified: trunk/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.cpp (134246 => 134247)


--- trunk/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.cpp	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.cpp	2012-11-12 17:34:46 UTC (rev 134247)
@@ -106,4 +106,25 @@
     return surface;
 }
 
+PassRefPtr<cairo_surface_t> createSurfaceForImage(Evas_Object* image)
+{
+    ASSERT(image);
+
+    Evas_Coord width;
+    Evas_Coord height;
+    evas_object_image_size_get(image, &width, &height);
+    ASSERT(width > 0 && height > 0);
+
+    unsigned char* buffer = static_cast<unsigned char*>(const_cast<void*>(evas_object_image_data_get(image, true)));
+    RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, width, height, width * 4));
+
+    cairo_status_t status = cairo_surface_status(surface.get());
+    if (status != CAIRO_STATUS_SUCCESS) {
+        EINA_LOG_ERR("Could not create cairo surface: %s", cairo_status_to_string(status));
+        return 0;
+    }
+
+    return surface.release();
 }
+
+}

Modified: trunk/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.h (134246 => 134247)


--- trunk/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.h	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.h	2012-11-12 17:34:46 UTC (rev 134247)
@@ -31,6 +31,7 @@
 
 PassRefPtr<Evas_Object> evasObjectFromCairoImageSurface(Evas* canvas, cairo_surface_t*);
 PassRefPtr<cairo_surface_t> createSurfaceForBackingStore(Ecore_Evas* ee);
+PassRefPtr<cairo_surface_t> createSurfaceForImage(Evas_Object* image);
 
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (134246 => 134247)


--- trunk/Source/WebKit2/ChangeLog	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-12 17:34:46 UTC (rev 134247)
@@ -1,3 +1,29 @@
+2012-11-12  Yael Aharon  <[email protected]>
+
+        [EFL][WK2][AC] Black screen when applications use software backend.
+        https://bugs.webkit.org/show_bug.cgi?id=101659
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        If creating openGL context fails, automatically fallback to software rendering.
+
+        * UIProcess/API/efl/EwkViewImpl.cpp:
+        (EwkViewImpl::EwkViewImpl):
+        (EwkViewImpl::displayTimerFired):
+        (EwkViewImpl::createGLSurface):
+        (EwkViewImpl::enterAcceleratedCompositingMode):
+        * UIProcess/API/efl/EwkViewImpl.h:
+        (EwkViewImpl::hardwareAccelerationEnabled):
+        (EwkViewImpl):
+        * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
+        (WebKit::LayerTreeRenderer::LayerTreeRenderer):
+        (WebKit::LayerTreeRenderer::ensureRootLayer):
+        * UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
+        (WebKit::LayerTreeRenderer::setAccelerationMode):
+        (LayerTreeRenderer):
+        * UIProcess/efl/PageClientBase.cpp:
+        (WebKit::PageClientBase::createDrawingAreaProxy):
+
 2012-11-12  Thiago Marcos P. Santos  <[email protected]>
 
         [WK2] Indentation nit on WebPage

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp (134246 => 134247)


--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp	2012-11-12 17:34:46 UTC (rev 134247)
@@ -54,6 +54,7 @@
 #include <Ecore_Evas.h>
 #include <Ecore_X.h>
 #include <Edje.h>
+#include <WebCore/CairoUtilitiesEfl.h>
 #include <WebCore/Cursor.h>
 
 #if ENABLE(VIBRATION)
@@ -127,6 +128,7 @@
 #endif
     , m_displayTimer(this, &EwkViewImpl::displayTimerFired)
     , m_inputMethodContext(InputMethodContextEfl::create(this, smartData()->base.evas))
+    , m_isHardwareAccelerated(true)
 {
     ASSERT(m_view);
     ASSERT(m_context);
@@ -334,10 +336,22 @@
     LayerTreeRenderer* renderer = page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
     renderer->setActive(true);
     renderer->syncRemoteContent();
+    if (m_isHardwareAccelerated) {
+        renderer->paintToCurrentGLContext(transformToScene().toTransformationMatrix(), /* opacity */ 1, viewport);
+        // sd->image is tied to a native surface. The native surface is in the parent's coordinates,
+        // so we need to account for the viewport position when calling evas_object_image_data_update_add.
+        evas_object_image_data_update_add(sd->image, viewport.x(), viewport.y(), viewport.width(), viewport.height());
+    } else {
+        RefPtr<cairo_surface_t> surface = createSurfaceForImage(sd->image);
+        if (!surface)
+            return;
 
-    renderer->paintToCurrentGLContext(transformToScene().toTransformationMatrix(), /* opacity */ 1, viewport);
-
-    evas_object_image_data_update_add(sd->image, viewport.x(), viewport.y(), viewport.width(), viewport.height());
+        RefPtr<cairo_t> graphicsContext = adoptRef(cairo_create(surface.get()));
+        cairo_translate(graphicsContext.get(), -m_scrollPosition.x(), -m_scrollPosition.y());
+        cairo_scale(graphicsContext.get(), m_scaleFactor, m_scaleFactor);
+        renderer->paintToGraphicsContext(graphicsContext.get());
+        evas_object_image_data_update_add(sd->image, 0, 0, viewport.width(), viewport.height());
+    }
 #endif
 }
 
@@ -568,11 +582,20 @@
 #if USE(ACCELERATED_COMPOSITING)
 bool EwkViewImpl::createGLSurface(const IntSize& viewSize)
 {
+    if (!m_isHardwareAccelerated)
+        return true;
+
     if (!m_evasGL) {
         Evas* evas = evas_object_evas_get(m_view);
         m_evasGL = adoptPtr(evas_gl_new(evas));
-        if (!m_evasGL)
+        if (!m_evasGL) {
+            m_isHardwareAccelerated = false;
+            page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setAccelerationMode(TextureMapper::SoftwareMode);
+#if ENABLE(WEBGL)
+            m_pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
+#endif
             return false;
+        }
     }
 
     if (!m_evasGLContext) {
@@ -612,6 +635,11 @@
 
 bool EwkViewImpl::enterAcceleratedCompositingMode()
 {
+    page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setActive(true);
+
+    if (!m_isHardwareAccelerated)
+        return true;
+
     if (!m_evasGLSurface) {
         if (!createGLSurface(size())) {
             WARN("Failed to create GLSurface.");
@@ -619,7 +647,6 @@
         }
     }
 
-    page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setActive(true);
     return true;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h (134246 => 134247)


--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h	2012-11-12 17:34:46 UTC (rev 134247)
@@ -199,6 +199,8 @@
     // FIXME: needs refactoring (split callback invoke)
     void informURLChange();
 
+    bool isHardwareAccelerated() const { return m_isHardwareAccelerated; }
+
 private:
     inline Ewk_View_Smart_Data* smartData() const;
     void displayTimerFired(WebCore::Timer<EwkViewImpl>*);
@@ -255,6 +257,7 @@
     OwnPtr<Ewk_Popup_Menu> m_popupMenu;
     OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
     OwnPtr<Ewk_Color_Picker> m_colorPicker;
+    bool m_isHardwareAccelerated;
 };
 
 #endif // EwkViewImpl_h

Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp (134246 => 134247)


--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp	2012-11-12 17:34:46 UTC (rev 134247)
@@ -92,6 +92,7 @@
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     , m_animationFrameRequested(false)
 #endif
+    , m_accelerationMode(TextureMapper::OpenGLMode)
 {
 }
 
@@ -456,7 +457,7 @@
     if (m_rootLayer)
         return;
     if (!m_textureMapper) {
-        m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);
+        m_textureMapper = TextureMapper::create(m_accelerationMode);
         static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
     }
 

Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h (134246 => 134247)


--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h	2012-11-12 17:34:46 UTC (rev 134247)
@@ -99,6 +99,12 @@
     void animationFrameReady();
 #endif
 
+    void setAccelerationMode(WebCore::TextureMapper::AccelerationMode mode)
+    {
+        // The acceleration mode is set only before TextureMapper was created.
+        ASSERT(!m_textureMapper);
+        m_accelerationMode = mode;
+    }
 private:
     PassOwnPtr<WebCore::GraphicsLayer> createLayer(WebLayerID);
 
@@ -153,6 +159,7 @@
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     bool m_animationFrameRequested;
 #endif
+    WebCore::TextureMapper::AccelerationMode m_accelerationMode;
 };
 
 };

Modified: trunk/Source/WebKit2/UIProcess/efl/PageClientBase.cpp (134246 => 134247)


--- trunk/Source/WebKit2/UIProcess/efl/PageClientBase.cpp	2012-11-12 16:43:14 UTC (rev 134246)
+++ trunk/Source/WebKit2/UIProcess/efl/PageClientBase.cpp	2012-11-12 17:34:46 UTC (rev 134247)
@@ -29,8 +29,11 @@
 #include "DrawingAreaProxyImpl.h"
 #include "EwkViewImpl.h"
 #include "InputMethodContextEfl.h"
+#include "LayerTreeCoordinatorProxy.h"
+#include "LayerTreeRenderer.h"
 #include "NativeWebKeyboardEvent.h"
 #include "NotImplemented.h"
+#include "TextureMapper.h"
 #include "WebContext.h"
 #include "WebContextMenuProxy.h"
 #include "WebPageGroup.h"
@@ -66,7 +69,12 @@
 // PageClient
 PassOwnPtr<DrawingAreaProxy> PageClientBase::createDrawingAreaProxy()
 {
-    return DrawingAreaProxyImpl::create(m_viewImpl->page());
+    OwnPtr<DrawingAreaProxy> drawingArea = DrawingAreaProxyImpl::create(m_viewImpl->page());
+#if USE(ACCELERATED_COMPOSITING)
+    if (!m_viewImpl->isHardwareAccelerated())
+        drawingArea->layerTreeCoordinatorProxy()->layerTreeRenderer()->setAccelerationMode(TextureMapper::SoftwareMode);
+#endif
+    return drawingArea.release();
 }
 
 void PageClientBase::setViewNeedsDisplay(const WebCore::IntRect& rect)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to