Source/WebCore/ChangeLog

 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
11242013-02-23 No'am Rosenthal <noam@webkit.org>
2125
3126 [Texmap] LayoutTests/compositing/animation/state-at-end-event-transform-layer.html shows a red square where it shouldn't

Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp

@@PlatformGraphicsContext3D GraphicsContext3DPrivate::platformContext()
7878}
7979
8080#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
81 void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask)
 81void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
8282{
8383 if (!m_glContext)
8484 return;

@@void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
142142 TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
143143 TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
144144 IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);
145  texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity, mask);
 145 texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity);
146146#endif // USE(ACCELERATED_COMPOSITING_GL)
147147}
148148#endif // USE(ACCELERATED_COMPOSITING)

Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h

@@public:
4444 GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
4545
4646#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
47  virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 47 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity);
4848#endif
4949
5050private:

Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp

@@bool GraphicsContext3DPrivate::prepareBuffer() const
197197}
198198
199199#if USE(TEXTURE_MAPPER_GL)
200 void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */)
 200void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */)
201201{
202202 notImplemented();
203203}

Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h

@@public:
4848 PlatformGraphicsContext3D platformGraphicsContext3D() const;
4949 void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback>);
5050#if USE(TEXTURE_MAPPER_GL)
51  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE;
 51 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float) OVERRIDE;
5252#endif
5353#if USE(GRAPHICS_SURFACE)
5454 virtual IntSize platformLayerSize() const OVERRIDE;

Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

@@public:
6666 ~GraphicsContext3DPrivate();
6767
6868#if USE(ACCELERATED_COMPOSITING)
69  virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 69 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity);
7070#endif
7171#if USE(GRAPHICS_SURFACE)
7272 virtual IntSize platformLayerSize() const;

@@static inline quint32 swapBgrToRgb(quint32 pixel)
209209}
210210
211211#if USE(ACCELERATED_COMPOSITING)
212 void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask)
 212void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
213213{
214214 m_context->markLayerComposited();
215215 blitMultisampleFramebufferAndRestoreContext();

@@void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
231231 currentContext->makeCurrent(currentSurface);
232232
233233 TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
234  m_graphicsSurface->paintToTextureMapper(texmapGL, targetRect, matrix, opacity, mask);
 234 m_graphicsSurface->paintToTextureMapper(texmapGL, targetRect, matrix, opacity);
235235#endif
236236 return;
237237 }

Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp

@@void MediaPlayerPrivateQt::paintCurrentFrameInContext(GraphicsContext* context,
645645}
646646
647647#if USE(ACCELERATED_COMPOSITING)
648 void MediaPlayerPrivateQt::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture*)
 648void MediaPlayerPrivateQt::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
649649{
650650}
651651#endif

Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h

@@public:
109109 virtual void acceleratedRenderingStateChanged() { }
110110 // Const-casting here is safe, since all of TextureMapperPlatformLayer's functions are const.g
111111 virtual PlatformLayer* platformLayer() const { return 0; }
112  virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 112 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity);
113113#endif
114114
115115 virtual PlatformMedia platformMedia() const;

Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp

@@void GraphicsSurface::copyFromTexture(uint32_t texture, const IntRect& sourceRec
6363 platformCopyFromTexture(texture, sourceRect);
6464}
6565
66 void GraphicsSurface::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 66void GraphicsSurface::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
6767{
68  platformPaintToTextureMapper(textureMapper, targetRect, transform, opacity, mask);
 68 platformPaintToTextureMapper(textureMapper, targetRect, transform, opacity);
6969}
7070
7171uint32_t GraphicsSurface::frontBuffer()

Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h

@@public:
7979 static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const GraphicsSurfaceToken&);
8080 void copyToGLTexture(uint32_t target, uint32_t texture, const IntRect& targetRect, const IntPoint& sourceOffset);
8181 void copyFromTexture(uint32_t texture, const IntRect& sourceRect);
82  void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 82 void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity);
8383 uint32_t frontBuffer();
8484 uint32_t swapBuffers();
8585 GraphicsSurfaceToken exportToken();

@@protected:
9999 void platformUnlock();
100100 void platformCopyToGLTexture(uint32_t target, uint32_t texture, const IntRect&, const IntPoint&);
101101 void platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect);
102  void platformPaintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 102 void platformPaintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity);
103103 uint32_t platformFrontBuffer() const;
104104 uint32_t platformSwapBuffers();
105105 IntSize platformSize() const;

Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp

@@void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
385385 m_private->copyFromTexture(texture, sourceRect);
386386}
387387
388 void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 388void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
389389{
390390 IntSize size = m_private->size();
391391 if (size.isEmpty())

@@void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper,
397397 FloatRect rectOnContents(FloatPoint::zero(), size);
398398 TransformationMatrix adjustedTransform = transform;
399399 adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
400  static_cast<TextureMapperGL*>(textureMapper)->drawTexture(texture, m_private->flags(), size, rectOnContents, adjustedTransform, opacity, mask);
 400 static_cast<TextureMapperGL*>(textureMapper)->drawTexture(texture, m_private->flags(), size, rectOnContents, adjustedTransform, opacity);
401401}
402402
403403uint32_t GraphicsSurface::platformFrontBuffer() const

Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp

@@void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
333333 m_private->copyFromTexture(texture, sourceRect);
334334}
335335
336 void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 336void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
337337{
338338 IntSize size = m_private->size();
339339 FloatRect rectOnContents(FloatPoint::zero(), size);
340340 TransformationMatrix adjustedTransform = transform;
341341 adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
342  static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, size, rectOnContents, adjustedTransform, opacity, mask);
 342 static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, size, rectOnContents, adjustedTransform, opacity);
343343}
344344
345345uint32_t GraphicsSurface::platformFrontBuffer() const

Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp

@@void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
421421 m_private->copyFromTexture(texture, sourceRect);
422422}
423423
424 void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 424void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
425425{
426426 IntSize size = m_private->size();
427427 FloatRect rectOnContents(FloatPoint::zero(), size);

Source/WebCore/platform/graphics/texmap/TextureMapper.cpp

@@TextureMapper::TextureMapper(AccelerationMode accelerationMode)
141141 , m_textDrawingMode(TextModeFill)
142142 , m_texturePool(adoptPtr(new BitmapTexturePool()))
143143 , m_accelerationMode(accelerationMode)
 144 , m_maskMode(false)
144145{ }
145146
146147TextureMapper::~TextureMapper()

Source/WebCore/platform/graphics/texmap/TextureMapper.h

@@public:
132132 virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) = 0;
133133 virtual void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) = 0;
134134
135  virtual void drawTexture(const BitmapTexture&, const FloatRect& target, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0f, const BitmapTexture* maskTexture = 0, unsigned exposedEdges = AllEdges) = 0;
 135 virtual void drawTexture(const BitmapTexture&, const FloatRect& target, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0f, unsigned exposedEdges = AllEdges) = 0;
136136 virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) = 0;
137137
138138 // makes a surface the target for the following drawTexture calls.

@@public:
153153 virtual void beginPainting(PaintFlags = 0) { }
154154 virtual void endPainting() { }
155155
 156 void setMaskMode(bool m) { m_maskMode = m; }
 157
156158 virtual IntSize maxTextureSize() const = 0;
157159
158160 virtual PassRefPtr<BitmapTexture> acquireTextureFromPool(const IntSize&);

@@protected:
166168
167169 GraphicsContext* m_context;
168170
 171 bool isInMaskMode() const { return m_maskMode; }
 172
169173private:
170174#if USE(TEXTURE_MAPPER_GL)
171175 static PassOwnPtr<TextureMapper> platformCreateAccelerated();

@@private:
179183 TextDrawingModeFlags m_textDrawingMode;
180184 OwnPtr<BitmapTexturePool> m_texturePool;
181185 AccelerationMode m_accelerationMode;
 186 bool m_maskMode;
182187};
183188
184189}

Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h

@@class GraphicsLayer;
3939class TextureMapperBackingStore : public TextureMapperPlatformLayer, public RefCounted<TextureMapperBackingStore> {
4040public:
4141 virtual PassRefPtr<BitmapTexture> texture() const = 0;
42  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) = 0;
 42 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float) = 0;
4343 virtual void drawRepaintCounter(TextureMapper*, int /* repaintCount */, const Color&, const FloatRect&, const TransformationMatrix&) { }
4444 virtual ~TextureMapperBackingStore() { }
4545

Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp

@@void TextureMapperGL::drawNumber(int number, const Color& color, const FloatPoin
349349 RefPtr<BitmapTexture> texture = acquireTextureFromPool(size);
350350 const uchar* bits = image.bits();
351351 static_cast<BitmapTextureGL*>(texture.get())->updateContentsNoSwizzle(bits, sourceRect, IntPoint::zero(), image.bytesPerLine());
352  drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, 0, AllEdges);
 352 drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, AllEdges);
353353
354354#elif USE(CAIRO)
355355 CString counterString = String::number(number).ascii();

@@void TextureMapperGL::drawNumber(int number, const Color& color, const FloatPoin
380380 const unsigned char* bits = cairo_image_surface_get_data(surface);
381381 int stride = cairo_image_surface_get_stride(surface);
382382 static_cast<BitmapTextureGL*>(texture.get())->updateContentsNoSwizzle(bits, sourceRect, IntPoint::zero(), stride);
383  drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, 0, AllEdges);
 383 drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, AllEdges);
384384
385385 cairo_surface_destroy(surface);
386386 cairo_destroy(cr);

@@void TextureMapperGL::drawNumber(int number, const Color& color, const FloatPoin
394394#endif
395395}
396396
397 void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* mask, unsigned exposedEdges)
 397void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, unsigned exposedEdges)
398398{
399399 if (!texture.isValid())
400400 return;

@@void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect&
403403 return;
404404
405405 const BitmapTextureGL& textureGL = static_cast<const BitmapTextureGL&>(texture);
406  drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : ShouldBlend, textureGL.size(), targetRect, matrix, opacity, mask, exposedEdges);
 406 drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : ShouldBlend, textureGL.size(), targetRect, matrix, opacity, exposedEdges);
407407}
408408
409 void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges)
 409void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges)
410410{
411411 bool useRect = flags & ShouldUseARBTextureRect;
412  bool masked = !!maskTexture;
413412 bool useAntialiasing = m_enableEdgeDistanceAntialiasing
414413 && exposedEdges == AllEdges
415414 && !modelViewMatrix.mapQuad(targetRect).isRectilinear();
416415
417416 TextureMapperShaderProgram::Options options = TextureMapperShaderProgram::Texture;
418  if (masked)
419  options |= TextureMapperShaderProgram::Mask;
420417 if (useRect)
421418 options |= TextureMapperShaderProgram::Rect;
422419 if (opacity < 1)

@@void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const I
426423 flags |= ShouldAntialias;
427424 }
428425
429  if (masked || useAntialiasing || opacity < 1)
 426 if (useAntialiasing || opacity < 1)
430427 flags |= ShouldBlend;
431428
432429 RefPtr<TextureMapperShaderProgram> program;
433430 program = data().sharedGLData().getShaderProgram(options);
434  drawTexturedQuadWithProgram(program.get(), texture, flags, textureSize, targetRect, modelViewMatrix, opacity, maskTexture);
 431 drawTexturedQuadWithProgram(program.get(), texture, flags, textureSize, targetRect, modelViewMatrix, opacity);
435432}
436433
437434void TextureMapperGL::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color)

@@void TextureMapperGL::draw(const FloatRect& rect, const TransformationMatrix& mo
504501 shaderProgram->setMatrix(shaderProgram->modelViewMatrixLocation(), matrix);
505502 shaderProgram->setMatrix(shaderProgram->projectionMatrixLocation(), data().projectionMatrix);
506503
507  if (flags & ShouldBlend) {
508  m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
 504 if (isInMaskMode()) {
 505 m_context3D->blendFunc(GraphicsContext3D::ZERO, GraphicsContext3D::SRC_ALPHA);
509506 m_context3D->enable(GraphicsContext3D::BLEND);
510  } else
511  m_context3D->disable(GraphicsContext3D::BLEND);
 507 } else {
 508 if (flags & ShouldBlend) {
 509 m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
 510 m_context3D->enable(GraphicsContext3D::BLEND);
 511 } else
 512 m_context3D->disable(GraphicsContext3D::BLEND);
 513 }
512514
513515 if (flags & ShouldAntialias)
514516 drawEdgeTriangles(shaderProgram);

@@void TextureMapperGL::draw(const FloatRect& rect, const TransformationMatrix& mo
516518 drawUnitRect(shaderProgram, drawingMode);
517519
518520 m_context3D->disableVertexAttribArray(shaderProgram->vertexLocation());
 521 m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
 522 m_context3D->enable(GraphicsContext3D::BLEND);
519523}
520 void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const IntSize& size, const FloatRect& rect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
 524
 525void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const IntSize& size, const FloatRect& rect, const TransformationMatrix& modelViewMatrix, float opacity)
521526{
522527 m_context3D->useProgram(program->programID());
523528 m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);

@@void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* pr
533538 if (flags & ShouldFlipTexture)
534539 patternTransform.translate(0, -1);
535540
536 
537541 program->setMatrix(program->textureSpaceMatrixLocation(), patternTransform);
538542 m_context3D->uniform1f(program->opacityLocation(), opacity);
539543
540  if (maskTexture && maskTexture->isValid()) {
541  const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture);
542  m_context3D->activeTexture(GraphicsContext3D::TEXTURE1);
543  m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureGL->id());
544  m_context3D->uniform1i(program->maskLocation(), 1);
545  m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
546  }
547 
548  if (opacity < 1 || maskTexture)
 544 if (opacity < 1)
549545 flags |= ShouldBlend;
550546
551547 draw(rect, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, flags);

@@void TextureMapperGL::drawFiltered(const BitmapTexture& sampler, const BitmapTex
943939
944940 prepareFilterProgram(program.get(), filter, pass, sampler.contentSize(), static_cast<const BitmapTextureGL&>(contentTexture).id());
945941 FloatRect targetRect(IntPoint::zero(), sampler.contentSize());
946  drawTexturedQuadWithProgram(program.get(), static_cast<const BitmapTextureGL&>(sampler).id(), 0, IntSize(1, 1), targetRect, TransformationMatrix(), 1, 0);
 942 drawTexturedQuadWithProgram(program.get(), static_cast<const BitmapTextureGL&>(sampler).id(), 0, IntSize(1, 1), targetRect, TransformationMatrix(), 1);
947943}
948944
949945PassRefPtr<BitmapTexture> BitmapTextureGL::applyFilters(TextureMapper* textureMapper, const BitmapTexture& contentTexture, const FilterOperations& filters)

Source/WebCore/platform/graphics/texmap/TextureMapperGL.h

@@public:
5454 // TextureMapper implementation
5555 virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
5656 virtual void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) OVERRIDE;
57  virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
58  virtual void drawTexture(Platform3DObject texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges);
 57 virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, unsigned exposedEdges) OVERRIDE;
 58 virtual void drawTexture(Platform3DObject texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges = AllEdges);
5959 virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) OVERRIDE;
6060
6161 virtual void bindSurface(BitmapTexture* surface) OVERRIDE;

@@private:
102102
103103 TextureMapperGL();
104104
105  void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
 105 void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity);
106106 void draw(const FloatRect&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, Flags);
107107
108108 void drawUnitRect(TextureMapperShaderProgram*, GC3Denum drawingMode);

Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp

@@void TextureMapperImageBuffer::beginClip(const TransformationMatrix& matrix, con
114114#endif
115115}
116116
117 void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* maskTexture, unsigned /* exposedEdges */)
 117void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, unsigned /* exposedEdges */)
118118{
119119 GraphicsContext* context = currentContext();
120120 if (!context)

@@void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const F
122122
123123 const BitmapTextureImageBuffer& textureImageBuffer = static_cast<const BitmapTextureImageBuffer&>(texture);
124124 ImageBuffer* image = textureImageBuffer.m_image.get();
125  OwnPtr<ImageBuffer> maskedImage;
126 
127  if (maskTexture && maskTexture->isValid()) {
128  const BitmapTextureImageBuffer* mask = static_cast<const BitmapTextureImageBuffer*>(maskTexture);
129  maskedImage = ImageBuffer::create(maskTexture->contentSize());
130  GraphicsContext* maskContext = maskedImage->context();
131  maskContext->drawImageBuffer(image, ColorSpaceDeviceRGB, IntPoint::zero(), CompositeCopy);
132  if (opacity < 1) {
133  maskContext->setAlpha(opacity);
134  opacity = 1;
135  }
136  maskContext->drawImageBuffer(mask->m_image.get(), ColorSpaceDeviceRGB, IntPoint::zero(), CompositeDestinationIn);
137  image = maskedImage.get();
138  }
139 
140125 context->save();
 126 context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
141127 context->setAlpha(opacity);
142128#if ENABLE(3D_RENDERING)
143129 context->concat3DTransform(matrix);

@@void TextureMapperImageBuffer::drawSolidColor(const FloatRect& rect, const Trans
155141 return;
156142
157143 context->save();
 144 context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
158145#if ENABLE(3D_RENDERING)
159146 context->concat3DTransform(matrix);
160147#else

Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h

@@public:
5555 // TextureMapper implementation
5656 virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
5757 virtual void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) OVERRIDE;
58  virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
 58 virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, unsigned exposedEdges) OVERRIDE;
5959 virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) OVERRIDE;
6060 virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
6161 virtual void bindSurface(BitmapTexture* surface) OVERRIDE { m_currentSurface = surface;}

Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

2020#include "config.h"
2121#include "TextureMapperLayer.h"
2222
 23#include "Region.h"
 24
2325#if USE(ACCELERATED_COMPOSITING)
2426
2527namespace WebCore {

@@namespace WebCore {
2729class TextureMapperPaintOptions {
2830public:
2931 RefPtr<BitmapTexture> surface;
30  RefPtr<BitmapTexture> mask;
3132 float opacity;
3233 TransformationMatrix transform;
3334 IntSize offset;

@@void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
108109 transform.multiply(m_currentTransform.combined());
109110
110111 float opacity = options.opacity;
111  RefPtr<BitmapTexture> mask = options.mask;
112 
113112 if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty()) {
114113 options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, opacity));
115114 if (m_state.showDebugBorders)

@@void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
120119 if (m_backingStore) {
121120 ASSERT(m_state.drawsContent && m_state.contentsVisible && !m_state.size.isEmpty());
122121 ASSERT(!layerRect().isEmpty());
123  m_backingStore->paintToTextureMapper(options.textureMapper, layerRect(), transform, opacity, mask.get());
 122 m_backingStore->paintToTextureMapper(options.textureMapper, layerRect(), transform, opacity);
124123 if (m_state.showDebugBorders)
125124 m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
126125 // Only draw repaint count for the main backing store.

@@void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
130129
131130 if (m_contentsLayer) {
132131 ASSERT(!layerRect().isEmpty());
133  m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, opacity, mask.get());
 132 m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, opacity);
134133 if (m_state.showDebugBorders)
135134 m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
136135 }

@@void TextureMapperLayer::paintSelfAndChildren(const TextureMapperPaintOptions& o
166165 options.textureMapper->endClip();
167166}
168167
169 IntRect TextureMapperLayer::intermediateSurfaceRect()
170 {
171  // FIXME: Add an inverse transform to LayerTransform.
172  return intermediateSurfaceRect(m_currentTransform.combined().inverse());
173 }
174 
175 IntRect TextureMapperLayer::intermediateSurfaceRect(const TransformationMatrix& matrix)
176 {
177  IntRect rect;
178  TransformationMatrix localTransform = TransformationMatrix(matrix).multiply(m_currentTransform.combined());
179  rect = enclosingIntRect(localTransform.mapRect(layerRect()));
180  if (!m_state.masksToBounds && !m_state.maskLayer) {
181  for (size_t i = 0; i < m_children.size(); ++i)
182  rect.unite(m_children[i]->intermediateSurfaceRect(matrix));
183  }
184 
185 #if ENABLE(CSS_FILTERS)
186  if (m_currentFilters.hasOutsets()) {
187  FilterOutsets outsets = m_currentFilters.outsets();
188  IntRect unfilteredTargetRect(rect);
189  rect.move(std::max(0, -outsets.left()), std::max(0, -outsets.top()));
190  rect.expand(outsets.left() + outsets.right(), outsets.top() + outsets.bottom());
191  rect.unite(unfilteredTargetRect);
192  }
193 #endif
194 
195  if (m_state.replicaLayer)
196  rect.unite(m_state.replicaLayer->intermediateSurfaceRect(matrix));
197 
198  return rect;
199 }
200 
201 TextureMapperLayer::ContentsLayerCount TextureMapperLayer::countPotentialLayersWithContents() const
 168bool TextureMapperLayer::shouldBlend() const
202169{
203  int selfLayersWithContents = (m_state.drawsContent ? 1 : 0) + (m_contentsLayer ? 1 : 0);
204  int potentialLayersWithContents = selfLayersWithContents + m_children.size();
205 
206  if (!potentialLayersWithContents)
207  return NoLayersWithContent;
208 
209  if (potentialLayersWithContents > 1)
210  return MultipleLayersWithContents;
211 
212  if (m_children.isEmpty())
213  return SingleLayerWithContents;
214 
215  return m_children.first()->countPotentialLayersWithContents();
216 }
 170 if (m_state.preserves3D)
 171 return false;
217172
218 bool TextureMapperLayer::shouldPaintToIntermediateSurface() const
219 {
220173#if ENABLE(CSS_FILTERS)
221174 if (m_currentFilters.size())
222175 return true;
223176#endif
224  bool hasOpacity = m_currentOpacity < 0.99;
225  bool canHaveMultipleLayersWithContent = countPotentialLayersWithContents() == MultipleLayersWithContents;
226  bool hasReplica = !!m_state.replicaLayer;
227  bool hasMask = !!m_state.maskLayer;
228 
229  // We don't use two-pass blending for preserves-3d, that's in sync with Safari.
230  if (m_state.preserves3D)
231  return false;
232 
233  // We should use an intermediate surface when blending several items with an ancestor opacity.
234  // Tested by compositing/reflections/reflection-opacity.html
235  if (hasOpacity && (canHaveMultipleLayersWithContent || hasReplica))
236  return true;
237 
238  // We should use an intermediate surface with a masked ancestor.
239  // In the case of replicas the mask is applied before replicating.
240  // Tested by compositing/masks/masked-ancestor.html
241  if (hasMask && canHaveMultipleLayersWithContent && !hasReplica)
242  return true;
243 
244  return false;
 177 return m_currentOpacity < 1 || m_state.maskLayer || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer);
245178}
246179
247180bool TextureMapperLayer::isVisible() const

@@void TextureMapperLayer::paintSelfAndChildrenWithReplica(const TextureMapperPain
261194{
262195 if (m_state.replicaLayer) {
263196 TextureMapperPaintOptions replicaOptions(options);
264  // We choose either the content's mask or the replica's mask.
265  // FIXME: blend the two if both exist.
266  if (m_state.replicaLayer->m_state.maskLayer)
267  replicaOptions.mask = m_state.replicaLayer->m_state.maskLayer->texture();
268 
269197 replicaOptions.transform
270198 .multiply(m_state.replicaLayer->m_currentTransform.combined())
271199 .multiply(m_currentTransform.combined().inverse());

@@void TextureMapperLayer::setAnimatedOpacity(float opacity)
285213 m_currentOpacity = opacity;
286214}
287215
 216TransformationMatrix TextureMapperLayer::replicaTransform()
 217{
 218 return TransformationMatrix(m_state.replicaLayer->m_currentTransform.combined()).multiply(m_currentTransform.combined().inverse());
 219}
 220
288221#if ENABLE(CSS_FILTERS)
289222void TextureMapperLayer::setAnimatedFilters(const FilterOperations& filters)
290223{

@@static bool shouldKeepContentTexture(const FilterOperations& filters)
307240 return false;
308241}
309242
310 static PassRefPtr<BitmapTexture> applyFilters(const FilterOperations& filters, TextureMapper* textureMapper, BitmapTexture* source, IntRect& targetRect)
 243static PassRefPtr<BitmapTexture> applyFilters(const FilterOperations& filters, TextureMapper* textureMapper, BitmapTexture* source)
311244{
312245 if (!filters.size())
313246 return source;

@@static PassRefPtr<BitmapTexture> applyFilters(const FilterOperations& filters, T
317250}
318251#endif
319252
320 void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options)
 253static void resolveOverlaps(Region& overlapRegion, Region& nonOverlapRegion, Region newRegion)
321254{
322  if (!isVisible())
 255 Region newOverlapRegion(newRegion);
 256 newOverlapRegion.intersect(nonOverlapRegion);
 257 nonOverlapRegion.subtract(newOverlapRegion);
 258 overlapRegion.unite(newOverlapRegion);
 259 newRegion.subtract(overlapRegion);
 260 nonOverlapRegion.unite(newRegion);
 261}
 262
 263void TextureMapperLayer::computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, bool alwaysResolveSelfOverlap)
 264{
 265 if (!m_state.visible || !m_state.contentsVisible)
323266 return;
324267
325  float opacity = options.opacity * m_currentOpacity;
326  RefPtr<BitmapTexture> maskTexture = m_state.maskLayer ? m_state.maskLayer->texture() : 0;
 268 FloatRect boundingRect;
 269 if (m_backingStore || m_state.masksToBounds || m_state.maskLayer || hasFilters())
 270 boundingRect = layerRect();
 271 else if (m_contentsLayer || m_state.solidColor.alpha())
 272 boundingRect = m_state.contentsRect;
327273
328  TextureMapperPaintOptions paintOptions(options);
329  paintOptions.mask = maskTexture.get();
 274#if ENABLE(CSS_FILTERS)
 275 if (m_currentFilters.hasOutsets()) {
 276 FilterOutsets outsets = m_currentFilters.outsets();
 277 IntRect unfilteredTargetRect(boundingRect);
 278 boundingRect.move(std::max(0, -outsets.left()), std::max(0, -outsets.top()));
 279 boundingRect.expand(outsets.left() + outsets.right(), outsets.top() + outsets.bottom());
 280 boundingRect.unite(unfilteredTargetRect);
 281 }
 282#endif
 283
 284 TransformationMatrix replicaMatrix;
 285 if (m_state.replicaLayer) {
 286 replicaMatrix = replicaTransform();
 287 boundingRect.unite(replicaMatrix.mapRect(boundingRect));
 288 }
330289
331  if (!shouldPaintToIntermediateSurface()) {
332  paintOptions.opacity = opacity;
333  paintSelfAndChildrenWithReplica(paintOptions);
 290 boundingRect = m_currentTransform.combined().mapRect(boundingRect);
 291
 292 // Count all masks and filters as overlap layers.
 293 if (hasFilters() || m_state.maskLayer || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer)) {
 294 Region newOverlapRegion(enclosingIntRect(boundingRect));
 295 nonOverlapRegion.subtract(newOverlapRegion);
 296 overlapRegion.unite(newOverlapRegion);
334297 return;
335298 }
336299
337  // Prepare a surface to paint into.
338  // We paint into the surface ignoring the opacity/transform of the current layer.
339  IntRect surfaceRect = intermediateSurfaceRect();
340  RefPtr<BitmapTexture> surface = options.textureMapper->acquireTextureFromPool(surfaceRect.size());
341  paintOptions.surface = surface;
342  options.textureMapper->bindSurface(surface.get());
343  paintOptions.opacity = 1;
 300 Region newOverlapRegion;
 301 Region newNonOverlapRegion(enclosingIntRect(boundingRect));
 302
 303 if (!m_state.masksToBounds) {
 304 for (size_t i = 0; i < m_children.size(); ++i) {
 305 TextureMapperLayer* child = m_children[i];
 306 bool alwaysResolveSelfOverlapForChildren = false;
 307 child->computeOverlapRegions(newOverlapRegion, newNonOverlapRegion, alwaysResolveSelfOverlapForChildren);
 308 }
 309 }
 310
 311 if (m_state.replicaLayer) {
 312 newOverlapRegion.unite(replicaMatrix.mapRect(newOverlapRegion.bounds()));
 313 Region replicaRegion(replicaMatrix.mapRect(newNonOverlapRegion.bounds()));
 314 resolveOverlaps(newOverlapRegion, newNonOverlapRegion, replicaRegion);
 315 }
344316
345  paintOptions.transform = m_currentTransform.combined().inverse();
346  paintOptions.offset = -IntSize(surfaceRect.x(), surfaceRect.y());
 317 if (!alwaysResolveSelfOverlap && shouldBlend()) {
 318 newNonOverlapRegion.unite(newOverlapRegion);
 319 newOverlapRegion = Region();
 320 }
347321
348  paintSelfAndChildrenWithReplica(paintOptions);
 322 overlapRegion.unite(newOverlapRegion);
 323 resolveOverlaps(overlapRegion, nonOverlapRegion, newNonOverlapRegion);
 324}
349325
350  // If we painted the replica, the mask is already applied so we don't need to paint it again.
351  if (m_state.replicaLayer)
352  maskTexture = 0;
 326void TextureMapperLayer::paintUsingOverlapRegions(const TextureMapperPaintOptions& options)
 327{
 328 Region overlapRegion;
 329 Region nonOverlapRegion;
 330 computeOverlapRegions(overlapRegion, nonOverlapRegion);
 331 if (overlapRegion.isEmpty()) {
 332 paintSelfAndChildrenWithReplica(options);
 333 return;
 334 }
 335
 336 Vector<IntRect> rects = nonOverlapRegion.rects();
 337 for (size_t i = 0; i < rects.size(); ++i) {
 338 options.textureMapper->beginClip(TransformationMatrix(), rects[i]);
 339 paintSelfAndChildrenWithReplica(options);
 340 options.textureMapper->endClip();
 341 }
 342
 343 rects = overlapRegion.rects();
 344 for (size_t i = 0; i < rects.size(); ++i) {
 345 IntRect rect = rects[i];
 346 const static int maxRectDimension = 2000;
 347 for (int x = rect.x(); x < rect.maxX(); x += maxRectDimension) {
 348 for (int y = rect.y(); y < rect.maxY(); y += maxRectDimension) {
 349 IntRect tileRect(x, y, maxRectDimension, maxRectDimension);
 350 tileRect.intersect(rect);
 351 paintWithIntermediateSurface(options, tileRect);
 352 }
 353 }
 354 }
 355}
353356
 357void TextureMapperLayer::applyMask(const TextureMapperPaintOptions& options)
 358{
 359 options.textureMapper->setMaskMode(true);
 360 paintSelf(options);
 361 options.textureMapper->setMaskMode(false);
 362}
 363
 364PassRefPtr<BitmapTexture> TextureMapperLayer::paintIntoSurface(const TextureMapperPaintOptions& options, const IntSize& size)
 365{
 366 RefPtr<BitmapTexture> surface = options.textureMapper->acquireTextureFromPool(size);
 367 options.textureMapper->bindSurface(surface.get());
 368 paintSelfAndChildren(options);
 369 if (m_state.maskLayer)
 370 m_state.maskLayer->applyMask(options);
354371#if ENABLE(CSS_FILTERS)
355  surface = applyFilters(m_currentFilters, options.textureMapper, surface.get(), surfaceRect);
 372 if (!m_currentFilters.isEmpty())
 373 surface = applyFilters(m_currentFilters, options.textureMapper, surface.get());
356374#endif
 375 options.textureMapper->bindSurface(surface.get());
 376 return surface;
 377}
357378
 379static PassRefPtr<BitmapTexture> commitSurface(const TextureMapperPaintOptions& options, PassRefPtr<BitmapTexture> surface, const IntRect& rect, float opacity)
 380{
358381 options.textureMapper->bindSurface(options.surface.get());
359382 TransformationMatrix targetTransform;
360383 targetTransform.translate(options.offset.width(), options.offset.height());
361384 targetTransform.multiply(options.transform);
362  targetTransform.multiply(m_currentTransform.combined());
 385 options.textureMapper->drawTexture(*surface.get(), rect, targetTransform, opacity);
 386 return 0;
 387}
 388
 389void TextureMapperLayer::paintWithIntermediateSurface(const TextureMapperPaintOptions& options, const IntRect& rect)
 390{
 391 RefPtr<BitmapTexture> replicaSurface;
 392 RefPtr<BitmapTexture> mainSurface;
 393 TextureMapperPaintOptions paintOptions(options);
 394 paintOptions.offset = -IntSize(rect.x(), rect.y());
 395 paintOptions.opacity = 1;
 396 paintOptions.transform = TransformationMatrix();
 397 if (m_state.replicaLayer) {
 398 paintOptions.transform = replicaTransform();
 399 replicaSurface = paintIntoSurface(paintOptions, rect.size());
 400 paintOptions.transform = TransformationMatrix();
 401 if (m_state.replicaLayer->m_state.maskLayer)
 402 m_state.replicaLayer->m_state.maskLayer->applyMask(paintOptions);
 403 }
363404
364  options.textureMapper->drawTexture(*surface.get(), surfaceRect, targetTransform, opacity, maskTexture.get());
 405 if (replicaSurface && options.opacity == 1)
 406 replicaSurface = commitSurface(options, replicaSurface, rect, 1);
 407
 408 mainSurface = paintIntoSurface(paintOptions, rect.size());
 409 if (replicaSurface) {
 410 options.textureMapper->bindSurface(replicaSurface.get());
 411 options.textureMapper->drawTexture(*mainSurface.get(), FloatRect(FloatPoint::zero(), rect.size()));
 412 mainSurface = replicaSurface;
 413 }
 414
 415 commitSurface(options, mainSurface, rect, options.opacity);
 416}
 417
 418void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options)
 419{
 420 if (!isVisible())
 421 return;
 422
 423 if (!shouldBlend()) {
 424 paintSelfAndChildrenWithReplica(options);
 425 return;
 426 }
 427
 428 TextureMapperPaintOptions paintOptions(options);
 429 paintOptions.opacity = options.opacity * m_currentOpacity;
 430 paintUsingOverlapRegions(paintOptions);
365431}
366432
367433TextureMapperLayer::~TextureMapperLayer()

Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

3131
3232namespace WebCore {
3333
 34class Region;
3435class TextureMapperPaintOptions;
3536class TextureMapperPlatformLayer;
3637

@@public:
7374#if ENABLE(CSS_FILTERS)
7475 void setFilters(const FilterOperations&);
7576#endif
 77
 78 bool hasFilters() const
 79 {
 80#if ENABLE(CSS_FILTERS)
 81 return !m_currentFilters.isEmpty();
 82#else
 83 return false;
 84#endif
 85 }
 86
7687 void setDebugVisuals(bool showDebugBorders, const Color& debugBorderColor, float debugBorderWidth, bool showRepaintCounter);
7788 void setRepaintCount(int);
7889 void setContentsLayer(TextureMapperPlatformLayer*);

@@public:
92103private:
93104 const TextureMapperLayer* rootLayer() const;
94105 void computeTransformsRecursive();
95  IntRect intermediateSurfaceRect(const TransformationMatrix&);
96  IntRect intermediateSurfaceRect();
97106
98107 static int compareGraphicsLayersZValue(const void* a, const void* b);
99108 static void sortByZOrder(Vector<TextureMapperLayer* >& array, int first, int last);

@@private:
101110 PassRefPtr<BitmapTexture> texture() { return m_backingStore ? m_backingStore->texture() : 0; }
102111 FloatPoint adjustedPosition() const { return m_state.pos + m_scrollPositionDelta; }
103112 bool isAncestorFixedToViewport() const;
104 
 113 TransformationMatrix replicaTransform();
105114 void addChild(TextureMapperLayer*);
106115 void removeFromParent();
107116 void removeAllChildren();
108117
 118 void computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, bool alwaysResolveSelfOverlap = true);
 119
109120 void paintRecursive(const TextureMapperPaintOptions&);
 121 void paintUsingOverlapRegions(const TextureMapperPaintOptions&);
 122 PassRefPtr<BitmapTexture> paintIntoSurface(const TextureMapperPaintOptions&, const IntSize&);
 123 void paintWithIntermediateSurface(const TextureMapperPaintOptions&, const IntRect&);
110124 void paintSelf(const TextureMapperPaintOptions&);
111125 void paintSelfAndChildren(const TextureMapperPaintOptions&);
112126 void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
 127 void applyMask(const TextureMapperPaintOptions&);
113128
114129 // GraphicsLayerAnimation::Client
115130 virtual void setAnimatedTransform(const TransformationMatrix&) OVERRIDE;

@@private:
125140 MultipleLayersWithContents
126141 };
127142
128  ContentsLayerCount countPotentialLayersWithContents() const;
129  bool shouldPaintToIntermediateSurface() const;
 143 bool shouldBlend() const;
130144
131145 inline FloatRect layerRect() const
132146 {

Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h

@@namespace WebCore {
3232class TextureMapperPlatformLayer {
3333public:
3434 virtual ~TextureMapperPlatformLayer() { }
35  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0, BitmapTexture* mask = 0) = 0;
 35 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0) = 0;
3636 virtual void swapBuffers() { }
3737 virtual void drawBorder(TextureMapper* textureMapper, const Color& color, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
3838 {

Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp

@@static const char* vertexTemplate =
127127 uniform mat4 u_textureSpaceMatrix;
128128
129129 varying vec2 v_texCoord;
130  varying vec2 v_maskTexCoord;
131130 varying float v_antialias;
132131
133132 void noop(inout vec2 dummyParameter) { }

@@static const char* vertexTemplate =
176175 // The texture position needs to be clamped to 0..1 before the texture matrix is applied.
177176 vec4 clampedPosition = clamp(vec4(position, 0., 1.), 0., 1.);
178177 v_texCoord = (u_textureSpaceMatrix * clampedPosition).xy;
179 
180  v_maskTexCoord = position;
181178 gl_Position = u_projectionMatrix * u_modelViewMatrix * vec4(position, 0., 1.);
182179 }
183180 );

@@static const char* fragmentTemplate =
204201 STRINGIFY(
205202 precision mediump float;
206203 uniform SamplerType s_sampler;
207  uniform sampler2D s_mask;
208204 uniform sampler2D s_contentTexture;
209205 uniform float u_opacity;
210206 varying float v_antialias;
211207 varying vec2 v_texCoord;
212  varying vec2 v_maskTexCoord;
213208 uniform float u_filterAmount;
214209 uniform vec2 u_blurRadius;
215210 uniform vec2 u_shadowOffset;

@@static const char* fragmentTemplate =
223218 void applyTexture(inout vec4 color) { color = SamplerFunction(s_sampler, v_texCoord); }
224219 void applyOpacity(inout vec4 color) { color *= u_opacity; }
225220 void applyAntialiasing(inout vec4 color) { color *= antialias(); }
226  void applyMask(inout vec4 color) { color *= texture2D(s_mask, v_maskTexCoord).a; }
227221
228222 void applyGrayscaleFilter(inout vec4 color)
229223 {

@@static const char* fragmentTemplate =
334328 applyTextureIfNeeded(color);
335329 applySolidColorIfNeeded(color);
336330 applyAntialiasingIfNeeded(color);
337  applyMaskIfNeeded(color);
338331 applyOpacityIfNeeded(color);
339332 applyGrayscaleFilterIfNeeded(color);
340333 applySepiaFilterIfNeeded(color);

@@PassRefPtr<TextureMapperShaderProgram> TextureMapperShaderProgram::create(PassRe
362355 SET_APPLIER_FROM_OPTIONS(Rect);
363356 SET_APPLIER_FROM_OPTIONS(SolidColor);
364357 SET_APPLIER_FROM_OPTIONS(Opacity);
365  SET_APPLIER_FROM_OPTIONS(Mask);
366358 SET_APPLIER_FROM_OPTIONS(Antialiasing);
367359 SET_APPLIER_FROM_OPTIONS(GrayscaleFilter);
368360 SET_APPLIER_FROM_OPTIONS(SepiaFilter);

Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h

@@public:
4242 Rect = 1L << 1,
4343 SolidColor = 1L << 2,
4444 Opacity = 1L << 3,
45  Mask = 1L << 4,
4645 Antialiasing = 1L << 5,
4746 GrayscaleFilter = 1L << 6,
4847 SepiaFilter = 1L << 7,

Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp

@@PassRefPtr<BitmapTexture> TextureMapperSurfaceBackingStore::texture() const
4444 return emptyTexture;
4545}
4646
47 void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 47void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
4848{
4949 if (m_graphicsSurface)
50  m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, transform, opacity, mask);
 50 m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, transform, opacity);
5151}
5252
5353} // namespace WebCore

Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.h

@@public:
3737 void setGraphicsSurface(PassRefPtr<GraphicsSurface>);
3838 void swapBuffersIfNeeded(uint32_t frontBuffer);
3939 virtual PassRefPtr<BitmapTexture> texture() const;
40  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
 40 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float);
4141 virtual ~TextureMapperSurfaceBackingStore() { }
4242
4343private:

Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp

@@void TextureMapperTile::updateContents(TextureMapper* textureMapper, GraphicsLay
6969 m_texture->updateContents(textureMapper, sourceLayer, targetRect, sourceOffset, updateContentsFlag);
7070}
7171
72 void TextureMapperTile::paint(TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, BitmapTexture* mask, const unsigned exposedEdges)
 72void TextureMapperTile::paint(TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, const unsigned exposedEdges)
7373{
7474 if (texture().get())
75  textureMapper->drawTexture(*texture().get(), rect(), transform, opacity, mask, exposedEdges);
 75 textureMapper->drawTexture(*texture().get(), rect(), transform, opacity, exposedEdges);
7676}
7777
7878} // namespace WebCore

Source/WebCore/platform/graphics/texmap/TextureMapperTile.h

@@public:
4141
4242 void updateContents(TextureMapper*, Image*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
4343 void updateContents(TextureMapper*, GraphicsLayer*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
44  virtual void paint(TextureMapper*, const TransformationMatrix&, float, BitmapTexture*, const unsigned exposedEdges);
 44 virtual void paint(TextureMapper*, const TransformationMatrix&, float, const unsigned exposedEdges);
4545 virtual ~TextureMapperTile() { }
4646
4747 explicit TextureMapperTile(const FloatRect& rect)

Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp

@@TransformationMatrix TextureMapperTiledBackingStore::adjustedTransformForRect(co
4747 return TransformationMatrix::rectToRect(rect(), targetRect);
4848}
4949
50 void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 50void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
5151{
5252 updateContentsFromImageIfNeeded(textureMapper);
5353 TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
5454 for (size_t i = 0; i < m_tiles.size(); ++i)
55  m_tiles[i].paint(textureMapper, adjustedTransform, opacity, mask, calculateExposedTileEdges(rect(), m_tiles[i].rect()));
 55 m_tiles[i].paint(textureMapper, adjustedTransform, opacity, calculateExposedTileEdges(rect(), m_tiles[i].rect()));
5656}
5757
5858void TextureMapperTiledBackingStore::drawBorder(TextureMapper* textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)

Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h

@@public:
3838 virtual ~TextureMapperTiledBackingStore() { }
3939
4040 virtual PassRefPtr<BitmapTexture> texture() const OVERRIDE;
41  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE;
 41 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float) OVERRIDE;
4242 virtual void drawBorder(TextureMapper*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
4343 virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) OVERRIDE;
4444 void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp

@@void CoordinatedBackingStore::setSize(const FloatSize& size)
106106 m_pendingSize = size;
107107}
108108
109 void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, BitmapTexture* mask, const FloatRect& rect)
 109void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, const FloatRect& rect)
110110{
111111 for (size_t i = 0; i < tiles.size(); ++i)
112  tiles[i]->paint(textureMapper, transform, opacity, mask, calculateExposedTileEdges(rect, tiles[i]->rect()));
 112 tiles[i]->paint(textureMapper, transform, opacity, calculateExposedTileEdges(rect, tiles[i]->rect()));
113113}
114114
115115TransformationMatrix CoordinatedBackingStore::adjustedTransformForRect(const FloatRect& targetRect)

@@TransformationMatrix CoordinatedBackingStore::adjustedTransformForRect(const Flo
117117 return TransformationMatrix::rectToRect(rect(), targetRect);
118118}
119119
120 void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 120void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
121121{
122122 if (m_tiles.isEmpty())
123123 return;

@@void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper,
152152 // See TiledBackingStore.
153153 TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
154154
155  paintTilesToTextureMapper(previousTilesToPaint, textureMapper, adjustedTransform, opacity, mask, rect());
156  paintTilesToTextureMapper(tilesToPaint, textureMapper, adjustedTransform, opacity, mask, rect());
 155 paintTilesToTextureMapper(previousTilesToPaint, textureMapper, adjustedTransform, opacity, rect());
 156 paintTilesToTextureMapper(tilesToPaint, textureMapper, adjustedTransform, opacity, rect());
157157}
158158
159159void CoordinatedBackingStore::drawBorder(TextureMapper* textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.h

@@public:
6262 void commitTileOperations(TextureMapper*);
6363 PassRefPtr<BitmapTexture> texture() const;
6464 void setSize(const FloatSize&);
65  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
 65 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float);
6666 virtual void drawBorder(TextureMapper*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
6767 virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) OVERRIDE;
6868

@@private:
7070 CoordinatedBackingStore()
7171 : m_scale(1.)
7272 { }
73  void paintTilesToTextureMapper(Vector<TextureMapperTile*>&, TextureMapper*, const TransformationMatrix&, float, BitmapTexture*, const FloatRect&);
 73 void paintTilesToTextureMapper(Vector<TextureMapperTile*>&, TextureMapper*, const TransformationMatrix&, float, const FloatRect&);
7474 TransformationMatrix adjustedTransformForRect(const FloatRect&);
7575 FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
7676

LayoutTests/ChangeLog

 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 Added a few ref-tests for correct overlap blending in accelearated compositing mode.
 9 Skipping the new reflection test on Mac/Chromium since it's not rendered
 10 properly on those platforms.
 11
 12 * compositing/overlap-blending/children-opacity-huge-expected.html: Added.
 13 * compositing/overlap-blending/children-opacity-huge.html: Added.
 14 * compositing/overlap-blending/children-opacity-no-overlap-expected.html: Added.
 15 * compositing/overlap-blending/children-opacity-no-overlap.html: Added.
 16 * compositing/overlap-blending/reflection-opacity-huge-expected.html: Added.
 17 * compositing/overlap-blending/reflection-opacity-huge.html: Added.
 18
1192013-02-26 Takashi Toyoshima <toyoshim@chromium.org>
220
321 Add User-Agent header in opening handshake headers.

LayoutTests/compositing/overlap-blending/children-opacity-huge-expected.html

 1<!DOCTYPE HTML>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
 5 <style type="text/css" media="screen">
 6
 7 div {
 8 -webkit-box-sizing: border-box;
 9 }
 10 .solid {
 11 position: absolute;
 12 width: 2150px;
 13 height: 200px;
 14 background-color: green;
 15 }
 16
 17 .opacity { opacity: .5; }
 18 .a { top: 0px; left: 0px;}
 19 .b { top: 100px; left: 0px;}
 20
 21 .composited {
 22 -webkit-transform: translateZ(0);
 23 }
 24 * { margin: 0; padding: 0; }
 25
 26 </style>
 27 </head>
 28 <div class="opacity">
 29 <div class="solid a">1</div>
 30 <div class="solid b">2</div>
 31 </div>
 32
 33</html>

LayoutTests/compositing/overlap-blending/children-opacity-huge.html

 1<!DOCTYPE HTML>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
 5 <style type="text/css" media="screen">
 6
 7 div {
 8 -webkit-box-sizing: border-box;
 9 }
 10 .solid {
 11 position: absolute;
 12 width: 2150px;
 13 height: 200px;
 14 background-color: green;
 15 }
 16
 17 .opacity { opacity: .5; }
 18 .a { top: 0px; left: 0px;}
 19 .b { top: 100px; left: 0px;}
 20
 21 .composited {
 22 -webkit-transform: translateZ(0);
 23 }
 24
 25 * { margin: 0; padding: 0; }
 26 </style>
 27 </head>
 28 <div class="opacity composited">
 29 <div class="solid a composited">1</div>
 30 <div class="solid b composited">2</div>
 31 </div>
 32
 33</html>

LayoutTests/compositing/overlap-blending/children-opacity-no-overlap-expected.html

 1<!DOCTYPE HTML>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
 5 <style type="text/css" media="screen">
 6
 7 div {
 8 -webkit-box-sizing: border-box;
 9 }
 10 .solid {
 11 position: absolute;
 12 width: 100px;
 13 height: 100px;
 14 background-color: green;
 15 }
 16
 17 .opacity { opacity: .5; }
 18 .a { top: 0px; left: 0px;}
 19 .b { top: 200px; left: 200px;}
 20 .c { top: 200px; left: 0px;}
 21 .d { top: 0px; left: 200px;}
 22 * { margin: 0; padding: 0; }
 23 .composited {
 24 -webkit-transform: translateZ(0);
 25 }
 26
 27 </style>
 28 </head>
 29 <div class="opacity">
 30 <div class="solid a">1</div>
 31 <div class="solid b">2</div>
 32 <div class="solid c">3</div>
 33 <div class="solid d"></div>
 34 </div>
 35
 36</html>

LayoutTests/compositing/overlap-blending/children-opacity-no-overlap.html

 1<!DOCTYPE HTML>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
 5 <style type="text/css" media="screen">
 6
 7 div {
 8 -webkit-box-sizing: border-box;
 9 }
 10 .solid {
 11 position: absolute;
 12 width: 100px;
 13 height: 100px;
 14 background-color: green;
 15 }
 16
 17 .opacity { opacity: .5; }
 18 .a { top: 0px; left: 0px;}
 19 .b { top: 200px; left: 200px;}
 20 .c { top: 200px; left: 0px;}
 21 .d { top: 0px; left: 200px;}
 22
 23 .composited {
 24 -webkit-transform: translateZ(0);
 25 }
 26 * { margin: 0; padding: 0; }
 27
 28 </style>
 29 </head>
 30 <div class="composited opacity">
 31 <div class="solid composited a">1</div>
 32 <div class="solid composited b">2</div>
 33 <div class="solid composited c">3</div>
 34 <div class="solid composited d"></div>
 35 </div>
 36
 37</html>

LayoutTests/compositing/overlap-blending/reflection-opacity-huge-expected.html

 1<!DOCTYPE HTML>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
 5 <style type="text/css" media="screen">
 6 .reflected {
 7 position: relative;
 8 width: 2150px;
 9 height: 200px;
 10 background-color: green;
 11 opacity: 0.5;
 12 -webkit-box-reflect: below -50px;
 13 }
 14
 15 * { margin: 0; padding: 0; }
 16
 17 </style>
 18 </head>
 19
 20 <p>Opacity should be applied after reflection, so you should see a green rectangle below. The overlap between the original and reflection should not be visible.</p>
 21 <div class="reflected">1
 22 </div>
 23
 24</html>

LayoutTests/compositing/overlap-blending/reflection-opacity-huge.html

 1<!DOCTYPE HTML>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
 5 <style type="text/css" media="screen">
 6 .reflected {
 7 position: relative;
 8 width: 2150px;
 9 height: 200px;
 10 background-color: green;
 11 opacity: 0.5;
 12 -webkit-box-reflect: below -50px;
 13 }
 14
 15 .composited { -webkit-transform: translateZ(0);}
 16 * { margin: 0; padding: 0; }
 17
 18 </style>
 19 </head>
 20
 21 <p>Opacity should be applied after reflection, so you should see a green rectangle below. The overlap between the original and reflection should not be visible.</p>
 22 <div class="reflected composited">1
 23 </div>
 24
 25</html>

LayoutTests/platform/chromium/TestExpectations

@@webkit.org/b/94353 platform/chromium/virtual/softwarecompositing/overflow/overfl
37813781webkit.org/b/94353 compositing/overflow/overflow-overlay-with-touch.html [ Failure ]
37823782webkit.org/b/94353 platform/chromium/virtual/softwarecompositing/overflow/overflow-overlay-with-touch.html [ Failure ]
37833783
 3784webkit.org/b/110871 compositing/overlap-blending/reflection-opacity-huge.html [ ImageOnlyFailure ]
 3785
37843786webkit.org/b/90488 [ Win ] http/tests/inspector/network-preflight-options.html [ Pass Slow ]
37853787webkit.org/b/90488 [ Win ] inspector/extensions/extensions-reload.html [ Pass Slow ]
37863788

LayoutTests/platform/mac/TestExpectations

@@compositing/overflow/textarea-scroll-touch.html
915915compositing/overflow/updating-scrolling-content.html
916916compositing/overflow/scrolling-without-painting.html
917917
 918# https://bugs.webkit.org/show_bug.cgi?id=110871
 919compositing/overlap-blending/reflection-opacity-huge.html
 920
918921# https://bugs.webkit.org/show_bug.cgi?id=95027
919922fast/block/float/016.html
920923