| 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/gpu_raster_worker_pool.h" | 11 #include "cc/resources/gpu_raster_worker_pool.h" |
| 12 #include "cc/resources/image_copy_raster_worker_pool.h" | 12 #include "cc/resources/image_copy_raster_worker_pool.h" |
| 13 #include "cc/resources/image_raster_worker_pool.h" | 13 #include "cc/resources/image_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/rasterizer.h" | 18 #include "cc/resources/rasterizer.h" |
| 18 #include "cc/resources/resource_pool.h" | 19 #include "cc/resources/resource_pool.h" |
| 19 #include "cc/resources/resource_provider.h" | 20 #include "cc/resources/resource_provider.h" |
| 20 #include "cc/resources/scoped_resource.h" | 21 #include "cc/resources/scoped_resource.h" |
| 21 #include "cc/test/fake_output_surface.h" | 22 #include "cc/test/fake_output_surface.h" |
| 22 #include "cc/test/fake_output_surface_client.h" | 23 #include "cc/test/fake_output_surface_client.h" |
| 23 #include "cc/test/test_shared_bitmap_manager.h" | 24 #include "cc/test/test_shared_bitmap_manager.h" |
| 24 #include "cc/test/test_web_graphics_context_3d.h" | 25 #include "cc/test/test_web_graphics_context_3d.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 public: | 44 public: |
| 44 typedef base::Callback< | 45 typedef base::Callback< |
| 45 void(const PicturePileImpl::Analysis& analysis, bool was_canceled)> Reply; | 46 void(const PicturePileImpl::Analysis& analysis, bool was_canceled)> Reply; |
| 46 | 47 |
| 47 TestRasterTaskImpl(const Resource* resource, | 48 TestRasterTaskImpl(const Resource* resource, |
| 48 const Reply& reply, | 49 const Reply& reply, |
| 49 ImageDecodeTask::Vector* dependencies) | 50 ImageDecodeTask::Vector* dependencies) |
| 50 : RasterTask(resource, dependencies), reply_(reply) {} | 51 : RasterTask(resource, dependencies), reply_(reply) {} |
| 51 | 52 |
| 52 // Overridden from Task: | 53 // Overridden from Task: |
| 53 virtual void RunOnWorkerThread() OVERRIDE {} | 54 virtual void RunOnWorkerThread() OVERRIDE { |
| 55 skia::RefPtr<SkCanvas> canvas = raster_buffer_->AcquireSkCanvas(); |
| 56 DCHECK(canvas); |
| 57 canvas->drawColor(SK_ColorWHITE); |
| 58 raster_buffer_->ReleaseSkCanvas(canvas); |
| 59 } |
| 54 | 60 |
| 55 // Overridden from RasterizerTask: | 61 // Overridden from RasterizerTask: |
| 56 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { | 62 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { |
| 57 client->AcquireBufferForRaster(this); | 63 raster_buffer_ = client->AcquireBufferForRaster(resource()); |
| 58 } | 64 } |
| 59 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { | 65 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { |
| 60 client->ReleaseBufferForRaster(this); | 66 client->ReleaseBufferForRaster(raster_buffer_.Pass()); |
| 61 } | 67 } |
| 62 virtual void RunReplyOnOriginThread() OVERRIDE { | 68 virtual void RunReplyOnOriginThread() OVERRIDE { |
| 63 reply_.Run(PicturePileImpl::Analysis(), !HasFinishedRunning()); | 69 reply_.Run(PicturePileImpl::Analysis(), !HasFinishedRunning()); |
| 64 } | 70 } |
| 65 | 71 |
| 66 protected: | 72 protected: |
| 67 virtual ~TestRasterTaskImpl() {} | 73 virtual ~TestRasterTaskImpl() {} |
| 68 | 74 |
| 69 private: | 75 private: |
| 70 const Reply reply_; | 76 const Reply reply_; |
| 77 scoped_ptr<RasterBuffer> raster_buffer_; |
| 71 | 78 |
| 72 DISALLOW_COPY_AND_ASSIGN(TestRasterTaskImpl); | 79 DISALLOW_COPY_AND_ASSIGN(TestRasterTaskImpl); |
| 73 }; | 80 }; |
| 74 | 81 |
| 75 class BlockingTestRasterTaskImpl : public TestRasterTaskImpl { | 82 class BlockingTestRasterTaskImpl : public TestRasterTaskImpl { |
| 76 public: | 83 public: |
| 77 BlockingTestRasterTaskImpl(const Resource* resource, | 84 BlockingTestRasterTaskImpl(const Resource* resource, |
| 78 const Reply& reply, | 85 const Reply& reply, |
| 79 base::Lock* lock, | 86 base::Lock* lock, |
| 80 ImageDecodeTask::Vector* dependencies) | 87 ImageDecodeTask::Vector* dependencies) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 111 | 118 |
| 112 enum NamedTaskSet { REQUIRED_FOR_ACTIVATION = 0, ALL = 1 }; | 119 enum NamedTaskSet { REQUIRED_FOR_ACTIVATION = 0, ALL = 1 }; |
| 113 | 120 |
| 114 RasterWorkerPoolTest() | 121 RasterWorkerPoolTest() |
| 115 : context_provider_(TestContextProvider::Create()), | 122 : context_provider_(TestContextProvider::Create()), |
| 116 timeout_seconds_(5), | 123 timeout_seconds_(5), |
| 117 timed_out_(false) { | 124 timed_out_(false) { |
| 118 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 125 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 119 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 126 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 120 | 127 |
| 128 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); |
| 129 context3d->set_support_sync_query(true); |
| 130 |
| 121 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 131 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 122 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 132 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 123 shared_bitmap_manager_.get(), | 133 shared_bitmap_manager_.get(), |
| 124 NULL, | 134 NULL, |
| 125 0, | 135 0, |
| 126 false, | 136 false, |
| 127 1, | 137 1, |
| 128 false).Pass(); | 138 false).Pass(); |
| 129 staging_resource_pool_ = ResourcePool::Create( | 139 staging_resource_pool_ = ResourcePool::Create( |
| 130 resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); | 140 resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 370 |
| 361 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 371 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
| 362 RasterWorkerPoolTest, | 372 RasterWorkerPoolTest, |
| 363 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 373 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 364 RASTER_WORKER_POOL_TYPE_IMAGE, | 374 RASTER_WORKER_POOL_TYPE_IMAGE, |
| 365 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, | 375 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, |
| 366 RASTER_WORKER_POOL_TYPE_GPU)); | 376 RASTER_WORKER_POOL_TYPE_GPU)); |
| 367 | 377 |
| 368 } // namespace | 378 } // namespace |
| 369 } // namespace cc | 379 } // namespace cc |
| OLD | NEW |