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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 enum TileTaskWorkerPoolType { | 47 enum TileTaskWorkerPoolType { |
48 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 48 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
49 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 49 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
50 TILE_TASK_WORKER_POOL_TYPE_GPU, | 50 TILE_TASK_WORKER_POOL_TYPE_GPU, |
51 TILE_TASK_WORKER_POOL_TYPE_BITMAP | 51 TILE_TASK_WORKER_POOL_TYPE_BITMAP |
52 }; | 52 }; |
53 | 53 |
54 class TestRasterTaskImpl : public RasterTask { | 54 class TestRasterTaskImpl : public RasterTask { |
55 public: | 55 public: |
56 typedef base::Callback<void( | 56 typedef base::Callback<void(bool was_canceled)> Reply; |
57 const DisplayListRasterSource::SolidColorAnalysis& analysis, | |
58 bool was_canceled)> Reply; | |
59 | 57 |
60 TestRasterTaskImpl(const Resource* resource, | 58 TestRasterTaskImpl(const Resource* resource, |
61 const Reply& reply, | 59 const Reply& reply, |
62 ImageDecodeTask::Vector* dependencies) | 60 ImageDecodeTask::Vector* dependencies) |
63 : RasterTask(dependencies), | 61 : RasterTask(dependencies), |
64 resource_(resource), | 62 resource_(resource), |
65 reply_(reply), | 63 reply_(reply), |
66 raster_source_( | 64 raster_source_( |
67 FakeDisplayListRasterSource::CreateFilled(gfx::Size(1, 1))) {} | 65 FakeDisplayListRasterSource::CreateFilled(gfx::Size(1, 1))) {} |
68 | 66 |
69 // Overridden from Task: | 67 // Overridden from Task: |
70 void RunOnWorkerThread() override { | 68 void RunOnWorkerThread() override { |
71 uint64_t new_content_id = 0; | 69 uint64_t new_content_id = 0; |
72 raster_buffer_->Playback(raster_source_.get(), gfx::Rect(1, 1), | 70 raster_buffer_->Playback(raster_source_.get(), gfx::Rect(1, 1), |
73 gfx::Rect(1, 1), new_content_id, 1.f, true); | 71 gfx::Rect(1, 1), new_content_id, 1.f, true); |
74 } | 72 } |
75 | 73 |
76 // Overridden from TileTask: | 74 // Overridden from TileTask: |
77 void ScheduleOnOriginThread(TileTaskClient* client) override { | 75 void ScheduleOnOriginThread(TileTaskClient* client) override { |
78 // The raster buffer has no tile ids associated with it for partial update, | 76 // The raster buffer has no tile ids associated with it for partial update, |
79 // so doesn't need to provide a valid dirty rect. | 77 // so doesn't need to provide a valid dirty rect. |
80 raster_buffer_ = client->AcquireBufferForRaster(resource_, 0, 0); | 78 raster_buffer_ = client->AcquireBufferForRaster(resource_, 0, 0); |
81 } | 79 } |
82 void CompleteOnOriginThread(TileTaskClient* client) override { | 80 void CompleteOnOriginThread(TileTaskClient* client) override { |
83 client->ReleaseBufferForRaster(std::move(raster_buffer_)); | 81 client->ReleaseBufferForRaster(std::move(raster_buffer_)); |
84 reply_.Run(DisplayListRasterSource::SolidColorAnalysis(), | 82 reply_.Run(!HasFinishedRunning()); |
85 !HasFinishedRunning()); | |
86 } | 83 } |
87 | 84 |
88 protected: | 85 protected: |
89 ~TestRasterTaskImpl() override {} | 86 ~TestRasterTaskImpl() override {} |
90 | 87 |
91 private: | 88 private: |
92 const Resource* resource_; | 89 const Resource* resource_; |
93 const Reply reply_; | 90 const Reply reply_; |
94 scoped_ptr<RasterBuffer> raster_buffer_; | 91 scoped_ptr<RasterBuffer> raster_buffer_; |
95 scoped_refptr<DisplayListRasterSource> raster_source_; | 92 scoped_refptr<DisplayListRasterSource> raster_source_; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 output_surface_ = FakeOutputSurface::CreateSoftware( | 263 output_surface_ = FakeOutputSurface::CreateSoftware( |
267 make_scoped_ptr(new SoftwareOutputDevice)); | 264 make_scoped_ptr(new SoftwareOutputDevice)); |
268 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 265 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
269 resource_provider_ = FakeResourceProvider::Create( | 266 resource_provider_ = FakeResourceProvider::Create( |
270 output_surface_.get(), &shared_bitmap_manager_, nullptr); | 267 output_surface_.get(), &shared_bitmap_manager_, nullptr); |
271 } | 268 } |
272 | 269 |
273 void OnTaskCompleted( | 270 void OnTaskCompleted( |
274 scoped_ptr<ScopedResource> resource, | 271 scoped_ptr<ScopedResource> resource, |
275 unsigned id, | 272 unsigned id, |
276 const DisplayListRasterSource::SolidColorAnalysis& analysis, | |
277 bool was_canceled) { | 273 bool was_canceled) { |
278 RasterTaskResult result; | 274 RasterTaskResult result; |
279 result.id = id; | 275 result.id = id; |
280 result.canceled = was_canceled; | 276 result.canceled = was_canceled; |
281 completed_tasks_.push_back(result); | 277 completed_tasks_.push_back(result); |
282 } | 278 } |
283 | 279 |
284 void OnTimeout() { | 280 void OnTimeout() { |
285 timed_out_ = true; | 281 timed_out_ = true; |
286 base::MessageLoop::current()->QuitWhenIdle(); | 282 base::MessageLoop::current()->QuitWhenIdle(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 369 |
374 INSTANTIATE_TEST_CASE_P(TileTaskWorkerPoolTests, | 370 INSTANTIATE_TEST_CASE_P(TileTaskWorkerPoolTests, |
375 TileTaskWorkerPoolTest, | 371 TileTaskWorkerPoolTest, |
376 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 372 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
377 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 373 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
378 TILE_TASK_WORKER_POOL_TYPE_GPU, | 374 TILE_TASK_WORKER_POOL_TYPE_GPU, |
379 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); | 375 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); |
380 | 376 |
381 } // namespace | 377 } // namespace |
382 } // namespace cc | 378 } // namespace cc |
OLD | NEW |