From c20c17d573d89e73a065de7ba1c165a4b6e3bd1a Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Tue, 31 Jan 2012 06:23:20 +0000 Subject: [PATCH] Unreviewed, rolling out r106324. http://trac.webkit.org/changeset/106324 https://bugs.webkit.org/show_bug.cgi?id=77406 Broke CCLayerTreeHostTestLayerOcclusion.runMultiThread and runSingleThread (Requested by yuzo1 on #webkit). Patch by Sheriff Bot on 2012-01-30 Source/WebCore: * platform/graphics/FloatRect.cpp: * platform/graphics/FloatRect.h: (WebCore): * platform/graphics/chromium/Canvas2DLayerChromium.cpp: (WebCore::Canvas2DLayerChromium::paintContentsIfDirty): * platform/graphics/chromium/Canvas2DLayerChromium.h: (WebCore): (Canvas2DLayerChromium): * platform/graphics/chromium/ContentLayerChromium.cpp: (WebCore::ContentLayerChromium::paintContentsIfDirty): * platform/graphics/chromium/ContentLayerChromium.h: (WebCore): (ContentLayerChromium): * platform/graphics/chromium/ImageLayerChromium.cpp: (WebCore::ImageLayerChromium::paintContentsIfDirty): * platform/graphics/chromium/ImageLayerChromium.h: (WebCore): (ImageLayerChromium): * platform/graphics/chromium/LayerChromium.cpp: * platform/graphics/chromium/LayerChromium.h: (WebCore): (WebCore::LayerChromium::paintContentsIfDirty): (LayerChromium): * platform/graphics/chromium/RenderSurfaceChromium.h: * platform/graphics/chromium/TiledLayerChromium.cpp: * platform/graphics/chromium/TiledLayerChromium.h: (WebCore): * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: (WebCore::CCLayerTreeHost::paintContentsIfDirty): (WebCore::CCLayerTreeHost::paintMaskAndReplicaForRenderSurface): (WebCore::CCLayerTreeHost::paintLayerContents): * platform/graphics/chromium/cc/CCLayerTreeHost.h: (WebCore): * platform/graphics/chromium/cc/CCQuadCuller.cpp: (WebCore::enclosedIntRect): (WebCore): Source/WebKit/chromium: * tests/CCLayerTreeHostCommonTest.cpp: (WebCore): * tests/CCLayerTreeHostTest.cpp: (WTF::ContentLayerChromiumWithUpdateTracking::paintContentsIfDirty): * tests/Canvas2DLayerChromiumTest.cpp: (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): * tests/TiledLayerChromiumTest.cpp: (FakeLayerTextureUpdater): (WTF::FakeTiledLayerChromium::paintContentsIfDirty): (WTF::FakeLayerTextureUpdater::prepareToUpdate): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106335 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 46 ++++ Source/WebCore/platform/graphics/FloatRect.cpp | 13 -- Source/WebCore/platform/graphics/FloatRect.h | 3 - .../graphics/chromium/Canvas2DLayerChromium.cpp | 2 +- .../graphics/chromium/Canvas2DLayerChromium.h | 3 +- .../graphics/chromium/ContentLayerChromium.cpp | 2 +- .../graphics/chromium/ContentLayerChromium.h | 3 +- .../graphics/chromium/ImageLayerChromium.cpp | 2 +- .../graphics/chromium/ImageLayerChromium.h | 3 +- .../platform/graphics/chromium/LayerChromium.cpp | 30 --- .../platform/graphics/chromium/LayerChromium.h | 12 +- .../graphics/chromium/RenderSurfaceChromium.h | 2 - .../graphics/chromium/TiledLayerChromium.cpp | 29 --- .../graphics/chromium/TiledLayerChromium.h | 3 - .../graphics/chromium/cc/CCLayerTreeHost.cpp | 71 +----- .../graphics/chromium/cc/CCLayerTreeHost.h | 3 +- .../platform/graphics/chromium/cc/CCQuadCuller.cpp | 12 + Source/WebKit/chromium/ChangeLog | 20 ++ .../chromium/tests/CCLayerTreeHostCommonTest.cpp | 177 --------------- .../WebKit/chromium/tests/CCLayerTreeHostTest.cpp | 245 +-------------------- .../chromium/tests/Canvas2DLayerChromiumTest.cpp | 4 +- .../chromium/tests/TiledLayerChromiumTest.cpp | 110 +-------- 22 files changed, 98 insertions(+), 697 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index a38b0c9..441b5c0 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,49 @@ +2012-01-30 Sheriff Bot + + Unreviewed, rolling out r106324. + http://trac.webkit.org/changeset/106324 + https://bugs.webkit.org/show_bug.cgi?id=77406 + + Broke CCLayerTreeHostTestLayerOcclusion.runMultiThread and + runSingleThread (Requested by yuzo1 on #webkit). + + * platform/graphics/FloatRect.cpp: + * platform/graphics/FloatRect.h: + (WebCore): + * platform/graphics/chromium/Canvas2DLayerChromium.cpp: + (WebCore::Canvas2DLayerChromium::paintContentsIfDirty): + * platform/graphics/chromium/Canvas2DLayerChromium.h: + (WebCore): + (Canvas2DLayerChromium): + * platform/graphics/chromium/ContentLayerChromium.cpp: + (WebCore::ContentLayerChromium::paintContentsIfDirty): + * platform/graphics/chromium/ContentLayerChromium.h: + (WebCore): + (ContentLayerChromium): + * platform/graphics/chromium/ImageLayerChromium.cpp: + (WebCore::ImageLayerChromium::paintContentsIfDirty): + * platform/graphics/chromium/ImageLayerChromium.h: + (WebCore): + (ImageLayerChromium): + * platform/graphics/chromium/LayerChromium.cpp: + * platform/graphics/chromium/LayerChromium.h: + (WebCore): + (WebCore::LayerChromium::paintContentsIfDirty): + (LayerChromium): + * platform/graphics/chromium/RenderSurfaceChromium.h: + * platform/graphics/chromium/TiledLayerChromium.cpp: + * platform/graphics/chromium/TiledLayerChromium.h: + (WebCore): + * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: + (WebCore::CCLayerTreeHost::paintContentsIfDirty): + (WebCore::CCLayerTreeHost::paintMaskAndReplicaForRenderSurface): + (WebCore::CCLayerTreeHost::paintLayerContents): + * platform/graphics/chromium/cc/CCLayerTreeHost.h: + (WebCore): + * platform/graphics/chromium/cc/CCQuadCuller.cpp: + (WebCore::enclosedIntRect): + (WebCore): + 2012-01-30 Raymond Liu Fix ASSERT fail within AudioBus::processWithGainFrom() diff --git a/Source/WebCore/platform/graphics/FloatRect.cpp b/Source/WebCore/platform/graphics/FloatRect.cpp index 595af2a..46fca6c 100644 --- a/Source/WebCore/platform/graphics/FloatRect.cpp +++ b/Source/WebCore/platform/graphics/FloatRect.cpp @@ -218,19 +218,6 @@ IntRect enclosingIntRect(const FloatRect& rect) clampToInteger(width), clampToInteger(height)); } -IntRect enclosedIntRect(const FloatRect& rect) -{ - int x = clampToInteger(ceilf(rect.x())); - int y = clampToInteger(ceilf(rect.y())); - float maxX = clampToInteger(floorf(rect.maxX())); - float maxY = clampToInteger(floorf(rect.maxY())); - // A rect of width 0 should not become a rect of width -1 due to ceil/floor. - int width = max(clampToInteger(maxX - x), 0); - int height = max(clampToInteger(maxY - y), 0); - - return IntRect(x, y, width, height); -} - FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect) { if (srcRect.width() == 0 || srcRect.height() == 0) diff --git a/Source/WebCore/platform/graphics/FloatRect.h b/Source/WebCore/platform/graphics/FloatRect.h index 22c171c..1409071 100644 --- a/Source/WebCore/platform/graphics/FloatRect.h +++ b/Source/WebCore/platform/graphics/FloatRect.h @@ -270,9 +270,6 @@ inline bool operator!=(const FloatRect& a, const FloatRect& b) IntRect enclosingIntRect(const FloatRect&); -// Returns a valid IntRect contained within the given FloatRect. -IntRect enclosedIntRect(const FloatRect&); - // Map rect r from srcRect to an equivalent rect in destRect. FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect); diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp index 0905474..1505ada 100644 --- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp @@ -91,7 +91,7 @@ bool Canvas2DLayerChromium::drawsContent() const && m_context && (m_context->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR); } -void Canvas2DLayerChromium::paintContentsIfDirty(const Region& /* occludedScreenSpace */) +void Canvas2DLayerChromium::paintContentsIfDirty() { if (!drawsContent()) return; diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h index ecba90f..83615a1 100644 --- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h @@ -40,7 +40,6 @@ namespace WebCore { class GraphicsContext3D; -class Region; // A layer containing an accelerated 2d canvas class Canvas2DLayerChromium : public CanvasLayerChromium { @@ -53,7 +52,7 @@ public: virtual void contentChanged(); virtual bool drawsContent() const; - virtual void paintContentsIfDirty(const Region& occludedScreenSpace); + virtual void paintContentsIfDirty(); virtual void setLayerTreeHost(CCLayerTreeHost*); virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp index 3430311..529fce0 100644 --- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp @@ -93,7 +93,7 @@ bool ContentLayerChromium::drawsContent() const return TiledLayerChromium::drawsContent() && m_delegate; } -void ContentLayerChromium::paintContentsIfDirty(const Region& /* occludedScreenSpace */) +void ContentLayerChromium::paintContentsIfDirty() { updateTileSizeAndTilingOption(); diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h index 5eff6a3..426679c 100644 --- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h @@ -41,7 +41,6 @@ namespace WebCore { class LayerTilerChromium; class LayerTextureUpdater; -class Region; class ContentLayerDelegate { public: @@ -59,7 +58,7 @@ public: void clearDelegate() { m_delegate = 0; } virtual bool drawsContent() const; - virtual void paintContentsIfDirty(const Region& occludedScreenSpace); + virtual void paintContentsIfDirty(); virtual void idlePaintContentsIfDirty(); virtual void setOpaque(bool); diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp index 831cbe8..0154fb2 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp @@ -158,7 +158,7 @@ void ImageLayerChromium::setContents(Image* contents) setNeedsDisplay(); } -void ImageLayerChromium::paintContentsIfDirty(const Region& /* occludedScreenSpace */) +void ImageLayerChromium::paintContentsIfDirty() { if (m_needsDisplay) { m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame()); diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h index ab5c1b2..d712924 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h @@ -45,7 +45,6 @@ namespace WebCore { class Image; class ImageLayerTextureUpdater; -class Region; // A Layer that contains only an Image element. class ImageLayerChromium : public TiledLayerChromium { @@ -54,7 +53,7 @@ public: virtual ~ImageLayerChromium(); virtual bool drawsContent() const; - virtual void paintContentsIfDirty(const Region& occludedScreenSpace); + virtual void paintContentsIfDirty(); virtual bool needsContentsScale() const; void setContents(Image* image); diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp index b2f7014..de5c702 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp @@ -39,7 +39,6 @@ #include "NativeImageSkia.h" #include "PlatformContextSkia.h" #endif -#include "Region.h" #include "RenderLayerBacking.h" #include "TextStream.h" #include "skia/ext/platform_canvas.h" @@ -470,35 +469,6 @@ void LayerChromium::setContentsScale(float contentsScale) setNeedsDisplay(); } -TransformationMatrix LayerChromium::contentToScreenSpaceTransform() const -{ - IntSize boundsInLayerSpace = bounds(); - IntSize boundsInContentSpace = contentBounds(); - - TransformationMatrix transform = screenSpaceTransform(); - - // Scale from content space to layer space - transform.scaleNonUniform(boundsInLayerSpace.width() / static_cast(boundsInContentSpace.width()), - boundsInLayerSpace.height() / static_cast(boundsInContentSpace.height())); - - return transform; -} - -void LayerChromium::addSelfToOccludedScreenSpace(Region& occludedScreenSpace) -{ - if (!opaque() || drawOpacity() != 1 || !isPaintedAxisAlignedInScreen()) - return; - - FloatRect targetRect = contentToScreenSpaceTransform().mapRect(FloatRect(visibleLayerRect())); - occludedScreenSpace.unite(enclosedIntRect(targetRect)); -} - -bool LayerChromium::isPaintedAxisAlignedInScreen() const -{ - FloatQuad quad = contentToScreenSpaceTransform().mapQuad(FloatQuad(visibleLayerRect())); - return quad.isRectilinear(); -} - void LayerChromium::createRenderSurface() { ASSERT(!m_renderSurface); diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerChromium.h index 764f730..945ee8e 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.h @@ -55,7 +55,6 @@ class CCLayerImpl; class CCLayerTreeHost; class CCTextureUpdater; class GraphicsContext3D; -class Region; // Base class for composited layers. Special layer types are derived from // this class. @@ -154,7 +153,7 @@ public: // These methods typically need to be overwritten by derived classes. virtual bool drawsContent() const { return m_isDrawable; } - virtual void paintContentsIfDirty(const Region& /* occludedScreenSpace */) { } + virtual void paintContentsIfDirty() { } virtual void idlePaintContentsIfDirty() { } virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&) { } virtual void setIsMask(bool) { } @@ -183,10 +182,8 @@ public: void setClipRect(const IntRect& clipRect) { m_clipRect = clipRect; } RenderSurfaceChromium* targetRenderSurface() const { return m_targetRenderSurface; } void setTargetRenderSurface(RenderSurfaceChromium* surface) { m_targetRenderSurface = surface; } - // This moves from layer space, with origin in the center to target space with origin in the top left const TransformationMatrix& drawTransform() const { return m_drawTransform; } void setDrawTransform(const TransformationMatrix& matrix) { m_drawTransform = matrix; } - // This moves from layer space, with origin the top left to screen space with origin in the top left const TransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; } void setScreenSpaceTransform(const TransformationMatrix& matrix) { m_screenSpaceTransform = matrix; } const IntRect& drawableContentRect() const { return m_drawableContentRect; } @@ -194,11 +191,6 @@ public: float contentsScale() const { return m_contentsScale; } void setContentsScale(float); - TransformationMatrix contentToScreenSpaceTransform() const; - - // Adds any opaque visible pixels to the occluded region. - virtual void addSelfToOccludedScreenSpace(Region& occludedScreenSpace); - // Returns true if any of the layer's descendants has content to draw. bool descendantDrawsContent(); virtual void contentChanged() { } @@ -219,8 +211,6 @@ protected: // hold context-dependent resources such as textures. virtual void cleanupResources(); - bool isPaintedAxisAlignedInScreen() const; - void setNeedsCommit(); // This flag is set when layer need repainting/updating. diff --git a/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h b/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h index bf4988c..4e1822b 100644 --- a/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h +++ b/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h @@ -63,8 +63,6 @@ public: float drawOpacity() const { return m_drawOpacity; } void setDrawOpacity(float drawOpacity) { m_drawOpacity = drawOpacity; } - // This goes from content space with the origin in the center of the rect being transformed to the target space with the origin in the top left of the - // rect being transformed. Position the rect so that the origin is in the center of it before applying this transform. const TransformationMatrix& drawTransform() const { return m_drawTransform; } void setDrawTransform(const TransformationMatrix& drawTransform) { m_drawTransform = drawTransform; } diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp index 283aa8d..0b0c9bf 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp @@ -488,35 +488,6 @@ void TiledLayerChromium::reserveTextures() } } -void TiledLayerChromium::addSelfToOccludedScreenSpace(Region& occludedScreenSpace) -{ - if (m_skipsDraw || drawOpacity() != 1 || !isPaintedAxisAlignedInScreen()) - return; - - if (opaque()) { - LayerChromium::addSelfToOccludedScreenSpace(occludedScreenSpace); - return; - } - - IntRect visibleRect = visibleLayerRect(); - TransformationMatrix contentTransform = contentToScreenSpaceTransform(); - - // FIXME: Create/Use a FloatRegion for the occludedScreenSpace, instead of a Region based on ints, to avoid this step and get better accuracy between layers in target space. - Region tileRegion; - int left, top, right, bottom; - m_tiler->layerRectToTileIndices(visibleLayerRect(), left, top, right, bottom); - for (int j = top; j <= bottom; ++j) { - for (int i = left; i <= right; ++i) { - UpdatableTile* tile = tileAt(i, j); - if (tile) { - IntRect visibleTileOpaqueRect = intersection(visibleRect, tile->m_opaqueRect); - FloatRect screenRect = contentTransform.mapRect(FloatRect(visibleTileOpaqueRect)); - occludedScreenSpace.unite(enclosedIntRect(screenRect)); - } - } - } -} - void TiledLayerChromium::prepareToUpdate(const IntRect& layerRect) { m_skipsDraw = false; diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h index 3cbbbcb..18e029c 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h @@ -35,7 +35,6 @@ namespace WebCore { class LayerTextureUpdater; -class Region; class UpdatableTile; class TiledLayerChromium : public LayerChromium { @@ -64,8 +63,6 @@ public: virtual void reserveTextures(); - virtual void addSelfToOccludedScreenSpace(Region& occludedScreenSpace); - protected: TiledLayerChromium(); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp index 4ff8434..62d6ce2 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp @@ -29,7 +29,6 @@ #include "LayerChromium.h" #include "LayerPainterChromium.h" #include "LayerRendererChromium.h" -#include "Region.h" #include "TraceEvent.h" #include "TreeSynchronizer.h" #include "cc/CCLayerIterator.h" @@ -414,12 +413,12 @@ void CCLayerTreeHost::reserveTextures() } // static -void CCLayerTreeHost::paintContentsIfDirty(LayerChromium* layer, PaintType paintType, const Region& occludedScreenSpace) +void CCLayerTreeHost::paintContentsIfDirty(LayerChromium* layer, PaintType paintType) { ASSERT(layer); ASSERT(PaintVisible == paintType || PaintIdle == paintType); if (PaintVisible == paintType) - layer->paintContentsIfDirty(occludedScreenSpace); + layer->paintContentsIfDirty(); else layer->idlePaintContentsIfDirty(); } @@ -430,93 +429,35 @@ void CCLayerTreeHost::paintMaskAndReplicaForRenderSurface(LayerChromium* renderS // in code, we already know that at least something will be drawn into this render surface, so the // mask and replica should be painted. - // FIXME: If the surface has a replica, it should be painted with occlusion that excludes the current target surface subtree. - Region noOcclusion; - if (renderSurfaceLayer->maskLayer()) { renderSurfaceLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), renderSurfaceLayer->contentBounds())); - paintContentsIfDirty(renderSurfaceLayer->maskLayer(), paintType, noOcclusion); + paintContentsIfDirty(renderSurfaceLayer->maskLayer(), paintType); } LayerChromium* replicaLayer = renderSurfaceLayer->replicaLayer(); if (replicaLayer) { - paintContentsIfDirty(replicaLayer, paintType, noOcclusion); + paintContentsIfDirty(replicaLayer, paintType); if (replicaLayer->maskLayer()) { replicaLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), replicaLayer->maskLayer()->contentBounds())); - paintContentsIfDirty(replicaLayer->maskLayer(), paintType, noOcclusion); + paintContentsIfDirty(replicaLayer->maskLayer(), paintType); } } } -struct RenderSurfaceRegion { - RenderSurfaceChromium* surface; - Region occludedInScreen; -}; - -// Add the surface to the top of the stack and copy the occlusion from the old top of the stack to the new. -static void enterTargetRenderSurface(Vector& stack, RenderSurfaceChromium* newTarget) -{ - if (stack.isEmpty()) { - stack.append(RenderSurfaceRegion()); - stack.last().surface = newTarget; - } else if (stack.last().surface != newTarget) { - const RenderSurfaceRegion& previous = stack.last(); - stack.append(RenderSurfaceRegion()); - stack.last().surface = newTarget; - stack.last().occludedInScreen = previous.occludedInScreen; - } -} - -// Pop the top of the stack off, push on the new surface, and merge the old top's occlusion into the new top surface. -static void leaveTargetRenderSurface(Vector& stack, RenderSurfaceChromium* newTarget) -{ - int lastIndex = stack.size() - 1; - bool surfaceWillBeAtTopAfterPop = stack.size() > 1 && stack[lastIndex - 1].surface == newTarget; - - if (surfaceWillBeAtTopAfterPop) { - // Merge the top of the stack down. - stack[lastIndex - 1].occludedInScreen.unite(stack[lastIndex].occludedInScreen); - stack.removeLast(); - } else { - // Replace the top of the stack with the new pushed surface. Copy the occluded region to the top. - stack.last().surface = newTarget; - } -} - void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, PaintType paintType) { // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk. typedef CCLayerIterator CCLayerIteratorType; - // The stack holds occluded regions for subtrees in the RenderSurface-Layer tree, so that when we leave a subtree we may - // apply a mask to it, but not to the parts outside the subtree. - // - The first time we see a new subtree under a target, we add that target to the top of the stack. This can happen as a layer representing itself, or as a target surface. - // - When we visit a target surface, we apply its mask to its subtree, which is at the top of the stack. - // - When we visit a layer representing itself, we add its occlusion to the current subtree, which is at the top of the stack. - // - When we visit a layer representing a contributing surface, the current target will never be the top of the stack since we just came from the contributing surface. - // We merge the occlusion at the top of the stack with the new current subtree. This new target is pushed onto the stack if not already there. - Vector targetSurfaceStack; - CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) { if (it.representsTargetRenderSurface()) { ASSERT(it->renderSurface()->drawOpacity()); - - enterTargetRenderSurface(targetSurfaceStack, it->renderSurface()); paintMaskAndReplicaForRenderSurface(*it, paintType); - // FIXME: add the replica layer to the current occlusion - - if (it->maskLayer() || it->renderSurface()->drawOpacity() < 1) - targetSurfaceStack.last().occludedInScreen = Region(); } else if (it.representsItself()) { ASSERT(!it->bounds().isEmpty()); - - enterTargetRenderSurface(targetSurfaceStack, it->targetRenderSurface()); - paintContentsIfDirty(*it, paintType, targetSurfaceStack.last().occludedInScreen); - it->addSelfToOccludedScreenSpace(targetSurfaceStack.last().occludedInScreen); - } else { - leaveTargetRenderSurface(targetSurfaceStack, it.targetRenderSurfaceLayer()->renderSurface()); + paintContentsIfDirty(*it, paintType); } } } diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h index f58203d..81b5f25 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h @@ -48,7 +48,6 @@ class CCLayerTreeHostImpl; class CCTextureUpdater; class GraphicsContext3D; class LayerPainterChromium; -class Region; class TextureAllocator; class TextureManager; @@ -206,7 +205,7 @@ private: typedef Vector > TextureList; enum PaintType { PaintVisible, PaintIdle }; - static void paintContentsIfDirty(LayerChromium*, PaintType, const Region& occludedScreenSpace); + static void paintContentsIfDirty(LayerChromium*, PaintType); void paintLayerContents(const LayerList&, PaintType); void paintMaskAndReplicaForRenderSurface(LayerChromium*, PaintType); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp index c8bd9b0..ba9c66e 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp @@ -75,6 +75,18 @@ static IntRect rectSubtractRegion(const Region& region, const IntRect& rect) return rect; } +static IntRect enclosedIntRect(const FloatRect& rect) +{ + float x = ceilf(rect.x()); + float y = ceilf(rect.y()); + // A rect of width 0 should not become a rect of width -1. + float width = max(floorf(rect.maxX()) - x, 0); + float height = max(floorf(rect.maxY()) - y, 0); + + return IntRect(clampToInteger(x), clampToInteger(y), + clampToInteger(width), clampToInteger(height)); +} + void CCQuadCuller::cullOccludedQuads(CCQuadList& quadList) { if (!quadList.size()) diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 3e9679e..020aab6 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,23 @@ +2012-01-30 Sheriff Bot + + Unreviewed, rolling out r106324. + http://trac.webkit.org/changeset/106324 + https://bugs.webkit.org/show_bug.cgi?id=77406 + + Broke CCLayerTreeHostTestLayerOcclusion.runMultiThread and + runSingleThread (Requested by yuzo1 on #webkit). + + * tests/CCLayerTreeHostCommonTest.cpp: + (WebCore): + * tests/CCLayerTreeHostTest.cpp: + (WTF::ContentLayerChromiumWithUpdateTracking::paintContentsIfDirty): + * tests/Canvas2DLayerChromiumTest.cpp: + (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): + * tests/TiledLayerChromiumTest.cpp: + (FakeLayerTextureUpdater): + (WTF::FakeTiledLayerChromium::paintContentsIfDirty): + (WTF::FakeLayerTextureUpdater::prepareToUpdate): + 2012-01-30 Dana Jansens [chromium] Compute occlusion during paint loop diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp index b1fa729..d2e1cfe 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp @@ -28,7 +28,6 @@ #include "CCLayerTreeTestCommon.h" #include "LayerChromium.h" -#include "Region.h" #include "TransformationMatrix.h" #include @@ -36,12 +35,6 @@ using namespace WebCore; -#define EXPECT_EQ_RECT(a, b) \ - EXPECT_EQ(a.x(), b.x()); \ - EXPECT_EQ(a.y(), b.y()); \ - EXPECT_EQ(a.width(), b.width()); \ - EXPECT_EQ(a.height(), b.height()); - namespace { void setLayerPropertiesForTesting(LayerChromium* layer, const TransformationMatrix& transform, const TransformationMatrix& sublayerTransform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) @@ -602,174 +595,4 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) // - test the other functions in CCLayerTreeHostCommon // -TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegion) -{ - // This tests that the right transforms are being used. - Region occluded; - const TransformationMatrix identityMatrix; - RefPtr parent = LayerChromium::create(); - RefPtr layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); - parent->createRenderSurface(); - parent->addChild(layer); - - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - - layer->setOpaque(true); - - Vector > renderSurfaceLayerList; - Vector > dummyLayerList; - int dummyMaxTextureSize = 512; - - // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. - parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); - parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); - - CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); -} - -TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithRotation) -{ - // This tests that the right transforms are being used. - Region occluded; - const TransformationMatrix identityMatrix; - RefPtr parent = LayerChromium::create(); - RefPtr layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); - parent->createRenderSurface(); - parent->addChild(layer); - - TransformationMatrix layerTransform; - layerTransform.translate(250, 250); - layerTransform.rotate(90); - layerTransform.translate(-250, -250); - - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - - layer->setOpaque(true); - - Vector > renderSurfaceLayerList; - Vector > dummyLayerList; - int dummyMaxTextureSize = 512; - - // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. - parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); - parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); - - CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); -} - -TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithTranslation) -{ - // This tests that the right transforms are being used. - Region occluded; - const TransformationMatrix identityMatrix; - RefPtr parent = LayerChromium::create(); - RefPtr layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); - parent->createRenderSurface(); - parent->addChild(layer); - - TransformationMatrix layerTransform; - layerTransform.translate(20, 20); - - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - - layer->setOpaque(true); - - Vector > renderSurfaceLayerList; - Vector > dummyLayerList; - int dummyMaxTextureSize = 512; - - // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. - parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); - parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); - - CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); -} - -TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithRotatedSurface) -{ - // This tests that the right transforms are being used. - Region occluded; - const TransformationMatrix identityMatrix; - RefPtr parent = LayerChromium::create(); - RefPtr child = LayerChromium::create(); - RefPtr layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); - parent->createRenderSurface(); - parent->addChild(child); - child->addChild(layer); - - TransformationMatrix childTransform; - childTransform.translate(250, 250); - childTransform.rotate(90); - childTransform.translate(-250, -250); - - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), false); - - child->setMasksToBounds(true); - layer->setOpaque(true); - - Vector > renderSurfaceLayerList; - Vector > dummyLayerList; - int dummyMaxTextureSize = 512; - - // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. - parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); - parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); - - CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - /* Justification for the above opaque rect from |layer|: - 100 - +---------------------+ +---------------------+ - | | | |30 Visible region of |layer|: ///// - | 30 | rotate(90) | | - | 30 + ---------------------------------+ | +---------------------------------+ - 100 | | 10 | | ==> | | |10 | - | |10+---------------------------------+ | +---------------------------------+ | - | | | | | | | | |///////////////| 420 | | - | | | | | | | | |///////////////|60 | | - | | | | | | | | |///////////////| | | - +----|--|-------------+ | | +--|--|---------------+ | | - | | | | 20|10| 70 | | - | | | | | | | | - | | | |500 | | | | - | | | | | | | | - | | | | | | | | - | | | | | | | | - | | | | | | |10| - +--|-------------------------------+ | | +------------------------------|--+ - | | | 490 | - +---------------------------------+ +---------------------------------+ - 500 500 - */ -} - } // namespace diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp index 1fec324..0cb2605 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp @@ -30,7 +30,6 @@ #include "ContentLayerChromium.h" #include "GraphicsContext3DPrivate.h" #include "LayerChromium.h" -#include "Region.h" #include "TextureManager.h" #include "WebCompositor.h" #include "WebKit.h" @@ -1006,9 +1005,9 @@ public: int updateCount() { return m_updateCount; } void resetUpdateCount() { m_updateCount = 0; } - virtual void paintContentsIfDirty(const Region& occludedScreenSpace) + virtual void paintContentsIfDirty() { - ContentLayerChromium::paintContentsIfDirty(occludedScreenSpace); + ContentLayerChromium::paintContentsIfDirty(); m_paintContentsCount++; } @@ -1229,244 +1228,4 @@ TEST_F(CCLayerTreeHostTestAtomicCommit, runMultiThread) runTest(true); } -#define EXPECT_EQ_RECT(a, b) \ - EXPECT_EQ(a.x(), b.x()); \ - EXPECT_EQ(a.y(), b.y()); \ - EXPECT_EQ(a.width(), b.width()); \ - EXPECT_EQ(a.height(), b.height()); - -class TestLayerChromium : public LayerChromium { -public: - static PassRefPtr create() { return adoptRef(new TestLayerChromium()); } - - virtual void paintContentsIfDirty(const Region& occludedScreenSpace) - { - m_occludedScreenSpace = occludedScreenSpace; - } - - virtual bool drawsContent() const { return true; } - - const Region& occludedScreenSpace() const { return m_occludedScreenSpace; } - void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); } - -private: - TestLayerChromium() : LayerChromium() { } - - Region m_occludedScreenSpace; -}; - -static void setLayerPropertiesForTesting(TestLayerChromium* layer, LayerChromium* parent, const TransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque) -{ - layer->removeAllChildren(); - if (parent) - parent->addChild(layer); - layer->setTransform(transform); - layer->setAnchorPoint(anchor); - layer->setPosition(position); - layer->setBounds(bounds); - layer->setOpaque(opaque); - layer->clearOccludedScreenSpace(); -} - -class CCLayerTreeHostTestLayerOcclusion : public CCLayerTreeHostTest { -public: - CCLayerTreeHostTestLayerOcclusion() { } - - virtual void beginTest() - { - RefPtr rootLayer = TestLayerChromium::create(); - RefPtr child = TestLayerChromium::create(); - RefPtr child2 = TestLayerChromium::create(); - RefPtr grandChild = TestLayerChromium::create(); - RefPtr mask = TestLayerChromium::create(); - - TransformationMatrix identityMatrix; - TransformationMatrix childTransform; - childTransform.translate(250, 250); - childTransform.rotate(90); - childTransform.translate(-250, -250); - - child->setMasksToBounds(true); - - // See CCLayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedSurface for a nice visual of these layers and how they end up - // positioned on the screen. - - // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); - setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); - - m_layerTreeHost->setRootLayer(rootLayer); - m_layerTreeHost->setViewportSize(rootLayer->bounds()); - m_layerTreeHost->updateLayers(); - m_layerTreeHost->commitComplete(); - - EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), rootLayer->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); - - // If the child layer is opaque, then it adds to the occlusion seen by the rootLayer. - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); - setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); - - m_layerTreeHost->setRootLayer(rootLayer); - m_layerTreeHost->setViewportSize(rootLayer->bounds()); - m_layerTreeHost->updateLayers(); - m_layerTreeHost->commitComplete(); - - EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), rootLayer->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); - - // Add a second child to the root layer and the regions should merge - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); - setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(70, 20), IntSize(500, 500), true); - setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); - - m_layerTreeHost->setRootLayer(rootLayer); - m_layerTreeHost->setViewportSize(rootLayer->bounds()); - m_layerTreeHost->updateLayers(); - m_layerTreeHost->commitComplete(); - - EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), child2->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, child2->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 20, 70, 80), rootLayer->occludedScreenSpace().bounds()); - EXPECT_EQ(2u, rootLayer->occludedScreenSpace().rects().size()); - - // Move the second child to be sure. - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); - setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); - setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); - - m_layerTreeHost->setRootLayer(rootLayer); - m_layerTreeHost->setViewportSize(rootLayer->bounds()); - m_layerTreeHost->updateLayers(); - m_layerTreeHost->commitComplete(); - - EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), child2->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, child2->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 30, 90, 70), rootLayer->occludedScreenSpace().bounds()); - EXPECT_EQ(2u, rootLayer->occludedScreenSpace().rects().size()); - - // If the child layer has a mask on it, then it shouldn't contribute to occlusion on stuff below it - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); - setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); - setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); - - child->setMaskLayer(mask.get()); - - m_layerTreeHost->setRootLayer(rootLayer); - m_layerTreeHost->setViewportSize(rootLayer->bounds()); - m_layerTreeHost->updateLayers(); - m_layerTreeHost->commitComplete(); - - EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); - - // If the child layer with a mask is below child2, then child2 should contribute to occlusion on everything, and child shouldn't contribute to the rootLayer - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); - setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); - setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); - - child->setMaskLayer(mask.get()); - - m_layerTreeHost->setRootLayer(rootLayer); - m_layerTreeHost->setViewportSize(rootLayer->bounds()); - m_layerTreeHost->updateLayers(); - m_layerTreeHost->commitComplete(); - - EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), grandChild->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 40, 90, 60), child->occludedScreenSpace().bounds()); - EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); - - // If the child layer has a non-opaque drawOpacity, then it shouldn't contribute to occlusion on stuff below it - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); - setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); - setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); - - child->setMaskLayer(0); - child->setDrawOpacity(0.5); - - m_layerTreeHost->setRootLayer(rootLayer); - m_layerTreeHost->setViewportSize(rootLayer->bounds()); - m_layerTreeHost->updateLayers(); - m_layerTreeHost->commitComplete(); - - EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); - - // If the child layer with non-opaque drawOpacity is below child2, then child2 should contribute to occlusion on everything, and child shouldn't contribute to the rootLayer - setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); - setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); - setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); - setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); - - child->setMaskLayer(0); - child->setDrawOpacity(0.5); - - m_layerTreeHost->setRootLayer(rootLayer); - m_layerTreeHost->setViewportSize(rootLayer->bounds()); - m_layerTreeHost->updateLayers(); - m_layerTreeHost->commitComplete(); - - EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds()); - EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), grandChild->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 40, 90, 60), child->occludedScreenSpace().bounds()); - EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); - EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds()); - EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); - - // Kill the layerTreeHost immediately. - m_layerTreeHost->setRootLayer(0); - m_layerTreeHost.clear(); - - endTest(); - } - - virtual void afterTest() - { - } -}; - -SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerOcclusion) - } // namespace diff --git a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp index 1df27c0..f0b5c41 100644 --- a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp @@ -29,7 +29,6 @@ #include "CCSchedulerTestCommon.h" #include "FakeWebGraphicsContext3D.h" #include "GraphicsContext3DPrivate.h" -#include "Region.h" #include "TextureManager.h" #include "cc/CCCanvasLayerImpl.h" #include "cc/CCSingleThreadProxy.h" @@ -139,8 +138,7 @@ protected: canvas->contentChanged(); EXPECT_TRUE(canvas->needsDisplay()); - Region occludedScreenSpace; - canvas->paintContentsIfDirty(occludedScreenSpace); + canvas->paintContentsIfDirty(); EXPECT_FALSE(canvas->needsDisplay()); { DebugScopedSetImplThread scopedImplThread; diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp index b0350db..b850f82 100644 --- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp @@ -29,7 +29,6 @@ #include "CCLayerTreeTestCommon.h" #include "FakeCCLayerTreeHostClient.h" #include "LayerTextureUpdater.h" -#include "Region.h" #include "TextureManager.h" #include "WebCompositor.h" #include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread @@ -40,12 +39,6 @@ using namespace WebCore; using namespace WTF; -#define EXPECT_EQ_RECT(a, b) \ - EXPECT_EQ(a.x(), b.x()); \ - EXPECT_EQ(a.y(), b.y()); \ - EXPECT_EQ(a.width(), b.width()); \ - EXPECT_EQ(a.height(), b.height()); - namespace { class FakeTextureAllocator : public TextureAllocator { @@ -77,20 +70,17 @@ public: int prepareCount() const { return m_prepareCount; } void clearPrepareCount() { m_prepareCount = 0; } - void setOpaquePaintRect(const IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; } - // Last rect passed to prepareToUpdate(). const IntRect& lastUpdateRect() const { return m_lastUpdateRect; } virtual PassOwnPtr createTexture(TextureManager* manager) { return adoptPtr(new Texture(ManagedTexture::create(manager))); } virtual SampledTexelFormat sampledTexelFormat(GC3Denum) { return SampledTexelFormatRGBA; } - virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect); + virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect*); private: int m_prepareCount; IntRect m_rectToInvalidate; IntRect m_lastUpdateRect; - IntRect m_opaquePaintRect; RefPtr m_layer; }; @@ -149,7 +139,7 @@ public: virtual TextureManager* textureManager() const { return m_textureManager; } - virtual void paintContentsIfDirty(const Region& /* occludedScreenSpace */) + virtual void paintContentsIfDirty() { prepareToUpdate(visibleLayerRect()); } @@ -197,7 +187,7 @@ void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const m_rectToInvalidate = IntRect(); m_layer = 0; } - *resultingOpaqueRect = m_opaquePaintRect; + *resultingOpaqueRect = IntRect(); } TEST(TiledLayerChromiumTest, pushDirtyTiles) @@ -470,98 +460,4 @@ TEST(TiledLayerChromiumTest, skipsDrawGetsReset) WebKit::WebCompositor::shutdown(); } -TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) -{ - OwnPtr textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); - RefPtr layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); - - // The tile size is 100x100, so this invalidates and then paints two tiles in various ways. - - Region occluded; - IntRect contentBounds = IntRect(0, 0, 100, 200); - IntRect visibleBounds = IntRect(0, 0, 100, 150); - - layer->setBounds(contentBounds.size()); - layer->setVisibleLayerRect(visibleBounds); - layer->setDrawOpacity(1); - - // The screenSpaceTransform is verified in CCLayerTreeHostCommonTests - TransformationMatrix screenSpaceTransform; - layer->setScreenSpaceTransform(screenSpaceTransform); - - // If the layer is opaque then the occluded region should be the whole layer's visible region. - layer->setOpaque(true); - layer->invalidateRect(contentBounds); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(visibleBounds, occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If the layer is not opaque then the occluded region should be empty. - layer->setOpaque(false); - layer->invalidateRect(contentBounds); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If the layer paints opaque content, then the occluded region should match the visible opaque content. - IntRect opaquePaintRect = IntRect(10, 10, 90, 190); - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); - layer->invalidateRect(contentBounds); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If we paint again without invalidating, the same stuff should be occluded. - layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // If the layer is transformed then the resulting occluded area needs to be transformed to its target space. - TransformationMatrix transform; - transform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); - transform.rotate(90); - transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - transform.translate(10, 10); - screenSpaceTransform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); - screenSpaceTransform *= transform; - screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - layer->setScreenSpaceTransform(screenSpaceTransform); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(screenSpaceTransform.mapRect(intersection(opaquePaintRect, visibleBounds)), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - // But a non-axis-aligned transform does not get considered for occlusion. - transform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); - transform.rotate(5); - transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - screenSpaceTransform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); - screenSpaceTransform *= transform; - screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); - layer->setScreenSpaceTransform(screenSpaceTransform); - layer->prepareToUpdate(contentBounds); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - // FIXME: If we find an opaque rect contained in the rotated non-axis-aligned rect, then - // this won't be an empty result. - EXPECT_EQ_RECT(IntRect(), occluded.bounds()); - EXPECT_EQ(0u, occluded.rects().size()); -} - } // namespace -- 2.7.4