| 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/resources/raster_worker_pool.h" | 5 #include "cc/resources/raster_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 28 matching lines...) Expand all Loading... |
| 39 enum RasterWorkerPoolType { | 39 enum RasterWorkerPoolType { |
| 40 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 40 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 41 RASTER_WORKER_POOL_TYPE_ZERO_COPY, | 41 RASTER_WORKER_POOL_TYPE_ZERO_COPY, |
| 42 RASTER_WORKER_POOL_TYPE_ONE_COPY, | 42 RASTER_WORKER_POOL_TYPE_ONE_COPY, |
| 43 RASTER_WORKER_POOL_TYPE_GPU, | 43 RASTER_WORKER_POOL_TYPE_GPU, |
| 44 RASTER_WORKER_POOL_TYPE_BITMAP | 44 RASTER_WORKER_POOL_TYPE_BITMAP |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class TestRasterTaskImpl : public RasterTask { | 47 class TestRasterTaskImpl : public RasterTask { |
| 48 public: | 48 public: |
| 49 typedef base::Callback< | 49 typedef base::Callback<void(const RasterSource::SolidColorAnalysis& analysis, |
| 50 void(const PicturePileImpl::Analysis& analysis, bool was_canceled)> Reply; | 50 bool was_canceled)> Reply; |
| 51 | 51 |
| 52 TestRasterTaskImpl(const Resource* resource, | 52 TestRasterTaskImpl(const Resource* resource, |
| 53 const Reply& reply, | 53 const Reply& reply, |
| 54 ImageDecodeTask::Vector* dependencies) | 54 ImageDecodeTask::Vector* dependencies) |
| 55 : RasterTask(resource, dependencies), | 55 : RasterTask(resource, dependencies), |
| 56 reply_(reply), | 56 reply_(reply), |
| 57 picture_pile_(FakePicturePileImpl::CreateEmptyPile(gfx::Size(1, 1), | 57 picture_pile_(FakePicturePileImpl::CreateEmptyPile(gfx::Size(1, 1), |
| 58 gfx::Size(1, 1))) {} | 58 gfx::Size(1, 1))) {} |
| 59 | 59 |
| 60 // Overridden from Task: | 60 // Overridden from Task: |
| 61 void RunOnWorkerThread() override { | 61 void RunOnWorkerThread() override { |
| 62 raster_buffer_->Playback( | 62 raster_buffer_->Playback( |
| 63 picture_pile_.get(), gfx::Rect(0, 0, 1, 1), 1.0, NULL); | 63 picture_pile_.get(), gfx::Rect(0, 0, 1, 1), 1.0, NULL); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Overridden from RasterizerTask: | 66 // Overridden from RasterizerTask: |
| 67 void ScheduleOnOriginThread(RasterizerTaskClient* client) override { | 67 void ScheduleOnOriginThread(RasterizerTaskClient* client) override { |
| 68 raster_buffer_ = client->AcquireBufferForRaster(resource()); | 68 raster_buffer_ = client->AcquireBufferForRaster(resource()); |
| 69 } | 69 } |
| 70 void CompleteOnOriginThread(RasterizerTaskClient* client) override { | 70 void CompleteOnOriginThread(RasterizerTaskClient* client) override { |
| 71 client->ReleaseBufferForRaster(raster_buffer_.Pass()); | 71 client->ReleaseBufferForRaster(raster_buffer_.Pass()); |
| 72 } | 72 } |
| 73 void RunReplyOnOriginThread() override { | 73 void RunReplyOnOriginThread() override { |
| 74 reply_.Run(PicturePileImpl::Analysis(), !HasFinishedRunning()); | 74 reply_.Run(RasterSource::SolidColorAnalysis(), !HasFinishedRunning()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 ~TestRasterTaskImpl() override {} | 78 ~TestRasterTaskImpl() override {} |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 const Reply reply_; | 81 const Reply reply_; |
| 82 scoped_ptr<RasterBuffer> raster_buffer_; | 82 scoped_ptr<RasterBuffer> raster_buffer_; |
| 83 scoped_refptr<PicturePileImpl> picture_pile_; | 83 scoped_refptr<PicturePileImpl> picture_pile_; |
| 84 | 84 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 &shared_bitmap_manager_, | 291 &shared_bitmap_manager_, |
| 292 NULL, | 292 NULL, |
| 293 NULL, | 293 NULL, |
| 294 0, | 294 0, |
| 295 false, | 295 false, |
| 296 1).Pass(); | 296 1).Pass(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void OnTaskCompleted(scoped_ptr<ScopedResource> resource, | 299 void OnTaskCompleted(scoped_ptr<ScopedResource> resource, |
| 300 unsigned id, | 300 unsigned id, |
| 301 const PicturePileImpl::Analysis& analysis, | 301 const RasterSource::SolidColorAnalysis& analysis, |
| 302 bool was_canceled) { | 302 bool was_canceled) { |
| 303 RasterTaskResult result; | 303 RasterTaskResult result; |
| 304 result.id = id; | 304 result.id = id; |
| 305 result.canceled = was_canceled; | 305 result.canceled = was_canceled; |
| 306 completed_tasks_.push_back(result); | 306 completed_tasks_.push_back(result); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void OnTimeout() { | 309 void OnTimeout() { |
| 310 timed_out_ = true; | 310 timed_out_ = true; |
| 311 base::MessageLoop::current()->Quit(); | 311 base::MessageLoop::current()->Quit(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 402 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
| 403 RasterWorkerPoolTest, | 403 RasterWorkerPoolTest, |
| 404 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 404 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 405 RASTER_WORKER_POOL_TYPE_ZERO_COPY, | 405 RASTER_WORKER_POOL_TYPE_ZERO_COPY, |
| 406 RASTER_WORKER_POOL_TYPE_ONE_COPY, | 406 RASTER_WORKER_POOL_TYPE_ONE_COPY, |
| 407 RASTER_WORKER_POOL_TYPE_GPU, | 407 RASTER_WORKER_POOL_TYPE_GPU, |
| 408 RASTER_WORKER_POOL_TYPE_BITMAP)); | 408 RASTER_WORKER_POOL_TYPE_BITMAP)); |
| 409 | 409 |
| 410 } // namespace | 410 } // namespace |
| 411 } // namespace cc | 411 } // namespace cc |
| OLD | NEW |