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

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

Issue 795783002: Revert of Fix to set correct output type when blending when we've read dst (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « include/gpu/effects/GrPorterDuffXferProcessor.h ('k') | no next file » | 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 "effects/GrPorterDuffXferProcessor.h" 8 #include "effects/GrPorterDuffXferProcessor.h"
9 9
10 #include "GrBlend.h" 10 #include "GrBlend.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 args.fOutputSecondary, args.fInputCol or, 61 args.fOutputSecondary, args.fInputCol or,
62 args.fInputCoverage); 62 args.fInputCoverage);
63 break; 63 break;
64 default: 64 default:
65 SkFAIL("Unexpected Secondary Output"); 65 SkFAIL("Unexpected Secondary Output");
66 } 66 }
67 } 67 }
68 68
69 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, args.fInput Color, 69 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, args.fInput Color,
70 args.fInputCoverage); 70 args.fInputCoverage);
71 if (GrPorterDuffXferProcessor::kCombineWithDst_PrimaryOutputType == xp.p rimaryOutputType()){
72 fsBuilder->codeAppendf("%s += (vec4(1.0) - %s) * %s;", args.fOutputP rimary,
73 args.fInputCoverage, fsBuilder->dstColor());
74 }
75 } 71 }
76 72
77 virtual void setData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVERRIDE {}; 73 virtual void setData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVERRIDE {};
78 74
79 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, 75 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps,
80 GrProcessorKeyBuilder* b) { 76 GrProcessorKeyBuilder* b) {
81 const GrPorterDuffXferProcessor& xp = processor.cast<GrPorterDuffXferPro cessor>(); 77 const GrPorterDuffXferProcessor& xp = processor.cast<GrPorterDuffXferPro cessor>();
82 b->add32(xp.primaryOutputType());
83 b->add32(xp.secondaryOutputType()); 78 b->add32(xp.secondaryOutputType());
84 }; 79 };
85 80
86 private: 81 private:
87 typedef GrGLXferProcessor INHERITED; 82 typedef GrGLXferProcessor INHERITED;
88 }; 83 };
89 84
90 /////////////////////////////////////////////////////////////////////////////// 85 ///////////////////////////////////////////////////////////////////////////////
91 86
92 GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBl endCoeff dstBlend, 87 GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBl endCoeff dstBlend,
93 GrColor constant) 88 GrColor constant)
94 : fSrcBlend(srcBlend) 89 : fSrcBlend(srcBlend)
95 , fDstBlend(dstBlend) 90 , fDstBlend(dstBlend)
96 , fBlendConstant(constant) 91 , fBlendConstant(constant)
97 , fPrimaryOutputType(kModulate_PrimaryOutputType)
98 , fSecondaryOutputType(kNone_SecondaryOutputType) { 92 , fSecondaryOutputType(kNone_SecondaryOutputType) {
99 this->initClassID<GrPorterDuffXferProcessor>(); 93 this->initClassID<GrPorterDuffXferProcessor>();
100 } 94 }
101 95
102 GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() { 96 GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() {
103 } 97 }
104 98
105 void GrPorterDuffXferProcessor::getGLProcessorKey(const GrGLCaps& caps, 99 void GrPorterDuffXferProcessor::getGLProcessorKey(const GrGLCaps& caps,
106 GrProcessorKeyBuilder* b) cons t { 100 GrProcessorKeyBuilder* b) cons t {
107 GrGLPorterDuffXferProcessor::GenKey(*this, caps, b); 101 GrGLPorterDuffXferProcessor::GenKey(*this, caps, b);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 145 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
152 } else if (kSA_GrBlendCoeff == fDstBlend) { 146 } else if (kSA_GrBlendCoeff == fDstBlend) {
153 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 147 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
154 fSecondaryOutputType = kCoverageISA_SecondaryOutputType; 148 fSecondaryOutputType = kCoverageISA_SecondaryOutputType;
155 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 149 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
156 } else if (kSC_GrBlendCoeff == fDstBlend) { 150 } else if (kSC_GrBlendCoeff == fDstBlend) {
157 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 151 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
158 fSecondaryOutputType = kCoverageISC_SecondaryOutputType; 152 fSecondaryOutputType = kCoverageISC_SecondaryOutputType;
159 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 153 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
160 } 154 }
161 } else if (readsDst &&
162 kOne_GrBlendCoeff == fSrcBlend &&
163 kZero_GrBlendCoeff == fDstBlend) {
164 fPrimaryOutputType = kCombineWithDst_PrimaryOutputType;
165 } 155 }
166 } 156 }
167 } 157 }
168 158
169 GrXferProcessor::OptFlags 159 GrXferProcessor::OptFlags
170 GrPorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPO I, 160 GrPorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPO I,
171 const GrProcOptInfo& coverag ePOI, 161 const GrProcOptInfo& coverag ePOI,
172 bool isCoverageDrawing, 162 bool isCoverageDrawing,
173 bool colorWriteDisabled, 163 bool colorWriteDisabled,
174 bool doesStencilWrite, 164 bool doesStencilWrite,
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } while (GrBlendCoeffRefsSrc(src)); 539 } while (GrBlendCoeffRefsSrc(src));
550 540
551 GrBlendCoeff dst; 541 GrBlendCoeff dst;
552 do { 542 do {
553 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff)); 543 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff));
554 } while (GrBlendCoeffRefsDst(dst)); 544 } while (GrBlendCoeffRefsDst(dst));
555 545
556 return GrPorterDuffXPFactory::Create(src, dst); 546 return GrPorterDuffXPFactory::Create(src, dst);
557 } 547 }
558 548
OLDNEW
« no previous file with comments | « include/gpu/effects/GrPorterDuffXferProcessor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698