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

Side by Side Diff: cc/nine_patch_layer_unittest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 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_impl_unittest.cc ('k') | cc/occlusion_tracker.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 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"
(...skipping 29 matching lines...) Expand all
40 FakeLayerImplTreeHostClient m_fakeClient; 40 FakeLayerImplTreeHostClient m_fakeClient;
41 }; 41 };
42 42
43 43
44 class NinePatchLayerTest : public testing::Test { 44 class NinePatchLayerTest : public testing::Test {
45 public: 45 public:
46 NinePatchLayerTest() 46 NinePatchLayerTest()
47 { 47 {
48 } 48 }
49 49
50 Proxy* proxy() const { return m_layerTreeHost->proxy(); } 50 Proxy* proxy() const { return layer_tree_host_->proxy(); }
51 51
52 protected: 52 protected:
53 virtual void SetUp() 53 virtual void SetUp()
54 { 54 {
55 m_layerTreeHost.reset(new MockLayerTreeHost); 55 layer_tree_host_.reset(new MockLayerTreeHost);
56 } 56 }
57 57
58 virtual void TearDown() 58 virtual void TearDown()
59 { 59 {
60 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 60 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
61 } 61 }
62 62
63 scoped_ptr<MockLayerTreeHost> m_layerTreeHost; 63 scoped_ptr<MockLayerTreeHost> layer_tree_host_;
64 }; 64 };
65 65
66 TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) 66 TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap)
67 { 67 {
68 scoped_refptr<NinePatchLayer> testLayer = NinePatchLayer::Create(); 68 scoped_refptr<NinePatchLayer> testLayer = NinePatchLayer::Create();
69 ASSERT_TRUE(testLayer); 69 ASSERT_TRUE(testLayer);
70 testLayer->setIsDrawable(true); 70 testLayer->SetIsDrawable(true);
71 testLayer->setBounds(gfx::Size(100, 100)); 71 testLayer->SetBounds(gfx::Size(100, 100));
72 72
73 m_layerTreeHost->setRootLayer(testLayer); 73 layer_tree_host_->setRootLayer(testLayer);
74 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 74 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
75 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); 75 EXPECT_EQ(testLayer->layer_tree_host(), layer_tree_host_.get());
76 76
77 m_layerTreeHost->initializeRendererIfNeeded(); 77 layer_tree_host_->initializeRendererIfNeeded();
78 78
79 PriorityCalculator calculator; 79 PriorityCalculator calculator;
80 ResourceUpdateQueue queue; 80 ResourceUpdateQueue queue;
81 OcclusionTracker occlusionTracker(gfx::Rect(), false); 81 OcclusionTracker occlusionTracker(gfx::Rect(), false);
82 82
83 // No bitmap set should not trigger any uploads. 83 // No bitmap set should not trigger any uploads.
84 testLayer->setTexturePriorities(calculator); 84 testLayer->SetTexturePriorities(calculator);
85 testLayer->update(queue, &occlusionTracker, NULL); 85 testLayer->Update(&queue, &occlusionTracker, NULL);
86 EXPECT_EQ(queue.fullUploadSize(), 0); 86 EXPECT_EQ(queue.fullUploadSize(), 0);
87 EXPECT_EQ(queue.partialUploadSize(), 0); 87 EXPECT_EQ(queue.partialUploadSize(), 0);
88 88
89 // Setting a bitmap set should trigger a single full upload. 89 // Setting a bitmap set should trigger a single full upload.
90 SkBitmap bitmap; 90 SkBitmap bitmap;
91 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); 91 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
92 bitmap.allocPixels(); 92 bitmap.allocPixels();
93 testLayer->SetBitmap(bitmap, gfx::Rect(5, 5, 1, 1)); 93 testLayer->SetBitmap(bitmap, gfx::Rect(5, 5, 1, 1));
94 testLayer->setTexturePriorities(calculator); 94 testLayer->SetTexturePriorities(calculator);
95 testLayer->update(queue, &occlusionTracker, NULL); 95 testLayer->Update(&queue, &occlusionTracker, NULL);
96 EXPECT_EQ(queue.fullUploadSize(), 1); 96 EXPECT_EQ(queue.fullUploadSize(), 1);
97 EXPECT_EQ(queue.partialUploadSize(), 0); 97 EXPECT_EQ(queue.partialUploadSize(), 0);
98 ResourceUpdate params = queue.takeFirstFullUpload(); 98 ResourceUpdate params = queue.takeFirstFullUpload();
99 EXPECT_TRUE(params.texture != NULL); 99 EXPECT_TRUE(params.texture != NULL);
100 100
101 // Upload the texture. 101 // Upload the texture.
102 m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 102 4); 102 layer_tree_host_->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 10 24);
103 m_layerTreeHost->contentsTextureManager()->prioritizeTextures(); 103 layer_tree_host_->contentsTextureManager()->prioritizeTextures();
104 104
105 scoped_ptr<OutputSurface> outputSurface; 105 scoped_ptr<OutputSurface> outputSurface;
106 scoped_ptr<ResourceProvider> resourceProvider; 106 scoped_ptr<ResourceProvider> resourceProvider;
107 { 107 {
108 DebugScopedSetImplThread implThread(proxy()); 108 DebugScopedSetImplThread implThread(proxy());
109 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy()); 109 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy());
110 outputSurface = createFakeOutputSurface(); 110 outputSurface = createFakeOutputSurface();
111 resourceProvider = ResourceProvider::Create(outputSurface.get()); 111 resourceProvider = ResourceProvider::Create(outputSurface.get());
112 params.texture->acquireBackingTexture(resourceProvider.get()); 112 params.texture->acquireBackingTexture(resourceProvider.get());
113 ASSERT_TRUE(params.texture->haveBackingTexture()); 113 ASSERT_TRUE(params.texture->haveBackingTexture());
114 } 114 }
115 115
116 // Nothing changed, so no repeated upload. 116 // Nothing changed, so no repeated upload.
117 testLayer->setTexturePriorities(calculator); 117 testLayer->SetTexturePriorities(calculator);
118 testLayer->update(queue, &occlusionTracker, NULL); 118 testLayer->Update(&queue, &occlusionTracker, NULL);
119 EXPECT_EQ(queue.fullUploadSize(), 0); 119 EXPECT_EQ(queue.fullUploadSize(), 0);
120 EXPECT_EQ(queue.partialUploadSize(), 0); 120 EXPECT_EQ(queue.partialUploadSize(), 0);
121 121
122 { 122 {
123 DebugScopedSetImplThread implThread(proxy()); 123 DebugScopedSetImplThread implThread(proxy());
124 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy()); 124 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy());
125 m_layerTreeHost->contentsTextureManager()->clearAllMemory(resourceProvid er.get()); 125 layer_tree_host_->contentsTextureManager()->clearAllMemory(resourceProvi der.get());
126 } 126 }
127 127
128 // Reupload after eviction 128 // Reupload after eviction
129 testLayer->setTexturePriorities(calculator); 129 testLayer->SetTexturePriorities(calculator);
130 testLayer->update(queue, &occlusionTracker, NULL); 130 testLayer->Update(&queue, &occlusionTracker, NULL);
131 EXPECT_EQ(queue.fullUploadSize(), 1); 131 EXPECT_EQ(queue.fullUploadSize(), 1);
132 EXPECT_EQ(queue.partialUploadSize(), 0); 132 EXPECT_EQ(queue.partialUploadSize(), 0);
133 133
134 // PrioritizedResourceManager clearing 134 // PrioritizedResourceManager clearing
135 m_layerTreeHost->contentsTextureManager()->unregisterTexture(params.texture) ; 135 layer_tree_host_->contentsTextureManager()->unregisterTexture(params.texture );
136 EXPECT_EQ(NULL, params.texture->resourceManager()); 136 EXPECT_EQ(NULL, params.texture->resourceManager());
137 testLayer->setTexturePriorities(calculator); 137 testLayer->SetTexturePriorities(calculator);
138 ResourceUpdateQueue queue2; 138 ResourceUpdateQueue queue2;
139 testLayer->update(queue2, &occlusionTracker, NULL); 139 testLayer->Update(&queue2, &occlusionTracker, NULL);
140 EXPECT_EQ(queue2.fullUploadSize(), 1); 140 EXPECT_EQ(queue2.fullUploadSize(), 1);
141 EXPECT_EQ(queue2.partialUploadSize(), 0); 141 EXPECT_EQ(queue2.partialUploadSize(), 0);
142 params = queue2.takeFirstFullUpload(); 142 params = queue2.takeFirstFullUpload();
143 EXPECT_TRUE(params.texture != NULL); 143 EXPECT_TRUE(params.texture != NULL);
144 EXPECT_EQ(params.texture->resourceManager(), m_layerTreeHost->contentsTextur eManager()); 144 EXPECT_EQ(params.texture->resourceManager(), layer_tree_host_->contentsTextu reManager());
145 } 145 }
146 146
147 } // namespace 147 } // namespace
148 } // namespace cc 148 } // namespace cc
OLDNEW
« no previous file with comments | « cc/nine_patch_layer_impl_unittest.cc ('k') | cc/occlusion_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698