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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 275563005: cleanup GrContext resource cache api (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix use of SK_ATTR_DEPRECATED Created 6 years, 7 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 | « tests/ResourceCacheTest.cpp ('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 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 canvas->clear(1); 297 canvas->clear(1);
298 surface->newImageSnapshot()->unref(); // Create and destroy SkImage 298 surface->newImageSnapshot()->unref(); // Create and destroy SkImage
299 canvas->clear(2); // Must not assert internally 299 canvas->clear(2); // Must not assert internally
300 } 300 }
301 301
302 #if SK_SUPPORT_GPU 302 #if SK_SUPPORT_GPU
303 static void TestSurfaceInCache(skiatest::Reporter* reporter, 303 static void TestSurfaceInCache(skiatest::Reporter* reporter,
304 SurfaceType surfaceType, 304 SurfaceType surfaceType,
305 GrContext* context) { 305 GrContext* context) {
306 context->freeGpuResources(); 306 context->freeGpuResources();
307 REPORTER_ASSERT(reporter, 0 == context->getGpuTextureCacheResourceCount()); 307 int resourceCount;
308
309 context->getResourceCacheUsage(&resourceCount, NULL);
310 REPORTER_ASSERT(reporter, 0 == resourceCount);
308 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context)); 311 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context));
309 // Note: the stencil buffer is always cached, so kGpu_SurfaceType uses 312 // Note: the stencil buffer is always cached, so kGpu_SurfaceType uses
310 // one cached resource, and kGpuScratch_SurfaceType uses two. 313 // one cached resource, and kGpuScratch_SurfaceType uses two.
311 int expectedCachedResources = surfaceType == kGpuScratch_SurfaceType ? 2 : 1 ; 314 int expectedCachedResources = surfaceType == kGpuScratch_SurfaceType ? 2 : 1 ;
312 REPORTER_ASSERT(reporter, expectedCachedResources == context->getGpuTextureC acheResourceCount()); 315 context->getResourceCacheUsage(&resourceCount, NULL);
316 REPORTER_ASSERT(reporter, expectedCachedResources == resourceCount);
313 317
314 // Verify that all the cached resources are locked in cache. 318 // Verify that all the cached resources are locked in cache.
315 context->freeGpuResources(); 319 context->freeGpuResources();
316 REPORTER_ASSERT(reporter, expectedCachedResources == context->getGpuTextureC acheResourceCount()); 320 context->getResourceCacheUsage(&resourceCount, NULL);
321 REPORTER_ASSERT(reporter, expectedCachedResources == resourceCount);
317 322
318 // Verify that all the cached resources are unlocked upon surface release 323 // Verify that all the cached resources are unlocked upon surface release
319 surface.reset(0); 324 surface.reset(0);
320 context->freeGpuResources(); 325 context->freeGpuResources();
321 REPORTER_ASSERT(reporter, 0 == context->getGpuTextureCacheResourceCount()); 326 context->getResourceCacheUsage(&resourceCount, NULL);
327 REPORTER_ASSERT(reporter, 0 == resourceCount);
322 } 328 }
323 329
324 static void Test_crbug263329(skiatest::Reporter* reporter, 330 static void Test_crbug263329(skiatest::Reporter* reporter,
325 SurfaceType surfaceType, 331 SurfaceType surfaceType,
326 GrContext* context) { 332 GrContext* context) {
327 // This is a regression test for crbug.com/263329 333 // This is a regression test for crbug.com/263329
328 // Bug was caused by onCopyOnWrite releasing the old surface texture 334 // Bug was caused by onCopyOnWrite releasing the old surface texture
329 // back to the scratch texture pool even though the texture is used 335 // back to the scratch texture pool even though the texture is used
330 // by and active SkImage_Gpu. 336 // by and active SkImage_Gpu.
331 SkAutoTUnref<SkSurface> surface1(createSurface(surfaceType, context)); 337 SkAutoTUnref<SkSurface> surface1(createSurface(surfaceType, context));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface:: kDiscard_ContentChangeMode); 438 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface:: kDiscard_ContentChangeMode);
433 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSu rface::kDiscard_ContentChangeMode); 439 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSu rface::kDiscard_ContentChangeMode);
434 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface:: kRetain_ContentChangeMode); 440 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface:: kRetain_ContentChangeMode);
435 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSu rface::kRetain_ContentChangeMode); 441 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSu rface::kRetain_ContentChangeMode);
436 TestGetTexture(reporter, kGpu_SurfaceType, context); 442 TestGetTexture(reporter, kGpu_SurfaceType, context);
437 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); 443 TestGetTexture(reporter, kGpuScratch_SurfaceType, context);
438 } 444 }
439 } 445 }
440 #endif 446 #endif
441 } 447 }
OLDNEW
« no previous file with comments | « tests/ResourceCacheTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698