Title: [200812] trunk/Source/WebCore
Revision
200812
Author
[email protected]
Date
2016-05-12 22:48:23 -0700 (Thu, 12 May 2016)

Log Message

[TexMap] Handle TextureMapperShaderProgram objects through references
https://bugs.webkit.org/show_bug.cgi?id=157619

Reviewed by Antonio Gomes.

TextureMapper code always expects valid TextureMapperShaderProgram
objects to be created, so it doesn't make sense to access these
objects through raw pointers or RefPtr<>s.

* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawBorder):
(WebCore::prepareFilterProgram):
(WebCore::TextureMapperGL::drawTexture):
(WebCore::TextureMapperGL::drawSolidColor):
(WebCore::TextureMapperGL::drawEdgeTriangles):
(WebCore::TextureMapperGL::drawUnitRect):
(WebCore::TextureMapperGL::draw):
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
(WebCore::TextureMapperGL::drawFiltered):
(WebCore::TextureMapperGL::beginClip):
* platform/graphics/texmap/TextureMapperGL.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200811 => 200812)


--- trunk/Source/WebCore/ChangeLog	2016-05-13 05:46:21 UTC (rev 200811)
+++ trunk/Source/WebCore/ChangeLog	2016-05-13 05:48:23 UTC (rev 200812)
@@ -1,5 +1,29 @@
 2016-05-12  Zan Dobersek  <[email protected]>
 
+        [TexMap] Handle TextureMapperShaderProgram objects through references
+        https://bugs.webkit.org/show_bug.cgi?id=157619
+
+        Reviewed by Antonio Gomes.
+
+        TextureMapper code always expects valid TextureMapperShaderProgram
+        objects to be created, so it doesn't make sense to access these
+        objects through raw pointers or RefPtr<>s.
+
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::drawBorder):
+        (WebCore::prepareFilterProgram):
+        (WebCore::TextureMapperGL::drawTexture):
+        (WebCore::TextureMapperGL::drawSolidColor):
+        (WebCore::TextureMapperGL::drawEdgeTriangles):
+        (WebCore::TextureMapperGL::drawUnitRect):
+        (WebCore::TextureMapperGL::draw):
+        (WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
+        (WebCore::TextureMapperGL::drawFiltered):
+        (WebCore::TextureMapperGL::beginClip):
+        * platform/graphics/texmap/TextureMapperGL.h:
+
+2016-05-12  Zan Dobersek  <[email protected]>
+
         VideoSinkGStreamer: plug a GstBuffer leak in webkitVideoSinkRequestRender()
         https://bugs.webkit.org/show_bug.cgi?id=157617
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (200811 => 200812)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2016-05-13 05:46:21 UTC (rev 200811)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2016-05-13 05:48:23 UTC (rev 200812)
@@ -221,7 +221,7 @@
     if (clipStack().isCurrentScissorBoxEmpty())
         return;
 
-    RefPtr<TextureMapperShaderProgram> program = data().getShaderProgram(TextureMapperShaderProgram::SolidColor);
+    Ref<TextureMapperShaderProgram> program = data().getShaderProgram(TextureMapperShaderProgram::SolidColor);
     m_context3D->useProgram(program->programID());
 
     float r, g, b, a;
@@ -343,23 +343,23 @@
     return kernel;
 }
 
-static void prepareFilterProgram(TextureMapperShaderProgram* program, const FilterOperation& operation, unsigned pass, const IntSize& size, GC3Duint contentTexture)
+static void prepareFilterProgram(TextureMapperShaderProgram& program, const FilterOperation& operation, unsigned pass, const IntSize& size, GC3Duint contentTexture)
 {
-    Ref<GraphicsContext3D> context = program->context();
-    context->useProgram(program->programID());
+    Ref<GraphicsContext3D> context = program.context();
+    context->useProgram(program.programID());
 
     switch (operation.type()) {
     case FilterOperation::GRAYSCALE:
     case FilterOperation::SEPIA:
     case FilterOperation::SATURATE:
     case FilterOperation::HUE_ROTATE:
-        context->uniform1f(program->filterAmountLocation(), static_cast<const BasicColorMatrixFilterOperation&>(operation).amount());
+        context->uniform1f(program.filterAmountLocation(), static_cast<const BasicColorMatrixFilterOperation&>(operation).amount());
         break;
     case FilterOperation::INVERT:
     case FilterOperation::BRIGHTNESS:
     case FilterOperation::CONTRAST:
     case FilterOperation::OPACITY:
-        context->uniform1f(program->filterAmountLocation(), static_cast<const BasicComponentTransferFilterOperation&>(operation).amount());
+        context->uniform1f(program.filterAmountLocation(), static_cast<const BasicComponentTransferFilterOperation&>(operation).amount());
         break;
     case FilterOperation::BLUR: {
         const BlurFilterOperation& blur = static_cast<const BlurFilterOperation&>(operation);
@@ -371,29 +371,29 @@
         else
             radius.setWidth(floatValueForLength(blur.stdDeviation(), size.width()) / size.width());
 
-        context->uniform2f(program->blurRadiusLocation(), radius.width(), radius.height());
-        context->uniform1fv(program->gaussianKernelLocation(), GaussianKernelHalfWidth, gaussianKernel());
+        context->uniform2f(program.blurRadiusLocation(), radius.width(), radius.height());
+        context->uniform1fv(program.gaussianKernelLocation(), GaussianKernelHalfWidth, gaussianKernel());
         break;
     }
     case FilterOperation::DROP_SHADOW: {
         const DropShadowFilterOperation& shadow = static_cast<const DropShadowFilterOperation&>(operation);
-        context->uniform1fv(program->gaussianKernelLocation(), GaussianKernelHalfWidth, gaussianKernel());
+        context->uniform1fv(program.gaussianKernelLocation(), GaussianKernelHalfWidth, gaussianKernel());
         switch (pass) {
         case 0:
             // First pass: horizontal alpha blur.
-            context->uniform2f(program->blurRadiusLocation(), shadow.stdDeviation() / float(size.width()), 0);
-            context->uniform2f(program->shadowOffsetLocation(), float(shadow.location().x()) / float(size.width()), float(shadow.location().y()) / float(size.height()));
+            context->uniform2f(program.blurRadiusLocation(), shadow.stdDeviation() / float(size.width()), 0);
+            context->uniform2f(program.shadowOffsetLocation(), float(shadow.location().x()) / float(size.width()), float(shadow.location().y()) / float(size.height()));
             break;
         case 1:
             // Second pass: we need the shadow color and the content texture for compositing.
             float r, g, b, a;
             Color(premultipliedARGBFromColor(shadow.color())).getRGBA(r, g, b, a);
-            context->uniform4f(program->colorLocation(), r, g, b, a);
-            context->uniform2f(program->blurRadiusLocation(), 0, shadow.stdDeviation() / float(size.height()));
-            context->uniform2f(program->shadowOffsetLocation(), 0, 0);
+            context->uniform4f(program.colorLocation(), r, g, b, a);
+            context->uniform2f(program.blurRadiusLocation(), 0, shadow.stdDeviation() / float(size.height()));
+            context->uniform2f(program.shadowOffsetLocation(), 0, 0);
             context->activeTexture(GraphicsContext3D::TEXTURE1);
             context->bindTexture(GraphicsContext3D::TEXTURE_2D, contentTexture);
-            context->uniform1i(program->contentTextureLocation(), 1);
+            context->uniform1i(program.contentTextureLocation(), 1);
             break;
         }
         break;
@@ -448,7 +448,7 @@
     if (useAntialiasing || opacity < 1)
         flags |= ShouldBlend;
 
-    RefPtr<TextureMapperShaderProgram> program = data().getShaderProgram(options);
+    Ref<TextureMapperShaderProgram> program = data().getShaderProgram(options);
 
     if (filter)
         prepareFilterProgram(program.get(), *filter.get(), data().filterInfo->pass, textureSize, filterContentTextureID);
@@ -465,7 +465,7 @@
         flags |= ShouldBlend | ShouldAntialias;
     }
 
-    RefPtr<TextureMapperShaderProgram> program = data().getShaderProgram(options);
+    Ref<TextureMapperShaderProgram> program = data().getShaderProgram(options);
     m_context3D->useProgram(program->programID());
 
     float r, g, b, a;
@@ -477,7 +477,7 @@
     draw(rect, matrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, flags);
 }
 
-void TextureMapperGL::drawEdgeTriangles(TextureMapperShaderProgram* program)
+void TextureMapperGL::drawEdgeTriangles(TextureMapperShaderProgram& program)
 {
     const GC3Dfloat left = 0;
     const GC3Dfloat top = 0;
@@ -502,29 +502,29 @@
 
     Platform3DObject vbo = data().getStaticVBO(GraphicsContext3D::ARRAY_BUFFER, sizeof(GC3Dfloat) * 48, unitRectSideTriangles);
     m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, vbo);
-    m_context3D->vertexAttribPointer(program->vertexLocation(), 4, GraphicsContext3D::FLOAT, false, 0, 0);
+    m_context3D->vertexAttribPointer(program.vertexLocation(), 4, GraphicsContext3D::FLOAT, false, 0, 0);
     m_context3D->drawArrays(GraphicsContext3D::TRIANGLES, 0, 12);
     m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0);
 }
 
-void TextureMapperGL::drawUnitRect(TextureMapperShaderProgram* program, GC3Denum drawingMode)
+void TextureMapperGL::drawUnitRect(TextureMapperShaderProgram& program, GC3Denum drawingMode)
 {
     static const GC3Dfloat unitRect[] = { 0, 0, 1, 0, 1, 1, 0, 1 };
     Platform3DObject vbo = data().getStaticVBO(GraphicsContext3D::ARRAY_BUFFER, sizeof(GC3Dfloat) * 8, unitRect);
     m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, vbo);
-    m_context3D->vertexAttribPointer(program->vertexLocation(), 2, GraphicsContext3D::FLOAT, false, 0, 0);
+    m_context3D->vertexAttribPointer(program.vertexLocation(), 2, GraphicsContext3D::FLOAT, false, 0, 0);
     m_context3D->drawArrays(drawingMode, 0, 4);
     m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0);
 }
 
-void TextureMapperGL::draw(const FloatRect& rect, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GC3Denum drawingMode, Flags flags)
+void TextureMapperGL::draw(const FloatRect& rect, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram& program, GC3Denum drawingMode, Flags flags)
 {
     TransformationMatrix matrix(modelViewMatrix);
     matrix.multiply(TransformationMatrix::rectToRect(FloatRect(0, 0, 1, 1), rect));
 
-    m_context3D->enableVertexAttribArray(shaderProgram->vertexLocation());
-    shaderProgram->setMatrix(shaderProgram->modelViewMatrixLocation(), matrix);
-    shaderProgram->setMatrix(shaderProgram->projectionMatrixLocation(), data().projectionMatrix);
+    m_context3D->enableVertexAttribArray(program.vertexLocation());
+    program.setMatrix(program.modelViewMatrixLocation(), matrix);
+    program.setMatrix(program.projectionMatrixLocation(), data().projectionMatrix);
 
     if (isInMaskMode()) {
         m_context3D->blendFunc(GraphicsContext3D::ZERO, GraphicsContext3D::SRC_ALPHA);
@@ -538,22 +538,22 @@
     }
 
     if (flags & ShouldAntialias)
-        drawEdgeTriangles(shaderProgram);
+        drawEdgeTriangles(program);
     else
-        drawUnitRect(shaderProgram, drawingMode);
+        drawUnitRect(program, drawingMode);
 
-    m_context3D->disableVertexAttribArray(shaderProgram->vertexLocation());
+    m_context3D->disableVertexAttribArray(program.vertexLocation());
     m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
     m_context3D->enable(GraphicsContext3D::BLEND);
 }
 
-void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const IntSize& size, const FloatRect& rect, const TransformationMatrix& modelViewMatrix, float opacity)
+void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram& program, uint32_t texture, Flags flags, const IntSize& size, const FloatRect& rect, const TransformationMatrix& modelViewMatrix, float opacity)
 {
-    m_context3D->useProgram(program->programID());
+    m_context3D->useProgram(program.programID());
     m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
     GC3Denum target = flags & ShouldUseARBTextureRect ? GC3Denum(Extensions3D::TEXTURE_RECTANGLE_ARB) : GC3Denum(GraphicsContext3D::TEXTURE_2D);
     m_context3D->bindTexture(target, texture);
-    m_context3D->uniform1i(program->samplerLocation(), 0);
+    m_context3D->uniform1i(program.samplerLocation(), 0);
     if (wrapMode() == RepeatWrap) {
         m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::REPEAT);
         m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::REPEAT);
@@ -567,8 +567,8 @@
     if (flags & ShouldFlipTexture)
         patternTransform.translate(0, -1);
 
-    program->setMatrix(program->textureSpaceMatrixLocation(), patternTransform);
-    m_context3D->uniform1f(program->opacityLocation(), opacity);
+    program.setMatrix(program.textureSpaceMatrixLocation(), patternTransform);
+    m_context3D->uniform1f(program.opacityLocation(), opacity);
 
     if (opacity < 1)
         flags |= ShouldBlend;
@@ -582,8 +582,7 @@
 {
     // For standard filters, we always draw the whole texture without transformations.
     TextureMapperShaderProgram::Options options = optionsForFilterType(filter.type(), pass);
-    RefPtr<TextureMapperShaderProgram> program = data().getShaderProgram(options);
-    ASSERT(program);
+    Ref<TextureMapperShaderProgram> program = data().getShaderProgram(options);
 
     prepareFilterProgram(program.get(), filter, pass, sampler.contentSize(), contentTexture ? static_cast<const BitmapTextureGL*>(contentTexture)->id() : 0);
     FloatRect targetRect(IntPoint::zero(), sampler.contentSize());
@@ -660,7 +659,7 @@
 
     data().initializeStencil();
 
-    RefPtr<TextureMapperShaderProgram> program = data().getShaderProgram(TextureMapperShaderProgram::SolidColor);
+    Ref<TextureMapperShaderProgram> program = data().getShaderProgram(TextureMapperShaderProgram::SolidColor);
 
     m_context3D->useProgram(program->programID());
     m_context3D->enableVertexAttribArray(program->vertexLocation());

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (200811 => 200812)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2016-05-13 05:46:21 UTC (rev 200811)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2016-05-13 05:48:23 UTC (rev 200812)
@@ -75,11 +75,11 @@
     void setEnableEdgeDistanceAntialiasing(bool enabled) { m_enableEdgeDistanceAntialiasing = enabled; }
 
 private:
-    void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity);
-    void draw(const FloatRect&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, Flags);
+    void drawTexturedQuadWithProgram(TextureMapperShaderProgram&, uint32_t texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity);
+    void draw(const FloatRect&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram&, GC3Denum drawingMode, Flags);
 
-    void drawUnitRect(TextureMapperShaderProgram*, GC3Denum drawingMode);
-    void drawEdgeTriangles(TextureMapperShaderProgram*);
+    void drawUnitRect(TextureMapperShaderProgram&, GC3Denum drawingMode);
+    void drawEdgeTriangles(TextureMapperShaderProgram&);
 
     bool beginScissorClip(const TransformationMatrix&, const FloatRect&);
     void bindDefaultSurface();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to