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

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: fix Created 6 years, 3 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
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 "GrContext.h" 15 #include "GrContext.h"
16 #include "GrPathUtils.h" 16 #include "GrPathUtils.h"
17 #include "GrTest.h" 17 #include "GrTest.h"
18 #include "SkColorPriv.h" 18 #include "SkColorPriv.h"
19 #include "SkDevice.h" 19 #include "SkDevice.h"
20 #include "SkGeometry.h" 20 #include "SkGeometry.h"
21 #include "SkTLList.h" 21 #include "SkTLList.h"
22 22
23 #include "effects/GrConvexPolyEffect.h" 23 #include "effects/GrConvexPolyEffect.h"
24 24
25 namespace skiagm { 25 namespace skiagm {
26 /** 26 /**
27 * This GM directly exercises a GrEffect that draws convex polygons. 27 * This GM directly exercises a GrProcessor that draws convex polygons.
28 */ 28 */
29 class ConvexPolyEffect : public GM { 29 class ConvexPolyEffect : public GM {
30 public: 30 public:
31 ConvexPolyEffect() { 31 ConvexPolyEffect() {
32 this->setBGColor(0xFFFFFFFF); 32 this->setBGColor(0xFFFFFFFF);
33 } 33 }
34 34
35 protected: 35 protected:
36 virtual SkString onShortName() SK_OVERRIDE { 36 virtual SkString onShortName() SK_OVERRIDE {
37 return SkString("convex_poly_effect"); 37 return SkString("convex_poly_effect");
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return; 106 return;
107 } 107 }
108 108
109 SkScalar y = 0; 109 SkScalar y = 0;
110 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I terStart); 110 for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_I terStart);
111 iter.get(); 111 iter.get();
112 iter.next()) { 112 iter.next()) {
113 const SkPath* path = iter.get(); 113 const SkPath* path = iter.get();
114 SkScalar x = 0; 114 SkScalar x = 0;
115 115
116 for (int et = 0; et < kGrEffectEdgeTypeCnt; ++et) { 116 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) {
117 GrTestTarget tt; 117 GrTestTarget tt;
118 context->getTestTarget(&tt); 118 context->getTestTarget(&tt);
119 if (NULL == tt.target()) { 119 if (NULL == tt.target()) {
120 SkDEBUGFAIL("Couldn't get Gr test target."); 120 SkDEBUGFAIL("Couldn't get Gr test target.");
121 return; 121 return;
122 } 122 }
123 GrDrawState* drawState = tt.target()->drawState(); 123 GrDrawState* drawState = tt.target()->drawState();
124 124
125 SkMatrix m; 125 SkMatrix m;
126 SkPath p; 126 SkPath p;
127 m.setTranslate(x, y); 127 m.setTranslate(x, y);
128 path->transform(m, &p); 128 path->transform(m, &p);
129 129
130 GrEffectEdgeType edgeType = (GrEffectEdgeType) et; 130 GrProcessorEdgeType edgeType = (GrProcessorEdgeType) et;
131 SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeTyp e, p)); 131 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, p));
132 if (!effect) { 132 if (!fp) {
133 continue; 133 continue;
134 } 134 }
135 drawState->addCoverageEffect(effect); 135 drawState->addCoverageProcessor(fp);
136 drawState->setIdentityViewMatrix(); 136 drawState->setIdentityViewMatrix();
137 drawState->setRenderTarget(rt); 137 drawState->setRenderTarget(rt);
138 drawState->setColor(0xff000000); 138 drawState->setColor(0xff000000);
139 139
140 SkPoint verts[4]; 140 SkPoint verts[4];
141 SkRect bounds = p.getBounds(); 141 SkRect bounds = p.getBounds();
142 // Make sure any artifacts around the exterior of path are visib le by using overly 142 // Make sure any artifacts around the exterior of path are visib le by using overly
143 // conservative bounding geometry. 143 // conservative bounding geometry.
144 bounds.outset(5.f, 5.f); 144 bounds.outset(5.f, 5.f);
145 bounds.toQuad(verts); 145 bounds.toQuad(verts);
(...skipping 17 matching lines...) Expand all
163 163
164 y += SkScalarCeilToScalar(path->getBounds().height() + 20.f); 164 y += SkScalarCeilToScalar(path->getBounds().height() + 20.f);
165 } 165 }
166 166
167 for (SkTLList<SkRect>::Iter iter(fRects, SkTLList<SkRect>::Iter::kHead_I terStart); 167 for (SkTLList<SkRect>::Iter iter(fRects, SkTLList<SkRect>::Iter::kHead_I terStart);
168 iter.get(); 168 iter.get();
169 iter.next()) { 169 iter.next()) {
170 170
171 SkScalar x = 0; 171 SkScalar x = 0;
172 172
173 for (int et = 0; et < kGrEffectEdgeTypeCnt; ++et) { 173 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) {
174 GrTestTarget tt; 174 GrTestTarget tt;
175 context->getTestTarget(&tt); 175 context->getTestTarget(&tt);
176 if (NULL == tt.target()) { 176 if (NULL == tt.target()) {
177 SkDEBUGFAIL("Couldn't get Gr test target."); 177 SkDEBUGFAIL("Couldn't get Gr test target.");
178 return; 178 return;
179 } 179 }
180 SkRect rect = *iter.get(); 180 SkRect rect = *iter.get();
181 rect.offset(x, y); 181 rect.offset(x, y);
182 GrEffectEdgeType edgeType = (GrEffectEdgeType) et; 182 GrProcessorEdgeType edgeType = (GrProcessorEdgeType) et;
183 SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeTyp e, rect)); 183 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, rect));
184 if (!effect) { 184 if (!fp) {
185 continue; 185 continue;
186 } 186 }
187 187
188 GrDrawState* drawState = tt.target()->drawState(); 188 GrDrawState* drawState = tt.target()->drawState();
189 drawState->addCoverageEffect(effect); 189 drawState->addCoverageProcessor(fp);
190 drawState->setIdentityViewMatrix(); 190 drawState->setIdentityViewMatrix();
191 drawState->setRenderTarget(rt); 191 drawState->setRenderTarget(rt);
192 drawState->setColor(0xff000000); 192 drawState->setColor(0xff000000);
193 193
194 SkPoint verts[4]; 194 SkPoint verts[4];
195 SkRect bounds = rect; 195 SkRect bounds = rect;
196 bounds.outset(5.f, 5.f); 196 bounds.outset(5.f, 5.f);
197 bounds.toQuad(verts); 197 bounds.toQuad(verts);
198 198
199 tt.target()->setVertexSourceToArray(verts, 4); 199 tt.target()->setVertexSourceToArray(verts, 4);
(...skipping 21 matching lines...) Expand all
221 SkTLList<SkPath> fPaths; 221 SkTLList<SkPath> fPaths;
222 SkTLList<SkRect> fRects; 222 SkTLList<SkRect> fRects;
223 223
224 typedef GM INHERITED; 224 typedef GM INHERITED;
225 }; 225 };
226 226
227 DEF_GM( return SkNEW(ConvexPolyEffect); ) 227 DEF_GM( return SkNEW(ConvexPolyEffect); )
228 } 228 }
229 229
230 #endif 230 #endif
OLDNEW
« no previous file with comments | « gm/beziereffects.cpp ('k') | gm/rrects.cpp » ('j') | include/gpu/GrGeometryProcessor.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698