aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-09-30 06:02:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-30 06:02:23 -0700
commit3d398c876440deaab39bbf2a9b881c337e6dc8d4 (patch)
treeb38c23d2b6742c9d515dd2b19a1cf8fca49a16f0 /gm
parentc0eb9b9818462471f5fc1c47fa549c6052d8bbae (diff)
GrResourceCache2 manages scratch texture.
BUG=skia: R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/608883003
Diffstat (limited to 'gm')
-rw-r--r--gm/texturedomaineffect.cpp5
-rw-r--r--gm/yuvtorgbeffect.cpp70
2 files changed, 36 insertions, 39 deletions
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 6534b0c1dd..acf039513d 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -92,8 +92,8 @@ protected:
GrDrawState* drawState = tt.target()->drawState();
- GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, fBmp, NULL);
- if (NULL == texture) {
+ SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp, NULL));
+ if (!texture) {
return;
}
@@ -144,7 +144,6 @@ protected:
y += renderRect.height() + kTestPad;
}
}
- GrUnlockAndUnrefCachedBitmapTexture(texture);
}
private:
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 026823e8ee..265491b757 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -83,11 +83,12 @@ protected:
GrDrawState* drawState = tt.target()->drawState();
- GrTexture* texture[3];
- texture[0] = GrLockAndRefCachedBitmapTexture(context, fBmp[0], NULL);
- texture[1] = GrLockAndRefCachedBitmapTexture(context, fBmp[1], NULL);
- texture[2] = GrLockAndRefCachedBitmapTexture(context, fBmp[2], NULL);
- if ((NULL == texture[0]) || (NULL == texture[1]) || (NULL == texture[2])) {
+ SkAutoTUnref<GrTexture> texture[3];
+ texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0], NULL));
+ texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1], NULL));
+ texture[2].reset(GrRefCachedBitmapTexture(context, fBmp[2], NULL));
+
+ if (!texture[0] || !texture[1] || !texture[2]) {
return;
}
@@ -97,38 +98,35 @@ protected:
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace;
++space) {
- SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp[0].width()),
- SkIntToScalar(fBmp[0].height()));
- renderRect.outset(kDrawPad, kDrawPad);
-
- SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset;
- SkScalar x = kDrawPad + kTestPad;
-
- const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
-
- for (int i = 0; i < 6; ++i) {
- SkAutoTUnref<GrFragmentProcessor> fp(
- GrYUVtoRGBEffect::Create(texture[indices[i][0]],
- texture[indices[i][1]],
- texture[indices[i][2]],
- static_cast<SkYUVColorSpace>(space)));
- if (fp) {
- SkMatrix viewMatrix;
- viewMatrix.setTranslate(x, y);
- drawState->reset(viewMatrix);
- drawState->setRenderTarget(rt);
- drawState->setColor(0xffffffff);
- drawState->addColorProcessor(fp);
- tt.target()->drawSimpleRect(renderRect);
- }
- x += renderRect.width() + kTestPad;
- }
+ SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp[0].width()),
+ SkIntToScalar(fBmp[0].height()));
+ renderRect.outset(kDrawPad, kDrawPad);
+
+ SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset;
+ SkScalar x = kDrawPad + kTestPad;
+
+ const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
+ {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
+
+ for (int i = 0; i < 6; ++i) {
+ SkAutoTUnref<GrFragmentProcessor> fp(
+ GrYUVtoRGBEffect::Create(texture[indices[i][0]],
+ texture[indices[i][1]],
+ texture[indices[i][2]],
+ static_cast<SkYUVColorSpace>(space)));
+ if (fp) {
+ SkMatrix viewMatrix;
+ viewMatrix.setTranslate(x, y);
+ drawState->reset(viewMatrix);
+ drawState->setRenderTarget(rt);
+ drawState->setColor(0xffffffff);
+ drawState->addColorProcessor(fp);
+ tt.target()->drawSimpleRect(renderRect);
+ }
+ x += renderRect.width() + kTestPad;
+ }
}
-
- GrUnlockAndUnrefCachedBitmapTexture(texture[0]);
- GrUnlockAndUnrefCachedBitmapTexture(texture[1]);
- GrUnlockAndUnrefCachedBitmapTexture(texture[2]);
- }
+ }
private:
SkBitmap fBmp[3];