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

Side by Side Diff: cc/damage_tracker_unittest.cc

Issue 11175009: Implement SkImageFilter support in the compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated to ToT (past the Great Renaming) 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
« no previous file with comments | « cc/damage_tracker.cc ('k') | 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 "config.h" 5 #include "config.h"
6 6
7 #include "CCDamageTracker.h" 7 #include "CCDamageTracker.h"
8 8
9 #include "CCLayerImpl.h" 9 #include "CCLayerImpl.h"
10 #include "CCLayerSorter.h" 10 #include "CCLayerSorter.h"
11 #include "CCLayerTreeHostCommon.h" 11 #include "CCLayerTreeHostCommon.h"
12 #include "cc/math_util.h" 12 #include "cc/math_util.h"
13 #include "cc/single_thread_proxy.h" 13 #include "cc/single_thread_proxy.h"
14 #include "cc/test/geometry_test_utils.h" 14 #include "cc/test/geometry_test_utils.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
16 #include <public/WebFilterOperation.h> 17 #include <public/WebFilterOperation.h>
17 #include <public/WebFilterOperations.h> 18 #include <public/WebFilterOperations.h>
18 19
19 using namespace cc; 20 using namespace cc;
20 using namespace WebKit; 21 using namespace WebKit;
21 using namespace WebKitTests; 22 using namespace WebKitTests;
22 23
23 namespace { 24 namespace {
24 25
25 void executeCalculateDrawTransformsAndVisibility(LayerImpl* root, std::vector<La yerImpl*>& renderSurfaceLayerList) 26 void executeCalculateDrawTransformsAndVisibility(LayerImpl* root, std::vector<La yerImpl*>& renderSurfaceLayerList)
(...skipping 26 matching lines...) Expand all
52 // 1. computing the render passes and layerlists 53 // 1. computing the render passes and layerlists
53 // 2. updating all damage trackers in the correct order 54 // 2. updating all damage trackers in the correct order
54 // 3. resetting all updateRects and propertyChanged flags for all layers a nd surfaces. 55 // 3. resetting all updateRects and propertyChanged flags for all layers a nd surfaces.
55 56
56 std::vector<LayerImpl*> renderSurfaceLayerList; 57 std::vector<LayerImpl*> renderSurfaceLayerList;
57 executeCalculateDrawTransformsAndVisibility(root, renderSurfaceLayerList); 58 executeCalculateDrawTransformsAndVisibility(root, renderSurfaceLayerList);
58 59
59 // Iterate back-to-front, so that damage correctly propagates from descendan t surfaces to ancestors. 60 // Iterate back-to-front, so that damage correctly propagates from descendan t surfaces to ancestors.
60 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { 61 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) {
61 RenderSurfaceImpl* targetSurface = renderSurfaceLayerList[i]->renderSurf ace(); 62 RenderSurfaceImpl* targetSurface = renderSurfaceLayerList[i]->renderSurf ace();
62 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface- >layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i] ->maskLayer(), renderSurfaceLayerList[i]->filters()); 63 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface- >layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i] ->maskLayer(), renderSurfaceLayerList[i]->filters(), renderSurfaceLayerList[i]-> filter());
63 } 64 }
64 65
65 root->resetAllChangeTrackingForSubtree(); 66 root->resetAllChangeTrackingForSubtree();
66 } 67 }
67 68
68 scoped_ptr<LayerImpl> createTestTreeWithOneSurface() 69 scoped_ptr<LayerImpl> createTestTreeWithOneSurface()
69 { 70 {
70 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 71 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
71 scoped_ptr<LayerImpl> child = LayerImpl::create(2); 72 scoped_ptr<LayerImpl> child = LayerImpl::create(2);
72 73
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 emulateDrawingOneFrame(root.get()); 386 emulateDrawingOneFrame(root.get());
386 387
387 // Damage position on the surface should be: position of updateRect (10, 11) relative to the child (100, 100), but expanded by the blur outsets. 388 // Damage position on the surface should be: position of updateRect (10, 11) relative to the child (100, 100), but expanded by the blur outsets.
388 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa mageRect(); 389 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa mageRect();
389 FloatRect expectedDamageRect = FloatRect(110, 111, 12, 13); 390 FloatRect expectedDamageRect = FloatRect(110, 111, 12, 13);
390 expectedDamageRect.move(-outsetLeft, -outsetTop); 391 expectedDamageRect.move(-outsetLeft, -outsetTop);
391 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom ); 392 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom );
392 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); 393 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect);
393 } 394 }
394 395
396 TEST_F(DamageTrackerTest, verifyDamageForImageFilter)
397 {
398 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
399 LayerImpl* child = root->children()[0];
400 FloatRect rootDamageRect, childDamageRect;
401
402 // Allow us to set damage on child too.
403 child->setDrawsContent(true);
404
405 SkAutoTUnref<SkImageFilter> filter(new SkBlurImageFilter(SkIntToScalar(2),
406 SkIntToScalar(2)));
407 // Setting the filter will damage the whole surface.
408 clearDamageForAllSurfaces(root.get());
409 child->setFilter(filter);
410 emulateDrawingOneFrame(root.get());
411 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
412 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect ();
413 EXPECT_FLOAT_RECT_EQ(FloatRect(100, 100, 30, 30), rootDamageRect);
414 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 30), childDamageRect);
415
416 // CASE 1: Setting the update rect should damage the whole surface (for now)
417 clearDamageForAllSurfaces(root.get());
418 child->setUpdateRect(FloatRect(0, 0, 1, 1));
419 emulateDrawingOneFrame(root.get());
420
421 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
422 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect ();
423 EXPECT_FLOAT_RECT_EQ(FloatRect(100, 100, 30, 30), rootDamageRect);
424 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 30), childDamageRect);
425 }
426
395 TEST_F(DamageTrackerTest, verifyDamageForBackgroundBlurredChild) 427 TEST_F(DamageTrackerTest, verifyDamageForBackgroundBlurredChild)
396 { 428 {
397 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 429 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
398 LayerImpl* child1 = root->children()[0]; 430 LayerImpl* child1 = root->children()[0];
399 LayerImpl* child2 = root->children()[1]; 431 LayerImpl* child2 = root->children()[1];
400 432
401 // Allow us to set damage on child1 too. 433 // Allow us to set damage on child1 too.
402 child1->setDrawsContent(true); 434 child1->setDrawsContent(true);
403 435
404 WebFilterOperations filters; 436 WebFilterOperations filters;
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 { 1120 {
1089 // Though it should never happen, its a good idea to verify that the damage tracker 1121 // Though it should never happen, its a good idea to verify that the damage tracker
1090 // does not crash when it receives an empty layerList. 1122 // does not crash when it receives an empty layerList.
1091 1123
1092 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1124 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1093 root->createRenderSurface(); 1125 root->createRenderSurface();
1094 1126
1095 ASSERT_TRUE(root == root->renderTarget()); 1127 ASSERT_TRUE(root == root->renderTarget());
1096 RenderSurfaceImpl* targetSurface = root->renderSurface(); 1128 RenderSurfaceImpl* targetSurface = root->renderSurface();
1097 targetSurface->clearLayerLists(); 1129 targetSurface->clearLayerLists();
1098 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay erList(), targetSurface->owningLayerId(), false, IntRect(), 0, WebFilterOperatio ns()); 1130 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay erList(), targetSurface->owningLayerId(), false, IntRect(), 0, WebFilterOperatio ns(), 0);
1099 1131
1100 FloatRect damageRect = targetSurface->damageTracker()->currentDamageRect(); 1132 FloatRect damageRect = targetSurface->damageTracker()->currentDamageRect();
1101 EXPECT_TRUE(damageRect.isEmpty()); 1133 EXPECT_TRUE(damageRect.isEmpty());
1102 } 1134 }
1103 1135
1104 TEST_F(DamageTrackerTest, verifyDamageAccumulatesUntilReset) 1136 TEST_F(DamageTrackerTest, verifyDamageAccumulatesUntilReset)
1105 { 1137 {
1106 // If damage is not cleared, it should accumulate. 1138 // If damage is not cleared, it should accumulate.
1107 1139
1108 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 1140 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
(...skipping 18 matching lines...) Expand all
1127 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 1159 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
1128 EXPECT_TRUE(rootDamageRect.isEmpty()); 1160 EXPECT_TRUE(rootDamageRect.isEmpty());
1129 1161
1130 // Damage should remain empty even after one frame, since there's yet no new damage 1162 // Damage should remain empty even after one frame, since there's yet no new damage
1131 emulateDrawingOneFrame(root.get()); 1163 emulateDrawingOneFrame(root.get());
1132 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 1164 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
1133 EXPECT_TRUE(rootDamageRect.isEmpty()); 1165 EXPECT_TRUE(rootDamageRect.isEmpty());
1134 } 1166 }
1135 1167
1136 } // namespace 1168 } // namespace
OLDNEW
« no previous file with comments | « cc/damage_tracker.cc ('k') | cc/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698