Changeset 106335 in webkit
- Timestamp:
- Jan 30, 2012 10:23:20 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106332 r106335 1 2012-01-30 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r106324. 4 http://trac.webkit.org/changeset/106324 5 https://bugs.webkit.org/show_bug.cgi?id=77406 6 7 Broke CCLayerTreeHostTestLayerOcclusion.runMultiThread and 8 runSingleThread (Requested by yuzo1 on #webkit). 9 10 * platform/graphics/FloatRect.cpp: 11 * platform/graphics/FloatRect.h: 12 (WebCore): 13 * platform/graphics/chromium/Canvas2DLayerChromium.cpp: 14 (WebCore::Canvas2DLayerChromium::paintContentsIfDirty): 15 * platform/graphics/chromium/Canvas2DLayerChromium.h: 16 (WebCore): 17 (Canvas2DLayerChromium): 18 * platform/graphics/chromium/ContentLayerChromium.cpp: 19 (WebCore::ContentLayerChromium::paintContentsIfDirty): 20 * platform/graphics/chromium/ContentLayerChromium.h: 21 (WebCore): 22 (ContentLayerChromium): 23 * platform/graphics/chromium/ImageLayerChromium.cpp: 24 (WebCore::ImageLayerChromium::paintContentsIfDirty): 25 * platform/graphics/chromium/ImageLayerChromium.h: 26 (WebCore): 27 (ImageLayerChromium): 28 * platform/graphics/chromium/LayerChromium.cpp: 29 * platform/graphics/chromium/LayerChromium.h: 30 (WebCore): 31 (WebCore::LayerChromium::paintContentsIfDirty): 32 (LayerChromium): 33 * platform/graphics/chromium/RenderSurfaceChromium.h: 34 * platform/graphics/chromium/TiledLayerChromium.cpp: 35 * platform/graphics/chromium/TiledLayerChromium.h: 36 (WebCore): 37 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 38 (WebCore::CCLayerTreeHost::paintContentsIfDirty): 39 (WebCore::CCLayerTreeHost::paintMaskAndReplicaForRenderSurface): 40 (WebCore::CCLayerTreeHost::paintLayerContents): 41 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 42 (WebCore): 43 * platform/graphics/chromium/cc/CCQuadCuller.cpp: 44 (WebCore::enclosedIntRect): 45 (WebCore): 46 1 47 2012-01-30 Raymond Liu <raymond.liu@intel.com> 2 48 -
trunk/Source/WebCore/platform/graphics/FloatRect.cpp
r106324 r106335 219 219 } 220 220 221 IntRect enclosedIntRect(const FloatRect& rect)222 {223 int x = clampToInteger(ceilf(rect.x()));224 int y = clampToInteger(ceilf(rect.y()));225 float maxX = clampToInteger(floorf(rect.maxX()));226 float maxY = clampToInteger(floorf(rect.maxY()));227 // A rect of width 0 should not become a rect of width -1 due to ceil/floor.228 int width = max(clampToInteger(maxX - x), 0);229 int height = max(clampToInteger(maxY - y), 0);230 231 return IntRect(x, y, width, height);232 }233 234 221 FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect) 235 222 { -
trunk/Source/WebCore/platform/graphics/FloatRect.h
r106324 r106335 271 271 IntRect enclosingIntRect(const FloatRect&); 272 272 273 // Returns a valid IntRect contained within the given FloatRect.274 IntRect enclosedIntRect(const FloatRect&);275 276 273 // Map rect r from srcRect to an equivalent rect in destRect. 277 274 FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect); -
trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp
r106324 r106335 92 92 } 93 93 94 void Canvas2DLayerChromium::paintContentsIfDirty( const Region& /* occludedScreenSpace */)94 void Canvas2DLayerChromium::paintContentsIfDirty() 95 95 { 96 96 if (!drawsContent()) -
trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h
r106324 r106335 41 41 42 42 class GraphicsContext3D; 43 class Region;44 43 45 44 // A layer containing an accelerated 2d canvas … … 54 53 55 54 virtual bool drawsContent() const; 56 virtual void paintContentsIfDirty( const Region& occludedScreenSpace);55 virtual void paintContentsIfDirty(); 57 56 58 57 virtual void setLayerTreeHost(CCLayerTreeHost*); -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
r106324 r106335 94 94 } 95 95 96 void ContentLayerChromium::paintContentsIfDirty( const Region& /* occludedScreenSpace */)96 void ContentLayerChromium::paintContentsIfDirty() 97 97 { 98 98 updateTileSizeAndTilingOption(); -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r106324 r106335 42 42 class LayerTilerChromium; 43 43 class LayerTextureUpdater; 44 class Region;45 44 46 45 class ContentLayerDelegate { … … 60 59 61 60 virtual bool drawsContent() const; 62 virtual void paintContentsIfDirty( const Region& occludedScreenSpace);61 virtual void paintContentsIfDirty(); 63 62 virtual void idlePaintContentsIfDirty(); 64 63 -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r106324 r106335 159 159 } 160 160 161 void ImageLayerChromium::paintContentsIfDirty( const Region& /* occludedScreenSpace */)161 void ImageLayerChromium::paintContentsIfDirty() 162 162 { 163 163 if (m_needsDisplay) { -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h
r106324 r106335 46 46 class Image; 47 47 class ImageLayerTextureUpdater; 48 class Region;49 48 50 49 // A Layer that contains only an Image element. … … 55 54 56 55 virtual bool drawsContent() const; 57 virtual void paintContentsIfDirty( const Region& occludedScreenSpace);56 virtual void paintContentsIfDirty(); 58 57 virtual bool needsContentsScale() const; 59 58 -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r106324 r106335 40 40 #include "PlatformContextSkia.h" 41 41 #endif 42 #include "Region.h"43 42 #include "RenderLayerBacking.h" 44 43 #include "TextStream.h" … … 471 470 } 472 471 473 TransformationMatrix LayerChromium::contentToScreenSpaceTransform() const474 {475 IntSize boundsInLayerSpace = bounds();476 IntSize boundsInContentSpace = contentBounds();477 478 TransformationMatrix transform = screenSpaceTransform();479 480 // Scale from content space to layer space481 transform.scaleNonUniform(boundsInLayerSpace.width() / static_cast<double>(boundsInContentSpace.width()),482 boundsInLayerSpace.height() / static_cast<double>(boundsInContentSpace.height()));483 484 return transform;485 }486 487 void LayerChromium::addSelfToOccludedScreenSpace(Region& occludedScreenSpace)488 {489 if (!opaque() || drawOpacity() != 1 || !isPaintedAxisAlignedInScreen())490 return;491 492 FloatRect targetRect = contentToScreenSpaceTransform().mapRect(FloatRect(visibleLayerRect()));493 occludedScreenSpace.unite(enclosedIntRect(targetRect));494 }495 496 bool LayerChromium::isPaintedAxisAlignedInScreen() const497 {498 FloatQuad quad = contentToScreenSpaceTransform().mapQuad(FloatQuad(visibleLayerRect()));499 return quad.isRectilinear();500 }501 502 472 void LayerChromium::createRenderSurface() 503 473 { -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r106324 r106335 56 56 class CCTextureUpdater; 57 57 class GraphicsContext3D; 58 class Region;59 58 60 59 // Base class for composited layers. Special layer types are derived from … … 155 154 // These methods typically need to be overwritten by derived classes. 156 155 virtual bool drawsContent() const { return m_isDrawable; } 157 virtual void paintContentsIfDirty( const Region& /* occludedScreenSpace */) { }156 virtual void paintContentsIfDirty() { } 158 157 virtual void idlePaintContentsIfDirty() { } 159 158 virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&) { } … … 184 183 RenderSurfaceChromium* targetRenderSurface() const { return m_targetRenderSurface; } 185 184 void setTargetRenderSurface(RenderSurfaceChromium* surface) { m_targetRenderSurface = surface; } 186 // This moves from layer space, with origin in the center to target space with origin in the top left187 185 const TransformationMatrix& drawTransform() const { return m_drawTransform; } 188 186 void setDrawTransform(const TransformationMatrix& matrix) { m_drawTransform = matrix; } 189 // This moves from layer space, with origin the top left to screen space with origin in the top left190 187 const TransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; } 191 188 void setScreenSpaceTransform(const TransformationMatrix& matrix) { m_screenSpaceTransform = matrix; } … … 195 192 void setContentsScale(float); 196 193 197 TransformationMatrix contentToScreenSpaceTransform() const;198 199 // Adds any opaque visible pixels to the occluded region.200 virtual void addSelfToOccludedScreenSpace(Region& occludedScreenSpace);201 202 194 // Returns true if any of the layer's descendants has content to draw. 203 195 bool descendantDrawsContent(); … … 219 211 // hold context-dependent resources such as textures. 220 212 virtual void cleanupResources(); 221 222 bool isPaintedAxisAlignedInScreen() const;223 213 224 214 void setNeedsCommit(); -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
r106324 r106335 64 64 void setDrawOpacity(float drawOpacity) { m_drawOpacity = drawOpacity; } 65 65 66 // 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 the67 // rect being transformed. Position the rect so that the origin is in the center of it before applying this transform.68 66 const TransformationMatrix& drawTransform() const { return m_drawTransform; } 69 67 void setDrawTransform(const TransformationMatrix& drawTransform) { m_drawTransform = drawTransform; } -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
r106324 r106335 489 489 } 490 490 491 void TiledLayerChromium::addSelfToOccludedScreenSpace(Region& occludedScreenSpace)492 {493 if (m_skipsDraw || drawOpacity() != 1 || !isPaintedAxisAlignedInScreen())494 return;495 496 if (opaque()) {497 LayerChromium::addSelfToOccludedScreenSpace(occludedScreenSpace);498 return;499 }500 501 IntRect visibleRect = visibleLayerRect();502 TransformationMatrix contentTransform = contentToScreenSpaceTransform();503 504 // 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.505 Region tileRegion;506 int left, top, right, bottom;507 m_tiler->layerRectToTileIndices(visibleLayerRect(), left, top, right, bottom);508 for (int j = top; j <= bottom; ++j) {509 for (int i = left; i <= right; ++i) {510 UpdatableTile* tile = tileAt(i, j);511 if (tile) {512 IntRect visibleTileOpaqueRect = intersection(visibleRect, tile->m_opaqueRect);513 FloatRect screenRect = contentTransform.mapRect(FloatRect(visibleTileOpaqueRect));514 occludedScreenSpace.unite(enclosedIntRect(screenRect));515 }516 }517 }518 }519 520 491 void TiledLayerChromium::prepareToUpdate(const IntRect& layerRect) 521 492 { -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
r106324 r106335 36 36 37 37 class LayerTextureUpdater; 38 class Region;39 38 class UpdatableTile; 40 39 … … 64 63 65 64 virtual void reserveTextures(); 66 67 virtual void addSelfToOccludedScreenSpace(Region& occludedScreenSpace);68 65 69 66 protected: -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r106324 r106335 30 30 #include "LayerPainterChromium.h" 31 31 #include "LayerRendererChromium.h" 32 #include "Region.h"33 32 #include "TraceEvent.h" 34 33 #include "TreeSynchronizer.h" … … 415 414 416 415 // static 417 void CCLayerTreeHost::paintContentsIfDirty(LayerChromium* layer, PaintType paintType , const Region& occludedScreenSpace)416 void CCLayerTreeHost::paintContentsIfDirty(LayerChromium* layer, PaintType paintType) 418 417 { 419 418 ASSERT(layer); 420 419 ASSERT(PaintVisible == paintType || PaintIdle == paintType); 421 420 if (PaintVisible == paintType) 422 layer->paintContentsIfDirty( occludedScreenSpace);421 layer->paintContentsIfDirty(); 423 422 else 424 423 layer->idlePaintContentsIfDirty(); … … 431 430 // mask and replica should be painted. 432 431 433 // FIXME: If the surface has a replica, it should be painted with occlusion that excludes the current target surface subtree.434 Region noOcclusion;435 436 432 if (renderSurfaceLayer->maskLayer()) { 437 433 renderSurfaceLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), renderSurfaceLayer->contentBounds())); 438 paintContentsIfDirty(renderSurfaceLayer->maskLayer(), paintType , noOcclusion);434 paintContentsIfDirty(renderSurfaceLayer->maskLayer(), paintType); 439 435 } 440 436 441 437 LayerChromium* replicaLayer = renderSurfaceLayer->replicaLayer(); 442 438 if (replicaLayer) { 443 paintContentsIfDirty(replicaLayer, paintType , noOcclusion);439 paintContentsIfDirty(replicaLayer, paintType); 444 440 445 441 if (replicaLayer->maskLayer()) { 446 442 replicaLayer->maskLayer()->setVisibleLayerRect(IntRect(IntPoint(), replicaLayer->maskLayer()->contentBounds())); 447 paintContentsIfDirty(replicaLayer->maskLayer(), paintType , noOcclusion);443 paintContentsIfDirty(replicaLayer->maskLayer(), paintType); 448 444 } 449 }450 }451 452 struct RenderSurfaceRegion {453 RenderSurfaceChromium* surface;454 Region occludedInScreen;455 };456 457 // Add the surface to the top of the stack and copy the occlusion from the old top of the stack to the new.458 static void enterTargetRenderSurface(Vector<RenderSurfaceRegion>& stack, RenderSurfaceChromium* newTarget)459 {460 if (stack.isEmpty()) {461 stack.append(RenderSurfaceRegion());462 stack.last().surface = newTarget;463 } else if (stack.last().surface != newTarget) {464 const RenderSurfaceRegion& previous = stack.last();465 stack.append(RenderSurfaceRegion());466 stack.last().surface = newTarget;467 stack.last().occludedInScreen = previous.occludedInScreen;468 }469 }470 471 // Pop the top of the stack off, push on the new surface, and merge the old top's occlusion into the new top surface.472 static void leaveTargetRenderSurface(Vector<RenderSurfaceRegion>& stack, RenderSurfaceChromium* newTarget)473 {474 int lastIndex = stack.size() - 1;475 bool surfaceWillBeAtTopAfterPop = stack.size() > 1 && stack[lastIndex - 1].surface == newTarget;476 477 if (surfaceWillBeAtTopAfterPop) {478 // Merge the top of the stack down.479 stack[lastIndex - 1].occludedInScreen.unite(stack[lastIndex].occludedInScreen);480 stack.removeLast();481 } else {482 // Replace the top of the stack with the new pushed surface. Copy the occluded region to the top.483 stack.last().surface = newTarget;484 445 } 485 446 } … … 489 450 // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk. 490 451 typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType; 491 492 // The stack holds occluded regions for subtrees in the RenderSurface-Layer tree, so that when we leave a subtree we may493 // apply a mask to it, but not to the parts outside the subtree.494 // - 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.495 // - When we visit a target surface, we apply its mask to its subtree, which is at the top of the stack.496 // - When we visit a layer representing itself, we add its occlusion to the current subtree, which is at the top of the stack.497 // - 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.498 // 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.499 Vector<RenderSurfaceRegion> targetSurfaceStack;500 452 501 453 CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList); … … 503 455 if (it.representsTargetRenderSurface()) { 504 456 ASSERT(it->renderSurface()->drawOpacity()); 505 506 enterTargetRenderSurface(targetSurfaceStack, it->renderSurface());507 457 paintMaskAndReplicaForRenderSurface(*it, paintType); 508 // FIXME: add the replica layer to the current occlusion509 510 if (it->maskLayer() || it->renderSurface()->drawOpacity() < 1)511 targetSurfaceStack.last().occludedInScreen = Region();512 458 } else if (it.representsItself()) { 513 459 ASSERT(!it->bounds().isEmpty()); 514 515 enterTargetRenderSurface(targetSurfaceStack, it->targetRenderSurface()); 516 paintContentsIfDirty(*it, paintType, targetSurfaceStack.last().occludedInScreen); 517 it->addSelfToOccludedScreenSpace(targetSurfaceStack.last().occludedInScreen); 518 } else { 519 leaveTargetRenderSurface(targetSurfaceStack, it.targetRenderSurfaceLayer()->renderSurface()); 460 paintContentsIfDirty(*it, paintType); 520 461 } 521 462 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r106324 r106335 49 49 class GraphicsContext3D; 50 50 class LayerPainterChromium; 51 class Region;52 51 class TextureAllocator; 53 52 class TextureManager; … … 207 206 208 207 enum PaintType { PaintVisible, PaintIdle }; 209 static void paintContentsIfDirty(LayerChromium*, PaintType , const Region& occludedScreenSpace);208 static void paintContentsIfDirty(LayerChromium*, PaintType); 210 209 void paintLayerContents(const LayerList&, PaintType); 211 210 void paintMaskAndReplicaForRenderSurface(LayerChromium*, PaintType); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCQuadCuller.cpp
r106324 r106335 76 76 } 77 77 78 static IntRect enclosedIntRect(const FloatRect& rect) 79 { 80 float x = ceilf(rect.x()); 81 float y = ceilf(rect.y()); 82 // A rect of width 0 should not become a rect of width -1. 83 float width = max<float>(floorf(rect.maxX()) - x, 0); 84 float height = max<float>(floorf(rect.maxY()) - y, 0); 85 86 return IntRect(clampToInteger(x), clampToInteger(y), 87 clampToInteger(width), clampToInteger(height)); 88 } 89 78 90 void CCQuadCuller::cullOccludedQuads(CCQuadList& quadList) 79 91 { -
trunk/Source/WebKit/chromium/ChangeLog
r106324 r106335 1 2012-01-30 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r106324. 4 http://trac.webkit.org/changeset/106324 5 https://bugs.webkit.org/show_bug.cgi?id=77406 6 7 Broke CCLayerTreeHostTestLayerOcclusion.runMultiThread and 8 runSingleThread (Requested by yuzo1 on #webkit). 9 10 * tests/CCLayerTreeHostCommonTest.cpp: 11 (WebCore): 12 * tests/CCLayerTreeHostTest.cpp: 13 (WTF::ContentLayerChromiumWithUpdateTracking::paintContentsIfDirty): 14 * tests/Canvas2DLayerChromiumTest.cpp: 15 (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): 16 * tests/TiledLayerChromiumTest.cpp: 17 (FakeLayerTextureUpdater): 18 (WTF::FakeTiledLayerChromium::paintContentsIfDirty): 19 (WTF::FakeLayerTextureUpdater::prepareToUpdate): 20 1 21 2012-01-30 Dana Jansens <danakj@chromium.org> 2 22 -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
r106324 r106335 29 29 #include "CCLayerTreeTestCommon.h" 30 30 #include "LayerChromium.h" 31 #include "Region.h"32 31 #include "TransformationMatrix.h" 33 32 … … 36 35 37 36 using namespace WebCore; 38 39 #define EXPECT_EQ_RECT(a, b) \40 EXPECT_EQ(a.x(), b.x()); \41 EXPECT_EQ(a.y(), b.y()); \42 EXPECT_EQ(a.width(), b.width()); \43 EXPECT_EQ(a.height(), b.height());44 37 45 38 namespace { … … 603 596 // 604 597 605 TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegion)606 {607 // This tests that the right transforms are being used.608 Region occluded;609 const TransformationMatrix identityMatrix;610 RefPtr<LayerChromium> parent = LayerChromium::create();611 RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent());612 parent->createRenderSurface();613 parent->addChild(layer);614 615 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);616 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false);617 618 layer->setOpaque(true);619 620 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;621 Vector<RefPtr<LayerChromium> > dummyLayerList;622 int dummyMaxTextureSize = 512;623 624 // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too.625 parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds()));626 parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds()));627 renderSurfaceLayerList.append(parent);628 629 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);630 631 occluded = Region();632 layer->addSelfToOccludedScreenSpace(occluded);633 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occluded.bounds());634 EXPECT_EQ(1u, occluded.rects().size());635 }636 637 TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithRotation)638 {639 // This tests that the right transforms are being used.640 Region occluded;641 const TransformationMatrix identityMatrix;642 RefPtr<LayerChromium> parent = LayerChromium::create();643 RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent());644 parent->createRenderSurface();645 parent->addChild(layer);646 647 TransformationMatrix layerTransform;648 layerTransform.translate(250, 250);649 layerTransform.rotate(90);650 layerTransform.translate(-250, -250);651 652 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);653 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false);654 655 layer->setOpaque(true);656 657 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;658 Vector<RefPtr<LayerChromium> > dummyLayerList;659 int dummyMaxTextureSize = 512;660 661 // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too.662 parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds()));663 parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds()));664 renderSurfaceLayerList.append(parent);665 666 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);667 668 occluded = Region();669 layer->addSelfToOccludedScreenSpace(occluded);670 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occluded.bounds());671 EXPECT_EQ(1u, occluded.rects().size());672 }673 674 TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithTranslation)675 {676 // This tests that the right transforms are being used.677 Region occluded;678 const TransformationMatrix identityMatrix;679 RefPtr<LayerChromium> parent = LayerChromium::create();680 RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent());681 parent->createRenderSurface();682 parent->addChild(layer);683 684 TransformationMatrix layerTransform;685 layerTransform.translate(20, 20);686 687 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);688 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false);689 690 layer->setOpaque(true);691 692 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;693 Vector<RefPtr<LayerChromium> > dummyLayerList;694 int dummyMaxTextureSize = 512;695 696 // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too.697 parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds()));698 parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds()));699 renderSurfaceLayerList.append(parent);700 701 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);702 703 occluded = Region();704 layer->addSelfToOccludedScreenSpace(occluded);705 EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), occluded.bounds());706 EXPECT_EQ(1u, occluded.rects().size());707 }708 709 TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithRotatedSurface)710 {711 // This tests that the right transforms are being used.712 Region occluded;713 const TransformationMatrix identityMatrix;714 RefPtr<LayerChromium> parent = LayerChromium::create();715 RefPtr<LayerChromium> child = LayerChromium::create();716 RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent());717 parent->createRenderSurface();718 parent->addChild(child);719 child->addChild(layer);720 721 TransformationMatrix childTransform;722 childTransform.translate(250, 250);723 childTransform.rotate(90);724 childTransform.translate(-250, -250);725 726 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);727 setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false);728 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), false);729 730 child->setMasksToBounds(true);731 layer->setOpaque(true);732 733 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;734 Vector<RefPtr<LayerChromium> > dummyLayerList;735 int dummyMaxTextureSize = 512;736 737 // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too.738 parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds()));739 parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds()));740 renderSurfaceLayerList.append(parent);741 742 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);743 744 occluded = Region();745 layer->addSelfToOccludedScreenSpace(occluded);746 EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occluded.bounds());747 EXPECT_EQ(1u, occluded.rects().size());748 749 /* Justification for the above opaque rect from |layer|:750 100751 +---------------------+ +---------------------+752 | | | |30 Visible region of |layer|: /////753 | 30 | rotate(90) | |754 | 30 + ---------------------------------+ | +---------------------------------+755 100 | | 10 | | ==> | | |10 |756 | |10+---------------------------------+ | +---------------------------------+ |757 | | | | | | | | |///////////////| 420 | |758 | | | | | | | | |///////////////|60 | |759 | | | | | | | | |///////////////| | |760 +----|--|-------------+ | | +--|--|---------------+ | |761 | | | | 20|10| 70 | |762 | | | | | | | |763 | | | |500 | | | |764 | | | | | | | |765 | | | | | | | |766 | | | | | | | |767 | | | | | | |10|768 +--|-------------------------------+ | | +------------------------------|--+769 | | | 490 |770 +---------------------------------+ +---------------------------------+771 500 500772 */773 }774 775 598 } // namespace -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r106324 r106335 31 31 #include "GraphicsContext3DPrivate.h" 32 32 #include "LayerChromium.h" 33 #include "Region.h"34 33 #include "TextureManager.h" 35 34 #include "WebCompositor.h" … … 1007 1006 void resetUpdateCount() { m_updateCount = 0; } 1008 1007 1009 virtual void paintContentsIfDirty( const Region& occludedScreenSpace)1010 { 1011 ContentLayerChromium::paintContentsIfDirty( occludedScreenSpace);1008 virtual void paintContentsIfDirty() 1009 { 1010 ContentLayerChromium::paintContentsIfDirty(); 1012 1011 m_paintContentsCount++; 1013 1012 } … … 1230 1229 } 1231 1230 1232 #define EXPECT_EQ_RECT(a, b) \1233 EXPECT_EQ(a.x(), b.x()); \1234 EXPECT_EQ(a.y(), b.y()); \1235 EXPECT_EQ(a.width(), b.width()); \1236 EXPECT_EQ(a.height(), b.height());1237 1238 class TestLayerChromium : public LayerChromium {1239 public:1240 static PassRefPtr<TestLayerChromium> create() { return adoptRef(new TestLayerChromium()); }1241 1242 virtual void paintContentsIfDirty(const Region& occludedScreenSpace)1243 {1244 m_occludedScreenSpace = occludedScreenSpace;1245 }1246 1247 virtual bool drawsContent() const { return true; }1248 1249 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; }1250 void clearOccludedScreenSpace() { m_occludedScreenSpace = Region(); }1251 1252 private:1253 TestLayerChromium() : LayerChromium() { }1254 1255 Region m_occludedScreenSpace;1256 };1257 1258 static void setLayerPropertiesForTesting(TestLayerChromium* layer, LayerChromium* parent, const TransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque)1259 {1260 layer->removeAllChildren();1261 if (parent)1262 parent->addChild(layer);1263 layer->setTransform(transform);1264 layer->setAnchorPoint(anchor);1265 layer->setPosition(position);1266 layer->setBounds(bounds);1267 layer->setOpaque(opaque);1268 layer->clearOccludedScreenSpace();1269 }1270 1271 class CCLayerTreeHostTestLayerOcclusion : public CCLayerTreeHostTest {1272 public:1273 CCLayerTreeHostTestLayerOcclusion() { }1274 1275 virtual void beginTest()1276 {1277 RefPtr<TestLayerChromium> rootLayer = TestLayerChromium::create();1278 RefPtr<TestLayerChromium> child = TestLayerChromium::create();1279 RefPtr<TestLayerChromium> child2 = TestLayerChromium::create();1280 RefPtr<TestLayerChromium> grandChild = TestLayerChromium::create();1281 RefPtr<TestLayerChromium> mask = TestLayerChromium::create();1282 1283 TransformationMatrix identityMatrix;1284 TransformationMatrix childTransform;1285 childTransform.translate(250, 250);1286 childTransform.rotate(90);1287 childTransform.translate(-250, -250);1288 1289 child->setMasksToBounds(true);1290 1291 // See CCLayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedSurface for a nice visual of these layers and how they end up1292 // positioned on the screen.1293 1294 // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer1295 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);1296 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false);1297 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);1298 1299 m_layerTreeHost->setRootLayer(rootLayer);1300 m_layerTreeHost->setViewportSize(rootLayer->bounds());1301 m_layerTreeHost->updateLayers();1302 m_layerTreeHost->commitComplete();1303 1304 EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());1305 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());1306 EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds());1307 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());1308 EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), rootLayer->occludedScreenSpace().bounds());1309 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());1310 1311 // If the child layer is opaque, then it adds to the occlusion seen by the rootLayer.1312 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);1313 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true);1314 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);1315 1316 m_layerTreeHost->setRootLayer(rootLayer);1317 m_layerTreeHost->setViewportSize(rootLayer->bounds());1318 m_layerTreeHost->updateLayers();1319 m_layerTreeHost->commitComplete();1320 1321 EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());1322 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());1323 EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds());1324 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());1325 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), rootLayer->occludedScreenSpace().bounds());1326 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());1327 1328 // Add a second child to the root layer and the regions should merge1329 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);1330 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(70, 20), IntSize(500, 500), true);1331 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true);1332 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);1333 1334 m_layerTreeHost->setRootLayer(rootLayer);1335 m_layerTreeHost->setViewportSize(rootLayer->bounds());1336 m_layerTreeHost->updateLayers();1337 m_layerTreeHost->commitComplete();1338 1339 EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());1340 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());1341 EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds());1342 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());1343 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), child2->occludedScreenSpace().bounds());1344 EXPECT_EQ(1u, child2->occludedScreenSpace().rects().size());1345 EXPECT_EQ_RECT(IntRect(30, 20, 70, 80), rootLayer->occludedScreenSpace().bounds());1346 EXPECT_EQ(2u, rootLayer->occludedScreenSpace().rects().size());1347 1348 // Move the second child to be sure.1349 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);1350 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true);1351 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true);1352 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);1353 1354 m_layerTreeHost->setRootLayer(rootLayer);1355 m_layerTreeHost->setViewportSize(rootLayer->bounds());1356 m_layerTreeHost->updateLayers();1357 m_layerTreeHost->commitComplete();1358 1359 EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());1360 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());1361 EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds());1362 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());1363 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), child2->occludedScreenSpace().bounds());1364 EXPECT_EQ(1u, child2->occludedScreenSpace().rects().size());1365 EXPECT_EQ_RECT(IntRect(10, 30, 90, 70), rootLayer->occludedScreenSpace().bounds());1366 EXPECT_EQ(2u, rootLayer->occludedScreenSpace().rects().size());1367 1368 // If the child layer has a mask on it, then it shouldn't contribute to occlusion on stuff below it1369 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);1370 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true);1371 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true);1372 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);1373 1374 child->setMaskLayer(mask.get());1375 1376 m_layerTreeHost->setRootLayer(rootLayer);1377 m_layerTreeHost->setViewportSize(rootLayer->bounds());1378 m_layerTreeHost->updateLayers();1379 m_layerTreeHost->commitComplete();1380 1381 EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());1382 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());1383 EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds());1384 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());1385 EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds());1386 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size());1387 EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds());1388 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());1389 1390 // 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 rootLayer1391 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);1392 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true);1393 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);1394 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true);1395 1396 child->setMaskLayer(mask.get());1397 1398 m_layerTreeHost->setRootLayer(rootLayer);1399 m_layerTreeHost->setViewportSize(rootLayer->bounds());1400 m_layerTreeHost->updateLayers();1401 m_layerTreeHost->commitComplete();1402 1403 EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds());1404 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size());1405 EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), grandChild->occludedScreenSpace().bounds());1406 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size());1407 EXPECT_EQ_RECT(IntRect(10, 40, 90, 60), child->occludedScreenSpace().bounds());1408 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size());1409 EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds());1410 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());1411 1412 // If the child layer has a non-opaque drawOpacity, then it shouldn't contribute to occlusion on stuff below it1413 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);1414 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true);1415 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true);1416 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);1417 1418 child->setMaskLayer(0);1419 child->setDrawOpacity(0.5);1420 1421 m_layerTreeHost->setRootLayer(rootLayer);1422 m_layerTreeHost->setViewportSize(rootLayer->bounds());1423 m_layerTreeHost->updateLayers();1424 m_layerTreeHost->commitComplete();1425 1426 EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds());1427 EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size());1428 EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds());1429 EXPECT_EQ(1u, child->occludedScreenSpace().rects().size());1430 EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds());1431 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size());1432 EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds());1433 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());1434 1435 // 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 rootLayer1436 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);1437 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true);1438 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true);1439 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true);1440 1441 child->setMaskLayer(0);1442 child->setDrawOpacity(0.5);1443 1444 m_layerTreeHost->setRootLayer(rootLayer);1445 m_layerTreeHost->setViewportSize(rootLayer->bounds());1446 m_layerTreeHost->updateLayers();1447 m_layerTreeHost->commitComplete();1448 1449 EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds());1450 EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size());1451 EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), grandChild->occludedScreenSpace().bounds());1452 EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size());1453 EXPECT_EQ_RECT(IntRect(10, 40, 90, 60), child->occludedScreenSpace().bounds());1454 EXPECT_EQ(2u, child->occludedScreenSpace().rects().size());1455 EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds());1456 EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size());1457 1458 // Kill the layerTreeHost immediately.1459 m_layerTreeHost->setRootLayer(0);1460 m_layerTreeHost.clear();1461 1462 endTest();1463 }1464 1465 virtual void afterTest()1466 {1467 }1468 };1469 1470 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerOcclusion)1471 1472 1231 } // namespace -
trunk/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp
r106324 r106335 30 30 #include "FakeWebGraphicsContext3D.h" 31 31 #include "GraphicsContext3DPrivate.h" 32 #include "Region.h"33 32 #include "TextureManager.h" 34 33 #include "cc/CCCanvasLayerImpl.h" … … 140 139 canvas->contentChanged(); 141 140 EXPECT_TRUE(canvas->needsDisplay()); 142 Region occludedScreenSpace; 143 canvas->paintContentsIfDirty(occludedScreenSpace); 141 canvas->paintContentsIfDirty(); 144 142 EXPECT_FALSE(canvas->needsDisplay()); 145 143 { -
trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
r106324 r106335 30 30 #include "FakeCCLayerTreeHostClient.h" 31 31 #include "LayerTextureUpdater.h" 32 #include "Region.h"33 32 #include "TextureManager.h" 34 33 #include "WebCompositor.h" … … 41 40 using namespace WTF; 42 41 43 #define EXPECT_EQ_RECT(a, b) \44 EXPECT_EQ(a.x(), b.x()); \45 EXPECT_EQ(a.y(), b.y()); \46 EXPECT_EQ(a.width(), b.width()); \47 EXPECT_EQ(a.height(), b.height());48 49 42 namespace { 50 43 … … 78 71 void clearPrepareCount() { m_prepareCount = 0; } 79 72 80 void setOpaquePaintRect(const IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; }81 82 73 // Last rect passed to prepareToUpdate(). 83 74 const IntRect& lastUpdateRect() const { return m_lastUpdateRect; } … … 85 76 virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture(ManagedTexture::create(manager))); } 86 77 virtual SampledTexelFormat sampledTexelFormat(GC3Denum) { return SampledTexelFormatRGBA; } 87 virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect);78 virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect*); 88 79 89 80 private: … … 91 82 IntRect m_rectToInvalidate; 92 83 IntRect m_lastUpdateRect; 93 IntRect m_opaquePaintRect;94 84 RefPtr<FakeTiledLayerChromium> m_layer; 95 85 }; … … 150 140 virtual TextureManager* textureManager() const { return m_textureManager; } 151 141 152 virtual void paintContentsIfDirty( const Region& /* occludedScreenSpace */)142 virtual void paintContentsIfDirty() 153 143 { 154 144 prepareToUpdate(visibleLayerRect()); … … 198 188 m_layer = 0; 199 189 } 200 *resultingOpaqueRect = m_opaquePaintRect;190 *resultingOpaqueRect = IntRect(); 201 191 } 202 192 … … 471 461 } 472 462 473 TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion)474 {475 OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024);476 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));477 478 // The tile size is 100x100, so this invalidates and then paints two tiles in various ways.479 480 Region occluded;481 IntRect contentBounds = IntRect(0, 0, 100, 200);482 IntRect visibleBounds = IntRect(0, 0, 100, 150);483 484 layer->setBounds(contentBounds.size());485 layer->setVisibleLayerRect(visibleBounds);486 layer->setDrawOpacity(1);487 488 // The screenSpaceTransform is verified in CCLayerTreeHostCommonTests489 TransformationMatrix screenSpaceTransform;490 layer->setScreenSpaceTransform(screenSpaceTransform);491 492 // If the layer is opaque then the occluded region should be the whole layer's visible region.493 layer->setOpaque(true);494 layer->invalidateRect(contentBounds);495 layer->prepareToUpdate(contentBounds);496 497 occluded = Region();498 layer->addSelfToOccludedScreenSpace(occluded);499 EXPECT_EQ_RECT(visibleBounds, occluded.bounds());500 EXPECT_EQ(1u, occluded.rects().size());501 502 // If the layer is not opaque then the occluded region should be empty.503 layer->setOpaque(false);504 layer->invalidateRect(contentBounds);505 layer->prepareToUpdate(contentBounds);506 507 occluded = Region();508 layer->addSelfToOccludedScreenSpace(occluded);509 EXPECT_EQ_RECT(IntRect(), occluded.bounds());510 EXPECT_EQ(1u, occluded.rects().size());511 512 // If the layer paints opaque content, then the occluded region should match the visible opaque content.513 IntRect opaquePaintRect = IntRect(10, 10, 90, 190);514 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect);515 layer->invalidateRect(contentBounds);516 layer->prepareToUpdate(contentBounds);517 518 occluded = Region();519 layer->addSelfToOccludedScreenSpace(occluded);520 EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds());521 EXPECT_EQ(1u, occluded.rects().size());522 523 // If we paint again without invalidating, the same stuff should be occluded.524 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect());525 layer->prepareToUpdate(contentBounds);526 527 occluded = Region();528 layer->addSelfToOccludedScreenSpace(occluded);529 EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds());530 EXPECT_EQ(1u, occluded.rects().size());531 532 // If the layer is transformed then the resulting occluded area needs to be transformed to its target space.533 TransformationMatrix transform;534 transform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0);535 transform.rotate(90);536 transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);537 transform.translate(10, 10);538 screenSpaceTransform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0);539 screenSpaceTransform *= transform;540 screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);541 layer->setScreenSpaceTransform(screenSpaceTransform);542 layer->prepareToUpdate(contentBounds);543 544 occluded = Region();545 layer->addSelfToOccludedScreenSpace(occluded);546 EXPECT_EQ_RECT(screenSpaceTransform.mapRect(intersection(opaquePaintRect, visibleBounds)), occluded.bounds());547 EXPECT_EQ(1u, occluded.rects().size());548 549 // But a non-axis-aligned transform does not get considered for occlusion.550 transform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0);551 transform.rotate(5);552 transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);553 screenSpaceTransform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0);554 screenSpaceTransform *= transform;555 screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);556 layer->setScreenSpaceTransform(screenSpaceTransform);557 layer->prepareToUpdate(contentBounds);558 559 occluded = Region();560 layer->addSelfToOccludedScreenSpace(occluded);561 // FIXME: If we find an opaque rect contained in the rotated non-axis-aligned rect, then562 // this won't be an empty result.563 EXPECT_EQ_RECT(IntRect(), occluded.bounds());564 EXPECT_EQ(0u, occluded.rects().size());565 }566 567 463 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.