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

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

Issue 2240993002: Change ResourcePool reuse to have looser size constraints. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp73_rp_refactor
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « cc/resources/resource_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/resource_pool.h" 5 #include "cc/resources/resource_pool.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // content ID and that it has the expected invalidated rect. 303 // content ID and that it has the expected invalidated rect.
304 gfx::Rect total_invalidated_rect; 304 gfx::Rect total_invalidated_rect;
305 reacquired_resource = resource_pool_->TryAcquireResourceForPartialRaster( 305 reacquired_resource = resource_pool_->TryAcquireResourceForPartialRaster(
306 content_ids[2], second_invalidated_rect, content_ids[1], 306 content_ids[2], second_invalidated_rect, content_ids[1],
307 &total_invalidated_rect); 307 &total_invalidated_rect);
308 EXPECT_EQ(resource, reacquired_resource); 308 EXPECT_EQ(resource, reacquired_resource);
309 EXPECT_EQ(expected_total_invalidated_rect, total_invalidated_rect); 309 EXPECT_EQ(expected_total_invalidated_rect, total_invalidated_rect);
310 resource_pool_->ReleaseResource(reacquired_resource); 310 resource_pool_->ReleaseResource(reacquired_resource);
311 } 311 }
312 312
313 TEST_F(ResourcePoolTest, ReuseResourceExactMatch) {
314 ResourceFormat format = RGBA_8888;
315 gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB();
316
317 // Create unused resources with sizes close to 100, 100.
318 resource_pool_->ReleaseResource(
319 resource_pool_->CreateResource(gfx::Size(99, 100), format, color_space));
320 resource_pool_->ReleaseResource(
321 resource_pool_->CreateResource(gfx::Size(99, 99), format, color_space));
322 resource_pool_->ReleaseResource(
323 resource_pool_->CreateResource(gfx::Size(100, 99), format, color_space));
324 resource_pool_->ReleaseResource(
325 resource_pool_->CreateResource(gfx::Size(101, 101), format, color_space));
326 resource_pool_->CheckBusyResources();
327
328 gfx::Size size(100, 100);
329 EXPECT_EQ(nullptr,
330 resource_pool_->ReuseResource(size, size, format, color_space));
331 size = gfx::Size(100, 99);
332 EXPECT_NE(nullptr,
333 resource_pool_->ReuseResource(size, size, format, color_space));
334 EXPECT_EQ(nullptr,
335 resource_pool_->ReuseResource(size, size, format, color_space));
336 }
337
338 TEST_F(ResourcePoolTest, ReuseResourceFuzzyMatch) {
339 ResourceFormat format = RGBA_8888;
340 gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB();
341
342 // Create unused resources with sizes close to 100, 100.
343 resource_pool_->ReleaseResource(
344 resource_pool_->CreateResource(gfx::Size(99, 100), format, color_space));
345 resource_pool_->ReleaseResource(
346 resource_pool_->CreateResource(gfx::Size(99, 99), format, color_space));
347 resource_pool_->ReleaseResource(
348 resource_pool_->CreateResource(gfx::Size(100, 99), format, color_space));
349 resource_pool_->ReleaseResource(
350 resource_pool_->CreateResource(gfx::Size(101, 101), format, color_space));
351 resource_pool_->ReleaseResource(
352 resource_pool_->CreateResource(gfx::Size(202, 202), format, color_space));
353 resource_pool_->CheckBusyResources();
354
355 EXPECT_EQ(nullptr,
356 resource_pool_->ReuseResource(
357 gfx::Size(50, 100), gfx::Size(50, 102), format, color_space));
358 EXPECT_EQ(nullptr,
359 resource_pool_->ReuseResource(
360 gfx::Size(100, 102), gfx::Size(102, 102), format, color_space));
361 EXPECT_NE(nullptr,
362 resource_pool_->ReuseResource(
363 gfx::Size(100, 100), gfx::Size(200, 200), format, color_space));
364 EXPECT_EQ(nullptr,
365 resource_pool_->ReuseResource(
366 gfx::Size(100, 100), gfx::Size(200, 200), format, color_space));
367 }
368
313 } // namespace 369 } // namespace
314 } // namespace cc 370 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698