Revert "Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv (take 2)"
This reverts commit aaee31f18c0845417103d84285e365575def3c40.
Reason for revert: possible valgrind leak
Original change's description:
> Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv (take 2)
>
> This is in service of: https://skia-review.googlesource.com/c/11125/ (Add parallel proxyID to StencilOps & RenderTargetOpList) where I want a better choke point for texture creation to improve discard handling.
>
> This is a reland of: https://skia-review.googlesource.com/c/11200/ (Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv)
>
> Change-Id: Icd0a90d2beb483dc24ed87c3bace9c817019e148
> Reviewed-on: https://skia-review.googlesource.com/11326
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
>
TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: Ia0b92bf6402cb5f9607310d356f43bff2e3e75eb
Reviewed-on: https://skia-review.googlesource.com/11361
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index fcf3fe8..a7a2b45 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -184,7 +184,7 @@
smallMSAART0 && smallMSAART0->asRenderTarget() &&
smallMSAART0->asRenderTarget()->numColorSamples() < 8) {
smallMSAADesc.fSampleCnt = 8;
- smallMSAART1 = resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo);
+ smallMSAART1.reset(resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo));
sk_sp<GrTexture> smallMSAART1(
resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo));
if (smallMSAART1 && smallMSAART1->asRenderTarget()) {
@@ -1514,13 +1514,13 @@
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSampleCnt = sampleCnt;
- return provider->createTexture(desc, SkBudgeted::kYes);
+ return sk_sp<GrTexture>(provider->createTexture(desc, SkBudgeted::kYes));
}
-static sk_sp<GrTextureProxy> make_mipmap_proxy(GrResourceProvider* provider,
- GrSurfaceFlags flags,
- int width, int height,
- int sampleCnt) {
+static sk_sp<GrTexture> make_mipmap_texture(GrResourceProvider* provider,
+ GrSurfaceFlags flags,
+ int width, int height,
+ int sampleCnt) {
SkBitmap bm;
bm.allocN32Pixels(width, height, true);
@@ -1552,7 +1552,8 @@
desc.fSampleCnt = sampleCnt;
desc.fIsMipMapped = true;
- return provider->createMipMappedTexture(desc, SkBudgeted::kYes, texels.get(), mipLevelCount);
+ return sk_sp<GrTexture>(provider->createMipMappedTexture(desc, SkBudgeted::kYes,
+ texels.get(), mipLevelCount));
}
// Exercise GrSurface::gpuMemorySize for different combos of MSAA, RT-only,
@@ -1563,49 +1564,42 @@
static const int kSize = 64;
+ sk_sp<GrTexture> tex;
+
// Normal versions
- {
- sk_sp<GrTexture> tex;
+ tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
+ size_t size = tex->gpuMemorySize();
+ REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
- tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
- size_t size = tex->gpuMemorySize();
- REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
-
- if (context->caps()->maxSampleCount() >= 4) {
- tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4);
- size = tex->gpuMemorySize();
- REPORTER_ASSERT(reporter, kSize*kSize*4 == size || // msaa4 failed
- kSize*kSize*4*4 == size || // auto-resolving
- kSize*kSize*4*5 == size); // explicit resolve buffer
- }
-
- tex = make_normal_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
+ if (context->caps()->maxSampleCount() >= 4) {
+ tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4);
size = tex->gpuMemorySize();
- REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
+ REPORTER_ASSERT(reporter, kSize*kSize*4 == size || // msaa4 failed
+ kSize*kSize*4*4 == size || // auto-resolving
+ kSize*kSize*4*5 == size); // explicit resolve buffer
}
+ tex = make_normal_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
+ size = tex->gpuMemorySize();
+ REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
// Mipmapped versions
- {
- sk_sp<GrTextureProxy> proxy;
+ tex = make_mipmap_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
+ size = tex->gpuMemorySize();
+ REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
- proxy = make_mipmap_proxy(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
- size_t size = proxy->gpuMemorySize();
- REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
-
- if (context->caps()->maxSampleCount() >= 4) {
- proxy = make_mipmap_proxy(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4);
- size = proxy->gpuMemorySize();
- REPORTER_ASSERT(reporter,
+ if (context->caps()->maxSampleCount() >= 4) {
+ tex = make_mipmap_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4);
+ size = tex->gpuMemorySize();
+ REPORTER_ASSERT(reporter,
kSize*kSize*4+(kSize*kSize*4)/3 == size || // msaa4 failed
kSize*kSize*4*4+(kSize*kSize*4)/3 == size || // auto-resolving
kSize*kSize*4*5+(kSize*kSize*4)/3 == size); // explicit resolve buffer
- }
-
- proxy = make_mipmap_proxy(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
- size = proxy->gpuMemorySize();
- REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
}
+
+ tex = make_mipmap_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
+ size = tex->gpuMemorySize();
+ REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
}
#endif