| 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 28 matching lines...) Expand all Loading... |
| 109 | 116 |
| 110 typedef std::vector<scoped_refptr<RasterTask> > RasterTaskVector; | 117 typedef std::vector<scoped_refptr<RasterTask> > RasterTaskVector; |
| 111 | 118 |
| 112 RasterWorkerPoolTest() | 119 RasterWorkerPoolTest() |
| 113 : context_provider_(TestContextProvider::Create()), | 120 : context_provider_(TestContextProvider::Create()), |
| 114 timeout_seconds_(5), | 121 timeout_seconds_(5), |
| 115 timed_out_(false) { | 122 timed_out_(false) { |
| 116 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 123 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 117 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 124 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 118 | 125 |
| 126 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); |
| 127 context3d->set_support_sync_query(true); |
| 128 |
| 119 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 129 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 120 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 130 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 121 shared_bitmap_manager_.get(), | 131 shared_bitmap_manager_.get(), |
| 122 NULL, | 132 NULL, |
| 123 0, | 133 0, |
| 124 false, | 134 false, |
| 125 1, | 135 1, |
| 126 false).Pass(); | 136 false).Pass(); |
| 127 staging_resource_pool_ = ResourcePool::Create( | 137 staging_resource_pool_ = ResourcePool::Create( |
| 128 resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); | 138 resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 365 |
| 356 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 366 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
| 357 RasterWorkerPoolTest, | 367 RasterWorkerPoolTest, |
| 358 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 368 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 359 RASTER_WORKER_POOL_TYPE_IMAGE, | 369 RASTER_WORKER_POOL_TYPE_IMAGE, |
| 360 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, | 370 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, |
| 361 RASTER_WORKER_POOL_TYPE_GPU)); | 371 RASTER_WORKER_POOL_TYPE_GPU)); |
| 362 | 372 |
| 363 } // namespace | 373 } // namespace |
| 364 } // namespace cc | 374 } // namespace cc |
| OLD | NEW |