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

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: reveman comments 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
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..98319948455bd608798dcaf3a280fc737a2626ed 100644
--- a/cc/resources/raster_worker_pool_unittest.cc
+++ b/cc/resources/raster_worker_pool_unittest.cc
@@ -27,6 +27,11 @@
namespace cc {
namespace {
+const size_t kMaxTransferBufferUsageBytes = 10000U;
+// A resource of this dimension^2 * 4 must be greater than the above transfer
+// buffer constant.
+const size_t kLargeResourceDimension = 1000U;
+
enum RasterWorkerPoolType {
RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER,
RASTER_WORKER_POOL_TYPE_IMAGE,
@@ -126,7 +131,7 @@ class RasterWorkerPoolTest
RasterWorkerPool::GetTaskGraphRunner(),
context_provider_.get(),
resource_provider_.get(),
- std::numeric_limits<size_t>::max());
+ kMaxTransferBufferUsageBytes);
break;
case RASTER_WORKER_POOL_TYPE_IMAGE:
raster_worker_pool_ = ImageRasterWorkerPool::Create(
@@ -203,9 +208,7 @@ class RasterWorkerPoolTest
raster_worker_pool_->AsRasterizer()->ScheduleTasks(&queue);
}
- void AppendTask(unsigned id) {
- const gfx::Size size(1, 1);
-
+ void AppendTask(unsigned id, const gfx::Size& size) {
scoped_ptr<ScopedResource> resource(
ScopedResource::Create(resource_provider_.get()));
resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888);
@@ -221,6 +224,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 +275,7 @@ class RasterWorkerPoolTest
scoped_ptr<RasterWorkerPool> raster_worker_pool_;
base::CancelableClosure timeout_;
int timeout_seconds_;
+ size_t throttle_bytes_;
reveman 2014/08/21 02:07:00 unused, right?
enne (OOO) 2014/08/21 17:10:51 Done.
bool timed_out_;
RasterTaskVector tasks_;
std::vector<RasterTaskResult> completed_tasks_;
@@ -324,6 +330,27 @@ TEST_P(RasterWorkerPoolTest, FalseThrottling) {
RunMessageLoopUntilAllTasksHaveCompleted();
}
+TEST_P(RasterWorkerPoolTest, LargeResources) {
+ gfx::Size size(kLargeResourceDimension, kLargeResourceDimension);
+
+ {
+ // Verify a resource of this size is larger than the transfer buffer.
+ scoped_ptr<ScopedResource> resource(
+ ScopedResource::Create(resource_provider_.get()));
+ resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888);
+ EXPECT_GE(resource->bytes(), kMaxTransferBufferUsageBytes);
+ }
+
+ 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(RasterWorkerPoolTests,
RasterWorkerPoolTest,
::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER,
« 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