[Texmap] TextureMapper is too eager to use intermediate surfaces
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2013 16:16:16 +0000 (16:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2013 16:16:16 +0000 (16:16 +0000)
commitf8b040df679466c5f0852f71174ff749b5645e3f
tree30af849fcd4ddff68dc3b34cb1d22c8379e18c90
parent684ed06e293e6f8e43f4c07159d2f20538ee6983
[Texmap] TextureMapper is too eager to use intermediate surfaces
https://bugs.webkit.org/show_bug.cgi?id=110762

Patch by No'am Rosenthal <noam@webkit.org> on 2013-02-27
Reviewed by Allan Sandfeld Jensen.

Source/WebCore:

Refactor the way intermediate surfaces are handled in TextureMapperLayer.
Beforehand, we would create an intermediate surface whenever there is a chance of overlap, and
the intermediate surface would be the largest possible. The result would then be drawn to the
target surface with the layer's opacity and mask.

This would make it so that (1) surfaces are created even when they're not needed, i.e. when there
is no actual overlap, and (2) mask wouldn't be applied correctly.

In this patch the behavior is changed so that the area to be painted is divided to "overlapping"
and "non overlapping" regions. The non-overlapping regions are painted directly, while the overlapping
regions are tiled to smaller rectangles painted using an intermediate surface.
Masks are applied to those intermediate surfaces based on the transform of the actual mask, not drawn
together with the content texture like before.

This optimizes for the more common case of opacity animations on a large tree, while making the quite
rare case of composited masks slightly less optimized but always correct.

Tests: compositing/overlap-blending/children-opacity-huge.html
       compositing/overlap-blending/reflection-opacity-huge.html
       compositing/overlap-blending/children-opacity-no-overlap.html

* platform/graphics/cairo/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
* platform/graphics/cairo/GraphicsContext3DPrivate.h:
(GraphicsContext3DPrivate):
* platform/graphics/efl/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
* platform/graphics/efl/GraphicsContext3DPrivate.h:
(GraphicsContext3DPrivate):
* platform/graphics/qt/GraphicsContext3DQt.cpp:
(GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
* platform/graphics/qt/MediaPlayerPrivateQt.cpp:
(WebCore::MediaPlayerPrivateQt::paintToTextureMapper):
* platform/graphics/qt/MediaPlayerPrivateQt.h:
(MediaPlayerPrivateQt):
* platform/graphics/surfaces/GraphicsSurface.cpp:
(WebCore::GraphicsSurface::paintToTextureMapper):
* platform/graphics/surfaces/GraphicsSurface.h:
(GraphicsSurface):
* platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
* platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
* platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp:
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
* platform/graphics/texmap/TextureMapperBackingStore.h:
(TextureMapperBackingStore):
* platform/graphics/texmap/TextureMapperPlatformLayer.h:
(TextureMapperPlatformLayer):
* platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp:
(WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):
* platform/graphics/texmap/TextureMapperSurfaceBackingStore.h:
(TextureMapperSurfaceBackingStore):
* platform/graphics/texmap/TextureMapperTile.cpp:
(WebCore::TextureMapperTile::paint):
* platform/graphics/texmap/TextureMapperTile.h:
(TextureMapperTile):
* platform/graphics/texmap/TextureMapperTiledBackingStore.cpp:
(WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
* platform/graphics/texmap/TextureMapperTiledBackingStore.h:
(TextureMapperTiledBackingStore):
* platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp:
(WebCore::CoordinatedBackingStore::paintTilesToTextureMapper):
(WebCore::CoordinatedBackingStore::paintToTextureMapper):
* platform/graphics/texmap/coordinated/CoordinatedBackingStore.h:
(CoordinatedBackingStore):
        Removed the "mask" parameter from TextureMapperPlatformLayer and overrides, since
        we no longer paint the contents and the mask in the same pass.

* platform/graphics/texmap/TextureMapper.cpp:
(WebCore::TextureMapper::TextureMapper):
* platform/graphics/texmap/TextureMapper.h:
(WebCore::TextureMapper::setMaskMode):
(TextureMapper):
(WebCore::TextureMapper::isInMaskMode):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawNumber):
(WebCore::TextureMapperGL::drawTexture):
(WebCore::TextureMapperGL::draw):
(WebCore):
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
(WebCore::TextureMapperGL::drawFiltered):
* platform/graphics/texmap/TextureMapperGL.h:
(TextureMapperGL):
* platform/graphics/texmap/TextureMapperImageBuffer.cpp:
(WebCore::TextureMapperImageBuffer::drawTexture):
(WebCore::TextureMapperImageBuffer::drawSolidColor):
* platform/graphics/texmap/TextureMapperImageBuffer.h:
(TextureMapperImageBuffer):
        Instead of painting the mask together with the texture/color, paint the mask
        by drawing with DestinationIn to an existing surface.

* platform/graphics/texmap/TextureMapperLayer.cpp:
(TextureMapperPaintOptions):
(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::shouldBlend):
(WebCore::TextureMapperLayer::paintSelfAndChildrenWithReplica):
(WebCore::TextureMapperLayer::replicaTransform):
(WebCore):
(WebCore::applyFilters):
(WebCore::resolveOverlaps):
(WebCore::TextureMapperLayer::computeOverlapRegions):
(WebCore::TextureMapperLayer::paintUsingOverlapRegions):
(WebCore::TextureMapperLayer::applyMask):
(WebCore::TextureMapperLayer::paintIntoSurface):
(WebCore::commitSurface):
(WebCore::TextureMapperLayer::paintWithIntermediateSurface):
(WebCore::TextureMapperLayer::paintRecursive):
* platform/graphics/texmap/TextureMapperLayer.h:
(WebCore):
(TextureMapperLayer):
(WebCore::TextureMapperLayer::hasFilters):
* platform/graphics/texmap/TextureMapperShaderProgram.cpp:
(WebCore):
(WebCore::TextureMapperShaderProgram::create):
* platform/graphics/texmap/TextureMapperShaderProgram.h:

LayoutTests:

Added a few ref-tests for correct overlap blending in accelearated compositing mode.
Skipping the new reflection test on Mac/Chromium since it's not rendered
properly on those platforms.

* compositing/overlap-blending/children-opacity-huge-expected.html: Added.
* compositing/overlap-blending/children-opacity-huge.html: Added.
* compositing/overlap-blending/children-opacity-no-overlap-expected.html: Added.
* compositing/overlap-blending/children-opacity-no-overlap.html: Added.
* compositing/overlap-blending/reflection-opacity-huge-expected.html: Added.
* compositing/overlap-blending/reflection-opacity-huge.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144190 268f45cc-cd09-0410-ab3c-d52691b4dbfc
42 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/overlap-blending/children-opacity-huge-expected.html [new file with mode: 0644]
LayoutTests/compositing/overlap-blending/children-opacity-huge.html [new file with mode: 0644]
LayoutTests/compositing/overlap-blending/children-opacity-no-overlap-expected.html [new file with mode: 0644]
LayoutTests/compositing/overlap-blending/children-opacity-no-overlap.html [new file with mode: 0644]
LayoutTests/compositing/overlap-blending/reflection-opacity-huge-expected.html [new file with mode: 0644]
LayoutTests/compositing/overlap-blending/reflection-opacity-huge.html [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp
Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h
Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp
Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp
Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
Source/WebCore/platform/graphics/texmap/TextureMapper.h
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/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h
Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h
Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.h
Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperTile.h
Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.h