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

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

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: more windows fix Created 6 years 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/effects/GrConvolutionEffect.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('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 "../GrAARectRenderer.h" 10 #include "../GrAARectRenderer.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 SkPoint devicePts[2]; 329 SkPoint devicePts[2];
330 vm.mapPoints(devicePts, ptsRot, 2); 330 vm.mapPoints(devicePts, ptsRot, 2);
331 SkScalar lineLength = SkPoint::Distance(devicePts[0], devicePts[1]); 331 SkScalar lineLength = SkPoint::Distance(devicePts[0], devicePts[1]);
332 if (hasCap) { 332 if (hasCap) {
333 lineLength += 2.f * halfDevStroke; 333 lineLength += 2.f * halfDevStroke;
334 } 334 }
335 devIntervals[0] = lineLength; 335 devIntervals[0] = lineLength;
336 } 336 }
337 337
338 const GrGeometryProcessor* gp; 338 SkAutoTUnref<const GrGeometryProcessor> gp;
339 bool fullDash = devIntervals[1] > 0.f || useAA; 339 bool fullDash = devIntervals[1] > 0.f || useAA;
340 if (fullDash) { 340 if (fullDash) {
341 SkPathEffect::DashInfo devInfo; 341 SkPathEffect::DashInfo devInfo;
342 devInfo.fPhase = devPhase; 342 devInfo.fPhase = devPhase;
343 devInfo.fCount = 2; 343 devInfo.fCount = 2;
344 devInfo.fIntervals = devIntervals; 344 devInfo.fIntervals = devIntervals;
345 GrPrimitiveEdgeType edgeType= useAA ? kFillAA_GrProcessorEdgeType : 345 GrPrimitiveEdgeType edgeType= useAA ? kFillAA_GrProcessorEdgeType :
346 kFillBW_GrProcessorEdgeType; 346 kFillBW_GrProcessorEdgeType;
347 bool isRoundCap = SkPaint::kRound_Cap == cap; 347 bool isRoundCap = SkPaint::kRound_Cap == cap;
348 GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_ DashCap : 348 GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_ DashCap :
349 GrDashingEffect::kNonRou nd_DashCap; 349 GrDashingEffect::kNonRou nd_DashCap;
350 gp = GrDashingEffect::Create(color, edgeType, devInfo, strokeWidth, capT ype); 350 gp.reset(GrDashingEffect::Create(color, edgeType, devInfo, strokeWidth, capType));
351 } else { 351 } else {
352 // Set up the vertex data for the line and start/end dashes 352 // Set up the vertex data for the line and start/end dashes
353 gp = GrDefaultGeoProcFactory::Create(color, GrDefaultGeoProcFactory::kPo sition_GPType); 353 gp.reset(GrDefaultGeoProcFactory::Create(color, GrDefaultGeoProcFactory: :kPosition_GPType));
354 } 354 }
355 355
356 drawState->setGeometryProcessor(gp)->unref();
357
358 int totalRectCnt = 0; 356 int totalRectCnt = 0;
359 357
360 totalRectCnt += !lineDone ? 1 : 0; 358 totalRectCnt += !lineDone ? 1 : 0;
361 totalRectCnt += hasStartRect ? 1 : 0; 359 totalRectCnt += hasStartRect ? 1 : 0;
362 totalRectCnt += hasEndRect ? 1 : 0; 360 totalRectCnt += hasEndRect ? 1 : 0;
363 361
364 GrDrawTarget::AutoReleaseGeometry geo(target, 362 GrDrawTarget::AutoReleaseGeometry geo(target,
365 totalRectCnt * 4, 363 totalRectCnt * 4,
366 gp->getVertexStride(), 0); 364 gp->getVertexStride(), 0);
367 if (!geo.succeeded()) { 365 if (!geo.succeeded()) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 devIntervals[0], halfDevStroke); 426 devIntervals[0], halfDevStroke);
429 } else { 427 } else {
430 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); 428 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices());
431 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); 429 SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
432 setup_dashed_rect_pos(endRect, curVIdx, combinedMatrix, verts); 430 setup_dashed_rect_pos(endRect, curVIdx, combinedMatrix, verts);
433 } 431 }
434 432
435 } 433 }
436 434
437 target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer()); 435 target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer());
438 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, totalRec tCnt, 4, 6); 436 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, tota lRectCnt, 4, 6);
439 target->resetIndexSource(); 437 target->resetIndexSource();
440 return true; 438 return true;
441 } 439 }
442 440
443 ////////////////////////////////////////////////////////////////////////////// 441 //////////////////////////////////////////////////////////////////////////////
444 442
445 class GLDashingCircleEffect; 443 class GLDashingCircleEffect;
446 /* 444 /*
447 * This effect will draw a dotted line (defined as a dashed lined with round cap s and no on 445 * This effect will draw a dotted line (defined as a dashed lined with round cap s and no on
448 * interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo. 446 * interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 480 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
483 481
484 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE; 482 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE;
485 483
486 private: 484 private:
487 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i nfo, 485 DashingCircleEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& i nfo,
488 SkScalar radius); 486 SkScalar radius);
489 487
490 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 488 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
491 489
492 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE; 490 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE;
493 491
494 GrPrimitiveEdgeType fEdgeType; 492 GrPrimitiveEdgeType fEdgeType;
495 const GrAttribute* fInPosition; 493 const GrAttribute* fInPosition;
496 const GrAttribute* fInCoord; 494 const GrAttribute* fInCoord;
497 SkScalar fIntervalLength; 495 SkScalar fIntervalLength;
498 SkScalar fRadius; 496 SkScalar fRadius;
499 SkScalar fCenterX; 497 SkScalar fCenterX;
500 498
501 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 499 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
502 500
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 SkScalar radius) { 605 SkScalar radius) {
608 if (info.fCount != 2 || info.fIntervals[0] != 0) { 606 if (info.fCount != 2 || info.fIntervals[0] != 0) {
609 return NULL; 607 return NULL;
610 } 608 }
611 609
612 return SkNEW_ARGS(DashingCircleEffect, (color, edgeType, info, radius)); 610 return SkNEW_ARGS(DashingCircleEffect, (color, edgeType, info, radius));
613 } 611 }
614 612
615 DashingCircleEffect::~DashingCircleEffect() {} 613 DashingCircleEffect::~DashingCircleEffect() {}
616 614
617 void DashingCircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con st { 615 void DashingCircleEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* ou t) const {
618 inout->mulByUnknownAlpha(); 616 out->setUnknownSingleComponent();
619 } 617 }
620 618
621 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, 619 void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt,
622 const GrGLCaps& caps, 620 const GrGLCaps& caps,
623 GrProcessorKeyBuilder* b) const { 621 GrProcessorKeyBuilder* b) const {
624 GLDashingCircleEffect::GenKey(*this, bt, caps, b); 622 GLDashingCircleEffect::GenKey(*this, bt, caps, b);
625 } 623 }
626 624
627 GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracke r& bt) const { 625 GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracke r& bt) const {
628 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); 626 return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 710 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
713 711
714 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE; 712 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE;
715 713
716 private: 714 private:
717 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o, 715 DashingLineEffect(GrColor, GrPrimitiveEdgeType edgeType, const DashInfo& inf o,
718 SkScalar strokeWidth); 716 SkScalar strokeWidth);
719 717
720 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; 718 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
721 719
722 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE; 720 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const SK_O VERRIDE;
723 721
724 GrPrimitiveEdgeType fEdgeType; 722 GrPrimitiveEdgeType fEdgeType;
725 const GrAttribute* fInPosition; 723 const GrAttribute* fInPosition;
726 const GrAttribute* fInCoord; 724 const GrAttribute* fInCoord;
727 SkRect fRect; 725 SkRect fRect;
728 SkScalar fIntervalLength; 726 SkScalar fIntervalLength;
729 727
730 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 728 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
731 729
732 typedef GrGeometryProcessor INHERITED; 730 typedef GrGeometryProcessor INHERITED;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 SkScalar strokeWidth) { 848 SkScalar strokeWidth) {
851 if (info.fCount != 2) { 849 if (info.fCount != 2) {
852 return NULL; 850 return NULL;
853 } 851 }
854 852
855 return SkNEW_ARGS(DashingLineEffect, (color, edgeType, info, strokeWidth)); 853 return SkNEW_ARGS(DashingLineEffect, (color, edgeType, info, strokeWidth));
856 } 854 }
857 855
858 DashingLineEffect::~DashingLineEffect() {} 856 DashingLineEffect::~DashingLineEffect() {}
859 857
860 void DashingLineEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 858 void DashingLineEffect::onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const {
861 inout->mulByUnknownAlpha(); 859 out->setUnknownSingleComponent();
862 } 860 }
863 861
864 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, 862 void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt,
865 const GrGLCaps& caps, 863 const GrGLCaps& caps,
866 GrProcessorKeyBuilder* b) const { 864 GrProcessorKeyBuilder* b) const {
867 GLDashingLineEffect::GenKey(*this, bt, caps, b); 865 GLDashingLineEffect::GenKey(*this, bt, caps, b);
868 } 866 }
869 867
870 GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt) const { 868 GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt) const {
871 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); 869 return SkNEW_ARGS(GLDashingLineEffect, (*this, bt));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 switch (cap) { 922 switch (cap) {
925 case GrDashingEffect::kRound_DashCap: 923 case GrDashingEffect::kRound_DashCap:
926 return DashingCircleEffect::Create(color, edgeType, info, SkScalarHa lf(strokeWidth)); 924 return DashingCircleEffect::Create(color, edgeType, info, SkScalarHa lf(strokeWidth));
927 case GrDashingEffect::kNonRound_DashCap: 925 case GrDashingEffect::kNonRound_DashCap:
928 return DashingLineEffect::Create(color, edgeType, info, strokeWidth) ; 926 return DashingLineEffect::Create(color, edgeType, info, strokeWidth) ;
929 default: 927 default:
930 SkFAIL("Unexpected dashed cap."); 928 SkFAIL("Unexpected dashed cap.");
931 } 929 }
932 return NULL; 930 return NULL;
933 } 931 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698