| OLD | NEW |
| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 GrContext* context) { | 317 GrContext* context) { |
| 318 context->freeGpuResources(); | 318 context->freeGpuResources(); |
| 319 REPORTER_ASSERT(reporter, 0 == context->getGpuTextureCacheResourceCount()); | 319 REPORTER_ASSERT(reporter, 0 == context->getGpuTextureCacheResourceCount()); |
| 320 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context)); | 320 SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context)); |
| 321 // Note: the stencil buffer is always cached, so kGpu_SurfaceType uses | 321 // Note: the stencil buffer is always cached, so kGpu_SurfaceType uses |
| 322 // one cached resource, and kGpuScratch_SurfaceType uses two. | 322 // one cached resource, and kGpuScratch_SurfaceType uses two. |
| 323 int expectedCachedResources = surfaceType == kGpuScratch_SurfaceType ? 2 : 1
; | 323 int expectedCachedResources = surfaceType == kGpuScratch_SurfaceType ? 2 : 1
; |
| 324 REPORTER_ASSERT(reporter, expectedCachedResources == context->getGpuTextureC
acheResourceCount()); | 324 REPORTER_ASSERT(reporter, expectedCachedResources == context->getGpuTextureC
acheResourceCount()); |
| 325 | 325 |
| 326 // Verify that all the cached resources are locked in cache. | 326 // Verify that all the cached resources are locked in cache. |
| 327 context->freeGpuResources(); | 327 context->freeGpuResources(); |
| 328 REPORTER_ASSERT(reporter, expectedCachedResources == context->getGpuTextureC
acheResourceCount()); | 328 REPORTER_ASSERT(reporter, expectedCachedResources == context->getGpuTextureC
acheResourceCount()); |
| 329 | 329 |
| 330 // Verify that all the cached resources are unlocked upon surface release | 330 // Verify that all the cached resources are unlocked upon surface release |
| 331 surface.reset(0); | 331 surface.reset(0); |
| 332 context->freeGpuResources(); | 332 context->freeGpuResources(); |
| 333 REPORTER_ASSERT(reporter, 0 == context->getGpuTextureCacheResourceCount()); | 333 REPORTER_ASSERT(reporter, 0 == context->getGpuTextureCacheResourceCount()); |
| 334 } | 334 } |
| 335 | 335 |
| 336 static void Test_crbug263329(skiatest::Reporter* reporter, | 336 static void Test_crbug263329(skiatest::Reporter* reporter, |
| 337 SurfaceType surfaceType, | 337 SurfaceType surfaceType, |
| 338 GrContext* context) { | 338 GrContext* context) { |
| 339 // This is a regression test for crbug.com/263329 | 339 // This is a regression test for crbug.com/263329 |
| 340 // Bug was caused by onCopyOnWrite releasing the old surface texture | 340 // Bug was caused by onCopyOnWrite releasing the old surface texture |
| 341 // back to the scratch texture pool even though the texture is used | 341 // back to the scratch texture pool even though the texture is used |
| 342 // by and active SkImage_Gpu. | 342 // by and active SkImage_Gpu. |
| 343 SkAutoTUnref<SkSurface> surface1(createSurface(surfaceType, context)); | 343 SkAutoTUnref<SkSurface> surface1(createSurface(surfaceType, context)); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::
kDiscard_ContentChangeMode); | 447 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::
kDiscard_ContentChangeMode); |
| 448 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSu
rface::kDiscard_ContentChangeMode); | 448 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSu
rface::kDiscard_ContentChangeMode); |
| 449 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::
kRetain_ContentChangeMode); | 449 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::
kRetain_ContentChangeMode); |
| 450 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSu
rface::kRetain_ContentChangeMode); | 450 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSu
rface::kRetain_ContentChangeMode); |
| 451 TestGetTexture(reporter, kGpu_SurfaceType, context); | 451 TestGetTexture(reporter, kGpu_SurfaceType, context); |
| 452 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); | 452 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); |
| 453 } | 453 } |
| 454 } | 454 } |
| 455 #endif | 455 #endif |
| 456 } | 456 } |
| OLD | NEW |