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 "cc/debug/test_web_graphics_context_3d.h" | 10 #include "cc/debug/test_web_graphics_context_3d.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 TestRasterWorkerPoolTaskImpl( | 29 TestRasterWorkerPoolTaskImpl( |
30 const Resource* resource, | 30 const Resource* resource, |
31 const Reply& reply, | 31 const Reply& reply, |
32 TaskVector* dependencies) | 32 TaskVector* dependencies) |
33 : internal::RasterWorkerPoolTask(resource, dependencies), | 33 : internal::RasterWorkerPoolTask(resource, dependencies), |
34 reply_(reply), | 34 reply_(reply), |
35 did_raster_(false) {} | 35 did_raster_(false) {} |
36 | 36 |
37 // Overridden from internal::WorkerPoolTask: | 37 // Overridden from internal::WorkerPoolTask: |
38 virtual bool RunOnWorkerThread(SkBaseDevice* device, unsigned thread_index) | 38 virtual bool RunOnWorkerThread(unsigned thread_index, |
39 OVERRIDE { | 39 void* buffer, |
| 40 gfx::Size size, |
| 41 int stride) OVERRIDE { |
40 did_raster_ = true; | 42 did_raster_ = true; |
41 return true; | 43 return true; |
42 } | 44 } |
43 virtual void CompleteOnOriginThread() OVERRIDE { | 45 virtual void CompleteOnOriginThread() OVERRIDE { |
44 reply_.Run(PicturePileImpl::Analysis(), !HasFinishedRunning(), did_raster_); | 46 reply_.Run(PicturePileImpl::Analysis(), !HasFinishedRunning(), did_raster_); |
45 } | 47 } |
46 | 48 |
47 protected: | 49 protected: |
48 virtual ~TestRasterWorkerPoolTaskImpl() {} | 50 virtual ~TestRasterWorkerPoolTaskImpl() {} |
49 | 51 |
50 private: | 52 private: |
51 const Reply reply_; | 53 const Reply reply_; |
52 bool did_raster_; | 54 bool did_raster_; |
53 | 55 |
54 DISALLOW_COPY_AND_ASSIGN(TestRasterWorkerPoolTaskImpl); | 56 DISALLOW_COPY_AND_ASSIGN(TestRasterWorkerPoolTaskImpl); |
55 }; | 57 }; |
56 | 58 |
57 class RasterWorkerPoolTest : public testing::Test, | 59 class RasterWorkerPoolTest : public testing::Test, |
58 public RasterWorkerPoolClient { | 60 public RasterWorkerPoolClient { |
59 public: | 61 public: |
60 RasterWorkerPoolTest() | 62 RasterWorkerPoolTest() |
61 : context_provider_(TestContextProvider::Create()), | 63 : context_provider_(TestContextProvider::Create()), |
62 check_interval_milliseconds_(1), | 64 check_interval_milliseconds_(1), |
63 timeout_seconds_(5), | 65 timeout_seconds_(5), |
64 timed_out_(false) { | 66 timed_out_(false) { |
65 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 67 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
66 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 68 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
67 | 69 |
68 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 70 resource_provider_ = |
69 0).Pass(); | 71 ResourceProvider::Create(output_surface_.get(), 0, false).Pass(); |
70 } | 72 } |
71 virtual ~RasterWorkerPoolTest() { | 73 virtual ~RasterWorkerPoolTest() { |
72 resource_provider_.reset(); | 74 resource_provider_.reset(); |
73 } | 75 } |
74 | 76 |
75 // Overridden from testing::Test: | 77 // Overridden from testing::Test: |
76 virtual void TearDown() OVERRIDE { | 78 virtual void TearDown() OVERRIDE { |
77 if (!raster_worker_pool_) | 79 if (!raster_worker_pool_) |
78 return; | 80 return; |
79 raster_worker_pool_->Shutdown(); | 81 raster_worker_pool_->Shutdown(); |
(...skipping 17 matching lines...) Expand all Loading... |
97 | 99 |
98 RasterWorkerPool* worker_pool() { | 100 RasterWorkerPool* worker_pool() { |
99 return raster_worker_pool_.get(); | 101 return raster_worker_pool_.get(); |
100 } | 102 } |
101 | 103 |
102 void RunTest(bool use_map_image) { | 104 void RunTest(bool use_map_image) { |
103 if (use_map_image) { | 105 if (use_map_image) { |
104 raster_worker_pool_ = ImageRasterWorkerPool::Create( | 106 raster_worker_pool_ = ImageRasterWorkerPool::Create( |
105 resource_provider(), 1); | 107 resource_provider(), 1); |
106 } else { | 108 } else { |
107 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( | 109 raster_worker_pool_ = |
108 resource_provider(), 1, std::numeric_limits<size_t>::max()); | 110 PixelBufferRasterWorkerPool::Create( |
| 111 resource_provider(), |
| 112 1, |
| 113 std::numeric_limits<size_t>::max()); |
109 } | 114 } |
110 | 115 |
111 raster_worker_pool_->SetClient(this); | 116 raster_worker_pool_->SetClient(this); |
112 | 117 |
113 BeginTest(); | 118 BeginTest(); |
114 | 119 |
115 ScheduleCheckForCompletedTasks(); | 120 ScheduleCheckForCompletedTasks(); |
116 | 121 |
117 if (timeout_seconds_) { | 122 if (timeout_seconds_) { |
118 timeout_.Reset(base::Bind(&RasterWorkerPoolTest::OnTimeout, | 123 timeout_.Reset(base::Bind(&RasterWorkerPoolTest::OnTimeout, |
(...skipping 29 matching lines...) Expand all Loading... |
148 tasks.Append(*it, false); | 153 tasks.Append(*it, false); |
149 | 154 |
150 worker_pool()->ScheduleTasks(&tasks); | 155 worker_pool()->ScheduleTasks(&tasks); |
151 } | 156 } |
152 | 157 |
153 void AppendTask(unsigned id) { | 158 void AppendTask(unsigned id) { |
154 const gfx::Size size(1, 1); | 159 const gfx::Size size(1, 1); |
155 | 160 |
156 scoped_ptr<ScopedResource> resource( | 161 scoped_ptr<ScopedResource> resource( |
157 ScopedResource::create(resource_provider())); | 162 ScopedResource::create(resource_provider())); |
158 resource->Allocate(size, GL_RGBA, ResourceProvider::TextureUsageAny); | 163 resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); |
159 const Resource* const_resource = resource.get(); | 164 const Resource* const_resource = resource.get(); |
160 | 165 |
161 RasterWorkerPool::Task::Set empty; | 166 RasterWorkerPool::Task::Set empty; |
162 tasks_.push_back( | 167 tasks_.push_back( |
163 RasterWorkerPool::RasterTask(new TestRasterWorkerPoolTaskImpl( | 168 RasterWorkerPool::RasterTask(new TestRasterWorkerPoolTaskImpl( |
164 const_resource, | 169 const_resource, |
165 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted, | 170 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted, |
166 base::Unretained(this), | 171 base::Unretained(this), |
167 base::Passed(&resource), | 172 base::Passed(&resource), |
168 id), | 173 id), |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 ASSERT_EQ(1u, tasks_.size()); | 283 ASSERT_EQ(1u, tasks_.size()); |
279 tasks_.clear(); | 284 tasks_.clear(); |
280 } | 285 } |
281 }; | 286 }; |
282 | 287 |
283 PIXEL_BUFFER_AND_IMAGE_TEST_F(RasterWorkerPoolTestFailedMapResource); | 288 PIXEL_BUFFER_AND_IMAGE_TEST_F(RasterWorkerPoolTestFailedMapResource); |
284 | 289 |
285 } // namespace | 290 } // namespace |
286 | 291 |
287 } // namespace cc | 292 } // namespace cc |
OLD | NEW |