12013-02-25 No'am Rosenthal <noam@webkit.org>
2
3 [Texmap] TextureMapper is too eager to use intermediate surfaces.
4 https://bugs.webkit.org/show_bug.cgi?id=110762
5
6 Reviewed by NOBODY (OOPS!).
7
8 Refactor the way intermediate surfaces are handled in TextureMapperLayer.
9 Beforehand, we would create an intermediate surface whenever there is a chance of overlap, and
10 the intermediate surface would be the largest possible. The result would then be drawn to the
11 target surface with the layer's opacity and mask.
12 This would make it so that (1) surfaces are created even when they're not needed, i.e. when there
13 is no actual overlap, and (2) mask wouldn't be applied correctly.
14
15 In this patch the behavior is changed so that the area to be painted is divided to "overlapping"
16 and "non overlapping" regions. The non-overlapping regions are painted directly, while the overlapping
17 regions are tiled to smaller rectangles painted using an intermediate surface.
18 Masks are applied to those intermediate surfaces based on the transform of the actual mask, not drawn
19 together with the content texture like before.
20
21 This optimizes for the more common case of opacity animations on a large tree, while making the quite
22 rare case of composited masks slightly less optimized but always correct.
23
24 Tests: compositing/overlap-blending/children-opacity-huge.html
25 compositing/overlap-blending/reflection-opacity-huge.html
26 compositing/overlap-blending/children-opacity-no-overlap.html
27
28 * platform/graphics/cairo/GraphicsContext3DPrivate.cpp:
29 (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
30 * platform/graphics/cairo/GraphicsContext3DPrivate.h:
31 (GraphicsContext3DPrivate):
32 * platform/graphics/efl/GraphicsContext3DPrivate.cpp:
33 (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
34 * platform/graphics/efl/GraphicsContext3DPrivate.h:
35 (GraphicsContext3DPrivate):
36 * platform/graphics/qt/GraphicsContext3DQt.cpp:
37 (GraphicsContext3DPrivate):
38 (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
39 * platform/graphics/qt/MediaPlayerPrivateQt.cpp:
40 (WebCore::MediaPlayerPrivateQt::paintToTextureMapper):
41 * platform/graphics/qt/MediaPlayerPrivateQt.h:
42 (MediaPlayerPrivateQt):
43 * platform/graphics/surfaces/GraphicsSurface.cpp:
44 (WebCore::GraphicsSurface::paintToTextureMapper):
45 * platform/graphics/surfaces/GraphicsSurface.h:
46 (GraphicsSurface):
47 * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
48 (WebCore::GraphicsSurface::platformPaintToTextureMapper):
49 * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
50 (WebCore::GraphicsSurface::platformPaintToTextureMapper):
51 * platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp:
52 (WebCore::GraphicsSurface::platformPaintToTextureMapper):
53 * platform/graphics/texmap/TextureMapperBackingStore.h:
54 (TextureMapperBackingStore):
55 * platform/graphics/texmap/TextureMapperPlatformLayer.h:
56 (TextureMapperPlatformLayer):
57 * platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp:
58 (WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):
59 * platform/graphics/texmap/TextureMapperSurfaceBackingStore.h:
60 (TextureMapperSurfaceBackingStore):
61 * platform/graphics/texmap/TextureMapperTile.cpp:
62 (WebCore::TextureMapperTile::paint):
63 * platform/graphics/texmap/TextureMapperTile.h:
64 (TextureMapperTile):
65 * platform/graphics/texmap/TextureMapperTiledBackingStore.cpp:
66 (WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
67 * platform/graphics/texmap/TextureMapperTiledBackingStore.h:
68 (TextureMapperTiledBackingStore):
69 * platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp:
70 (WebCore::CoordinatedBackingStore::paintTilesToTextureMapper):
71 (WebCore::CoordinatedBackingStore::paintToTextureMapper):
72 * platform/graphics/texmap/coordinated/CoordinatedBackingStore.h:
73 (CoordinatedBackingStore):
74 Removed the "mask" parameter from TextureMapperPlatformLayer and overrides.
75
76 * platform/graphics/texmap/TextureMapper.cpp:
77 (WebCore::TextureMapper::TextureMapper):
78 * platform/graphics/texmap/TextureMapper.h:
79 (WebCore::TextureMapper::setMaskMode):
80 (TextureMapper):
81 (WebCore::TextureMapper::isInMaskMode):
82 * platform/graphics/texmap/TextureMapperGL.cpp:
83 (WebCore::TextureMapperGL::drawNumber):
84 (WebCore::TextureMapperGL::drawTexture):
85 (WebCore::TextureMapperGL::draw):
86 (WebCore):
87 (WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
88 (WebCore::TextureMapperGL::drawFiltered):
89 * platform/graphics/texmap/TextureMapperGL.h:
90 (TextureMapperGL):
91 * platform/graphics/texmap/TextureMapperImageBuffer.cpp:
92 (WebCore::TextureMapperImageBuffer::drawTexture):
93 (WebCore::TextureMapperImageBuffer::drawSolidColor):
94 * platform/graphics/texmap/TextureMapperImageBuffer.h:
95 (TextureMapperImageBuffer):
96 Instead of painting the mask together with the texture/color, paint the mask
97 by drawing with DestinationIn to an existing surface.
98
99 * platform/graphics/texmap/TextureMapperLayer.cpp:
100 (TextureMapperPaintOptions):
101 (WebCore::TextureMapperLayer::paintSelf):
102 (WebCore::TextureMapperLayer::shouldBlend):
103 (WebCore::TextureMapperLayer::paintSelfAndChildrenWithReplica):
104 (WebCore::TextureMapperLayer::replicaTransform):
105 (WebCore):
106 (WebCore::applyFilters):
107 (WebCore::resolveOverlaps):
108 (WebCore::TextureMapperLayer::computeOverlapRegions):
109 (WebCore::TextureMapperLayer::paintUsingOverlapRegions):
110 (WebCore::TextureMapperLayer::applyMask):
111 (WebCore::TextureMapperLayer::paintIntoSurface):
112 (WebCore::commitSurface):
113 (WebCore::TextureMapperLayer::paintWithIntermediateSurface):
114 (WebCore::TextureMapperLayer::paintRecursive):
115 * platform/graphics/texmap/TextureMapperLayer.h:
116 (WebCore):
117 (TextureMapperLayer):
118 (WebCore::TextureMapperLayer::hasFilters):
119 * platform/graphics/texmap/TextureMapperShaderProgram.cpp:
120 (WebCore):
121 (WebCore::TextureMapperShaderProgram::create):
122 * platform/graphics/texmap/TextureMapperShaderProgram.h:
123