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

Unified Diff: gm/texdata.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 8 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/imagefiltersscaled.cpp ('k') | gm/texturedomaineffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/texdata.cpp
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index c89ce734f7584e3d12d015310d66768f53b26855..d6ab1f12f7f7eb95b5bc0e0daef68f36870dbd74 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -22,6 +22,10 @@ static const int S = 200;
DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
GrRenderTarget* target = canvas->internal_private_accessTopLayerRenderTarget();
GrContext* ctx = canvas->getGrContext();
+ if (!ctx) {
+ skiagm::GM::DrawGpuOnlyMessage(canvas);
+ return;
+ }
SkAutoTUnref<GrDrawContext> drawContext(ctx ? ctx->drawContext(target) : nullptr);
if (drawContext && target) {
SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S));
@@ -77,6 +81,19 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
}
SkAutoTUnref<GrTexture> au(texture);
+ SkASSERT(texture->fromRawPixels2());
+
+ SkAutoTUnref<GrDrawContext> dc9;
+ if (i) {
+ texture->setFromRawPixels(false);
+ dc9.reset(ctx->drawContext(texture->asRenderTarget()));
+ if (!dc9) {
+ return;
+ }
+ } else {
+ texture->setException(true);
+ }
+
// setup new clip
GrClip clip(SkRect::MakeWH(2*S, 2*S));
@@ -94,10 +111,19 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
SkMatrix tm;
tm = vm;
tm.postIDiv(2*S, 2*S);
- paint.addColorTextureProcessor(texture, tm);
+ paint.addColorTextureProcessor(texture, tm, target);
drawContext->drawRect(clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
+#if 0
+ // Here we've used dc9/texture as a src for a drawRect. This "closed"
+ // the DT. We need to reopen it here so we can use dc9/texture for
+ // the writePixels
+ if (dc9) {
+ dc9 = ctx->drawContext(texture->asRenderTarget());
+ }
+#endif
+
// now update the lower right of the texture in first pass
// or upper right in second pass
offset = 0;
@@ -107,13 +133,11 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
((x + y) % 2) ? (i ? green : red) : blue;
}
}
- texture->writePixels(S, (i ? 0 : S), S, S,
+ texture->writePixels(dc9, S, (i ? 0 : S), S, S,
texture->config(), gTextureData.get(),
4 * stride);
drawContext->drawRect(clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
}
- } else {
- skiagm::GM::DrawGpuOnlyMessage(canvas);
}
}
#endif
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | gm/texturedomaineffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698