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

Unified Diff: gm/yuvtorgbeffect.cpp

Issue 608883003: GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: remove todo Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/texturedomaineffect.cpp ('k') | include/gpu/GrContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/yuvtorgbeffect.cpp
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 026823e8ee03f51c73a8f2f0fc0af92d44ae0138..b5c6b95314993dfc4ad383cfbf5473984cbe2371 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];
« no previous file with comments | « gm/texturedomaineffect.cpp ('k') | include/gpu/GrContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698