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

Side by Side Diff: cc/nine_patch_layer_unittest.cc

Issue 12095053: cc: Avoid expensive RenderingStats collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 10 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/nine_patch_layer.cc ('k') | cc/picture.h » ('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 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 "cc/nine_patch_layer.h" 5 #include "cc/nine_patch_layer.h"
6 6
7 #include "cc/layer_tree_host.h" 7 #include "cc/layer_tree_host.h"
8 #include "cc/occlusion_tracker.h" 8 #include "cc/occlusion_tracker.h"
9 #include "cc/overdraw_metrics.h" 9 #include "cc/overdraw_metrics.h"
10 #include "cc/prioritized_resource_manager.h" 10 #include "cc/prioritized_resource_manager.h"
11 #include "cc/rendering_stats.h"
12 #include "cc/resource_provider.h" 11 #include "cc/resource_provider.h"
13 #include "cc/resource_update_queue.h" 12 #include "cc/resource_update_queue.h"
14 #include "cc/single_thread_proxy.h" 13 #include "cc/single_thread_proxy.h"
15 #include "cc/test/fake_layer_tree_host_client.h" 14 #include "cc/test/fake_layer_tree_host_client.h"
16 #include "cc/test/fake_output_surface.h" 15 #include "cc/test/fake_output_surface.h"
17 #include "cc/test/geometry_test_utils.h" 16 #include "cc/test/geometry_test_utils.h"
18 #include "cc/test/layer_tree_test_common.h" 17 #include "cc/test/layer_tree_test_common.h"
19 #include "cc/texture_uploader.h" 18 #include "cc/texture_uploader.h"
20 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 72
74 m_layerTreeHost->setRootLayer(testLayer); 73 m_layerTreeHost->setRootLayer(testLayer);
75 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 74 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
76 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); 75 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get());
77 76
78 m_layerTreeHost->initializeRendererIfNeeded(); 77 m_layerTreeHost->initializeRendererIfNeeded();
79 78
80 PriorityCalculator calculator; 79 PriorityCalculator calculator;
81 ResourceUpdateQueue queue; 80 ResourceUpdateQueue queue;
82 OcclusionTracker occlusionTracker(gfx::Rect(), false); 81 OcclusionTracker occlusionTracker(gfx::Rect(), false);
83 RenderingStats stats;
84 82
85 // No bitmap set should not trigger any uploads. 83 // No bitmap set should not trigger any uploads.
86 testLayer->setTexturePriorities(calculator); 84 testLayer->setTexturePriorities(calculator);
87 testLayer->update(queue, &occlusionTracker, stats); 85 testLayer->update(queue, &occlusionTracker, NULL);
88 EXPECT_EQ(queue.fullUploadSize(), 0); 86 EXPECT_EQ(queue.fullUploadSize(), 0);
89 EXPECT_EQ(queue.partialUploadSize(), 0); 87 EXPECT_EQ(queue.partialUploadSize(), 0);
90 88
91 // Setting a bitmap set should trigger a single full upload. 89 // Setting a bitmap set should trigger a single full upload.
92 SkBitmap bitmap; 90 SkBitmap bitmap;
93 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); 91 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
94 bitmap.allocPixels(); 92 bitmap.allocPixels();
95 testLayer->setBitmap(bitmap, gfx::Rect(5, 5, 1, 1)); 93 testLayer->setBitmap(bitmap, gfx::Rect(5, 5, 1, 1));
96 testLayer->setTexturePriorities(calculator); 94 testLayer->setTexturePriorities(calculator);
97 testLayer->update(queue, &occlusionTracker, stats); 95 testLayer->update(queue, &occlusionTracker, NULL);
98 EXPECT_EQ(queue.fullUploadSize(), 1); 96 EXPECT_EQ(queue.fullUploadSize(), 1);
99 EXPECT_EQ(queue.partialUploadSize(), 0); 97 EXPECT_EQ(queue.partialUploadSize(), 0);
100 ResourceUpdate params = queue.takeFirstFullUpload(); 98 ResourceUpdate params = queue.takeFirstFullUpload();
101 EXPECT_TRUE(params.texture != NULL); 99 EXPECT_TRUE(params.texture != NULL);
102 100
103 // Upload the texture. 101 // Upload the texture.
104 m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 102 4); 102 m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 102 4);
105 m_layerTreeHost->contentsTextureManager()->prioritizeTextures(); 103 m_layerTreeHost->contentsTextureManager()->prioritizeTextures();
106 104
107 scoped_ptr<OutputSurface> outputSurface; 105 scoped_ptr<OutputSurface> outputSurface;
108 scoped_ptr<ResourceProvider> resourceProvider; 106 scoped_ptr<ResourceProvider> resourceProvider;
109 { 107 {
110 DebugScopedSetImplThread implThread(proxy()); 108 DebugScopedSetImplThread implThread(proxy());
111 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy()); 109 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy());
112 outputSurface = createFakeOutputSurface(); 110 outputSurface = createFakeOutputSurface();
113 resourceProvider = ResourceProvider::create(outputSurface.get()); 111 resourceProvider = ResourceProvider::create(outputSurface.get());
114 params.texture->acquireBackingTexture(resourceProvider.get()); 112 params.texture->acquireBackingTexture(resourceProvider.get());
115 ASSERT_TRUE(params.texture->haveBackingTexture()); 113 ASSERT_TRUE(params.texture->haveBackingTexture());
116 } 114 }
117 115
118 // Nothing changed, so no repeated upload. 116 // Nothing changed, so no repeated upload.
119 testLayer->setTexturePriorities(calculator); 117 testLayer->setTexturePriorities(calculator);
120 testLayer->update(queue, &occlusionTracker, stats); 118 testLayer->update(queue, &occlusionTracker, NULL);
121 EXPECT_EQ(queue.fullUploadSize(), 0); 119 EXPECT_EQ(queue.fullUploadSize(), 0);
122 EXPECT_EQ(queue.partialUploadSize(), 0); 120 EXPECT_EQ(queue.partialUploadSize(), 0);
123 121
124 { 122 {
125 DebugScopedSetImplThread implThread(proxy()); 123 DebugScopedSetImplThread implThread(proxy());
126 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy()); 124 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy());
127 m_layerTreeHost->contentsTextureManager()->clearAllMemory(resourceProvid er.get()); 125 m_layerTreeHost->contentsTextureManager()->clearAllMemory(resourceProvid er.get());
128 } 126 }
129 127
130 // Reupload after eviction 128 // Reupload after eviction
131 testLayer->setTexturePriorities(calculator); 129 testLayer->setTexturePriorities(calculator);
132 testLayer->update(queue, &occlusionTracker, stats); 130 testLayer->update(queue, &occlusionTracker, NULL);
133 EXPECT_EQ(queue.fullUploadSize(), 1); 131 EXPECT_EQ(queue.fullUploadSize(), 1);
134 EXPECT_EQ(queue.partialUploadSize(), 0); 132 EXPECT_EQ(queue.partialUploadSize(), 0);
135 133
136 // PrioritizedResourceManager clearing 134 // PrioritizedResourceManager clearing
137 m_layerTreeHost->contentsTextureManager()->unregisterTexture(params.texture) ; 135 m_layerTreeHost->contentsTextureManager()->unregisterTexture(params.texture) ;
138 EXPECT_EQ(NULL, params.texture->resourceManager()); 136 EXPECT_EQ(NULL, params.texture->resourceManager());
139 testLayer->setTexturePriorities(calculator); 137 testLayer->setTexturePriorities(calculator);
140 ResourceUpdateQueue queue2; 138 ResourceUpdateQueue queue2;
141 testLayer->update(queue2, &occlusionTracker, stats); 139 testLayer->update(queue2, &occlusionTracker, NULL);
142 EXPECT_EQ(queue2.fullUploadSize(), 1); 140 EXPECT_EQ(queue2.fullUploadSize(), 1);
143 EXPECT_EQ(queue2.partialUploadSize(), 0); 141 EXPECT_EQ(queue2.partialUploadSize(), 0);
144 params = queue2.takeFirstFullUpload(); 142 params = queue2.takeFirstFullUpload();
145 EXPECT_TRUE(params.texture != NULL); 143 EXPECT_TRUE(params.texture != NULL);
146 EXPECT_EQ(params.texture->resourceManager(), m_layerTreeHost->contentsTextur eManager()); 144 EXPECT_EQ(params.texture->resourceManager(), m_layerTreeHost->contentsTextur eManager());
147 } 145 }
148 146
149 } // namespace 147 } // namespace
150 } // namespace cc 148 } // namespace cc
OLDNEW
« no previous file with comments | « cc/nine_patch_layer.cc ('k') | cc/picture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698