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

Side by Side Diff: gm/texturedomaineffect.cpp

Issue 1930623003: Clean up test drawContext usage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix typo Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « gm/texdata.cpp ('k') | gm/yuvtorgbeffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 // This test only works with the GPU backend. 8 // This test only works with the GPU backend.
9 9
10 #include "gm.h" 10 #include "gm.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 SkColor colors3[] = { SK_ColorBLUE, SK_ColorLTGRAY, SK_ColorGREEN }; 64 SkColor colors3[] = { SK_ColorBLUE, SK_ColorLTGRAY, SK_ColorGREEN };
65 paint.setShader(SkGradientShader::MakeSweep(25.f, 35.f, colors3, nullptr , 65 paint.setShader(SkGradientShader::MakeSweep(25.f, 35.f, colors3, nullptr ,
66 SK_ARRAY_COUNT(colors3))); 66 SK_ARRAY_COUNT(colors3)));
67 paint.setXfermodeMode(SkXfermode::kLighten_Mode); 67 paint.setXfermodeMode(SkXfermode::kLighten_Mode);
68 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, fBmp.width() + 10.f, fBmp.h eight() + 10.f), 68 canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, fBmp.width() + 10.f, fBmp.h eight() + 10.f),
69 paint); 69 paint);
70 } 70 }
71 71
72 void onDraw(SkCanvas* canvas) override { 72 void onDraw(SkCanvas* canvas) override {
73 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget (); 73 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw Context();
74 if (nullptr == rt) { 74 if (!drawContext) {
75 return;
76 }
77 GrContext* context = rt->getContext();
78 if (nullptr == context) {
79 skiagm::GM::DrawGpuOnlyMessage(canvas); 75 skiagm::GM::DrawGpuOnlyMessage(canvas);
80 return; 76 return;
81 } 77 }
82 78
83 sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(rt))); 79 GrContext* context = canvas->getGrContext();
84 if (!drawContext) { 80 if (!context) {
85 return; 81 return;
86 } 82 }
87 83
88 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp, 84 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp,
89 GrTextureParams ::ClampNoFilter())); 85 GrTextureParams ::ClampNoFilter()));
90 if (!texture) { 86 if (!texture) {
91 return; 87 return;
92 } 88 }
93 89
94 SkTArray<SkMatrix> textureMatrices; 90 SkTArray<SkMatrix> textureMatrices;
(...skipping 26 matching lines...) Expand all
121 SkAutoTUnref<const GrFragmentProcessor> fp( 117 SkAutoTUnref<const GrFragmentProcessor> fp(
122 GrTextureDomainEffect::Create(texture, textureMatrices[t m], 118 GrTextureDomainEffect::Create(texture, textureMatrices[t m],
123 GrTextureDomain::MakeTexelDomain (texture, 119 GrTextureDomain::MakeTexelDomain (texture,
124 texelDomains[d]), 120 texelDomains[d]),
125 mode, GrTextureParams::kNone_Fil terMode)); 121 mode, GrTextureParams::kNone_Fil terMode));
126 122
127 if (!fp) { 123 if (!fp) {
128 continue; 124 continue;
129 } 125 }
130 const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y); 126 const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
131 pipelineBuilder.setRenderTarget(rt); 127 pipelineBuilder.setRenderTarget(drawContext->accessRenderTar get());
132 pipelineBuilder.addColorFragmentProcessor(fp); 128 pipelineBuilder.addColorFragmentProcessor(fp);
133 129
134 SkAutoTUnref<GrDrawBatch> batch( 130 SkAutoTUnref<GrDrawBatch> batch(
135 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v iewMatrix, 131 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v iewMatrix,
136 renderRect, null ptr, nullptr)); 132 renderRect, null ptr, nullptr));
137 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin eBuilder, batch); 133 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin eBuilder, batch);
138 x += renderRect.width() + kTestPad; 134 x += renderRect.width() + kTestPad;
139 } 135 }
140 y += renderRect.height() + kTestPad; 136 y += renderRect.height() + kTestPad;
141 } 137 }
(...skipping 11 matching lines...) Expand all
153 }; 149 };
154 150
155 // Windows builds did not like SkScalar initialization in class :( 151 // Windows builds did not like SkScalar initialization in class :(
156 const SkScalar TextureDomainEffect::kDrawPad = 10.f; 152 const SkScalar TextureDomainEffect::kDrawPad = 10.f;
157 const SkScalar TextureDomainEffect::kTestPad = 10.f; 153 const SkScalar TextureDomainEffect::kTestPad = 10.f;
158 154
159 DEF_GM(return new TextureDomainEffect;) 155 DEF_GM(return new TextureDomainEffect;)
160 } 156 }
161 157
162 #endif 158 #endif
OLDNEW
« no previous file with comments | « gm/texdata.cpp ('k') | gm/yuvtorgbeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698