Title: [122189] trunk/Source/WebCore
Revision
122189
Author
ach...@adobe.com
Date
2012-07-09 20:27:37 -0700 (Mon, 09 Jul 2012)

Log Message

[CSS Shaders] The FECustomFilter is not making the GL context active
https://bugs.webkit.org/show_bug.cgi?id=90840

Reviewed by Dean Jackson.

I've added a couple of makeContextCurrent() in the FECustomFilter related classes.
Also, removed the assumption that GraphicsContext3D::create() never returns 0.

No new tests, this was crashing on existing tests.

* platform/graphics/filters/CustomFilterCompiledProgram.cpp:
(WebCore::CustomFilterCompiledProgram::CustomFilterCompiledProgram):
(WebCore::CustomFilterCompiledProgram::~CustomFilterCompiledProgram):
* platform/graphics/filters/CustomFilterGlobalContext.cpp:
(WebCore::CustomFilterGlobalContext::prepareContextIfNeeded):
* platform/graphics/filters/CustomFilterMesh.cpp:
(WebCore::CustomFilterMesh::CustomFilterMesh):
(WebCore::CustomFilterMesh::~CustomFilterMesh):
* platform/graphics/filters/FECustomFilter.cpp:
(WebCore::FECustomFilter::deleteRenderBuffers):
(WebCore::FECustomFilter::platformApplySoftware):
(WebCore::FECustomFilter::initializeContext):
* platform/graphics/filters/FECustomFilter.h:
(FECustomFilter):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122188 => 122189)


--- trunk/Source/WebCore/ChangeLog	2012-07-10 03:18:15 UTC (rev 122188)
+++ trunk/Source/WebCore/ChangeLog	2012-07-10 03:27:37 UTC (rev 122189)
@@ -1,3 +1,30 @@
+2012-07-09  Alexandru Chiculita  <ach...@adobe.com>
+
+        [CSS Shaders] The FECustomFilter is not making the GL context active
+        https://bugs.webkit.org/show_bug.cgi?id=90840
+
+        Reviewed by Dean Jackson.
+
+        I've added a couple of makeContextCurrent() in the FECustomFilter related classes.
+        Also, removed the assumption that GraphicsContext3D::create() never returns 0.
+
+        No new tests, this was crashing on existing tests.
+
+        * platform/graphics/filters/CustomFilterCompiledProgram.cpp:
+        (WebCore::CustomFilterCompiledProgram::CustomFilterCompiledProgram):
+        (WebCore::CustomFilterCompiledProgram::~CustomFilterCompiledProgram):
+        * platform/graphics/filters/CustomFilterGlobalContext.cpp:
+        (WebCore::CustomFilterGlobalContext::prepareContextIfNeeded):
+        * platform/graphics/filters/CustomFilterMesh.cpp:
+        (WebCore::CustomFilterMesh::CustomFilterMesh):
+        (WebCore::CustomFilterMesh::~CustomFilterMesh):
+        * platform/graphics/filters/FECustomFilter.cpp:
+        (WebCore::FECustomFilter::deleteRenderBuffers):
+        (WebCore::FECustomFilter::platformApplySoftware):
+        (WebCore::FECustomFilter::initializeContext):
+        * platform/graphics/filters/FECustomFilter.h:
+        (FECustomFilter):
+
 2012-07-09  Kent Tamura  <tk...@chromium.org>
 
         REGRESSION(r114862-r114886): Fix a crash by switching the input type to hidden.

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp (122188 => 122189)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp	2012-07-10 03:18:15 UTC (rev 122188)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp	2012-07-10 03:27:37 UTC (rev 122189)
@@ -87,6 +87,8 @@
     , m_contentSamplerLocation(-1)
     , m_isInitialized(false)
 {
+    m_context->makeContextCurrent();
+    
     Platform3DObject vertexShader = compileShader(GraphicsContext3D::VERTEX_SHADER, m_vertexShaderString);
     if (!vertexShader)
         return;
@@ -171,8 +173,10 @@
     
 CustomFilterCompiledProgram::~CustomFilterCompiledProgram()
 {
-    if (m_program)
+    if (m_program) {
+        m_context->makeContextCurrent();
         m_context->deleteProgram(m_program);
+    }
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp (122188 => 122189)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp	2012-07-10 03:18:15 UTC (rev 122188)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp	2012-07-10 03:27:37 UTC (rev 122189)
@@ -53,7 +53,9 @@
     attributes.preserveDrawingBuffer = true;
     attributes.premultipliedAlpha = false;
     m_context = GraphicsContext3D::create(attributes, hostWindow, GraphicsContext3D::RenderOffscreen);
-
+    if (!m_context)
+        return;
+    m_context->makeContextCurrent();
     m_context->enable(GraphicsContext3D::DEPTH_TEST);
 }
 

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterMesh.cpp (122188 => 122189)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterMesh.cpp	2012-07-10 03:18:15 UTC (rev 122188)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterMesh.cpp	2012-07-10 03:27:37 UTC (rev 122189)
@@ -245,6 +245,8 @@
     m_indicesCount = generator.indicesCount();
     m_bytesPerVertex = generator.floatsPerVertex() * sizeof(float);    
 
+    m_context->makeContextCurrent();
+
     m_verticesBufferObject = m_context->createBuffer();
     m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_verticesBufferObject);
     m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, generator.vertices().size() * sizeof(float), generator.vertices().data(), GraphicsContext3D::STATIC_DRAW);
@@ -256,6 +258,7 @@
 
 CustomFilterMesh::~CustomFilterMesh()
 {
+    m_context->makeContextCurrent();
     m_context->deleteBuffer(m_verticesBufferObject);
     m_context->deleteBuffer(m_elementsBufferObject);
 }

Modified: trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp (122188 => 122189)


--- trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp	2012-07-10 03:18:15 UTC (rev 122188)
+++ trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp	2012-07-10 03:27:37 UTC (rev 122189)
@@ -103,6 +103,9 @@
 
 void FECustomFilter::deleteRenderBuffers()
 {
+    if (!m_context)
+        return;
+    m_context->makeContextCurrent();
     if (m_frameBuffer) {
         m_context->deleteFramebuffer(m_frameBuffer);
         m_frameBuffer = 0;
@@ -129,8 +132,9 @@
     
     IntSize newContextSize(effectDrawingRect.size());
     bool hadContext = m_context;
-    if (!m_context)
-        initializeContext();
+    if (!m_context && !initializeContext())
+        return;
+    m_context->makeContextCurrent();
     
     if (!hadContext || m_contextSize != newContextSize)
         resizeContext(newContextSize);
@@ -157,11 +161,13 @@
     m_context->readPixels(0, 0, newContextSize.width(), newContextSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, dstPixelArray->data());
 }
 
-void FECustomFilter::initializeContext()
+bool FECustomFilter::initializeContext()
 {
     ASSERT(!m_context.get());
-    ASSERT(m_globalContext->context());
     m_context = m_globalContext->context();
+    if (!m_context)
+        return false;
+    m_context->makeContextCurrent();
     
     // FIXME: The shader and the mesh can be shared across multiple elements when possible.
     // Sharing the shader means it's no need to analyze / compile and upload to GPU again.
@@ -174,6 +180,7 @@
     m_mesh = CustomFilterMesh::create(m_context.get(), m_meshColumns, m_meshRows, 
                                       FloatRect(0, 0, 1, 1),
                                       m_meshType);
+    return true;
 }
 
 void FECustomFilter::resizeContext(const IntSize& newContextSize)

Modified: trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.h (122188 => 122189)


--- trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.h	2012-07-10 03:18:15 UTC (rev 122188)
+++ trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.h	2012-07-10 03:27:37 UTC (rev 122189)
@@ -72,7 +72,7 @@
                    CustomFilterOperation::MeshType);
     ~FECustomFilter();
     
-    void initializeContext();
+    bool initializeContext();
     void deleteRenderBuffers();
     void resizeContext(const IntSize& newContextSize);
     void bindVertexAttribute(int attributeLocation, unsigned size, unsigned& offset);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to