| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/damage_tracker.h" | 5 #include "cc/damage_tracker.h" |
| 6 | 6 |
| 7 #include "cc/layer_impl.h" | 7 #include "cc/layer_impl.h" |
| 8 #include "cc/layer_sorter.h" | 8 #include "cc/layer_sorter.h" |
| 9 #include "cc/layer_tree_host_common.h" | 9 #include "cc/layer_tree_host_common.h" |
| 10 #include "cc/math_util.h" | 10 #include "cc/math_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // 1. computing the render passes and layerlists | 51 // 1. computing the render passes and layerlists |
| 52 // 2. updating all damage trackers in the correct order | 52 // 2. updating all damage trackers in the correct order |
| 53 // 3. resetting all updateRects and propertyChanged flags for all layers a
nd surfaces. | 53 // 3. resetting all updateRects and propertyChanged flags for all layers a
nd surfaces. |
| 54 | 54 |
| 55 std::vector<LayerImpl*> renderSurfaceLayerList; | 55 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 56 executeCalculateDrawTransformsAndVisibility(root, renderSurfaceLayerList); | 56 executeCalculateDrawTransformsAndVisibility(root, renderSurfaceLayerList); |
| 57 | 57 |
| 58 // Iterate back-to-front, so that damage correctly propagates from descendan
t surfaces to ancestors. | 58 // Iterate back-to-front, so that damage correctly propagates from descendan
t surfaces to ancestors. |
| 59 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { | 59 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { |
| 60 RenderSurfaceImpl* targetSurface = renderSurfaceLayerList[i]->renderSurf
ace(); | 60 RenderSurfaceImpl* targetSurface = renderSurfaceLayerList[i]->renderSurf
ace(); |
| 61 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface-
>layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan
gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i]
->maskLayer(), renderSurfaceLayerList[i]->filters(), renderSurfaceLayerList[i]->
filter()); | 61 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface-
>layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan
gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i]
->maskLayer(), renderSurfaceLayerList[i]->filters(), renderSurfaceLayerList[i]->
filter().get()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 root->resetAllChangeTrackingForSubtree(); | 64 root->resetAllChangeTrackingForSubtree(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 scoped_ptr<LayerImpl> createTestTreeWithOneSurface() | 67 scoped_ptr<LayerImpl> createTestTreeWithOneSurface() |
| 68 { | 68 { |
| 69 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 69 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 70 scoped_ptr<LayerImpl> child = LayerImpl::create(2); | 70 scoped_ptr<LayerImpl> child = LayerImpl::create(2); |
| 71 | 71 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 389 |
| 390 TEST_F(DamageTrackerTest, verifyDamageForImageFilter) | 390 TEST_F(DamageTrackerTest, verifyDamageForImageFilter) |
| 391 { | 391 { |
| 392 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 392 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
| 393 LayerImpl* child = root->children()[0]; | 393 LayerImpl* child = root->children()[0]; |
| 394 gfx::RectF rootDamageRect, childDamageRect; | 394 gfx::RectF rootDamageRect, childDamageRect; |
| 395 | 395 |
| 396 // Allow us to set damage on child too. | 396 // Allow us to set damage on child too. |
| 397 child->setDrawsContent(true); | 397 child->setDrawsContent(true); |
| 398 | 398 |
| 399 SkAutoTUnref<SkImageFilter> filter(new SkBlurImageFilter(SkIntToScalar(2), | 399 skia::RefPtr<SkImageFilter> filter = new SkBlurImageFilter(SkIntToScalar(2),
SkIntToScalar(2)); |
| 400 SkIntToScalar(2))); | |
| 401 // Setting the filter will damage the whole surface. | 400 // Setting the filter will damage the whole surface. |
| 402 clearDamageForAllSurfaces(root.get()); | 401 clearDamageForAllSurfaces(root.get()); |
| 403 child->setFilter(filter); | 402 child->setFilter(filter); |
| 404 emulateDrawingOneFrame(root.get()); | 403 emulateDrawingOneFrame(root.get()); |
| 405 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 404 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
| 406 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect
(); | 405 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect
(); |
| 407 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect); | 406 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect); |
| 408 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect); | 407 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect); |
| 409 | 408 |
| 410 // CASE 1: Setting the update rect should damage the whole surface (for now) | 409 // CASE 1: Setting the update rect should damage the whole surface (for now) |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 EXPECT_TRUE(rootDamageRect.IsEmpty()); | 1149 EXPECT_TRUE(rootDamageRect.IsEmpty()); |
| 1151 | 1150 |
| 1152 // Damage should remain empty even after one frame, since there's yet no new
damage | 1151 // Damage should remain empty even after one frame, since there's yet no new
damage |
| 1153 emulateDrawingOneFrame(root.get()); | 1152 emulateDrawingOneFrame(root.get()); |
| 1154 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1153 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
| 1155 EXPECT_TRUE(rootDamageRect.IsEmpty()); | 1154 EXPECT_TRUE(rootDamageRect.IsEmpty()); |
| 1156 } | 1155 } |
| 1157 | 1156 |
| 1158 } // namespace | 1157 } // namespace |
| 1159 } // namespace cc | 1158 } // namespace cc |
| OLD | NEW |