Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: cc/CCOcclusionTrackerTest.cpp

Issue 10915313: cc: Apply the layer's initial CSS scale to the contentsScale to render text at the right resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCOcclusionTracker.h" 7 #include "CCOcclusionTracker.h"
8 8
9 #include "CCAnimationTestCommon.h" 9 #include "CCAnimationTestCommon.h"
10 #include "CCGeometryTestUtils.h" 10 #include "CCGeometryTestUtils.h"
11 #include "CCLayerAnimationController.h" 11 #include "CCLayerAnimationController.h"
12 #include "CCLayerImpl.h"
13 #include "CCLayerTreeHostCommon.h" 12 #include "CCLayerTreeHostCommon.h"
14 #include "CCMathUtil.h" 13 #include "CCMathUtil.h"
15 #include "CCOcclusionTrackerTestCommon.h" 14 #include "CCOcclusionTrackerTestCommon.h"
16 #include "CCOverdrawMetrics.h" 15 #include "CCOverdrawMetrics.h"
17 #include "CCSingleThreadProxy.h" 16 #include "CCSingleThreadProxy.h"
18 #include "LayerChromium.h" 17 #include "CCTiledLayerImpl.h"
19 #include "Region.h" 18 #include "Region.h"
19 #include "TiledLayerChromium.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include <public/WebFilterOperation.h> 22 #include <public/WebFilterOperation.h>
23 #include <public/WebFilterOperations.h> 23 #include <public/WebFilterOperations.h>
24 #include <public/WebTransformationMatrix.h> 24 #include <public/WebTransformationMatrix.h>
25 25
26 using namespace cc; 26 using namespace cc;
27 using namespace WebKit; 27 using namespace WebKit;
28 using namespace WebKitTests; 28 using namespace WebKitTests;
29 29
30 namespace { 30 namespace {
31 31
32 class TestContentLayerChromium : public LayerChromium { 32 class TestContentLayerChromium : public TiledLayerChromium {
33 public: 33 public:
34 TestContentLayerChromium() 34 TestContentLayerChromium()
35 : LayerChromium() 35 : TiledLayerChromium()
36 , m_overrideOpaqueContentsRect(false) 36 , m_overrideOpaqueContentsRect(false)
37 { 37 {
38 } 38 }
39 39
40 virtual bool drawsContent() const OVERRIDE { return true; } 40 virtual bool drawsContent() const OVERRIDE { return true; }
41 virtual Region visibleContentOpaqueRegion() const OVERRIDE 41 virtual Region visibleContentOpaqueRegion() const OVERRIDE
42 { 42 {
43 if (m_overrideOpaqueContentsRect) 43 if (m_overrideOpaqueContentsRect)
44 return intersection(m_opaqueContentsRect, visibleContentRect()); 44 return intersection(m_opaqueContentsRect, visibleContentRect());
45 return LayerChromium::visibleContentOpaqueRegion(); 45 return LayerChromium::visibleContentOpaqueRegion();
46 } 46 }
47 void setOpaqueContentsRect(const IntRect& opaqueContentsRect) 47 void setOpaqueContentsRect(const IntRect& opaqueContentsRect)
48 { 48 {
49 m_overrideOpaqueContentsRect = true; 49 m_overrideOpaqueContentsRect = true;
50 m_opaqueContentsRect = opaqueContentsRect; 50 m_opaqueContentsRect = opaqueContentsRect;
51 } 51 }
52 52
53 virtual LayerTextureUpdater* textureUpdater() const OVERRIDE { return 0; }
54 virtual void createTextureUpdaterIfNeeded() OVERRIDE { }
55
53 private: 56 private:
54 bool m_overrideOpaqueContentsRect; 57 bool m_overrideOpaqueContentsRect;
55 IntRect m_opaqueContentsRect; 58 IntRect m_opaqueContentsRect;
56 }; 59 };
57 60
58 class TestContentLayerImpl : public CCLayerImpl { 61 class TestContentLayerImpl : public CCTiledLayerImpl {
59 public: 62 public:
60 TestContentLayerImpl(int id) 63 TestContentLayerImpl(int id)
61 : CCLayerImpl(id) 64 : CCTiledLayerImpl(id)
62 , m_overrideOpaqueContentsRect(false) 65 , m_overrideOpaqueContentsRect(false)
63 { 66 {
64 setDrawsContent(true); 67 setDrawsContent(true);
65 } 68 }
66 69
67 virtual Region visibleContentOpaqueRegion() const OVERRIDE 70 virtual Region visibleContentOpaqueRegion() const OVERRIDE
68 { 71 {
69 if (m_overrideOpaqueContentsRect) 72 if (m_overrideOpaqueContentsRect)
70 return intersection(m_opaqueContentsRect, visibleContentRect()); 73 return intersection(m_opaqueContentsRect, visibleContentRect());
71 return CCLayerImpl::visibleContentOpaqueRegion(); 74 return CCLayerImpl::visibleContentOpaqueRegion();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 236 }
234 237
235 void calcDrawEtc(TestContentLayerImpl* root) 238 void calcDrawEtc(TestContentLayerImpl* root)
236 { 239 {
237 ASSERT(root == m_root.get()); 240 ASSERT(root == m_root.get());
238 int dummyMaxTextureSize = 512; 241 int dummyMaxTextureSize = 512;
239 CCLayerSorter layerSorter; 242 CCLayerSorter layerSorter;
240 243
241 ASSERT(!root->renderSurface()); 244 ASSERT(!root->renderSurface());
242 245
243 CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, &layerSorter, dummyMaxTextureSize, m_renderSurfaceLayerListImpl); 246 CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, 1, &layerSorter, dummyMaxTextureSize, m_renderSurfaceLayerListImpl);
244 CCLayerTreeHostCommon::calculateVisibleRects(m_renderSurfaceLayerListImp l); 247 CCLayerTreeHostCommon::calculateVisibleRects(m_renderSurfaceLayerListImp l);
245 248
246 m_layerIterator = m_layerIteratorBegin = Types::LayerIterator::begin(&m_ renderSurfaceLayerListImpl); 249 m_layerIterator = m_layerIteratorBegin = Types::LayerIterator::begin(&m_ renderSurfaceLayerListImpl);
247 } 250 }
248 251
249 void calcDrawEtc(TestContentLayerChromium* root) 252 void calcDrawEtc(TestContentLayerChromium* root)
250 { 253 {
251 ASSERT(root == m_root.get()); 254 ASSERT(root == m_root.get());
252 int dummyMaxTextureSize = 512; 255 int dummyMaxTextureSize = 512;
253 256
254 ASSERT(!root->renderSurface()); 257 ASSERT(!root->renderSurface());
255 258
256 CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, dummyMaxTextureSize, m_renderSurfaceLayerListChromium); 259 CCLayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, 1, dummyMaxTextureSize, m_renderSurfaceLayerListChromium);
257 CCLayerTreeHostCommon::calculateVisibleRects(m_renderSurfaceLayerListChr omium); 260 CCLayerTreeHostCommon::calculateVisibleRects(m_renderSurfaceLayerListChr omium);
258 261
259 m_layerIterator = m_layerIteratorBegin = Types::LayerIterator::begin(&m_ renderSurfaceLayerListChromium); 262 m_layerIterator = m_layerIteratorBegin = Types::LayerIterator::begin(&m_ renderSurfaceLayerListChromium);
260 } 263 }
261 264
262 void enterLayer(typename Types::LayerType* layer, typename Types::OcclusionT rackerType& occlusion) 265 void enterLayer(typename Types::LayerType* layer, typename Types::OcclusionT rackerType& occlusion)
263 { 266 {
264 ASSERT_EQ(layer, *m_layerIterator); 267 ASSERT_EQ(layer, *m_layerIterator);
265 ASSERT_TRUE(m_layerIterator.representsItself()); 268 ASSERT_TRUE(m_layerIterator.representsItself());
266 occlusion.enterLayer(m_layerIterator); 269 occlusion.enterLayer(m_layerIterator);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 }; \ 398 }; \
396 TEST_F(ClassName##ImplThreadOpaquePaints, runTest) { runMyTest(); } 399 TEST_F(ClassName##ImplThreadOpaquePaints, runTest) { runMyTest(); }
397 400
398 #define ALL_CCOCCLUSIONTRACKER_TEST(ClassName) \ 401 #define ALL_CCOCCLUSIONTRACKER_TEST(ClassName) \
399 RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \ 402 RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
400 RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \ 403 RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \
401 RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ 404 RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
402 RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) 405 RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName)
403 406
404 #define MAIN_THREAD_TEST(ClassName) \ 407 #define MAIN_THREAD_TEST(ClassName) \
405 RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) 408 RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
409 RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName)
406 410
407 #define IMPL_THREAD_TEST(ClassName) \ 411 #define IMPL_THREAD_TEST(ClassName) \
408 RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) 412 RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
413 RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName)
409 414
410 #define MAIN_AND_IMPL_THREAD_TEST(ClassName) \ 415 #define MAIN_AND_IMPL_THREAD_TEST(ClassName) \
411 RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \ 416 RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \
412 RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) 417 RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \
418 RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \
419 RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName)
413 420
414 template<class Types, bool opaqueLayers> 421 template<class Types, bool opaqueLayers>
415 class CCOcclusionTrackerTestIdentityTransforms : public CCOcclusionTrackerTest<T ypes, opaqueLayers> { 422 class CCOcclusionTrackerTestIdentityTransforms : public CCOcclusionTrackerTest<T ypes, opaqueLayers> {
416 protected: 423 protected:
417 void runMyTest() 424 void runMyTest()
418 { 425 {
419 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(100, 100)); 426 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(100, 100));
420 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, this->identityMatrix, FloatPoint(30, 30), IntSize(500, 500), true); 427 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, this->identityMatrix, FloatPoint(30, 30), IntSize(500, 500), true);
421 this->calcDrawEtc(parent); 428 this->calcDrawEtc(parent);
422 429
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 void runMyTest() 2173 void runMyTest()
2167 { 2174 {
2168 WebTransformationMatrix surfaceTransform; 2175 WebTransformationMatrix surfaceTransform;
2169 surfaceTransform.translate(300, 300); 2176 surfaceTransform.translate(300, 300);
2170 surfaceTransform.scale(2); 2177 surfaceTransform.scale(2);
2171 surfaceTransform.translate(-150, -150); 2178 surfaceTransform.translate(-150, -150);
2172 2179
2173 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(500, 500)); 2180 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(500, 500));
2174 typename Types::ContentLayerType* surface = this->createDrawingSurface(p arent, surfaceTransform, FloatPoint(0, 0), IntSize(300, 300), false); 2181 typename Types::ContentLayerType* surface = this->createDrawingSurface(p arent, surfaceTransform, FloatPoint(0, 0), IntSize(300, 300), false);
2175 typename Types::ContentLayerType* surface2 = this->createDrawingSurface( parent, this->identityMatrix, FloatPoint(50, 50), IntSize(300, 300), false); 2182 typename Types::ContentLayerType* surface2 = this->createDrawingSurface( parent, this->identityMatrix, FloatPoint(50, 50), IntSize(300, 300), false);
2176 surface->setOpaqueContentsRect(IntRect(0, 0, 200, 200)); 2183 surface->setOpaqueContentsRect(IntRect(0, 0, 400, 400));
2177 surface2->setOpaqueContentsRect(IntRect(0, 0, 200, 200)); 2184 surface2->setOpaqueContentsRect(IntRect(0, 0, 200, 200));
2178 this->calcDrawEtc(parent); 2185 this->calcDrawEtc(parent);
2179 2186
2180 TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types ::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); 2187 TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types ::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
2181 2188
2182 this->visitLayer(surface2, occlusion); 2189 this->visitLayer(surface2, occlusion);
2183 this->visitContributingSurface(surface2, occlusion); 2190 this->visitContributingSurface(surface2, occlusion);
2184 2191
2185 EXPECT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.occlusionInScreenSpa ce().bounds()); 2192 EXPECT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.occlusionInScreenSpa ce().bounds());
2186 EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); 2193 EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
2187 EXPECT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.occlusionInTargetSur face().bounds()); 2194 EXPECT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.occlusionInTargetSur face().bounds());
2188 EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); 2195 EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
2189 2196
2190 // Clear any stored occlusion. 2197 // Clear any stored occlusion.
2191 occlusion.setOcclusionInScreenSpace(Region()); 2198 occlusion.setOcclusionInScreenSpace(Region());
2192 occlusion.setOcclusionInTargetSurface(Region()); 2199 occlusion.setOcclusionInTargetSurface(Region());
2193 2200
2194 this->visitLayer(surface, occlusion); 2201 this->visitLayer(surface, occlusion);
2195 this->visitContributingSurface(surface, occlusion); 2202 this->visitContributingSurface(surface, occlusion);
2196 2203
2197 EXPECT_RECT_EQ(IntRect(0, 0, 400, 400), occlusion.occlusionInScreenSpace ().bounds()); 2204 EXPECT_RECT_EQ(IntRect(0, 0, 400, 400), occlusion.occlusionInScreenSpace ().bounds());
2198 EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); 2205 EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
2199 EXPECT_RECT_EQ(IntRect(0, 0, 400, 400), occlusion.occlusionInTargetSurfa ce().bounds()); 2206 EXPECT_RECT_EQ(IntRect(0, 0, 400, 400), occlusion.occlusionInTargetSurfa ce().bounds());
2200 EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); 2207 EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
2201 } 2208 }
2202 }; 2209 };
2203 2210
2204 MAIN_AND_IMPL_THREAD_TEST(CCOcclusionTrackerTestSurfaceOcclusionTranslatesToPare nt); 2211 // Scale transforms require main thread+commit to get contentBounds right.
2212 MAIN_THREAD_TEST(CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent);
2205 2213
2206 template<class Types, bool opaqueLayers> 2214 template<class Types, bool opaqueLayers>
2207 class CCOcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping : public CCOc clusionTrackerTest<Types, opaqueLayers> { 2215 class CCOcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping : public CCOc clusionTrackerTest<Types, opaqueLayers> {
2208 protected: 2216 protected:
2209 void runMyTest() 2217 void runMyTest()
2210 { 2218 {
2211 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(300, 300)); 2219 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(300, 300));
2212 parent->setMasksToBounds(true); 2220 parent->setMasksToBounds(true);
2213 typename Types::ContentLayerType* surface = this->createDrawingSurface(p arent, this->identityMatrix, FloatPoint(0, 0), IntSize(500, 300), false); 2221 typename Types::ContentLayerType* surface = this->createDrawingSurface(p arent, this->identityMatrix, FloatPoint(0, 0), IntSize(500, 300), false);
2214 surface->setOpaqueContentsRect(IntRect(0, 0, 400, 200)); 2222 surface->setOpaqueContentsRect(IntRect(0, 0, 400, 200));
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 this->visitLayer(occludingLayer2, occlusion); 2544 this->visitLayer(occludingLayer2, occlusion);
2537 this->visitLayer(occludingLayer1, occlusion); 2545 this->visitLayer(occludingLayer1, occlusion);
2538 2546
2539 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace ().bounds()); 2547 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace ().bounds());
2540 EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); 2548 EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
2541 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurfa ce().bounds()); 2549 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurfa ce().bounds());
2542 EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size()); 2550 EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size());
2543 2551
2544 // Everything outside the surface/replica is occluded but the surface/re plica itself is not. 2552 // Everything outside the surface/replica is occluded but the surface/re plica itself is not.
2545 this->enterLayer(filteredSurface, occlusion); 2553 this->enterLayer(filteredSurface, occlusion);
2546 EXPECT_RECT_EQ(IntRect(1, 0, 99, 100), occlusion.unoccludedContentRect(f ilteredSurface, IntRect(1, 0, 100, 100))); 2554 EXPECT_RECT_EQ(IntRect(1, 0, 49, 50), occlusion.unoccludedContentRect(fi lteredSurface, IntRect(1, 0, 50, 50)));
2547 EXPECT_RECT_EQ(IntRect(0, 1, 100, 99), occlusion.unoccludedContentRect(f ilteredSurface, IntRect(0, 1, 100, 100))); 2555 EXPECT_RECT_EQ(IntRect(0, 1, 50, 49), occlusion.unoccludedContentRect(fi lteredSurface, IntRect(0, 1, 50, 50)));
2548 EXPECT_RECT_EQ(IntRect(0, 0, 99, 100), occlusion.unoccludedContentRect(f ilteredSurface, IntRect(-1, 0, 100, 100))); 2556 EXPECT_RECT_EQ(IntRect(0, 0, 49, 50), occlusion.unoccludedContentRect(fi lteredSurface, IntRect(-1, 0, 50, 50)));
2549 EXPECT_RECT_EQ(IntRect(0, 0, 100, 99), occlusion.unoccludedContentRect(f ilteredSurface, IntRect(0, -1, 100, 100))); 2557 EXPECT_RECT_EQ(IntRect(0, 0, 50, 49), occlusion.unoccludedContentRect(fi lteredSurface, IntRect(0, -1, 50, 50)));
2550 2558
2551 EXPECT_RECT_EQ(IntRect(300 + 1, 0, 99, 100), occlusion.unoccludedContent Rect(filteredSurface, IntRect(300 + 1, 0, 100, 100))); 2559 EXPECT_RECT_EQ(IntRect(150 + 1, 0, 49, 50), occlusion.unoccludedContentR ect(filteredSurface, IntRect(150 + 1, 0, 50, 50)));
2552 EXPECT_RECT_EQ(IntRect(300 + 0, 1, 100, 99), occlusion.unoccludedContent Rect(filteredSurface, IntRect(300 + 0, 1, 100, 100))); 2560 EXPECT_RECT_EQ(IntRect(150 + 0, 1, 50, 49), occlusion.unoccludedContentR ect(filteredSurface, IntRect(150 + 0, 1, 50, 50)));
2553 EXPECT_RECT_EQ(IntRect(300 + 0, 0, 99, 100), occlusion.unoccludedContent Rect(filteredSurface, IntRect(300 - 1, 0, 100, 100))); 2561 EXPECT_RECT_EQ(IntRect(150 + 0, 0, 49, 50), occlusion.unoccludedContentR ect(filteredSurface, IntRect(150 - 1, 0, 50, 50)));
2554 EXPECT_RECT_EQ(IntRect(300 + 0, 0, 100, 99), occlusion.unoccludedContent Rect(filteredSurface, IntRect(300 + 0, -1, 100, 100))); 2562 EXPECT_RECT_EQ(IntRect(150 + 0, 0, 50, 49), occlusion.unoccludedContentR ect(filteredSurface, IntRect(150 + 0, -1, 50, 50)));
2555 this->leaveLayer(filteredSurface, occlusion); 2563 this->leaveLayer(filteredSurface, occlusion);
2556 2564
2557 // The filtered layer/replica does not occlude. 2565 // The filtered layer/replica does not occlude.
2558 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace ().bounds()); 2566 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace ().bounds());
2559 EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); 2567 EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
2560 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface() .bounds()); 2568 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface() .bounds());
2561 EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size()); 2569 EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size());
2562 2570
2563 // The surface has a background blur, so it needs pixels that are curren tly considered occluded in order to be drawn. So the pixels 2571 // The surface has a background blur, so it needs pixels that are curren tly considered occluded in order to be drawn. So the pixels
2564 // it needs should be removed some the occluded area so that when we get to the parent they are drawn. 2572 // it needs should be removed from the occluded area so that when we get to the parent they are drawn.
2565 this->visitContributingSurface(filteredSurface, occlusion); 2573 this->visitContributingSurface(filteredSurface, occlusion);
2566 2574
2567 this->enterLayer(parent, occlusion); 2575 this->enterLayer(parent, occlusion);
2568 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace ().bounds()); 2576 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace ().bounds());
2569 EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); 2577 EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
2570 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurfa ce().bounds()); 2578 EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurfa ce().bounds());
2571 EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size()); 2579 EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size());
2572 2580
2573 IntRect outsetRect; 2581 IntRect outsetRect;
2574 IntRect testRect; 2582 IntRect testRect;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 testRect.move(-1, 0); 2618 testRect.move(-1, 0);
2611 testRect.expand(1, 0); 2619 testRect.expand(1, 0);
2612 EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testR ect)); 2620 EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testR ect));
2613 testRect = outsetRect; 2621 testRect = outsetRect;
2614 testRect.move(0, -1); 2622 testRect.move(0, -1);
2615 testRect.expand(0, 1); 2623 testRect.expand(0, 1);
2616 EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testR ect)); 2624 EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testR ect));
2617 } 2625 }
2618 }; 2626 };
2619 2627
2620 ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestDontOccludePixelsNeededForBack groundFilter); 2628 // Scale transforms require main thread+commit to get contentBounds right.
2629 MAIN_THREAD_TEST(CCOcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilte r);
2621 2630
2622 template<class Types, bool opaqueLayers> 2631 template<class Types, bool opaqueLayers>
2623 class CCOcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice : public CC OcclusionTrackerTest<Types, opaqueLayers> { 2632 class CCOcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice : public CC OcclusionTrackerTest<Types, opaqueLayers> {
2624 protected: 2633 protected:
2625 void runMyTest() 2634 void runMyTest()
2626 { 2635 {
2627 WebTransformationMatrix scaleByHalf; 2636 WebTransformationMatrix scaleByHalf;
2628 scaleByHalf.scale(0.5); 2637 scaleByHalf.scale(0.5);
2629 2638
2630 // Makes two surfaces that completely cover |parent|. The occlusion both above and below the filters will be reduced by each of them. 2639 // Makes two surfaces that completely cover |parent|. The occlusion both above and below the filters will be reduced by each of them.
2631 typename Types::ContentLayerType* root = this->createRoot(this->identity Matrix, FloatPoint(0, 0), IntSize(75, 75)); 2640 typename Types::ContentLayerType* root = this->createRoot(this->identity Matrix, FloatPoint(0, 0), IntSize(150, 150));
2632 typename Types::LayerType* parent = this->createSurface(root, scaleByHal f, FloatPoint(0, 0), IntSize(150, 150)); 2641 typename Types::LayerType* parent = this->createDrawingSurface(root, sca leByHalf, FloatPoint(0, 0), IntSize(300, 300), false);
2633 parent->setMasksToBounds(true); 2642 parent->setMasksToBounds(true);
2634 typename Types::LayerType* filteredSurface1 = this->createDrawingLayer(p arent, scaleByHalf, FloatPoint(0, 0), IntSize(300, 300), false); 2643 typename Types::LayerType* filteredSurface1 = this->createDrawingLayer(p arent, scaleByHalf, FloatPoint(0, 0), IntSize(600, 600), false);
2635 typename Types::LayerType* filteredSurface2 = this->createDrawingLayer(p arent, scaleByHalf, FloatPoint(0, 0), IntSize(300, 300), false); 2644 typename Types::LayerType* filteredSurface2 = this->createDrawingLayer(p arent, scaleByHalf, FloatPoint(0, 0), IntSize(600, 600), false);
2636 typename Types::LayerType* occludingLayerAbove = this->createDrawingLaye r(parent, this->identityMatrix, FloatPoint(100, 100), IntSize(50, 50), true); 2645 typename Types::LayerType* occludingLayerAbove = this->createDrawingLaye r(parent, this->identityMatrix, FloatPoint(200, 200), IntSize(100, 100), true);
2637 2646
2638 // Filters make the layers own surfaces. 2647 // Filters make the layers own surfaces.
2639 WebFilterOperations filters; 2648 WebFilterOperations filters;
2640 filters.append(WebFilterOperation::createBlurFilter(3)); 2649 filters.append(WebFilterOperation::createBlurFilter(3));
2641 filteredSurface1->setBackgroundFilters(filters); 2650 filteredSurface1->setBackgroundFilters(filters);
2642 filteredSurface2->setBackgroundFilters(filters); 2651 filteredSurface2->setBackgroundFilters(filters);
2643 2652
2644 // Save the distance of influence for the blur effect. 2653 // Save the distance of influence for the blur effect.
2645 int outsetTop, outsetRight, outsetBottom, outsetLeft; 2654 int outsetTop, outsetRight, outsetBottom, outsetLeft;
2646 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); 2655 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft);
2647 2656
2648 this->calcDrawEtc(root); 2657 this->calcDrawEtc(root);
2649 2658
2650 TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types ::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); 2659 TestCCOcclusionTrackerWithClip<typename Types::LayerType, typename Types ::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
2651 occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); 2660 occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000));
2652 2661
2653 this->visitLayer(occludingLayerAbove, occlusion); 2662 this->visitLayer(occludingLayerAbove, occlusion);
2654 EXPECT_RECT_EQ(IntRect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.occl usionInScreenSpace().bounds()); 2663 EXPECT_RECT_EQ(IntRect(200 / 2, 200 / 2, 100 / 2, 100 / 2), occlusion.oc clusionInScreenSpace().bounds());
2655 EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); 2664 EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
2656 EXPECT_RECT_EQ(IntRect(100, 100, 50, 50), occlusion.occlusionInTargetSur face().bounds()); 2665 EXPECT_RECT_EQ(IntRect(200 / 2, 200 / 2, 100 / 2, 100 / 2), occlusion.oc clusionInTargetSurface().bounds());
2657 EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); 2666 EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
2658 2667
2659 this->visitLayer(filteredSurface2, occlusion); 2668 this->visitLayer(filteredSurface2, occlusion);
2660 this->visitContributingSurface(filteredSurface2, occlusion); 2669 this->visitContributingSurface(filteredSurface2, occlusion);
2661 this->visitLayer(filteredSurface1, occlusion); 2670 this->visitLayer(filteredSurface1, occlusion);
2662 this->visitContributingSurface(filteredSurface1, occlusion); 2671 this->visitContributingSurface(filteredSurface1, occlusion);
2663 2672
2664 ASSERT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); 2673 ASSERT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
2665 ASSERT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); 2674 ASSERT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
2666 2675
2667 // Test expectations in the target. 2676 // Test expectations in the target. The target is scaled in half so the occlusion should be scaled within its contents as well.
2668 IntRect expectedOcclusion = IntRect(100 + outsetRight * 2, 100 + outsetB ottom * 2, 50 - (outsetLeft + outsetRight) * 2, 50 - (outsetTop + outsetBottom) * 2); 2677 IntRect expectedOcclusion = IntRect(200 / 2 + outsetRight * 2, 200 / 2 + outsetBottom * 2, 100 / 2 - (outsetLeft + outsetRight) * 2, 100 / 2 - (outsetTo p + outsetBottom) * 2);
2669 EXPECT_RECT_EQ(expectedOcclusion, occlusion.occlusionInTargetSurface().r ects()[0]); 2678 EXPECT_RECT_EQ(expectedOcclusion, occlusion.occlusionInTargetSurface().r ects()[0]);
2670 2679
2671 // Test expectations in the screen. Take the ceiling of half of the outs ets. 2680 // Test expectations in the screen. The parent is scaled in half so it w ill scale the occlusion to the screen as well.
2672 outsetTop = (outsetTop + 1) / 2; 2681 expectedOcclusion = IntRect(200 / 2 + outsetRight * 2, 200 / 2 + outsetB ottom * 2, 100 / 2 - (outsetLeft + outsetRight) * 2, 100 / 2 - (outsetTop + outs etBottom) * 2);
2673 outsetRight = (outsetRight + 1) / 2;
2674 outsetBottom = (outsetBottom + 1) / 2;
2675 outsetLeft = (outsetLeft + 1) / 2;
2676 expectedOcclusion = IntRect(100 / 2 + outsetRight * 2, 100 / 2 + outsetB ottom * 2, 50 / 2 - (outsetLeft + outsetRight) * 2, 50 /2 - (outsetTop + outsetB ottom) * 2);
2677
2678 EXPECT_RECT_EQ(expectedOcclusion, occlusion.occlusionInScreenSpace().rec ts()[0]); 2682 EXPECT_RECT_EQ(expectedOcclusion, occlusion.occlusionInScreenSpace().rec ts()[0]);
2679 } 2683 }
2680 }; 2684 };
2681 2685
2682 ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestTwoBackgroundFiltersReduceOccl usionTwice); 2686 // Scale transforms require main thread+commit to get contentBounds right.
2687 MAIN_THREAD_TEST(CCOcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice) ;
2683 2688
2684 template<class Types, bool opaqueLayers> 2689 template<class Types, bool opaqueLayers>
2685 class CCOcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip : public CCOcclusionTrackerTest<Types, opaqueLayers> { 2690 class CCOcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip : public CCOcclusionTrackerTest<Types, opaqueLayers> {
2686 protected: 2691 protected:
2687 void runMyTest() 2692 void runMyTest()
2688 { 2693 {
2689 // Make a surface and its replica, each 50x50, that are completely surro unded by opaque layers which are above them in the z-order. 2694 // Make a surface and its replica, each 50x50, that are completely surro unded by opaque layers which are above them in the z-order.
2690 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(300, 150)); 2695 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(300, 150));
2691 // We stick the filtered surface inside a clipping surface so that we ca n make sure the clip is honored when exposing pixels for 2696 // We stick the filtered surface inside a clipping surface so that we ca n make sure the clip is honored when exposing pixels for
2692 // the background filter. 2697 // the background filter.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 IntRect occlusionBehindReplica = IntRect(210, 60, 30, 30); 2851 IntRect occlusionBehindReplica = IntRect(210, 60, 30, 30);
2847 2852
2848 IntRect expectedOpaqueBounds = unionRect(occlusionBehindSurface, occlusi onBehindReplica); 2853 IntRect expectedOpaqueBounds = unionRect(occlusionBehindSurface, occlusi onBehindReplica);
2849 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace(). bounds()); 2854 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace(). bounds());
2850 EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); 2855 EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
2851 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface( ).bounds()); 2856 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface( ).bounds());
2852 EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); 2857 EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
2853 } 2858 }
2854 }; 2859 };
2855 2860
2856 ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestDontReduceOcclusionBelowBackgr oundFilter); 2861 // Scale transforms require main thread+commit to get contentBounds right.
2862 MAIN_THREAD_TEST(CCOcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter) ;
2857 2863
2858 template<class Types, bool opaqueLayers> 2864 template<class Types, bool opaqueLayers>
2859 class CCOcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded : pu blic CCOcclusionTrackerTest<Types, opaqueLayers> { 2865 class CCOcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded : pu blic CCOcclusionTrackerTest<Types, opaqueLayers> {
2860 protected: 2866 protected:
2861 void runMyTest() 2867 void runMyTest()
2862 { 2868 {
2863 WebTransformationMatrix scaleByHalf; 2869 WebTransformationMatrix scaleByHalf;
2864 scaleByHalf.scale(0.5); 2870 scaleByHalf.scale(0.5);
2865 2871
2866 // Make a surface and its replica, each 50x50, that are completely occlu ded by opaque layers which are above them in the z-order. 2872 // Make a surface and its replica, each 50x50, that are completely occlu ded by opaque layers which are above them in the z-order.
(...skipping 27 matching lines...) Expand all
2894 IntRect occlusionAboveReplica = IntRect(200, 50, 50, 50); 2900 IntRect occlusionAboveReplica = IntRect(200, 50, 50, 50);
2895 2901
2896 IntRect expectedOpaqueBounds = unionRect(occlusionAboveSurface, occlusio nAboveReplica); 2902 IntRect expectedOpaqueBounds = unionRect(occlusionAboveSurface, occlusio nAboveReplica);
2897 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace(). bounds()); 2903 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace(). bounds());
2898 EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); 2904 EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
2899 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface( ).bounds()); 2905 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface( ).bounds());
2900 EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); 2906 EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
2901 } 2907 }
2902 }; 2908 };
2903 2909
2904 ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestDontReduceOcclusionIfBackgroun dFilterIsOccluded); 2910 // Scale transforms require main thread+commit to get contentBounds right.
2911 MAIN_THREAD_TEST(CCOcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOc cluded);
2905 2912
2906 template<class Types, bool opaqueLayers> 2913 template<class Types, bool opaqueLayers>
2907 class CCOcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOcclud ed : public CCOcclusionTrackerTest<Types, opaqueLayers> { 2914 class CCOcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOcclud ed : public CCOcclusionTrackerTest<Types, opaqueLayers> {
2908 protected: 2915 protected:
2909 void runMyTest() 2916 void runMyTest()
2910 { 2917 {
2911 WebTransformationMatrix scaleByHalf; 2918 WebTransformationMatrix scaleByHalf;
2912 scaleByHalf.scale(0.5); 2919 scaleByHalf.scale(0.5);
2913 2920
2914 // Make a surface and its replica, each 50x50, that are partially occlud ed by opaque layers which are above them in the z-order. 2921 // Make a surface and its replica, each 50x50, that are partially occlud ed by opaque layers which are above them in the z-order.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 for (size_t i = 0; i < expectedOcclusion.rects().size(); ++i) { 2973 for (size_t i = 0; i < expectedOcclusion.rects().size(); ++i) {
2967 IntRect expectedRect = expectedOcclusion.rects()[i]; 2974 IntRect expectedRect = expectedOcclusion.rects()[i];
2968 IntRect screenRect = occlusion.occlusionInScreenSpace().rects()[i]; 2975 IntRect screenRect = occlusion.occlusionInScreenSpace().rects()[i];
2969 IntRect targetRect = occlusion.occlusionInTargetSurface().rects()[i] ; 2976 IntRect targetRect = occlusion.occlusionInTargetSurface().rects()[i] ;
2970 EXPECT_EQ(expectedRect, screenRect); 2977 EXPECT_EQ(expectedRect, screenRect);
2971 EXPECT_EQ(expectedRect, targetRect); 2978 EXPECT_EQ(expectedRect, targetRect);
2972 } 2979 }
2973 } 2980 }
2974 }; 2981 };
2975 2982
2976 ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestReduceOcclusionWhenBackgroundF ilterIsPartiallyOccluded); 2983 // Scale transforms require main thread+commit to get contentBounds right.
2984 MAIN_THREAD_TEST(CCOcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPart iallyOccluded);
2977 2985
2978 template<class Types, bool opaqueLayers> 2986 template<class Types, bool opaqueLayers>
2979 class CCOcclusionTrackerTestMinimumTrackingSize : public CCOcclusionTrackerTest< Types, opaqueLayers> { 2987 class CCOcclusionTrackerTestMinimumTrackingSize : public CCOcclusionTrackerTest< Types, opaqueLayers> {
2980 protected: 2988 protected:
2981 void runMyTest() 2989 void runMyTest()
2982 { 2990 {
2983 IntSize trackingSize(100, 100); 2991 IntSize trackingSize(100, 100);
2984 IntSize belowTrackingSize(99, 99); 2992 IntSize belowTrackingSize(99, 99);
2985 2993
2986 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(400, 400)); 2994 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, FloatPoint(0, 0), IntSize(400, 400));
(...skipping 19 matching lines...) Expand all
3006 EXPECT_RECT_EQ(IntRect(IntPoint(), trackingSize), occlusion.occlusionInS creenSpace().bounds()); 3014 EXPECT_RECT_EQ(IntRect(IntPoint(), trackingSize), occlusion.occlusionInS creenSpace().bounds());
3007 EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); 3015 EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
3008 EXPECT_RECT_EQ(IntRect(IntPoint(), trackingSize), occlusion.occlusionInT argetSurface().bounds()); 3016 EXPECT_RECT_EQ(IntRect(IntPoint(), trackingSize), occlusion.occlusionInT argetSurface().bounds());
3009 EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); 3017 EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
3010 } 3018 }
3011 }; 3019 };
3012 3020
3013 ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestMinimumTrackingSize); 3021 ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestMinimumTrackingSize);
3014 3022
3015 } // namespace 3023 } // namespace
OLDNEW
« cc/CCLayerTreeHostCommon.cpp ('K') | « cc/CCMathUtil.cpp ('k') | cc/LayerChromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698