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

Side by Side Diff: gm/texturedomaineffect.cpp

Issue 1584703003: Remove two varieties of drawNonAARect from GrDrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@hidedrawtargetabit
Patch Set: deprecation message on GrTest Created 4 years, 11 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/rrects.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 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This test only works with the GPU backend. 9 // This test only works with the GPU backend.
10 10
11 #include "gm.h" 11 #include "gm.h"
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 14
15 #include "GrDrawContext.h"
15 #include "GrContext.h" 16 #include "GrContext.h"
16 #include "GrTest.h"
17 #include "effects/GrTextureDomain.h"
18 #include "SkBitmap.h" 17 #include "SkBitmap.h"
19 #include "SkGr.h" 18 #include "SkGr.h"
20 #include "SkGradientShader.h" 19 #include "SkGradientShader.h"
20 #include "batches/GrDrawBatch.h"
21 #include "batches/GrRectBatchFactory.h"
22 #include "effects/GrTextureDomain.h"
21 23
22 namespace skiagm { 24 namespace skiagm {
23 /** 25 /**
24 * This GM directly exercises GrTextureDomainEffect. 26 * This GM directly exercises GrTextureDomainEffect.
25 */ 27 */
26 class TextureDomainEffect : public GM { 28 class TextureDomainEffect : public GM {
27 public: 29 public:
28 TextureDomainEffect() { 30 TextureDomainEffect() {
29 this->setBGColor(0xFFFFFFFF); 31 this->setBGColor(0xFFFFFFFF);
30 } 32 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget (); 74 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget ();
73 if (nullptr == rt) { 75 if (nullptr == rt) {
74 return; 76 return;
75 } 77 }
76 GrContext* context = rt->getContext(); 78 GrContext* context = rt->getContext();
77 if (nullptr == context) { 79 if (nullptr == context) {
78 skiagm::GM::DrawGpuOnlyMessage(canvas); 80 skiagm::GM::DrawGpuOnlyMessage(canvas);
79 return; 81 return;
80 } 82 }
81 83
82 GrTestTarget tt; 84 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt));
83 context->getTestTarget(&tt, rt); 85 if (!drawContext) {
84 if (nullptr == tt.target()) {
85 SkDEBUGFAIL("Couldn't get Gr test target.");
86 return; 86 return;
87 } 87 }
88 88
89 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp, 89 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp,
90 GrTextureParams ::ClampNoFilter())); 90 GrTextureParams ::ClampNoFilter()));
91 if (!texture) { 91 if (!texture) {
92 return; 92 return;
93 } 93 }
94 94
95 SkTArray<SkMatrix> textureMatrices; 95 SkTArray<SkMatrix> textureMatrices;
(...skipping 29 matching lines...) Expand all
125 texelDomains[d]), 125 texelDomains[d]),
126 mode, GrTextureParams::kNone_Fil terMode)); 126 mode, GrTextureParams::kNone_Fil terMode));
127 127
128 if (!fp) { 128 if (!fp) {
129 continue; 129 continue;
130 } 130 }
131 const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y); 131 const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
132 pipelineBuilder.setRenderTarget(rt); 132 pipelineBuilder.setRenderTarget(rt);
133 pipelineBuilder.addColorFragmentProcessor(fp); 133 pipelineBuilder.addColorFragmentProcessor(fp);
134 134
135 tt.target()->drawNonAARect(pipelineBuilder, 135 SkAutoTUnref<GrDrawBatch> batch(
136 GrColor_WHITE, 136 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v iewMatrix,
137 viewMatrix, 137 renderRect, null ptr, nullptr));
138 renderRect); 138 drawContext->internal_drawBatch(pipelineBuilder, batch);
139 x += renderRect.width() + kTestPad; 139 x += renderRect.width() + kTestPad;
140 } 140 }
141 y += renderRect.height() + kTestPad; 141 y += renderRect.height() + kTestPad;
142 } 142 }
143 } 143 }
144 } 144 }
145 145
146 private: 146 private:
147 static const SkScalar kDrawPad; 147 static const SkScalar kDrawPad;
148 static const SkScalar kTestPad; 148 static const SkScalar kTestPad;
149 static const int kTargetWidth = 100; 149 static const int kTargetWidth = 100;
150 static const int kTargetHeight = 100; 150 static const int kTargetHeight = 100;
151 SkBitmap fBmp; 151 SkBitmap fBmp;
152 152
153 typedef GM INHERITED; 153 typedef GM INHERITED;
154 }; 154 };
155 155
156 // Windows builds did not like SkScalar initialization in class :( 156 // Windows builds did not like SkScalar initialization in class :(
157 const SkScalar TextureDomainEffect::kDrawPad = 10.f; 157 const SkScalar TextureDomainEffect::kDrawPad = 10.f;
158 const SkScalar TextureDomainEffect::kTestPad = 10.f; 158 const SkScalar TextureDomainEffect::kTestPad = 10.f;
159 159
160 DEF_GM(return new TextureDomainEffect;) 160 DEF_GM(return new TextureDomainEffect;)
161 } 161 }
162 162
163 #endif 163 #endif
OLDNEW
« no previous file with comments | « gm/rrects.cpp ('k') | gm/yuvtorgbeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698