[Chromium] Fix opaque tracking for box shadows and non-composited child elements
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 23:48:18 +0000 (23:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 23:48:18 +0000 (23:48 +0000)
commit09747004e3aa04940d3fe106b7ca8839da24bfef
treebc6f905b5425eb444d69e8eb43074223509f6baf
parent1db75be819f20c12bea30db016fedbe39d0d2b69
[Chromium] Fix opaque tracking for box shadows and non-composited child elements
https://bugs.webkit.org/show_bug.cgi?id=78073

Patch by Dana Jansens <danakj@chromium.org> on 2012-02-08
Reviewed by Stephen White.

Source/WebCore:

Tests: compositing/culling/scrolled-within-boxshadow.html
       compositing/culling/translated-boxshadow.html

Unit tests: PlatformContextSkiaTest.cpp

When painting a box shadow, a filter is applied to the skia canvas, that can make
pixels painted with an opaque color end up non-opaque. So consider image/mask/color
filters when deciding if a paint is opaque.

Also when painting the background of an element with a box shadow, the background is
painted with a transform on the skia canvas based on the size of the box shadow. This
transform needs to be considered when tracking an opaque paint.

However, when a layer's contentRect position is non-zero, we translate the GraphicsContext
to put the contentRect at 0,0 in the skia canvas. For tracking opaque regions in the resulting
layer, we need to unto this translation. Scaling can also occur which we must undo. So we pass
the transform in to PlatformContextSkia to go from the SkCanvas back to the layer's content
coordinate space. Opaque paints can then be tracked in the layer's content space rather than
in the skia canvas space.

* platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp:
(WebCore::BitmapCanvasLayerTextureUpdater::prepareToUpdate):
* platform/graphics/chromium/CanvasLayerTextureUpdater.cpp:
(WebCore::CanvasLayerTextureUpdater::paintContents):
* platform/graphics/chromium/CanvasLayerTextureUpdater.h:
(WebCore):
(CanvasLayerTextureUpdater):
* platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp:
(WebCore::SkPictureCanvasLayerTextureUpdater::prepareToUpdate):
* platform/graphics/skia/OpaqueRegionSkia.cpp:
(WebCore::paintIsOpaque):
(WebCore::OpaqueRegionSkia::didDrawRect):
(WebCore::OpaqueRegionSkia::didDrawPath):
(WebCore::OpaqueRegionSkia::didDrawPoints):
(WebCore::OpaqueRegionSkia::didDrawBounded):
(WebCore::OpaqueRegionSkia::didDraw):
(WebCore::OpaqueRegionSkia::markRectAsOpaque):
(WebCore::OpaqueRegionSkia::markRectAsNonOpaque):
* platform/graphics/skia/OpaqueRegionSkia.h:
(WebCore):
(OpaqueRegionSkia):
* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::didDrawRect):
(WebCore::PlatformContextSkia::didDrawPath):
(WebCore::PlatformContextSkia::didDrawPoints):
(WebCore::PlatformContextSkia::didDrawBounded):
* platform/graphics/skia/PlatformContextSkia.h:
(PlatformContextSkia):
(WebCore::PlatformContextSkia::setOpaqueRegionTransform):

Source/WebKit/chromium:

* tests/PlatformContextSkiaTest.cpp:
(WebCore::TEST):
(WebCore):

LayoutTests:

* compositing/culling/scrolled-within-boxshadow-expected.png: Added.
* compositing/culling/scrolled-within-boxshadow-expected.txt: Added.
* compositing/culling/scrolled-within-boxshadow.html: Added.
* compositing/culling/translated-boxshadow-expected.png: Added.
* compositing/culling/translated-boxshadow-expected.txt: Added.
* compositing/culling/translated-boxshadow.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107143 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/culling/scrolled-within-boxshadow-expected.png [new file with mode: 0644]
LayoutTests/compositing/culling/scrolled-within-boxshadow-expected.txt [new file with mode: 0644]
LayoutTests/compositing/culling/scrolled-within-boxshadow.html [new file with mode: 0644]
LayoutTests/compositing/culling/translated-boxshadow-expected.png [new file with mode: 0644]
LayoutTests/compositing/culling/translated-boxshadow-expected.txt [new file with mode: 0644]
LayoutTests/compositing/culling/translated-boxshadow.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h
Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.cpp
Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.h
Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
Source/WebCore/platform/graphics/skia/PlatformContextSkia.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp