OLD | NEW |
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/rendering_stats.h" | 10 #include "cc/rendering_stats.h" |
11 #include "cc/resource_provider.h" | 11 #include "cc/resource_provider.h" |
12 #include "cc/single_thread_proxy.h" | 12 #include "cc/single_thread_proxy.h" |
13 #include "cc/resource_update_queue.h" | 13 #include "cc/resource_update_queue.h" |
14 #include "cc/texture_uploader.h" | 14 #include "cc/texture_uploader.h" |
| 15 #include "cc/test/fake_graphics_context.h" |
15 #include "cc/test/fake_layer_tree_host_client.h" | 16 #include "cc/test/fake_layer_tree_host_client.h" |
16 #include "cc/test/fake_output_surface.h" | |
17 #include "cc/test/geometry_test_utils.h" | 17 #include "cc/test/geometry_test_utils.h" |
18 #include "cc/test/layer_tree_test_common.h" | 18 #include "cc/test/layer_tree_test_common.h" |
19 #include "SkBitmap.h" | 19 #include "SkBitmap.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 using ::testing::Mock; | 23 using ::testing::Mock; |
24 using ::testing::_; | 24 using ::testing::_; |
25 using ::testing::AtLeast; | 25 using ::testing::AtLeast; |
26 using ::testing::AnyNumber; | 26 using ::testing::AnyNumber; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 testLayer->update(queue, &occlusionTracker, stats); | 96 testLayer->update(queue, &occlusionTracker, stats); |
97 EXPECT_EQ(queue.fullUploadSize(), 1); | 97 EXPECT_EQ(queue.fullUploadSize(), 1); |
98 EXPECT_EQ(queue.partialUploadSize(), 0); | 98 EXPECT_EQ(queue.partialUploadSize(), 0); |
99 ResourceUpdate params = queue.takeFirstFullUpload(); | 99 ResourceUpdate params = queue.takeFirstFullUpload(); |
100 EXPECT_TRUE(params.texture != NULL); | 100 EXPECT_TRUE(params.texture != NULL); |
101 | 101 |
102 // Upload the texture. | 102 // Upload the texture. |
103 m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 102
4); | 103 m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 102
4); |
104 m_layerTreeHost->contentsTextureManager()->prioritizeTextures(); | 104 m_layerTreeHost->contentsTextureManager()->prioritizeTextures(); |
105 | 105 |
106 scoped_ptr<OutputSurface> outputSurface; | 106 scoped_ptr<GraphicsContext> context; |
107 scoped_ptr<ResourceProvider> resourceProvider; | 107 scoped_ptr<ResourceProvider> resourceProvider; |
108 { | 108 { |
109 DebugScopedSetImplThread implThread(proxy()); | 109 DebugScopedSetImplThread implThread(proxy()); |
110 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy()); | 110 DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy()); |
111 outputSurface = createFakeOutputSurface(); | 111 context = WebKit::createFakeGraphicsContext(); |
112 resourceProvider = ResourceProvider::create(outputSurface.get()); | 112 resourceProvider = ResourceProvider::create(context.get()); |
113 params.texture->acquireBackingTexture(resourceProvider.get()); | 113 params.texture->acquireBackingTexture(resourceProvider.get()); |
114 ASSERT_TRUE(params.texture->haveBackingTexture()); | 114 ASSERT_TRUE(params.texture->haveBackingTexture()); |
115 } | 115 } |
116 | 116 |
117 // Nothing changed, so no repeated upload. | 117 // Nothing changed, so no repeated upload. |
118 testLayer->setTexturePriorities(calculator); | 118 testLayer->setTexturePriorities(calculator); |
119 testLayer->update(queue, &occlusionTracker, stats); | 119 testLayer->update(queue, &occlusionTracker, stats); |
120 EXPECT_EQ(queue.fullUploadSize(), 0); | 120 EXPECT_EQ(queue.fullUploadSize(), 0); |
121 EXPECT_EQ(queue.partialUploadSize(), 0); | 121 EXPECT_EQ(queue.partialUploadSize(), 0); |
122 | 122 |
(...skipping 17 matching lines...) Expand all Loading... |
140 testLayer->update(queue2, &occlusionTracker, stats); | 140 testLayer->update(queue2, &occlusionTracker, stats); |
141 EXPECT_EQ(queue2.fullUploadSize(), 1); | 141 EXPECT_EQ(queue2.fullUploadSize(), 1); |
142 EXPECT_EQ(queue2.partialUploadSize(), 0); | 142 EXPECT_EQ(queue2.partialUploadSize(), 0); |
143 params = queue2.takeFirstFullUpload(); | 143 params = queue2.takeFirstFullUpload(); |
144 EXPECT_TRUE(params.texture != NULL); | 144 EXPECT_TRUE(params.texture != NULL); |
145 EXPECT_EQ(params.texture->resourceManager(), m_layerTreeHost->contentsTextur
eManager()); | 145 EXPECT_EQ(params.texture->resourceManager(), m_layerTreeHost->contentsTextur
eManager()); |
146 } | 146 } |
147 | 147 |
148 } // namespace | 148 } // namespace |
149 } // namespace cc | 149 } // namespace cc |
OLD | NEW |