Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: cc/resources/raster_worker_pool_unittest.cc

Issue 131763003: cc: Fix logic for detecting when raster tasks were throttled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/resources/image_raster_worker_pool.h" 10 #include "cc/resources/image_raster_worker_pool.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 protected: 63 protected:
64 virtual ~TestRasterWorkerPoolTaskImpl() {} 64 virtual ~TestRasterWorkerPoolTaskImpl() {}
65 65
66 private: 66 private:
67 const Reply reply_; 67 const Reply reply_;
68 RasterThread raster_thread_; 68 RasterThread raster_thread_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(TestRasterWorkerPoolTaskImpl); 70 DISALLOW_COPY_AND_ASSIGN(TestRasterWorkerPoolTaskImpl);
71 }; 71 };
72 72
73 class BlockingRasterWorkerPoolTaskImpl : public TestRasterWorkerPoolTaskImpl {
74 public:
75 BlockingRasterWorkerPoolTaskImpl(const Resource* resource,
76 const Reply& reply,
77 base::Lock* lock,
78 TaskVector* dependencies,
79 bool use_gpu_rasterization)
80 : TestRasterWorkerPoolTaskImpl(resource,
81 reply,
82 dependencies,
83 use_gpu_rasterization),
84 lock_(lock) {}
85
86 // Overridden from TestRasterWorkerPoolTaskImpl:
87 virtual bool RunOnWorkerThread(unsigned thread_index,
88 void* buffer,
89 gfx::Size size,
90 int stride) OVERRIDE {
91 base::AutoLock lock(*lock_);
92 return TestRasterWorkerPoolTaskImpl::RunOnWorkerThread(
93 thread_index, buffer, size, stride);
94 }
95 virtual void CompleteOnOriginThread() OVERRIDE {}
96
97 protected:
98 virtual ~BlockingRasterWorkerPoolTaskImpl() {}
99
100 private:
101 base::Lock* lock_;
102
103 DISALLOW_COPY_AND_ASSIGN(BlockingRasterWorkerPoolTaskImpl);
104 };
105
73 class RasterWorkerPoolTest : public testing::Test, 106 class RasterWorkerPoolTest : public testing::Test,
74 public RasterWorkerPoolClient { 107 public RasterWorkerPoolClient {
75 public: 108 public:
76 RasterWorkerPoolTest() 109 RasterWorkerPoolTest()
77 : context_provider_(TestContextProvider::Create()), 110 : context_provider_(TestContextProvider::Create()),
78 check_interval_milliseconds_(1), 111 check_interval_milliseconds_(1),
79 timeout_seconds_(5), 112 timeout_seconds_(5),
80 timed_out_(false) { 113 timed_out_(false) {
81 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); 114 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass();
82 CHECK(output_surface_->BindToClient(&output_surface_client_)); 115 CHECK(output_surface_->BindToClient(&output_surface_client_));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 RasterWorkerPool::RasterTask(new TestRasterWorkerPoolTaskImpl( 216 RasterWorkerPool::RasterTask(new TestRasterWorkerPoolTaskImpl(
184 const_resource, 217 const_resource,
185 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted, 218 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted,
186 base::Unretained(this), 219 base::Unretained(this),
187 base::Passed(&resource), 220 base::Passed(&resource),
188 id), 221 id),
189 &empty.tasks_, 222 &empty.tasks_,
190 use_gpu_rasterization))); 223 use_gpu_rasterization)));
191 } 224 }
192 225
226 void AppendBlockingTask(unsigned id, base::Lock* lock) {
227 const gfx::Size size(1, 1);
228
229 scoped_ptr<ScopedResource> resource(
230 ScopedResource::Create(resource_provider()));
231 resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888);
232 const Resource* const_resource = resource.get();
233
234 RasterWorkerPool::Task::Set empty;
235 tasks_.push_back(
236 RasterWorkerPool::RasterTask(new BlockingRasterWorkerPoolTaskImpl(
237 const_resource,
238 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted,
239 base::Unretained(this),
240 base::Passed(&resource),
241 id),
242 lock,
243 &empty.tasks_,
244 false)));
245 }
246
193 virtual void OnTaskCompleted( 247 virtual void OnTaskCompleted(
194 scoped_ptr<ScopedResource> resource, 248 scoped_ptr<ScopedResource> resource,
195 unsigned id, 249 unsigned id,
196 const PicturePileImpl::Analysis& analysis, 250 const PicturePileImpl::Analysis& analysis,
197 bool was_canceled, 251 bool was_canceled,
198 TestRasterWorkerPoolTaskImpl::RasterThread raster_thread) {} 252 TestRasterWorkerPoolTaskImpl::RasterThread raster_thread) {}
199 253
200 private: 254 private:
201 void ScheduleCheckForCompletedTasks() { 255 void ScheduleCheckForCompletedTasks() {
202 check_.Reset(base::Bind(&RasterWorkerPoolTest::OnCheckForCompletedTasks, 256 check_.Reset(base::Bind(&RasterWorkerPoolTest::OnCheckForCompletedTasks,
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 426 }
373 427
374 virtual void AfterTest() OVERRIDE { 428 virtual void AfterTest() OVERRIDE {
375 ASSERT_EQ(1u, tasks_.size()); 429 ASSERT_EQ(1u, tasks_.size());
376 tasks_.clear(); 430 tasks_.clear();
377 } 431 }
378 }; 432 };
379 433
380 PIXEL_BUFFER_AND_IMAGE_TEST_F(RasterWorkerPoolTestFailedMapResource); 434 PIXEL_BUFFER_AND_IMAGE_TEST_F(RasterWorkerPoolTestFailedMapResource);
381 435
436 class RasterWorkerPoolTestFalseThrottling : public RasterWorkerPoolTest {
437 public:
438 // Overridden from RasterWorkerPoolTest:
439 virtual void BeginTest() OVERRIDE {
440 // This test checks that replacing a pending raster task with another does
441 // not prevent the DidFinishRunningTasks notification from being sent.
442
443 // Schedule a task that is prevented from completing with a lock.
444 lock_.Acquire();
445 AppendBlockingTask(0u, &lock_);
446 ScheduleTasks();
447
448 // Schedule another task to replace the still-pending task. Because the old
449 // task is not a throttled task in the new task set, it should not prevent
450 // DidFinishRunningTasks from getting signaled.
451 tasks_.clear();
452 AppendTask(1u, false);
453 ScheduleTasks();
454
455 // Unblock the first task to allow the second task to complete.
456 lock_.Release();
457 }
458
459 virtual void AfterTest() OVERRIDE {}
460
461 virtual void DidFinishRunningTasks() OVERRIDE {
462 EndTest();
463 }
464
465 base::Lock lock_;
466 };
467
468 PIXEL_BUFFER_AND_IMAGE_TEST_F(RasterWorkerPoolTestFalseThrottling);
469
382 } // namespace 470 } // namespace
383 471
384 } // namespace cc 472 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698