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

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

Issue 1462123003: Create GrGLSLVaryingHandler class for program building (Closed) Base URL: https://skia.googlesource.com/skia.git@putCapsOnArgs
Patch Set: fix release builder 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/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"
11 #include "glsl/GrGLSLFragmentShaderBuilder.h" 11 #include "glsl/GrGLSLFragmentShaderBuilder.h"
12 #include "glsl/GrGLSLGeometryProcessor.h" 12 #include "glsl/GrGLSLGeometryProcessor.h"
13 #include "glsl/GrGLSLProgramBuilder.h" 13 #include "glsl/GrGLSLProgramBuilder.h"
14 #include "glsl/GrGLSLProgramDataManager.h" 14 #include "glsl/GrGLSLProgramDataManager.h"
15 #include "glsl/GrGLSLVarying.h"
15 #include "glsl/GrGLSLVertexShaderBuilder.h" 16 #include "glsl/GrGLSLVertexShaderBuilder.h"
16 17
17 class GrGLBitmapTextGeoProc : public GrGLSLGeometryProcessor { 18 class GrGLBitmapTextGeoProc : public GrGLSLGeometryProcessor {
18 public: 19 public:
19 GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {} 20 GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {}
20 21
21 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { 22 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
22 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); 23 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
23 24
24 GrGLSLGPBuilder* pb = args.fPB; 25 GrGLSLGPBuilder* pb = args.fPB;
25 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 26 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
27 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
26 28
27 // emit attributes 29 // emit attributes
28 vertBuilder->emitAttributes(cte); 30 varyingHandler->emitAttributes(cte);
29 31
30 // compute numbers to be hardcoded to convert texture coordinates from i nt to float 32 // compute numbers to be hardcoded to convert texture coordinates from i nt to float
31 SkASSERT(cte.numTextures() == 1); 33 SkASSERT(cte.numTextures() == 1);
32 GrTexture* atlas = cte.textureAccess(0).getTexture(); 34 GrTexture* atlas = cte.textureAccess(0).getTexture();
33 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ; 35 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ;
34 SkScalar recipWidth = 1.0f / atlas->width(); 36 SkScalar recipWidth = 1.0f / atlas->width();
35 SkScalar recipHeight = 1.0f / atlas->height(); 37 SkScalar recipHeight = 1.0f / atlas->height();
36 38
37 GrGLSLVertToFrag v(kVec2f_GrSLType); 39 GrGLSLVertToFrag v(kVec2f_GrSLType);
38 pb->addVarying("TextureCoords", &v); 40 varyingHandler->addVarying("TextureCoords", &v);
39 vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), 41 vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(),
40 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, 42 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
41 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, 43 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
42 cte.inTextureCoords()->fName); 44 cte.inTextureCoords()->fName);
43 45
44 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 46 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
45 // Setup pass through color 47 // Setup pass through color
46 if (!cte.colorIgnored()) { 48 if (!cte.colorIgnored()) {
47 if (cte.hasVertexColor()) { 49 if (cte.hasVertexColor()) {
48 pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor); 50 varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOut putColor);
49 } else { 51 } else {
50 this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fCo lorUniform); 52 this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fCo lorUniform);
51 } 53 }
52 } 54 }
53 55
54 // Setup position 56 // Setup position
55 this->setupPosition(pb, vertBuilder, gpArgs, cte.inPosition()->fName); 57 this->setupPosition(pb, vertBuilder, gpArgs, cte.inPosition()->fName);
56 58
57 // emit transforms 59 // emit transforms
58 this->emitTransforms(args.fPB, 60 this->emitTransforms(args.fPB,
59 vertBuilder, 61 vertBuilder,
62 varyingHandler,
60 gpArgs->fPositionVar, 63 gpArgs->fPositionVar,
61 cte.inPosition()->fName, 64 cte.inPosition()->fName,
62 cte.localMatrix(), 65 cte.localMatrix(),
63 args.fTransformsIn, 66 args.fTransformsIn,
64 args.fTransformsOut); 67 args.fTransformsOut);
65 68
66 if (cte.maskFormat() == kARGB_GrMaskFormat) { 69 if (cte.maskFormat() == kARGB_GrMaskFormat) {
67 fragBuilder->codeAppendf("%s = ", args.fOutputColor); 70 fragBuilder->codeAppendf("%s = ", args.fOutputColor);
68 fragBuilder->appendTextureLookupAndModulate(args.fOutputColor, 71 fragBuilder->appendTextureLookupAndModulate(args.fOutputColor,
69 args.fSamplers[0], 72 args.fSamplers[0],
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 break; 192 break;
190 case 2: 193 case 2:
191 format = kARGB_GrMaskFormat; 194 format = kARGB_GrMaskFormat;
192 break; 195 break;
193 } 196 }
194 197
195 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params, 198 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params,
196 format, GrTest::TestMatrix(d->fRandom), 199 format, GrTest::TestMatrix(d->fRandom),
197 d->fRandom->nextBool()); 200 d->fRandom->nextBool());
198 } 201 }
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