[TextureMapper] The TextureMapper should support edge-distance anti-antialiasing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2012 04:25:35 +0000 (04:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2012 04:25:35 +0000 (04:25 +0000)
commit27e8235ce84c743d254c99b81ac91dc28c3a6228
tree6cbe1491db417f31cdcf65e8b4b92ec7c2dc9b8e
parent086fffa518c99e2a116278662b15f008738f5b07
[TextureMapper] The TextureMapper should support edge-distance anti-antialiasing
https://bugs.webkit.org/show_bug.cgi?id=90308

Patch by Martin Robinson <mrobinson@igalia.com> on 2012-07-02
Reviewed by Noam Rosenthal.

Source/WebCore:

Add an edge-distance anti-aliasing implementation for the TextureMapper. Currently
this implementation is not active for tiled layers. This implementation is based
on the one in the Chromium compositor originally written by David Raveman.

When a layer is transformed in a way that leaves its edge dimensions across pixel
boundaries, edge distance anti-aliasing will do a cheaper form of anti-aliasing
than full-scene anti-aliasing to make the transition from the layer pixel
to the background pixel smoother.

No new tests. This will be covered by pixel tests for Qt and GTK+ accelerated
compositing and 3D transforms, when those test harnesses are capable of
producing pixel output (in progress).

* platform/graphics/texmap/TextureMapper.h: Add an enum which is used to tell
the texture mapper what edges of a texture are exposed. This will be used for
properly dealing with tiled layers in the future.
* platform/graphics/texmap/TextureMapperBackingStore.cpp: Properly pass information
about exposed layer edges to the TextureMapper while painting.
* platform/graphics/texmap/TextureMapperBackingStore.h:
(TextureMapperTile): Modified arguments include exposed edges.
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawQuad): Renamed from drawRect, this method can now
draw quads that have non unit-rect texture coordinates. This is necessary because
the edge distance approach draws such quad.
(WebCore::TextureMapperGL::drawBorder): Call drawQuad now instead of drawRect.
(WebCore::TextureMapperGL::drawTexture): Pass the exposedEdges argument down.
(WebCore::TextureMapperGL::drawTextureRectangleARB): Call drawQuad now instead of
drawRect.
(WebCore::viewportMatrix): Added this helper which can calculate the viewport
transform based on the current OpenGL viewport settings.
(WebCore::scaleLineEquationCoeffecientsToOptimizeDistanceCalculation): Added this
helper which optimizes the fragment shader by precalculating some constant parts
of the distance calculation.
(WebCore::getStandardEquationCoeffecientsForLine): Given two end points of line segment
get the coeffecients of the line in the standard form of the line equation.
(WebCore::quadToEdgeArray): Converts a FloatQuad to an array of four sets of pre-scaled
line coefficients so that they can be passed to OpenGL.
(WebCore::scaledVectorDifference): Helper which helps expand a quad of arbitrary
orientation.
(WebCore::inflateQuad): Inflate a quad of arbitrary orientation. The transform may
flip it so we have to look at neighboring points to expand the quad.
(WebCore::TextureMapperGL::drawTextureWithAntialiasing): Activate the anti-aliasing
program and set up all uniforms.
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram): Abstract out common operations
from drawTexture to be used with drawTextureWithAntialiasing.
* platform/graphics/texmap/TextureMapperGL.h:
(WebCore::TextureMapperGL::DrawQuad::DrawQuad): Add this small type which stores information
necessary to draw a quad -- it's original destination rect and the final size mapped to
texture coordinates.
(TextureMapperGL):
* platform/graphics/texmap/TextureMapperImageBuffer.cpp: Add the new exposedEdges argument.
* platform/graphics/texmap/TextureMapperImageBuffer.h: Ditto.
* platform/graphics/texmap/TextureMapperShaderManager.cpp: Add the new fragment shader for
doing edge-distance AA and a program which uses that shader.
* platform/graphics/texmap/TextureMapperShaderManager.h: Ditto.

Source/WebKit2:

* UIProcess/texmap/LayerBackingStore.cpp:
(WebKit::LayerBackingStore::paintToTextureMapper): Update the method to call paint with
the new argument.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121729 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/TextureMapper.h
Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/texmap/LayerBackingStore.cpp