Title: [109696] trunk/Source/WebCore
Revision
109696
Author
[email protected]
Date
2012-03-04 19:15:18 -0800 (Sun, 04 Mar 2012)

Log Message

[EFL] Evas_GL initialization and destruction in GraphicsContext3DPrivate
https://bugs.webkit.org/show_bug.cgi?id=80211

Patch by Hyowon Kim <[email protected]> on 2012-03-04
Reviewed by Noam Rosenthal.

This patch adds initialization and destruction codes using Evas_GL APIs to GC3DPrivate.

No new tests. No behavior change.

* platform/graphics/efl/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::create):
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::initialize):
(WebCore::GraphicsContext3DPrivate::createSurface):
(WebCore::GraphicsContext3DPrivate::makeContextCurrent):
* platform/graphics/efl/GraphicsContext3DPrivate.h:
(GraphicsContext3DPrivate):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109695 => 109696)


--- trunk/Source/WebCore/ChangeLog	2012-03-05 03:01:38 UTC (rev 109695)
+++ trunk/Source/WebCore/ChangeLog	2012-03-05 03:15:18 UTC (rev 109696)
@@ -1,3 +1,24 @@
+2012-03-04  Hyowon Kim  <[email protected]>
+
+        [EFL] Evas_GL initialization and destruction in GraphicsContext3DPrivate
+        https://bugs.webkit.org/show_bug.cgi?id=80211
+
+        Reviewed by Noam Rosenthal.
+
+        This patch adds initialization and destruction codes using Evas_GL APIs to GC3DPrivate.
+
+        No new tests. No behavior change.
+
+        * platform/graphics/efl/GraphicsContext3DPrivate.cpp:
+        (WebCore::GraphicsContext3DPrivate::create):
+        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
+        (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
+        (WebCore::GraphicsContext3DPrivate::initialize):
+        (WebCore::GraphicsContext3DPrivate::createSurface):
+        (WebCore::GraphicsContext3DPrivate::makeContextCurrent):
+        * platform/graphics/efl/GraphicsContext3DPrivate.h:
+        (GraphicsContext3DPrivate):
+
 2012-03-04  Raphael Kubo da Costa  <[email protected]>
 
         [CMake] Libraries are installed to /usr/lib and not /usr/lib64 on x86_64

Modified: trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp (109695 => 109696)


--- trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp	2012-03-05 03:01:38 UTC (rev 109695)
+++ trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp	2012-03-05 03:15:18 UTC (rev 109696)
@@ -32,11 +32,11 @@
 
 namespace WebCore {
 
-PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool renderDirectlyToEvasGLObject)
+PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
 {
     OwnPtr<GraphicsContext3DPrivate> internal = adoptPtr(new GraphicsContext3DPrivate());
 
-    if (!internal->initialize(attributes, hostWindow, renderDirectlyToEvasGLObject))
+    if (!internal->initialize(attributes, hostWindow, renderDirectlyToHostWindow))
         return nullptr;
 
     return internal.release();
@@ -49,25 +49,101 @@
     , m_evasGL(0)
     , m_context(0)
     , m_surface(0)
-    , m_config(0)
     , m_api(0)
 {
 }
 
 GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
 {
+    if (!m_evasGL)
+        return;
+
+    if (m_surface)
+        evas_gl_surface_destroy(m_evasGL, m_surface);
+
+    if (m_context)
+        evas_gl_context_destroy(m_evasGL, m_context);
+
+    evas_gl_free(m_evasGL);
 }
 
-bool GraphicsContext3DPrivate::initialize(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool bRenderDirectlyToEvasGLObject)
+bool GraphicsContext3DPrivate::initialize(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
 {
-    notImplemented();
-    return false;
+    PageClientEfl* pageClient = static_cast<PageClientEfl*>(hostWindow->platformPageClient());
+
+    Evas* evas = evas_object_evas_get(pageClient->view());
+
+    // Create a new Evas_GL object for gl rendering on efl.
+    m_evasGL = evas_gl_new(evas);
+    if (!m_evasGL)
+        return false;
+
+    // Get the API for rendering using OpenGL.
+    // This returns a structure that contains all the OpenGL functions we can use to render in Evas
+    m_api = evas_gl_api_get(m_evasGL);
+    if (!m_api)
+        return false;
+
+    Evas_GL_Context* shareContext = 0;
+
+#if USE(ACCELERATED_COMPOSITING)
+    // GC3D with RenderOffscreen style for WebGL has to be shared with AC's context when AC is enabled.
+    if (!renderDirectlyToHostWindow) {
+        GraphicsContext3D* context = pageClient->acceleratedCompositingContext();
+        if (context)
+            shareContext = static_cast<Evas_GL_Context*>(context->platformGraphicsContext3D());
+    }
+#endif
+
+    // Create a context
+    m_context = evas_gl_context_create(m_evasGL, shareContext);
+    if (!m_context)
+        return false;
+
+    // Create a surface
+    if (!createSurface(pageClient, renderDirectlyToHostWindow))
+        return false;
+
+    return makeContextCurrent();
 }
 
-bool GraphicsContext3DPrivate::createSurface(PageClientEfl* pageClient, bool renderDirectlyToEvasGLObject)
+bool GraphicsContext3DPrivate::createSurface(PageClientEfl* pageClient, bool renderDirectlyToHostWindow)
 {
-    notImplemented();
-    return false;
+    // If RenderStyle is RenderOffscreen, we will be rendering to a FBO,
+    // so Evas_GL_Surface has a 1x1 dummy surface.
+    int x = 0;
+    int y = 0;
+    int width = 1;
+    int height = 1;
+
+    // But, in case of RenderDirectlyToHostWindow, we have to render to a render target surface with the same size as our webView.
+    if (renderDirectlyToHostWindow)
+        evas_object_geometry_get(pageClient->view(), &x, &y, &width, &height);
+
+    Evas_GL_Config config = {
+        EVAS_GL_RGBA_8888,
+        EVAS_GL_DEPTH_BIT_8,
+        EVAS_GL_STENCIL_NONE, // FIXME: set EVAS_GL_STENCIL_BIT_8 after fixing Evas_GL bug.
+        EVAS_GL_OPTIONS_NONE
+    };
+
+    // Create a new Evas_GL_Surface object
+    m_surface = evas_gl_surface_create(m_evasGL, &config, width, height);
+    if (!m_surface)
+        return false;
+
+#if USE(ACCELERATED_COMPOSITING)
+    if (renderDirectlyToHostWindow) {
+        Evas_Native_Surface nativeSurface;
+        // Fill in the Native Surface information from the given Evas GL surface.
+        evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface);
+
+        // Create and specially set up a evas_object which act as the render targer surface.
+        if (!pageClient->createEvasObjectForAcceleratedCompositing(&nativeSurface, x, y, width, height))
+            return false;
+    }
+#endif
+    return true;
 }
 
 PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const
@@ -77,8 +153,7 @@
 
 bool GraphicsContext3DPrivate::makeContextCurrent()
 {
-    notImplemented();
-    return false;
+    return evas_gl_make_current(m_evasGL, m_surface, m_context);
 }
 
 bool GraphicsContext3DPrivate::isGLES2Compliant() const

Modified: trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h (109695 => 109696)


--- trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h	2012-03-05 03:01:38 UTC (rev 109695)
+++ trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h	2012-03-05 03:15:18 UTC (rev 109696)
@@ -204,7 +204,7 @@
 private:
     GraphicsContext3DPrivate();
 
-    bool initialize(GraphicsContext3D::Attributes attrs, HostWindow*, bool renderDirectlyToEvasGLObject);
+    bool initialize(GraphicsContext3D::Attributes attrs, HostWindow*, bool renderDirectlyToHostWindow);
 
     bool createSurface(PageClientEfl*, bool renderDirectlyToEvasGLObject);
 
@@ -219,7 +219,6 @@
     Evas_GL* m_evasGL;
     Evas_GL_Context* m_context;
     Evas_GL_Surface* m_surface;
-    Evas_GL_Config* m_config;
     Evas_GL_API* m_api;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to