OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/raster/tile_task_worker_pool.h" | 5 #include "cc/raster/tile_task_worker_pool.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 enum TileTaskWorkerPoolType { | 42 enum TileTaskWorkerPoolType { |
43 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 43 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
44 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 44 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
45 TILE_TASK_WORKER_POOL_TYPE_GPU, | 45 TILE_TASK_WORKER_POOL_TYPE_GPU, |
46 TILE_TASK_WORKER_POOL_TYPE_BITMAP | 46 TILE_TASK_WORKER_POOL_TYPE_BITMAP |
47 }; | 47 }; |
48 | 48 |
49 class TestRasterTaskImpl : public RasterTask { | 49 class TestRasterTaskImpl : public RasterTask { |
50 public: | 50 public: |
51 typedef base::Callback<void(const RasterSource::SolidColorAnalysis& analysis, | 51 typedef base::Callback<void( |
52 bool was_canceled)> Reply; | 52 const DisplayListRasterSource::SolidColorAnalysis& analysis, |
| 53 bool was_canceled)> Reply; |
53 | 54 |
54 TestRasterTaskImpl(const Resource* resource, | 55 TestRasterTaskImpl(const Resource* resource, |
55 const Reply& reply, | 56 const Reply& reply, |
56 ImageDecodeTask::Vector* dependencies) | 57 ImageDecodeTask::Vector* dependencies) |
57 : RasterTask(dependencies), | 58 : RasterTask(dependencies), |
58 resource_(resource), | 59 resource_(resource), |
59 reply_(reply), | 60 reply_(reply), |
60 raster_source_( | 61 raster_source_( |
61 FakeDisplayListRasterSource::CreateFilled(gfx::Size(1, 1))) {} | 62 FakeDisplayListRasterSource::CreateFilled(gfx::Size(1, 1))) {} |
62 | 63 |
63 // Overridden from Task: | 64 // Overridden from Task: |
64 void RunOnWorkerThread() override { | 65 void RunOnWorkerThread() override { |
65 uint64_t new_content_id = 0; | 66 uint64_t new_content_id = 0; |
66 raster_buffer_->Playback(raster_source_.get(), gfx::Rect(1, 1), | 67 raster_buffer_->Playback(raster_source_.get(), gfx::Rect(1, 1), |
67 gfx::Rect(1, 1), new_content_id, 1.f, true); | 68 gfx::Rect(1, 1), new_content_id, 1.f, true); |
68 } | 69 } |
69 | 70 |
70 // Overridden from TileTask: | 71 // Overridden from TileTask: |
71 void ScheduleOnOriginThread(TileTaskClient* client) override { | 72 void ScheduleOnOriginThread(TileTaskClient* client) override { |
72 // The raster buffer has no tile ids associated with it for partial update, | 73 // The raster buffer has no tile ids associated with it for partial update, |
73 // so doesn't need to provide a valid dirty rect. | 74 // so doesn't need to provide a valid dirty rect. |
74 raster_buffer_ = client->AcquireBufferForRaster(resource_, 0, 0); | 75 raster_buffer_ = client->AcquireBufferForRaster(resource_, 0, 0); |
75 } | 76 } |
76 void CompleteOnOriginThread(TileTaskClient* client) override { | 77 void CompleteOnOriginThread(TileTaskClient* client) override { |
77 client->ReleaseBufferForRaster(raster_buffer_.Pass()); | 78 client->ReleaseBufferForRaster(raster_buffer_.Pass()); |
78 reply_.Run(RasterSource::SolidColorAnalysis(), !HasFinishedRunning()); | 79 reply_.Run(DisplayListRasterSource::SolidColorAnalysis(), |
| 80 !HasFinishedRunning()); |
79 } | 81 } |
80 | 82 |
81 protected: | 83 protected: |
82 ~TestRasterTaskImpl() override {} | 84 ~TestRasterTaskImpl() override {} |
83 | 85 |
84 private: | 86 private: |
85 const Resource* resource_; | 87 const Resource* resource_; |
86 const Reply reply_; | 88 const Reply reply_; |
87 scoped_ptr<RasterBuffer> raster_buffer_; | 89 scoped_ptr<RasterBuffer> raster_buffer_; |
88 scoped_refptr<RasterSource> raster_source_; | 90 scoped_refptr<DisplayListRasterSource> raster_source_; |
89 | 91 |
90 DISALLOW_COPY_AND_ASSIGN(TestRasterTaskImpl); | 92 DISALLOW_COPY_AND_ASSIGN(TestRasterTaskImpl); |
91 }; | 93 }; |
92 | 94 |
93 class BlockingTestRasterTaskImpl : public TestRasterTaskImpl { | 95 class BlockingTestRasterTaskImpl : public TestRasterTaskImpl { |
94 public: | 96 public: |
95 BlockingTestRasterTaskImpl(const Resource* resource, | 97 BlockingTestRasterTaskImpl(const Resource* resource, |
96 const Reply& reply, | 98 const Reply& reply, |
97 base::Lock* lock, | 99 base::Lock* lock, |
98 ImageDecodeTask::Vector* dependencies) | 100 ImageDecodeTask::Vector* dependencies) |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 283 } |
282 | 284 |
283 void CreateSoftwareOutputSurfaceAndResourceProvider() { | 285 void CreateSoftwareOutputSurfaceAndResourceProvider() { |
284 output_surface_ = FakeOutputSurface::CreateSoftware( | 286 output_surface_ = FakeOutputSurface::CreateSoftware( |
285 make_scoped_ptr(new SoftwareOutputDevice)); | 287 make_scoped_ptr(new SoftwareOutputDevice)); |
286 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 288 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
287 resource_provider_ = FakeResourceProvider::Create( | 289 resource_provider_ = FakeResourceProvider::Create( |
288 output_surface_.get(), &shared_bitmap_manager_, nullptr); | 290 output_surface_.get(), &shared_bitmap_manager_, nullptr); |
289 } | 291 } |
290 | 292 |
291 void OnTaskCompleted(scoped_ptr<ScopedResource> resource, | 293 void OnTaskCompleted( |
292 unsigned id, | 294 scoped_ptr<ScopedResource> resource, |
293 const RasterSource::SolidColorAnalysis& analysis, | 295 unsigned id, |
294 bool was_canceled) { | 296 const DisplayListRasterSource::SolidColorAnalysis& analysis, |
| 297 bool was_canceled) { |
295 RasterTaskResult result; | 298 RasterTaskResult result; |
296 result.id = id; | 299 result.id = id; |
297 result.canceled = was_canceled; | 300 result.canceled = was_canceled; |
298 completed_tasks_.push_back(result); | 301 completed_tasks_.push_back(result); |
299 } | 302 } |
300 | 303 |
301 void OnTimeout() { | 304 void OnTimeout() { |
302 timed_out_ = true; | 305 timed_out_ = true; |
303 base::MessageLoop::current()->Quit(); | 306 base::MessageLoop::current()->Quit(); |
304 } | 307 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 408 |
406 INSTANTIATE_TEST_CASE_P(TileTaskWorkerPoolTests, | 409 INSTANTIATE_TEST_CASE_P(TileTaskWorkerPoolTests, |
407 TileTaskWorkerPoolTest, | 410 TileTaskWorkerPoolTest, |
408 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 411 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
409 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 412 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
410 TILE_TASK_WORKER_POOL_TYPE_GPU, | 413 TILE_TASK_WORKER_POOL_TYPE_GPU, |
411 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); | 414 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); |
412 | 415 |
413 } // namespace | 416 } // namespace |
414 } // namespace cc | 417 } // namespace cc |
OLD | NEW |