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

Side by Side Diff: cc/damage_tracker_unittest.cc

Issue 11412255: cc: Use skia::RefPtr in place of raw pointers and SkAutoTUnref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ref() 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
« no previous file with comments | « no previous file | cc/gl_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 TEST_F(DamageTrackerTest, verifyDamageForImageFilter) 391 TEST_F(DamageTrackerTest, verifyDamageForImageFilter)
392 { 392 {
393 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 393 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
394 LayerImpl* child = root->children()[0]; 394 LayerImpl* child = root->children()[0];
395 gfx::RectF rootDamageRect, childDamageRect; 395 gfx::RectF rootDamageRect, childDamageRect;
396 396
397 // Allow us to set damage on child too. 397 // Allow us to set damage on child too.
398 child->setDrawsContent(true); 398 child->setDrawsContent(true);
399 399
400 SkAutoTUnref<SkImageFilter> filter(new SkBlurImageFilter(SkIntToScalar(2), 400 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef(new SkBlurImageFilter(Sk IntToScalar(2), SkIntToScalar(2)));
401 SkIntToScalar(2)));
402 // Setting the filter will damage the whole surface. 401 // Setting the filter will damage the whole surface.
403 clearDamageForAllSurfaces(root.get()); 402 clearDamageForAllSurfaces(root.get());
404 child->setFilter(filter); 403 child->setFilter(filter);
405 emulateDrawingOneFrame(root.get()); 404 emulateDrawingOneFrame(root.get());
406 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 405 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
407 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect (); 406 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect ();
408 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect); 407 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect);
409 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect); 408 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect);
410 409
411 // CASE 1: Setting the update rect should damage the whole surface (for now) 410 // CASE 1: Setting the update rect should damage the whole surface (for now)
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1152 EXPECT_TRUE(rootDamageRect.IsEmpty());
1154 1153
1155 // 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
1156 emulateDrawingOneFrame(root.get()); 1155 emulateDrawingOneFrame(root.get());
1157 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 1156 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
1158 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1157 EXPECT_TRUE(rootDamageRect.IsEmpty());
1159 } 1158 }
1160 1159
1161 } // namespace 1160 } // namespace
1162 } // namespace cc 1161 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698