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

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

Issue 1428543003: Create GLSL base class for ProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add space Created 5 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/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConstColorProcessor.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"
11 #include "gl/GrGLFragmentProcessor.h" 11 #include "gl/GrGLFragmentProcessor.h"
12 #include "gl/GrGLTexture.h" 12 #include "gl/GrGLTexture.h"
13 #include "gl/GrGLGeometryProcessor.h" 13 #include "gl/GrGLGeometryProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h" 14 #include "gl/builders/GrGLProgramBuilder.h"
15 #include "glsl/GrGLSLProgramDataManager.h"
15 16
16 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { 17 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor {
17 public: 18 public:
18 GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {} 19 GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {}
19 20
20 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { 21 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
21 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); 22 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
22 23
23 GrGLGPBuilder* pb = args.fPB; 24 GrGLGPBuilder* pb = args.fPB;
24 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); 25 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 fsBuilder->codeAppend(";"); 72 fsBuilder->codeAppend(";");
72 if (cte.maskFormat() == kA565_GrMaskFormat) { 73 if (cte.maskFormat() == kA565_GrMaskFormat) {
73 // set alpha to be max of rgb coverage 74 // set alpha to be max of rgb coverage
74 fsBuilder->codeAppendf("%s.a = max(max(%s.r, %s.g), %s.b);", 75 fsBuilder->codeAppendf("%s.a = max(max(%s.r, %s.g), %s.b);",
75 args.fOutputCoverage, args.fOutputCoverag e, 76 args.fOutputCoverage, args.fOutputCoverag e,
76 args.fOutputCoverage, args.fOutputCoverag e); 77 args.fOutputCoverage, args.fOutputCoverag e);
77 } 78 }
78 } 79 }
79 } 80 }
80 81
81 void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor & gp) override { 82 void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcess or& gp) override {
82 const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>(); 83 const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>();
83 if (btgp.color() != fColor && !btgp.hasVertexColor()) { 84 if (btgp.color() != fColor && !btgp.hasVertexColor()) {
84 GrGLfloat c[4]; 85 float c[4];
85 GrColorToRGBAFloat(btgp.color(), c); 86 GrColorToRGBAFloat(btgp.color(), c);
86 pdman.set4fv(fColorUniform, 1, c); 87 pdman.set4fv(fColorUniform, 1, c);
87 fColor = btgp.color(); 88 fColor = btgp.color();
88 } 89 }
89 } 90 }
90 91
91 void setTransformData(const GrPrimitiveProcessor& primProc, 92 void setTransformData(const GrPrimitiveProcessor& primProc,
92 const GrGLProgramDataManager& pdman, 93 const GrGLSLProgramDataManager& pdman,
93 int index, 94 int index,
94 const SkTArray<const GrCoordTransform*, true>& transfo rms) override { 95 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
95 this->setTransformDataHelper<GrBitmapTextGeoProc>(primProc, pdman, index , transforms); 96 this->setTransformDataHelper<GrBitmapTextGeoProc>(primProc, pdman, index , transforms);
96 } 97 }
97 98
98 static inline void GenKey(const GrGeometryProcessor& proc, 99 static inline void GenKey(const GrGeometryProcessor& proc,
99 const GrGLSLCaps&, 100 const GrGLSLCaps&,
100 GrProcessorKeyBuilder* b) { 101 GrProcessorKeyBuilder* b) {
101 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); 102 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
102 uint32_t key = 0; 103 uint32_t key = 0;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 break; 183 break;
183 case 2: 184 case 2:
184 format = kARGB_GrMaskFormat; 185 format = kARGB_GrMaskFormat;
185 break; 186 break;
186 } 187 }
187 188
188 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params, 189 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params,
189 format, GrTest::TestMatrix(d->fRandom), 190 format, GrTest::TestMatrix(d->fRandom),
190 d->fRandom->nextBool()); 191 d->fRandom->nextBool());
191 } 192 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConstColorProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698