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

Side by Side Diff: cc/damage_tracker_unittest.cc

Issue 11280263: Organize internal properties of cc/ layer types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed all feedback so far Created 8 years 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 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"
11 #include "cc/single_thread_proxy.h" 11 #include "cc/single_thread_proxy.h"
12 #include "cc/test/geometry_test_utils.h" 12 #include "cc/test/geometry_test_utils.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 14 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
15 #include <public/WebFilterOperation.h> 15 #include <public/WebFilterOperation.h>
16 #include <public/WebFilterOperations.h> 16 #include <public/WebFilterOperations.h>
17 17
18 using namespace WebKit; 18 using namespace WebKit;
19 using namespace WebKitTests; 19 using namespace WebKitTests;
20 20
21 namespace cc { 21 namespace cc {
22 namespace { 22 namespace {
23 23
24 void executeCalculateDrawTransformsAndVisibility(LayerImpl* root, std::vector<La yerImpl*>& renderSurfaceLayerList) 24 void executeCalculateDrawProperties(LayerImpl* root, std::vector<LayerImpl*>& re nderSurfaceLayerList)
25 { 25 {
26 LayerSorter layerSorter; 26 LayerSorter layerSorter;
27 int dummyMaxTextureSize = 512; 27 int dummyMaxTextureSize = 512;
28 28
29 // Sanity check: The test itself should create the root layer's render surfa ce, so 29 // Sanity check: The test itself should create the root layer's render surfa ce, so
30 // that the surface (and its damage tracker) can persist acros s multiple 30 // that the surface (and its damage tracker) can persist acros s multiple
31 // calls to this function. 31 // calls to this function.
32 ASSERT_TRUE(root->renderSurface()); 32 ASSERT_TRUE(root->renderSurface());
33 ASSERT_FALSE(renderSurfaceLayerList.size()); 33 ASSERT_FALSE(renderSurfaceLayerList.size());
34 34
35 LayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, 1, &la yerSorter, dummyMaxTextureSize, renderSurfaceLayerList); 35 LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, &la yerSorter, dummyMaxTextureSize, renderSurfaceLayerList);
36 } 36 }
37 37
38 void clearDamageForAllSurfaces(LayerImpl* layer) 38 void clearDamageForAllSurfaces(LayerImpl* layer)
39 { 39 {
40 if (layer->renderSurface()) 40 if (layer->renderSurface())
41 layer->renderSurface()->damageTracker()->didDrawDamagedArea(); 41 layer->renderSurface()->damageTracker()->didDrawDamagedArea();
42 42
43 // Recursively clear damage for any existing surface. 43 // Recursively clear damage for any existing surface.
44 for (size_t i = 0; i < layer->children().size(); ++i) 44 for (size_t i = 0; i < layer->children().size(); ++i)
45 clearDamageForAllSurfaces(layer->children()[i]); 45 clearDamageForAllSurfaces(layer->children()[i]);
46 } 46 }
47 47
48 void emulateDrawingOneFrame(LayerImpl* root) 48 void emulateDrawingOneFrame(LayerImpl* root)
49 { 49 {
50 // This emulates only the steps that are relevant to testing the damage trac ker: 50 // This emulates only the steps that are relevant to testing the damage trac ker:
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 executeCalculateDrawProperties(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().get()); 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
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1152 EXPECT_TRUE(rootDamageRect.IsEmpty());
1153 1153
1154 // Damage should remain empty even after one frame, since there's yet no new damage 1154 // Damage should remain empty even after one frame, since there's yet no new damage
1155 emulateDrawingOneFrame(root.get()); 1155 emulateDrawingOneFrame(root.get());
1156 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 1156 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
1157 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1157 EXPECT_TRUE(rootDamageRect.IsEmpty());
1158 } 1158 }
1159 1159
1160 } // namespace 1160 } // namespace
1161 } // namespace cc 1161 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc.gyp ('k') | cc/draw_properties.h » ('j') | cc/draw_properties.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698