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

Side by Side Diff: src/gpu/GrPaint.cpp

Issue 699943003: Move GrInvariantOutput out of GrProcessor and into its own class. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleanup Created 6 years, 1 month 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/GrOvalRenderer.cpp ('k') | src/gpu/GrProcessor.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrPaint.h" 9 #include "GrPaint.h"
10 10
11 #include "GrBlend.h" 11 #include "GrBlend.h"
12 #include "GrInvariantOutput.h"
12 #include "effects/GrSimpleTextureEffect.h" 13 #include "effects/GrSimpleTextureEffect.h"
13 14
14 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri x) { 15 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri x) {
15 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr ef(); 16 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr ef();
16 } 17 }
17 18
18 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma trix) { 19 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma trix) {
19 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))-> unref(); 20 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))-> unref();
20 } 21 }
21 22
(...skipping 23 matching lines...) Expand all
45 } 46 }
46 } 47 }
47 return false; 48 return false;
48 } 49 }
49 50
50 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, 51 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
51 uint32_t* solidColorKnownComponents) const { 52 uint32_t* solidColorKnownComponents) const {
52 53
53 // TODO: Share this implementation with GrDrawState 54 // TODO: Share this implementation with GrDrawState
54 55
55 GrProcessor::InvariantOutput inout; 56 GrInvariantOutput inoutCoverage(0xFFFFFFFF,
56 inout.fColor = 0xFFFFFFFF; 57 kRGBA_GrColorComponentFlags,
57 inout.fValidFlags = kRGBA_GrColorComponentFlags; 58 true);
58 inout.fIsSingleComponent = true;
59 int count = fCoverageStages.count(); 59 int count = fCoverageStages.count();
60 for (int i = 0; i < count; ++i) { 60 for (int i = 0; i < count; ++i) {
61 fCoverageStages[i].getProcessor()->computeInvariantOutput(&inout); 61 fCoverageStages[i].getProcessor()->computeInvariantOutput(&inoutCoverage );
62 } 62 }
63 if (!inout.isSolidWhite()) { 63 if (!inoutCoverage.isSolidWhite()) {
64 return false; 64 return false;
65 } 65 }
66 66
67 inout.fColor = fColor; 67 GrInvariantOutput inout(fColor, kRGBA_GrColorComponentFlags, false);
68 inout.fValidFlags = kRGBA_GrColorComponentFlags;
69 inout.fIsSingleComponent = false;
70 count = fColorStages.count(); 68 count = fColorStages.count();
71 for (int i = 0; i < count; ++i) { 69 for (int i = 0; i < count; ++i) {
72 fColorStages[i].getProcessor()->computeInvariantOutput(&inout); 70 fColorStages[i].getProcessor()->computeInvariantOutput(&inout);
73 } 71 }
74 72
75 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents)); 73 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents));
76 74
77 GrBlendCoeff srcCoeff = fSrcBlendCoeff; 75 GrBlendCoeff srcCoeff = fSrcBlendCoeff;
78 GrBlendCoeff dstCoeff = fDstBlendCoeff; 76 GrBlendCoeff dstCoeff = fDstBlendCoeff;
79 GrSimplifyBlend(&srcCoeff, &dstCoeff, inout.fColor, inout.fValidFlags, 77 GrSimplifyBlend(&srcCoeff, &dstCoeff, inout.color(), inout.validFlags(),
80 0, 0, 0); 78 0, 0, 0);
81 79
82 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef f); 80 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef f);
83 if (solidColor) { 81 if (solidColor) {
84 if (opaque) { 82 if (opaque) {
85 switch (srcCoeff) { 83 switch (srcCoeff) {
86 case kZero_GrBlendCoeff: 84 case kZero_GrBlendCoeff:
87 *solidColor = 0; 85 *solidColor = 0;
88 *solidColorKnownComponents = kRGBA_GrColorComponentFlags; 86 *solidColorKnownComponents = kRGBA_GrColorComponentFlags;
89 break; 87 break;
90 88
91 case kOne_GrBlendCoeff: 89 case kOne_GrBlendCoeff:
92 *solidColor = inout.fColor; 90 *solidColor = inout.color();
93 *solidColorKnownComponents = inout.fValidFlags; 91 *solidColorKnownComponents = inout.validFlags();
94 break; 92 break;
95 93
96 // The src coeff should never refer to the src and if it refers to dst then opaque 94 // The src coeff should never refer to the src and if it refers to dst then opaque
97 // should have been false. 95 // should have been false.
98 case kSC_GrBlendCoeff: 96 case kSC_GrBlendCoeff:
99 case kISC_GrBlendCoeff: 97 case kISC_GrBlendCoeff:
100 case kDC_GrBlendCoeff: 98 case kDC_GrBlendCoeff:
101 case kIDC_GrBlendCoeff: 99 case kIDC_GrBlendCoeff:
102 case kSA_GrBlendCoeff: 100 case kSA_GrBlendCoeff:
103 case kISA_GrBlendCoeff: 101 case kISA_GrBlendCoeff:
(...skipping 10 matching lines...) Expand all
114 case kIConstA_GrBlendCoeff: 112 case kIConstA_GrBlendCoeff:
115 *solidColorKnownComponents = 0; 113 *solidColorKnownComponents = 0;
116 break; 114 break;
117 } 115 }
118 } else { 116 } else {
119 solidColorKnownComponents = 0; 117 solidColorKnownComponents = 0;
120 } 118 }
121 } 119 }
122 return opaque; 120 return opaque;
123 } 121 }
OLDNEW
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698