| 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" |
| 11 #include "cc/resources/bitmap_raster_worker_pool.h" | 11 #include "cc/resources/bitmap_raster_worker_pool.h" |
| 12 #include "cc/resources/gpu_raster_worker_pool.h" | 12 #include "cc/resources/gpu_raster_worker_pool.h" |
| 13 #include "cc/resources/one_copy_raster_worker_pool.h" | 13 #include "cc/resources/one_copy_raster_worker_pool.h" |
| 14 #include "cc/resources/picture_pile.h" | 14 #include "cc/resources/picture_pile.h" |
| 15 #include "cc/resources/picture_pile_impl.h" | 15 #include "cc/resources/picture_pile_impl.h" |
| 16 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 16 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
| 17 #include "cc/resources/raster_buffer.h" | 17 #include "cc/resources/raster_buffer.h" |
| 18 #include "cc/resources/rasterizer.h" | 18 #include "cc/resources/rasterizer.h" |
| 19 #include "cc/resources/resource_pool.h" | 19 #include "cc/resources/resource_pool.h" |
| 20 #include "cc/resources/resource_provider.h" | 20 #include "cc/resources/resource_provider.h" |
| 21 #include "cc/resources/scoped_resource.h" | 21 #include "cc/resources/scoped_resource.h" |
| 22 #include "cc/resources/zero_copy_raster_worker_pool.h" | 22 #include "cc/resources/zero_copy_raster_worker_pool.h" |
| 23 #include "cc/test/fake_output_surface.h" | 23 #include "cc/test/fake_output_surface.h" |
| 24 #include "cc/test/fake_output_surface_client.h" | 24 #include "cc/test/fake_output_surface_client.h" |
| 25 #include "cc/test/fake_picture_pile_impl.h" |
| 25 #include "cc/test/test_gpu_memory_buffer_manager.h" | 26 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 26 #include "cc/test/test_shared_bitmap_manager.h" | 27 #include "cc/test/test_shared_bitmap_manager.h" |
| 27 #include "cc/test/test_web_graphics_context_3d.h" | 28 #include "cc/test/test_web_graphics_context_3d.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 30 |
| 30 namespace cc { | 31 namespace cc { |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 const size_t kMaxTransferBufferUsageBytes = 10000U; | 34 const size_t kMaxTransferBufferUsageBytes = 10000U; |
| 34 // A resource of this dimension^2 * 4 must be greater than the above transfer | 35 // A resource of this dimension^2 * 4 must be greater than the above transfer |
| 35 // buffer constant. | 36 // buffer constant. |
| 36 const size_t kLargeResourceDimension = 1000U; | 37 const size_t kLargeResourceDimension = 1000U; |
| 37 | 38 |
| 38 enum RasterWorkerPoolType { | 39 enum RasterWorkerPoolType { |
| 39 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 40 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 40 RASTER_WORKER_POOL_TYPE_ZERO_COPY, | 41 RASTER_WORKER_POOL_TYPE_ZERO_COPY, |
| 41 RASTER_WORKER_POOL_TYPE_ONE_COPY, | 42 RASTER_WORKER_POOL_TYPE_ONE_COPY, |
| 42 RASTER_WORKER_POOL_TYPE_GPU, | 43 RASTER_WORKER_POOL_TYPE_GPU, |
| 43 RASTER_WORKER_POOL_TYPE_BITMAP | 44 RASTER_WORKER_POOL_TYPE_BITMAP |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 class TestRasterTaskImpl : public RasterTask { | 47 class TestRasterTaskImpl : public RasterTask { |
| 47 public: | 48 public: |
| 48 typedef base::Callback< | 49 typedef base::Callback< |
| 49 void(const PicturePileImpl::Analysis& analysis, bool was_canceled)> Reply; | 50 void(const PicturePileImpl::Analysis& analysis, bool was_canceled)> Reply; |
| 50 | 51 |
| 51 TestRasterTaskImpl(const Resource* resource, | 52 TestRasterTaskImpl(const Resource* resource, |
| 52 const Reply& reply, | 53 const Reply& reply, |
| 53 ImageDecodeTask::Vector* dependencies) | 54 ImageDecodeTask::Vector* dependencies) |
| 54 : RasterTask(resource, dependencies), reply_(reply) {} | 55 : RasterTask(resource, dependencies), |
| 56 reply_(reply), |
| 57 picture_pile_(FakePicturePileImpl::CreateEmptyPile(gfx::Size(1, 1), |
| 58 gfx::Size(1, 1))) {} |
| 55 | 59 |
| 56 // Overridden from Task: | 60 // Overridden from Task: |
| 57 virtual void RunOnWorkerThread() override { | 61 virtual void RunOnWorkerThread() override { |
| 58 skia::RefPtr<SkCanvas> canvas = raster_buffer_->AcquireSkCanvas(); | 62 raster_buffer_->Playback( |
| 59 DCHECK(canvas); | 63 picture_pile_.get(), gfx::Rect(0, 0, 1, 1), 1.0, NULL); |
| 60 canvas->drawColor(SK_ColorWHITE); | |
| 61 raster_buffer_->ReleaseSkCanvas(canvas); | |
| 62 } | 64 } |
| 63 | 65 |
| 64 // Overridden from RasterizerTask: | 66 // Overridden from RasterizerTask: |
| 65 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) override { | 67 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) override { |
| 66 raster_buffer_ = client->AcquireBufferForRaster(resource()); | 68 raster_buffer_ = client->AcquireBufferForRaster(resource()); |
| 67 } | 69 } |
| 68 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) override { | 70 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) override { |
| 69 client->ReleaseBufferForRaster(raster_buffer_.Pass()); | 71 client->ReleaseBufferForRaster(raster_buffer_.Pass()); |
| 70 } | 72 } |
| 71 virtual void RunReplyOnOriginThread() override { | 73 virtual void RunReplyOnOriginThread() override { |
| 72 reply_.Run(PicturePileImpl::Analysis(), !HasFinishedRunning()); | 74 reply_.Run(PicturePileImpl::Analysis(), !HasFinishedRunning()); |
| 73 } | 75 } |
| 74 | 76 |
| 75 protected: | 77 protected: |
| 76 virtual ~TestRasterTaskImpl() {} | 78 virtual ~TestRasterTaskImpl() {} |
| 77 | 79 |
| 78 private: | 80 private: |
| 79 const Reply reply_; | 81 const Reply reply_; |
| 80 scoped_ptr<RasterBuffer> raster_buffer_; | 82 scoped_ptr<RasterBuffer> raster_buffer_; |
| 83 scoped_refptr<PicturePileImpl> picture_pile_; |
| 81 | 84 |
| 82 DISALLOW_COPY_AND_ASSIGN(TestRasterTaskImpl); | 85 DISALLOW_COPY_AND_ASSIGN(TestRasterTaskImpl); |
| 83 }; | 86 }; |
| 84 | 87 |
| 85 class BlockingTestRasterTaskImpl : public TestRasterTaskImpl { | 88 class BlockingTestRasterTaskImpl : public TestRasterTaskImpl { |
| 86 public: | 89 public: |
| 87 BlockingTestRasterTaskImpl(const Resource* resource, | 90 BlockingTestRasterTaskImpl(const Resource* resource, |
| 88 const Reply& reply, | 91 const Reply& reply, |
| 89 base::Lock* lock, | 92 base::Lock* lock, |
| 90 ImageDecodeTask::Vector* dependencies) | 93 ImageDecodeTask::Vector* dependencies) |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 403 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
| 401 RasterWorkerPoolTest, | 404 RasterWorkerPoolTest, |
| 402 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 405 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 403 RASTER_WORKER_POOL_TYPE_ZERO_COPY, | 406 RASTER_WORKER_POOL_TYPE_ZERO_COPY, |
| 404 RASTER_WORKER_POOL_TYPE_ONE_COPY, | 407 RASTER_WORKER_POOL_TYPE_ONE_COPY, |
| 405 RASTER_WORKER_POOL_TYPE_GPU, | 408 RASTER_WORKER_POOL_TYPE_GPU, |
| 406 RASTER_WORKER_POOL_TYPE_BITMAP)); | 409 RASTER_WORKER_POOL_TYPE_BITMAP)); |
| 407 | 410 |
| 408 } // namespace | 411 } // namespace |
| 409 } // namespace cc | 412 } // namespace cc |
| OLD | NEW |