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

Side by Side Diff: gm/convexpolyeffect.cpp

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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/constcolorprocessor.cpp ('k') | gm/dcshader.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 , fRect(outset(rect)) { 51 , fRect(outset(rect)) {
52 } 52 }
53 53
54 private: 54 private:
55 void onPrepareDraws(Target* target) const override { 55 void onPrepareDraws(Target* target) const override {
56 using namespace GrDefaultGeoProcFactory; 56 using namespace GrDefaultGeoProcFactory;
57 57
58 Color color(this->color()); 58 Color color(this->color());
59 Coverage coverage(Coverage::kSolid_Type); 59 Coverage coverage(Coverage::kSolid_Type);
60 LocalCoords localCoords(LocalCoords::kUnused_Type); 60 LocalCoords localCoords(LocalCoords::kUnused_Type);
61 SkAutoTUnref<const GrGeometryProcessor> gp( 61 sk_sp<GrGeometryProcessor> gp(
62 GrDefaultGeoProcFactory::Create(color, coverage, localCoords, SkMatr ix::I())); 62 GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix ::I()));
63 63
64 size_t vertexStride = gp->getVertexStride(); 64 size_t vertexStride = gp->getVertexStride();
65 SkASSERT(vertexStride == sizeof(SkPoint)); 65 SkASSERT(vertexStride == sizeof(SkPoint));
66 QuadHelper helper; 66 QuadHelper helper;
67 SkPoint* verts = reinterpret_cast<SkPoint*>(helper.init(target, vertexSt ride, 1)); 67 SkPoint* verts = reinterpret_cast<SkPoint*>(helper.init(target, vertexSt ride, 1));
68 if (!verts) { 68 if (!verts) {
69 return; 69 return;
70 } 70 }
71 71
72 fRect.toQuad(verts); 72 fRect.toQuad(verts);
73 73
74 helper.recordDraw(target, gp); 74 helper.recordDraw(target, gp.get());
75 } 75 }
76 76
77 SkRect fRect; 77 SkRect fRect;
78 78
79 typedef GrTestBatch INHERITED; 79 typedef GrTestBatch INHERITED;
80 }; 80 };
81 81
82 /** 82 /**
83 * This GM directly exercises a GrProcessor that draws convex polygons. 83 * This GM directly exercises a GrProcessor that draws convex polygons.
84 */ 84 */
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 iter.next()) { 166 iter.next()) {
167 const SkPath* path = iter.get(); 167 const SkPath* path = iter.get();
168 SkScalar x = 0; 168 SkScalar x = 0;
169 169
170 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { 170 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) {
171 const SkMatrix m = SkMatrix::MakeTrans(x, y); 171 const SkMatrix m = SkMatrix::MakeTrans(x, y);
172 SkPath p; 172 SkPath p;
173 path->transform(m, &p); 173 path->transform(m, &p);
174 174
175 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; 175 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
176 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, p)); 176 sk_sp<GrFragmentProcessor> fp(GrConvexPolyEffect::Make(edgeType, p));
177 if (!fp) { 177 if (!fp) {
178 continue; 178 continue;
179 } 179 }
180 180
181 GrPipelineBuilder pipelineBuilder; 181 GrPipelineBuilder pipelineBuilder;
182 pipelineBuilder.setXPFactory( 182 pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXferm ode::kSrc_Mode));
183 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref (); 183 pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
184 pipelineBuilder.addCoverageFragmentProcessor(fp);
185 184
186 SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(p.getBounds( ), 0xff000000)); 185 SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(p.getBounds( ), 0xff000000));
187 186
188 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui lder, batch); 187 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui lder, batch);
189 188
190 x += SkScalarCeilToScalar(path->getBounds().width() + kDX); 189 x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
191 } 190 }
192 191
193 // Draw AA and non AA paths using normal API for reference. 192 // Draw AA and non AA paths using normal API for reference.
194 canvas->save(); 193 canvas->save();
(...skipping 11 matching lines...) Expand all
206 for (RectList::Iter iter(fRects, RectList::Iter::kHead_IterStart); 205 for (RectList::Iter iter(fRects, RectList::Iter::kHead_IterStart);
207 iter.get(); 206 iter.get();
208 iter.next()) { 207 iter.next()) {
209 208
210 SkScalar x = 0; 209 SkScalar x = 0;
211 210
212 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { 211 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) {
213 SkRect rect = *iter.get(); 212 SkRect rect = *iter.get();
214 rect.offset(x, y); 213 rect.offset(x, y);
215 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et; 214 GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
216 SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create( edgeType, rect)); 215 sk_sp<GrFragmentProcessor> fp(GrConvexPolyEffect::Make(edgeType, rect));
217 if (!fp) { 216 if (!fp) {
218 continue; 217 continue;
219 } 218 }
220 219
221 GrPipelineBuilder pipelineBuilder; 220 GrPipelineBuilder pipelineBuilder;
222 pipelineBuilder.setXPFactory( 221 pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXferm ode::kSrc_Mode));
223 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref (); 222 pipelineBuilder.addCoverageFragmentProcessor(std::move(fp));
224 pipelineBuilder.addCoverageFragmentProcessor(fp);
225 223
226 SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(rect, 0xff00 0000)); 224 SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(rect, 0xff00 0000));
227 225
228 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui lder, batch); 226 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui lder, batch);
229 227
230 x += SkScalarCeilToScalar(rect.width() + kDX); 228 x += SkScalarCeilToScalar(rect.width() + kDX);
231 } 229 }
232 230
233 // Draw rect without and with AA using normal API for reference 231 // Draw rect without and with AA using normal API for reference
234 canvas->save(); 232 canvas->save();
(...skipping 15 matching lines...) Expand all
250 PathList fPaths; 248 PathList fPaths;
251 RectList fRects; 249 RectList fRects;
252 250
253 typedef GM INHERITED; 251 typedef GM INHERITED;
254 }; 252 };
255 253
256 DEF_GM(return new ConvexPolyEffect;) 254 DEF_GM(return new ConvexPolyEffect;)
257 } 255 }
258 256
259 #endif 257 #endif
OLDNEW
« no previous file with comments | « gm/constcolorprocessor.cpp ('k') | gm/dcshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698