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