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/layers/nine_patch_layer.h" | 5 #include "cc/layers/nine_patch_layer.h" |
6 | 6 |
7 #include "cc/debug/overdraw_metrics.h" | 7 #include "cc/debug/overdraw_metrics.h" |
8 #include "cc/resources/prioritized_resource_manager.h" | 8 #include "cc/resources/prioritized_resource_manager.h" |
9 #include "cc/resources/resource_provider.h" | 9 #include "cc/resources/resource_provider.h" |
10 #include "cc/resources/resource_update_queue.h" | 10 #include "cc/resources/resource_update_queue.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 64 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
65 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); | 65 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); |
66 | 66 |
67 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); | 67 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); |
68 | 68 |
69 PriorityCalculator calculator; | 69 PriorityCalculator calculator; |
70 ResourceUpdateQueue queue; | 70 ResourceUpdateQueue queue; |
71 OcclusionTracker occlusion_tracker(gfx::Rect(), false); | 71 OcclusionTracker occlusion_tracker(gfx::Rect(), false); |
72 | 72 |
73 // No bitmap set should not trigger any uploads. | 73 // No bitmap set should not trigger any uploads. |
| 74 test_layer->SavePaintProperties(); |
74 test_layer->SetTexturePriorities(calculator); | 75 test_layer->SetTexturePriorities(calculator); |
75 test_layer->Update(&queue, &occlusion_tracker); | 76 test_layer->Update(&queue, &occlusion_tracker); |
76 EXPECT_EQ(0u, queue.FullUploadSize()); | 77 EXPECT_EQ(0u, queue.FullUploadSize()); |
77 EXPECT_EQ(0u, queue.PartialUploadSize()); | 78 EXPECT_EQ(0u, queue.PartialUploadSize()); |
78 | 79 |
79 // Setting a bitmap set should trigger a single full upload. | 80 // Setting a bitmap set should trigger a single full upload. |
80 SkBitmap bitmap; | 81 SkBitmap bitmap; |
81 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); | 82 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); |
82 bitmap.allocPixels(); | 83 bitmap.allocPixels(); |
83 test_layer->SetBitmap(bitmap, gfx::Rect(5, 5, 1, 1)); | 84 test_layer->SetBitmap(bitmap, gfx::Rect(5, 5, 1, 1)); |
| 85 test_layer->SavePaintProperties(); |
84 test_layer->SetTexturePriorities(calculator); | 86 test_layer->SetTexturePriorities(calculator); |
85 test_layer->Update(&queue, &occlusion_tracker); | 87 test_layer->Update(&queue, &occlusion_tracker); |
86 EXPECT_EQ(1u, queue.FullUploadSize()); | 88 EXPECT_EQ(1u, queue.FullUploadSize()); |
87 EXPECT_EQ(0u, queue.PartialUploadSize()); | 89 EXPECT_EQ(0u, queue.PartialUploadSize()); |
88 ResourceUpdate params = queue.TakeFirstFullUpload(); | 90 ResourceUpdate params = queue.TakeFirstFullUpload(); |
89 EXPECT_TRUE(params.texture != NULL); | 91 EXPECT_TRUE(params.texture != NULL); |
90 | 92 |
91 // Upload the texture. | 93 // Upload the texture. |
92 layer_tree_host_->contents_texture_manager()->SetMaxMemoryLimitBytes( | 94 layer_tree_host_->contents_texture_manager()->SetMaxMemoryLimitBytes( |
93 1024 * 1024); | 95 1024 * 1024); |
94 layer_tree_host_->contents_texture_manager()->PrioritizeTextures(); | 96 layer_tree_host_->contents_texture_manager()->PrioritizeTextures(); |
95 | 97 |
96 scoped_ptr<OutputSurface> output_surface; | 98 scoped_ptr<OutputSurface> output_surface; |
97 scoped_ptr<ResourceProvider> resource_provider; | 99 scoped_ptr<ResourceProvider> resource_provider; |
98 { | 100 { |
99 DebugScopedSetImplThread impl_thread(Proxy()); | 101 DebugScopedSetImplThread impl_thread(Proxy()); |
100 DebugScopedSetMainThreadBlocked main_thread_blocked(Proxy()); | 102 DebugScopedSetMainThreadBlocked main_thread_blocked(Proxy()); |
101 output_surface = CreateFakeOutputSurface(); | 103 output_surface = CreateFakeOutputSurface(); |
102 resource_provider = ResourceProvider::Create(output_surface.get(), 0); | 104 resource_provider = ResourceProvider::Create(output_surface.get(), 0); |
103 params.texture->AcquireBackingTexture(resource_provider.get()); | 105 params.texture->AcquireBackingTexture(resource_provider.get()); |
104 ASSERT_TRUE(params.texture->have_backing_texture()); | 106 ASSERT_TRUE(params.texture->have_backing_texture()); |
105 } | 107 } |
106 | 108 |
107 // Nothing changed, so no repeated upload. | 109 // Nothing changed, so no repeated upload. |
| 110 test_layer->SavePaintProperties(); |
108 test_layer->SetTexturePriorities(calculator); | 111 test_layer->SetTexturePriorities(calculator); |
109 test_layer->Update(&queue, &occlusion_tracker); | 112 test_layer->Update(&queue, &occlusion_tracker); |
110 EXPECT_EQ(0u, queue.FullUploadSize()); | 113 EXPECT_EQ(0u, queue.FullUploadSize()); |
111 EXPECT_EQ(0u, queue.PartialUploadSize()); | 114 EXPECT_EQ(0u, queue.PartialUploadSize()); |
112 { | 115 { |
113 DebugScopedSetImplThread impl_thread(Proxy()); | 116 DebugScopedSetImplThread impl_thread(Proxy()); |
114 DebugScopedSetMainThreadBlocked main_thread_blocked(Proxy()); | 117 DebugScopedSetMainThreadBlocked main_thread_blocked(Proxy()); |
115 layer_tree_host_->contents_texture_manager()->ClearAllMemory( | 118 layer_tree_host_->contents_texture_manager()->ClearAllMemory( |
116 resource_provider.get()); | 119 resource_provider.get()); |
117 } | 120 } |
118 | 121 |
119 // Reupload after eviction | 122 // Reupload after eviction |
| 123 test_layer->SavePaintProperties(); |
120 test_layer->SetTexturePriorities(calculator); | 124 test_layer->SetTexturePriorities(calculator); |
121 test_layer->Update(&queue, &occlusion_tracker); | 125 test_layer->Update(&queue, &occlusion_tracker); |
122 EXPECT_EQ(1u, queue.FullUploadSize()); | 126 EXPECT_EQ(1u, queue.FullUploadSize()); |
123 EXPECT_EQ(0u, queue.PartialUploadSize()); | 127 EXPECT_EQ(0u, queue.PartialUploadSize()); |
124 | 128 |
125 // PrioritizedResourceManager clearing | 129 // PrioritizedResourceManager clearing |
126 layer_tree_host_->contents_texture_manager()->UnregisterTexture( | 130 layer_tree_host_->contents_texture_manager()->UnregisterTexture( |
127 params.texture); | 131 params.texture); |
128 EXPECT_EQ(NULL, params.texture->resource_manager()); | 132 EXPECT_EQ(NULL, params.texture->resource_manager()); |
| 133 test_layer->SavePaintProperties(); |
129 test_layer->SetTexturePriorities(calculator); | 134 test_layer->SetTexturePriorities(calculator); |
130 ResourceUpdateQueue queue2; | 135 ResourceUpdateQueue queue2; |
131 test_layer->Update(&queue2, &occlusion_tracker); | 136 test_layer->Update(&queue2, &occlusion_tracker); |
132 EXPECT_EQ(1u, queue2.FullUploadSize()); | 137 EXPECT_EQ(1u, queue2.FullUploadSize()); |
133 EXPECT_EQ(0u, queue2.PartialUploadSize()); | 138 EXPECT_EQ(0u, queue2.PartialUploadSize()); |
134 params = queue2.TakeFirstFullUpload(); | 139 params = queue2.TakeFirstFullUpload(); |
135 EXPECT_TRUE(params.texture != NULL); | 140 EXPECT_TRUE(params.texture != NULL); |
136 EXPECT_EQ(params.texture->resource_manager(), | 141 EXPECT_EQ(params.texture->resource_manager(), |
137 layer_tree_host_->contents_texture_manager()); | 142 layer_tree_host_->contents_texture_manager()); |
138 } | 143 } |
139 | 144 |
140 } // namespace | 145 } // namespace |
141 } // namespace cc | 146 } // namespace cc |
OLD | NEW |