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/resources/resource_update_controller.h" | 5 #include "cc/resources/resource_update_controller.h" |
6 | 6 |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "cc/resources/prioritized_resource_manager.h" | 8 #include "cc/resources/prioritized_resource_manager.h" |
9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
11 #include "cc/test/fake_proxy.h" | 11 #include "cc/test/fake_proxy.h" |
12 #include "cc/test/scheduler_test_common.h" | 12 #include "cc/test/scheduler_test_common.h" |
| 13 #include "cc/test/test_shared_bitmap_manager.h" |
13 #include "cc/test/test_web_graphics_context_3d.h" | 14 #include "cc/test/test_web_graphics_context_3d.h" |
14 #include "cc/test/tiled_layer_test_common.h" | 15 #include "cc/test/tiled_layer_test_common.h" |
15 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread | 16 #include "cc/trees/single_thread_proxy.h" // For DebugScopedSetImplThread |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/khronos/GLES2/gl2ext.h" | 18 #include "third_party/khronos/GLES2/gl2ext.h" |
18 | 19 |
19 using testing::Test; | 20 using testing::Test; |
20 | 21 |
21 namespace cc { | 22 namespace cc { |
22 namespace { | 23 namespace { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 textures_[i]-> | 118 textures_[i]-> |
118 set_request_priority(PriorityCalculator::VisiblePriority(true)); | 119 set_request_priority(PriorityCalculator::VisiblePriority(true)); |
119 } | 120 } |
120 resource_manager_->PrioritizeTextures(); | 121 resource_manager_->PrioritizeTextures(); |
121 | 122 |
122 output_surface_ = FakeOutputSurface::Create3d( | 123 output_surface_ = FakeOutputSurface::Create3d( |
123 scoped_ptr<TestWebGraphicsContext3D>( | 124 scoped_ptr<TestWebGraphicsContext3D>( |
124 new WebGraphicsContext3DForUploadTest(this))); | 125 new WebGraphicsContext3DForUploadTest(this))); |
125 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 126 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
126 | 127 |
127 resource_provider_ = | 128 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
128 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); | 129 resource_provider_ = ResourceProvider::Create( |
| 130 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1); |
129 } | 131 } |
130 | 132 |
131 void AppendFullUploadsOfIndexedTextureToUpdateQueue(int count, | 133 void AppendFullUploadsOfIndexedTextureToUpdateQueue(int count, |
132 int texture_index) { | 134 int texture_index) { |
133 full_upload_count_expected_ += count; | 135 full_upload_count_expected_ += count; |
134 total_upload_count_expected_ += count; | 136 total_upload_count_expected_ += count; |
135 | 137 |
136 const gfx::Rect rect(0, 0, 300, 150); | 138 const gfx::Rect rect(0, 0, 300, 150); |
137 const ResourceUpdate upload = ResourceUpdate::Create( | 139 const ResourceUpdate upload = ResourceUpdate::Create( |
138 textures_[texture_index].get(), &bitmap_, rect, rect, gfx::Vector2d()); | 140 textures_[texture_index].get(), &bitmap_, rect, rect, gfx::Vector2d()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 update_controller->Finalize(); | 177 update_controller->Finalize(); |
176 } | 178 } |
177 | 179 |
178 void MakeQueryResultAvailable() { query_results_available_++; } | 180 void MakeQueryResultAvailable() { query_results_available_++; } |
179 | 181 |
180 protected: | 182 protected: |
181 // Classes required to interact and test the ResourceUpdateController | 183 // Classes required to interact and test the ResourceUpdateController |
182 FakeProxy proxy_; | 184 FakeProxy proxy_; |
183 FakeOutputSurfaceClient output_surface_client_; | 185 FakeOutputSurfaceClient output_surface_client_; |
184 scoped_ptr<OutputSurface> output_surface_; | 186 scoped_ptr<OutputSurface> output_surface_; |
| 187 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
185 scoped_ptr<ResourceProvider> resource_provider_; | 188 scoped_ptr<ResourceProvider> resource_provider_; |
186 scoped_ptr<ResourceUpdateQueue> queue_; | 189 scoped_ptr<ResourceUpdateQueue> queue_; |
187 scoped_ptr<PrioritizedResource> textures_[4]; | 190 scoped_ptr<PrioritizedResource> textures_[4]; |
188 scoped_ptr<PrioritizedResourceManager> resource_manager_; | 191 scoped_ptr<PrioritizedResourceManager> resource_manager_; |
189 SkBitmap bitmap_; | 192 SkBitmap bitmap_; |
190 int query_results_available_; | 193 int query_results_available_; |
191 | 194 |
192 // Properties / expectations of this test | 195 // Properties / expectations of this test |
193 int full_upload_count_expected_; | 196 int full_upload_count_expected_; |
194 int partial_count_expected_; | 197 int partial_count_expected_; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 RunPendingTask(task_runner.get(), controller.get()); | 504 RunPendingTask(task_runner.get(), controller.get()); |
502 } | 505 } |
503 | 506 |
504 EXPECT_FALSE(task_runner->HasPendingTask()); | 507 EXPECT_FALSE(task_runner->HasPendingTask()); |
505 EXPECT_TRUE(client.ReadyToFinalizeCalled()); | 508 EXPECT_TRUE(client.ReadyToFinalizeCalled()); |
506 EXPECT_EQ(2, num_total_uploads_); | 509 EXPECT_EQ(2, num_total_uploads_); |
507 } | 510 } |
508 | 511 |
509 } // namespace | 512 } // namespace |
510 } // namespace cc | 513 } // namespace cc |
OLD | NEW |