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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 726913002: Revert of Replace GrResourceCache with GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 | « 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 "SkDecodingImageGenerator.h" 10 #include "SkDecodingImageGenerator.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // The test verifies that the surface remains writable (usable) after 314 // The test verifies that the surface remains writable (usable) after
315 // acquiring and releasing a snapshot without triggering a copy on write. 315 // acquiring and releasing a snapshot without triggering a copy on write.
316 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context)); 316 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context));
317 SkCanvas* canvas = surface->getCanvas(); 317 SkCanvas* canvas = surface->getCanvas();
318 canvas->clear(1); 318 canvas->clear(1);
319 surface->newImageSnapshot()->unref(); // Create and destroy SkImage 319 surface->newImageSnapshot()->unref(); // Create and destroy SkImage
320 canvas->clear(2); // Must not assert internally 320 canvas->clear(2); // Must not assert internally
321 } 321 }
322 322
323 #if SK_SUPPORT_GPU 323 #if SK_SUPPORT_GPU
324 static void TestSurfaceInCache(skiatest::Reporter* reporter,
325 SurfaceType surfaceType,
326 GrContext* context) {
327 context->freeGpuResources();
328 int resourceCount;
329
330 context->getResourceCacheUsage(&resourceCount, NULL);
331 REPORTER_ASSERT(reporter, 0 == resourceCount);
332 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context));
333 // Note: the stencil buffer is always cached, so kGpu_SurfaceType uses
334 // one cached resource, and kGpuScratch_SurfaceType uses two.
335 int expectedCachedResources = surfaceType == kGpuScratch_SurfaceType ? 2 : 1 ;
336 context->getResourceCacheUsage(&resourceCount, NULL);
337 REPORTER_ASSERT(reporter, expectedCachedResources == resourceCount);
338
339 // Verify that all the cached resources are locked in cache.
340 context->freeGpuResources();
341 context->getResourceCacheUsage(&resourceCount, NULL);
342 REPORTER_ASSERT(reporter, expectedCachedResources == resourceCount);
343
344 // Verify that all the cached resources are unlocked upon surface release
345 surface.reset(0);
346 context->freeGpuResources();
347 context->getResourceCacheUsage(&resourceCount, NULL);
348 REPORTER_ASSERT(reporter, 0 == resourceCount);
349 }
350
324 static void Test_crbug263329(skiatest::Reporter* reporter, 351 static void Test_crbug263329(skiatest::Reporter* reporter,
325 SurfaceType surfaceType, 352 SurfaceType surfaceType,
326 GrContext* context) { 353 GrContext* context) {
327 // This is a regression test for crbug.com/263329 354 // This is a regression test for crbug.com/263329
328 // Bug was caused by onCopyOnWrite releasing the old surface texture 355 // Bug was caused by onCopyOnWrite releasing the old surface texture
329 // back to the scratch texture pool even though the texture is used 356 // back to the scratch texture pool even though the texture is used
330 // by and active SkImage_Gpu. 357 // by and active SkImage_Gpu.
331 SkAutoTUnref<SkSurface> surface1(createSurface(surfaceType, context)); 358 SkAutoTUnref<SkSurface> surface1(createSurface(surfaceType, context));
332 SkAutoTUnref<SkSurface> surface2(createSurface(surfaceType, context)); 359 SkAutoTUnref<SkSurface> surface2(createSurface(surfaceType, context));
333 SkCanvas* canvas1 = surface1->getCanvas(); 360 SkCanvas* canvas1 = surface1->getCanvas();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 #if SK_SUPPORT_GPU 446 #if SK_SUPPORT_GPU
420 TestGetTexture(reporter, kRaster_SurfaceType, NULL); 447 TestGetTexture(reporter, kRaster_SurfaceType, NULL);
421 if (factory) { 448 if (factory) {
422 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { 449 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
423 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i; 450 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLCon textType) i;
424 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { 451 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
425 continue; 452 continue;
426 } 453 }
427 GrContext* context = factory->get(glCtxType); 454 GrContext* context = factory->get(glCtxType);
428 if (context) { 455 if (context) {
456 TestSurfaceInCache(reporter, kGpu_SurfaceType, context);
457 TestSurfaceInCache(reporter, kGpuScratch_SurfaceType, context);
429 Test_crbug263329(reporter, kGpu_SurfaceType, context); 458 Test_crbug263329(reporter, kGpu_SurfaceType, context);
430 Test_crbug263329(reporter, kGpuScratch_SurfaceType, context); 459 Test_crbug263329(reporter, kGpuScratch_SurfaceType, context);
431 TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context); 460 TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context);
432 TestSurfaceCopyOnWrite(reporter, kGpuScratch_SurfaceType, contex t); 461 TestSurfaceCopyOnWrite(reporter, kGpuScratch_SurfaceType, contex t);
433 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceTy pe, context); 462 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceTy pe, context);
434 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpuScratch_Su rfaceType, context); 463 TestSurfaceWritableAfterSnapshotRelease(reporter, kGpuScratch_Su rfaceType, context);
435 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurfa ce::kDiscard_ContentChangeMode); 464 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurfa ce::kDiscard_ContentChangeMode);
436 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode); 465 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
437 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurfa ce::kRetain_ContentChangeMode); 466 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurfa ce::kRetain_ContentChangeMode);
438 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode); 467 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
439 TestGetTexture(reporter, kGpu_SurfaceType, context); 468 TestGetTexture(reporter, kGpu_SurfaceType, context);
440 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); 469 TestGetTexture(reporter, kGpuScratch_SurfaceType, context);
441 } 470 }
442 } 471 }
443 } 472 }
444 #endif 473 #endif
445 } 474 }
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