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

Side by Side Diff: src/gpu/effects/GrDashingEffect.cpp

Issue 1261083003: Use new API everywhere for GrDefaultGeoProcFactory (Closed) Base URL: https://skia.googlesource.com/skia.git@lccleanup2
Patch Set: Created 5 years, 4 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 * 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 #include "GrDashingEffect.h" 8 #include "GrDashingEffect.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 SkScalar fHalfDevStroke; 293 SkScalar fHalfDevStroke;
294 SkScalar fDevBloatX; 294 SkScalar fDevBloatX;
295 SkScalar fDevBloatY; 295 SkScalar fDevBloatY;
296 bool fLineDone; 296 bool fLineDone;
297 bool fHasStartRect; 297 bool fHasStartRect;
298 bool fHasEndRect; 298 bool fHasEndRect;
299 }; 299 };
300 300
301 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override { 301 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override {
302 int instanceCount = fGeoData.count(); 302 int instanceCount = fGeoData.count();
303 SkPaint::Cap cap = this->cap();
304 bool isRoundCap = SkPaint::kRound_Cap == cap;
305 DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
303 306
304 SkMatrix invert; 307 SkAutoTUnref<const GrGeometryProcessor> gp;
305 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { 308 if (this->fullDash()) {
306 SkDebugf("Failed to invert\n"); 309 gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this ->viewMatrix(),
310 this->usesLocalCoords()));
311 } else {
312 // Set up the vertex data for the line and start/end dashes
313 using namespace GrDefaultGeoProcFactory;
314 Color color(this->color());
315 Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type :
316 Coverage::kSolid_Type);
317 if (this->usesLocalCoords()) {
318 LocalCoords localCoords(LocalCoords::kUsePosition_Type);
319 gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this ->viewMatrix()));
320 } else {
321 LocalCoords localCoords(LocalCoords::kUnused_Type);
322 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localC oords));
323 }
324 }
325
326 if (!gp) {
327 SkDebugf("Could not create GrGeometryProcessor\n");
307 return; 328 return;
308 } 329 }
309 330
310 SkPaint::Cap cap = this->cap();
311
312 SkAutoTUnref<const GrGeometryProcessor> gp;
313
314 bool isRoundCap = SkPaint::kRound_Cap == cap;
315 DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
316 if (this->fullDash()) {
317 gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, inve rt,
318 this->usesLocalCoords()));
319 } else {
320 // Set up the vertex data for the line and start/end dashes
321 gp.reset(GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kP osition_GPType,
322 this->color(),
323 this->usesLocalCoords(),
324 this->coverageIgnored(),
325 SkMatrix::I(),
326 invert));
327 }
328
329 batchTarget->initDraw(gp, pipeline); 331 batchTarget->initDraw(gp, pipeline);
330 332
331 // useAA here means Edge AA or MSAA 333 // useAA here means Edge AA or MSAA
332 bool useAA = this->aaMode() != kBW_DashAAMode; 334 bool useAA = this->aaMode() != kBW_DashAAMode;
333 bool fullDash = this->fullDash(); 335 bool fullDash = this->fullDash();
334 336
335 // We do two passes over all of the dashes. First we setup the start, e nd, and bounds, 337 // We do two passes over all of the dashes. First we setup the start, e nd, and bounds,
336 // rectangles. We preserve all of this work in the rects / draws arrays below. Then we 338 // rectangles. We preserve all of this work in the rects / draws arrays below. Then we
337 // iterate again over these decomposed dashes to generate vertices 339 // iterate again over these decomposed dashes to generate vertices
338 SkSTArray<128, SkRect, true> rects; 340 SkSTArray<128, SkRect, true> rects;
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 return DashingLineEffect::Create(GrRandomColor(d->fRandom), 1204 return DashingLineEffect::Create(GrRandomColor(d->fRandom),
1203 aaMode, GrTest::TestMatrix(d->fRandom), 1205 aaMode, GrTest::TestMatrix(d->fRandom),
1204 d->fRandom->nextBool()); 1206 d->fRandom->nextBool());
1205 } 1207 }
1206 1208
1207 ////////////////////////////////////////////////////////////////////////////// 1209 //////////////////////////////////////////////////////////////////////////////
1208 1210
1209 static GrGeometryProcessor* create_dash_gp(GrColor color, 1211 static GrGeometryProcessor* create_dash_gp(GrColor color,
1210 DashAAMode dashAAMode, 1212 DashAAMode dashAAMode,
1211 DashCap cap, 1213 DashCap cap,
1212 const SkMatrix& localMatrix, 1214 const SkMatrix& viewMatrix,
1213 bool usesLocalCoords) { 1215 bool usesLocalCoords) {
1216 SkMatrix invert;
1217 if (usesLocalCoords && !viewMatrix.invert(&invert)) {
1218 SkDebugf("Failed to invert\n");
1219 return NULL;
1220 }
1221
1214 switch (cap) { 1222 switch (cap) {
1215 case kRound_DashCap: 1223 case kRound_DashCap:
1216 return DashingCircleEffect::Create(color, dashAAMode, localMatrix, u sesLocalCoords); 1224 return DashingCircleEffect::Create(color, dashAAMode, invert, usesLo calCoords);
1217 case kNonRound_DashCap: 1225 case kNonRound_DashCap:
1218 return DashingLineEffect::Create(color, dashAAMode, localMatrix, use sLocalCoords); 1226 return DashingLineEffect::Create(color, dashAAMode, invert, usesLoca lCoords);
1219 default:
1220 SkFAIL("Unexpected dashed cap.");
1221 } 1227 }
1222 return NULL; 1228 return NULL;
1223 } 1229 }
1224 1230
1225 //////////////////////////////////////////////////////////////////////////////// ///////////////// 1231 //////////////////////////////////////////////////////////////////////////////// /////////////////
1226 1232
1227 #ifdef GR_TEST_UTILS 1233 #ifdef GR_TEST_UTILS
1228 1234
1229 BATCH_TEST_DEFINE(DashBatch) { 1235 BATCH_TEST_DEFINE(DashBatch) {
1230 GrColor color = GrRandomColor(random); 1236 GrColor color = GrRandomColor(random);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 info.fIntervals = intervals; 1301 info.fIntervals = intervals;
1296 info.fCount = 2; 1302 info.fCount = 2;
1297 info.fPhase = phase; 1303 info.fPhase = phase;
1298 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); 1304 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
1299 SkASSERT(success); 1305 SkASSERT(success);
1300 1306
1301 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); 1307 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
1302 } 1308 }
1303 1309
1304 #endif 1310 #endif
OLDNEW
« src/gpu/GrAARectRenderer.cpp ('K') | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698