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

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

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl 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
« no previous file with comments | « src/gpu/batches/GrVertexBatch.cpp ('k') | tests/GrPorterDuffTest.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 #include "GrDashingEffect.h" 8 #include "GrDashingEffect.h"
9 9
10 #include "GrBatchTarget.h" 10 #include "GrBatchFlushState.h"
11 #include "GrBatchTest.h" 11 #include "GrBatchTest.h"
12 #include "GrCaps.h" 12 #include "GrCaps.h"
13 #include "GrGeometryProcessor.h" 13 #include "GrGeometryProcessor.h"
14 #include "GrContext.h" 14 #include "GrContext.h"
15 #include "GrCoordTransform.h" 15 #include "GrCoordTransform.h"
16 #include "GrDefaultGeoProcFactory.h" 16 #include "GrDefaultGeoProcFactory.h"
17 #include "GrDrawTarget.h" 17 #include "GrDrawTarget.h"
18 #include "GrInvariantOutput.h" 18 #include "GrInvariantOutput.h"
19 #include "GrProcessor.h" 19 #include "GrProcessor.h"
20 #include "GrStrokeInfo.h" 20 #include "GrStrokeInfo.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 SkScalar fStrokeWidth; 291 SkScalar fStrokeWidth;
292 SkScalar fLineLength; 292 SkScalar fLineLength;
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) override { 301 void onPrepareDraws(Target* target) override {
302 int instanceCount = fGeoData.count(); 302 int instanceCount = fGeoData.count();
303 SkPaint::Cap cap = this->cap(); 303 SkPaint::Cap cap = this->cap();
304 bool isRoundCap = SkPaint::kRound_Cap == cap; 304 bool isRoundCap = SkPaint::kRound_Cap == cap;
305 DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap; 305 DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
306 306
307 SkAutoTUnref<const GrGeometryProcessor> gp; 307 SkAutoTUnref<const GrGeometryProcessor> gp;
308 if (this->fullDash()) { 308 if (this->fullDash()) {
309 gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this ->viewMatrix(), 309 gp.reset(create_dash_gp(this->color(), this->aaMode(), capType, this ->viewMatrix(),
310 this->usesLocalCoords())); 310 this->usesLocalCoords()));
311 } else { 311 } else {
312 // Set up the vertex data for the line and start/end dashes 312 // Set up the vertex data for the line and start/end dashes
313 using namespace GrDefaultGeoProcFactory; 313 using namespace GrDefaultGeoProcFactory;
314 Color color(this->color()); 314 Color color(this->color());
315 Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type : 315 Coverage coverage(this->coverageIgnored() ? Coverage::kNone_Type :
316 Coverage::kSolid_Type); 316 Coverage::kSolid_Type);
317 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type : 317 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP osition_Type :
318 LocalCoords::kUnus ed_Type); 318 LocalCoords::kUnus ed_Type);
319 gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->vi ewMatrix())); 319 gp.reset(CreateForDeviceSpace(color, coverage, localCoords, this->vi ewMatrix()));
320 } 320 }
321 321
322 if (!gp) { 322 if (!gp) {
323 SkDebugf("Could not create GrGeometryProcessor\n"); 323 SkDebugf("Could not create GrGeometryProcessor\n");
324 return; 324 return;
325 } 325 }
326 326
327 batchTarget->initDraw(gp, this->pipeline()); 327 target->initDraw(gp, this->pipeline());
328 328
329 // useAA here means Edge AA or MSAA 329 // useAA here means Edge AA or MSAA
330 bool useAA = this->aaMode() != kBW_DashAAMode; 330 bool useAA = this->aaMode() != kBW_DashAAMode;
331 bool fullDash = this->fullDash(); 331 bool fullDash = this->fullDash();
332 332
333 // We do two passes over all of the dashes. First we setup the start, e nd, and bounds, 333 // We do two passes over all of the dashes. First we setup the start, e nd, and bounds,
334 // rectangles. We preserve all of this work in the rects / draws arrays below. Then we 334 // rectangles. We preserve all of this work in the rects / draws arrays below. Then we
335 // iterate again over these decomposed dashes to generate vertices 335 // iterate again over these decomposed dashes to generate vertices
336 SkSTArray<128, SkRect, true> rects; 336 SkSTArray<128, SkRect, true> rects;
337 SkSTArray<128, DashDraw, true> draws; 337 SkSTArray<128, DashDraw, true> draws;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 draw.fHasStartRect = hasStartRect; 522 draw.fHasStartRect = hasStartRect;
523 draw.fLineDone = lineDone; 523 draw.fLineDone = lineDone;
524 draw.fHasEndRect = hasEndRect; 524 draw.fHasEndRect = hasEndRect;
525 } 525 }
526 526
527 if (!totalRectCount) { 527 if (!totalRectCount) {
528 return; 528 return;
529 } 529 }
530 530
531 QuadHelper helper; 531 QuadHelper helper;
532 void* vertices = helper.init(batchTarget, gp->getVertexStride(), totalRe ctCount); 532 void* vertices = helper.init(target, gp->getVertexStride(), totalRectCou nt);
533 if (!vertices) { 533 if (!vertices) {
534 return; 534 return;
535 } 535 }
536 536
537 int curVIdx = 0; 537 int curVIdx = 0;
538 int rectIndex = 0; 538 int rectIndex = 0;
539 for (int i = 0; i < instanceCount; i++) { 539 for (int i = 0; i < instanceCount; i++) {
540 Geometry& geom = fGeoData[i]; 540 Geometry& geom = fGeoData[i];
541 541
542 if (!draws[i].fLineDone) { 542 if (!draws[i].fLineDone) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 } else { 584 } else {
585 SkPoint* verts = reinterpret_cast<SkPoint*>(vertices); 585 SkPoint* verts = reinterpret_cast<SkPoint*>(vertices);
586 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); 586 SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
587 setup_dashed_rect_pos(rects[rectIndex], curVIdx, geom.fSrcRo tInv, verts); 587 setup_dashed_rect_pos(rects[rectIndex], curVIdx, geom.fSrcRo tInv, verts);
588 } 588 }
589 curVIdx += 4; 589 curVIdx += 4;
590 } 590 }
591 rectIndex++; 591 rectIndex++;
592 } 592 }
593 SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount); 593 SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount);
594 helper.issueDraw(batchTarget); 594 helper.recordDraw(target);
595 } 595 }
596 596
597 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 597 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
598 598
599 private: 599 private:
600 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo l fullDash) { 600 DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, boo l fullDash) {
601 this->initClassID<DashBatch>(); 601 this->initClassID<DashBatch>();
602 fGeoData.push_back(geometry); 602 fGeoData.push_back(geometry);
603 603
604 fBatch.fAAMode = aaMode; 604 fBatch.fAAMode = aaMode;
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 info.fIntervals = intervals; 1297 info.fIntervals = intervals;
1298 info.fCount = 2; 1298 info.fCount = 2;
1299 info.fPhase = phase; 1299 info.fPhase = phase;
1300 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); 1300 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
1301 SkASSERT(success); 1301 SkASSERT(success);
1302 1302
1303 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); 1303 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
1304 } 1304 }
1305 1305
1306 #endif 1306 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrVertexBatch.cpp ('k') | tests/GrPorterDuffTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698