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

Unified Diff: cc/resources/raster_worker_pool_unittest.cc

Issue 489293002: cc: Don't infinitely throttle large raster tasks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: cc/resources/raster_worker_pool_unittest.cc
diff --git a/cc/resources/raster_worker_pool_unittest.cc b/cc/resources/raster_worker_pool_unittest.cc
index 3b43c099b97074ce17065cbdbf8e0407bbd2fde4..96127ebca66adcd23e40ccde599c09d9381d6f38 100644
--- a/cc/resources/raster_worker_pool_unittest.cc
+++ b/cc/resources/raster_worker_pool_unittest.cc
@@ -107,6 +107,7 @@ class RasterWorkerPoolTest
RasterWorkerPoolTest()
: context_provider_(TestContextProvider::Create()),
timeout_seconds_(5),
+ throttle_bytes_(10000),
timed_out_(false) {
output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass();
CHECK(output_surface_->BindToClient(&output_surface_client_));
@@ -126,7 +127,7 @@ class RasterWorkerPoolTest
RasterWorkerPool::GetTaskGraphRunner(),
context_provider_.get(),
resource_provider_.get(),
- std::numeric_limits<size_t>::max());
+ throttle_bytes_);
break;
case RASTER_WORKER_POOL_TYPE_IMAGE:
raster_worker_pool_ = ImageRasterWorkerPool::Create(
@@ -203,9 +204,7 @@ class RasterWorkerPoolTest
raster_worker_pool_->AsRasterizer()->ScheduleTasks(&queue);
}
- void AppendTask(unsigned id) {
- const gfx::Size size(1, 1);
-
+ void AppendTask(unsigned id, gfx::Size size) {
reveman 2014/08/21 01:15:47 nit: const gfx::Size& size
enne (OOO) 2014/08/21 01:34:15 Done.
scoped_ptr<ScopedResource> resource(
ScopedResource::Create(resource_provider_.get()));
resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888);
@@ -221,6 +220,8 @@ class RasterWorkerPoolTest
&empty));
}
+ void AppendTask(unsigned id) { AppendTask(id, gfx::Size(1, 1)); }
+
void AppendBlockingTask(unsigned id, base::Lock* lock) {
const gfx::Size size(1, 1);
@@ -270,6 +271,7 @@ class RasterWorkerPoolTest
scoped_ptr<RasterWorkerPool> raster_worker_pool_;
base::CancelableClosure timeout_;
int timeout_seconds_;
+ size_t throttle_bytes_;
reveman 2014/08/21 01:15:47 nit: max_transfer_buffer_usage_bytes_ as from this
enne (OOO) 2014/08/21 01:34:16 Done.
bool timed_out_;
RasterTaskVector tasks_;
std::vector<RasterTaskResult> completed_tasks_;
@@ -331,5 +333,33 @@ INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests,
RASTER_WORKER_POOL_TYPE_IMAGE_COPY,
RASTER_WORKER_POOL_TYPE_GPU));
+class PixelBufferRasterWorkerPoolTest : public RasterWorkerPoolTest {};
+
+TEST_P(PixelBufferRasterWorkerPoolTest, BigTaskThrottling) {
reveman 2014/08/21 01:15:47 How about we call this LargeResources and run it f
enne (OOO) 2014/08/21 01:34:15 Done.
+ gfx::Size size(1000, 1000);
+
+ {
+ // Verify a resource of this size will get throttled.
reveman 2014/08/21 01:15:47 are we missing a "not" here? Maybe just "Verify a
enne (OOO) 2014/08/21 01:34:16 No, but maybe it should be "could get throttled".
+ scoped_ptr<ScopedResource> resource(
+ ScopedResource::Create(resource_provider_.get()));
+ resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888);
+ EXPECT_GE(resource->bytes(), throttle_bytes_);
reveman 2014/08/21 01:15:47 Could you instead compute |size| based on kMaxTran
enne (OOO) 2014/08/21 01:34:15 That's why there's the block of code right here, t
+ }
+
+ AppendTask(0u, size);
+ AppendTask(1u, size);
+ AppendTask(2u, size);
+ ScheduleTasks();
+
+ // This will time out if a resource that is larger than the throttle limit
+ // never gets scheduled.
+ RunMessageLoopUntilAllTasksHaveCompleted();
+}
+
+INSTANTIATE_TEST_CASE_P(
+ PixelBufferRasterWorkerPoolTests,
+ PixelBufferRasterWorkerPoolTest,
+ ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER));
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698