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

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

Issue 2339203002: Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Fix issue of taking ref to a temporary Created 4 years, 3 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/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrDashingEffect.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 2013 Google Inc. 2 * Copyright 2013 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 "GrBitmapTextGeoProc.h" 8 #include "GrBitmapTextGeoProc.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Setup position 53 // Setup position
54 this->setupPosition(vertBuilder, gpArgs, cte.inPosition()->fName); 54 this->setupPosition(vertBuilder, gpArgs, cte.inPosition()->fName);
55 55
56 // emit transforms 56 // emit transforms
57 this->emitTransforms(vertBuilder, 57 this->emitTransforms(vertBuilder,
58 varyingHandler, 58 varyingHandler,
59 uniformHandler, 59 uniformHandler,
60 gpArgs->fPositionVar, 60 gpArgs->fPositionVar,
61 cte.inPosition()->fName, 61 cte.inPosition()->fName,
62 cte.localMatrix(), 62 cte.localMatrix(),
63 args.fTransformsIn, 63 args.fFPCoordTransformHandler);
64 args.fTransformsOut);
65 64
66 if (cte.maskFormat() == kARGB_GrMaskFormat) { 65 if (cte.maskFormat() == kARGB_GrMaskFormat) {
67 fragBuilder->codeAppendf("%s = ", args.fOutputColor); 66 fragBuilder->codeAppendf("%s = ", args.fOutputColor);
68 fragBuilder->appendTextureLookupAndModulate(args.fOutputColor, 67 fragBuilder->appendTextureLookupAndModulate(args.fOutputColor,
69 args.fTexSamplers[0], 68 args.fTexSamplers[0],
70 v.fsIn(), 69 v.fsIn(),
71 kVec2f_GrSLType); 70 kVec2f_GrSLType);
72 fragBuilder->codeAppend(";"); 71 fragBuilder->codeAppend(";");
73 fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage); 72 fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
74 } else { 73 } else {
75 fragBuilder->codeAppendf("%s = ", args.fOutputCoverage); 74 fragBuilder->codeAppendf("%s = ", args.fOutputCoverage);
76 fragBuilder->appendTextureLookup(args.fTexSamplers[0], v.fsIn(), kVe c2f_GrSLType); 75 fragBuilder->appendTextureLookup(args.fTexSamplers[0], v.fsIn(), kVe c2f_GrSLType);
77 fragBuilder->codeAppend(";"); 76 fragBuilder->codeAppend(";");
78 if (cte.maskFormat() == kA565_GrMaskFormat) { 77 if (cte.maskFormat() == kA565_GrMaskFormat) {
79 // set alpha to be max of rgb coverage 78 // set alpha to be max of rgb coverage
80 fragBuilder->codeAppendf("%s.a = max(max(%s.r, %s.g), %s.b);", 79 fragBuilder->codeAppendf("%s.a = max(max(%s.r, %s.g), %s.b);",
81 args.fOutputCoverage, args.fOutputCover age, 80 args.fOutputCoverage, args.fOutputCover age,
82 args.fOutputCoverage, args.fOutputCover age); 81 args.fOutputCoverage, args.fOutputCover age);
83 } 82 }
84 } 83 }
85 } 84 }
86 85
87 void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcess or& gp) override { 86 void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcess or& gp,
87 FPCoordTransformIter&& transformIter) override {
88 const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>(); 88 const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>();
89 if (btgp.color() != fColor && !btgp.hasVertexColor()) { 89 if (btgp.color() != fColor && !btgp.hasVertexColor()) {
90 float c[4]; 90 float c[4];
91 GrColorToRGBAFloat(btgp.color(), c); 91 GrColorToRGBAFloat(btgp.color(), c);
92 pdman.set4fv(fColorUniform, 1, c); 92 pdman.set4fv(fColorUniform, 1, c);
93 fColor = btgp.color(); 93 fColor = btgp.color();
94 } 94 }
95 } 95 this->setTransformDataHelper(btgp.localMatrix(), pdman, &transformIter);
96
97 void setTransformData(const GrPrimitiveProcessor& primProc,
98 const GrGLSLProgramDataManager& pdman,
99 int index,
100 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
101 this->setTransformDataHelper(primProc.cast<GrBitmapTextGeoProc>().localM atrix(), pdman,
102 index, transforms);
103 } 96 }
104 97
105 static inline void GenKey(const GrGeometryProcessor& proc, 98 static inline void GenKey(const GrGeometryProcessor& proc,
106 const GrGLSLCaps&, 99 const GrGLSLCaps&,
107 GrProcessorKeyBuilder* b) { 100 GrProcessorKeyBuilder* b) {
108 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); 101 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
109 uint32_t key = 0; 102 uint32_t key = 0;
110 key |= gp.usesLocalCoords() && gp.localMatrix().hasPerspective() ? 0x1 : 0x0; 103 key |= gp.usesLocalCoords() && gp.localMatrix().hasPerspective() ? 0x1 : 0x0;
111 key |= gp.colorIgnored() ? 0x2 : 0x0; 104 key |= gp.colorIgnored() ? 0x2 : 0x0;
112 key |= gp.maskFormat() << 3; 105 key |= gp.maskFormat() << 3;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 break; 182 break;
190 case 2: 183 case 2:
191 format = kARGB_GrMaskFormat; 184 format = kARGB_GrMaskFormat;
192 break; 185 break;
193 } 186 }
194 187
195 return GrBitmapTextGeoProc::Make(GrRandomColor(d->fRandom), d->fTextures[tex Idx], params, 188 return GrBitmapTextGeoProc::Make(GrRandomColor(d->fRandom), d->fTextures[tex Idx], params,
196 format, GrTest::TestMatrix(d->fRandom), 189 format, GrTest::TestMatrix(d->fRandom),
197 d->fRandom->nextBool()); 190 d->fRandom->nextBool());
198 } 191 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698