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

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

Issue 1490283004: Create GLSLUniformHandler class for gpu backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up public api of uniformhandler Created 5 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 | « src/gpu/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConfigConversionEffect.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"
14 #include "glsl/GrGLSLProgramDataManager.h" 13 #include "glsl/GrGLSLProgramDataManager.h"
14 #include "glsl/GrGLSLUniformHandler.h"
15 #include "glsl/GrGLSLVarying.h" 15 #include "glsl/GrGLSLVarying.h"
16 #include "glsl/GrGLSLVertexShaderBuilder.h" 16 #include "glsl/GrGLSLVertexShaderBuilder.h"
17 17
18 class GrGLBitmapTextGeoProc : public GrGLSLGeometryProcessor { 18 class GrGLBitmapTextGeoProc : public GrGLSLGeometryProcessor {
19 public: 19 public:
20 GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {} 20 GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {}
21 21
22 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { 22 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
23 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); 23 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
24 24
25 GrGLSLGPBuilder* pb = args.fPB;
26 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 25 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
27 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; 26 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
27 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
28 28
29 // emit attributes 29 // emit attributes
30 varyingHandler->emitAttributes(cte); 30 varyingHandler->emitAttributes(cte);
31 31
32 // 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
33 SkASSERT(cte.numTextures() == 1); 33 SkASSERT(cte.numTextures() == 1);
34 GrTexture* atlas = cte.textureAccess(0).getTexture(); 34 GrTexture* atlas = cte.textureAccess(0).getTexture();
35 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ; 35 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height())) ;
36 SkScalar recipWidth = 1.0f / atlas->width(); 36 SkScalar recipWidth = 1.0f / atlas->width();
37 SkScalar recipHeight = 1.0f / atlas->height(); 37 SkScalar recipHeight = 1.0f / atlas->height();
38 38
39 GrGLSLVertToFrag v(kVec2f_GrSLType); 39 GrGLSLVertToFrag v(kVec2f_GrSLType);
40 varyingHandler->addVarying("TextureCoords", &v); 40 varyingHandler->addVarying("TextureCoords", &v);
41 vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), 41 vertBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(),
42 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, 42 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
43 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, 43 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
44 cte.inTextureCoords()->fName); 44 cte.inTextureCoords()->fName);
45 45
46 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 46 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
47 // Setup pass through color 47 // Setup pass through color
48 if (!cte.colorIgnored()) { 48 if (!cte.colorIgnored()) {
49 if (cte.hasVertexColor()) { 49 if (cte.hasVertexColor()) {
50 varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOut putColor); 50 varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOut putColor);
51 } else { 51 } else {
52 this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fCo lorUniform); 52 this->setupUniformColor(fragBuilder, uniformHandler, args.fOutpu tColor,
53 &fColorUniform);
53 } 54 }
54 } 55 }
55 56
56 // Setup position 57 // Setup position
57 this->setupPosition(pb, vertBuilder, gpArgs, cte.inPosition()->fName); 58 this->setupPosition(vertBuilder, gpArgs, cte.inPosition()->fName);
58 59
59 // emit transforms 60 // emit transforms
60 this->emitTransforms(args.fPB, 61 this->emitTransforms(vertBuilder,
61 vertBuilder,
62 varyingHandler, 62 varyingHandler,
63 uniformHandler,
63 gpArgs->fPositionVar, 64 gpArgs->fPositionVar,
64 cte.inPosition()->fName, 65 cte.inPosition()->fName,
65 cte.localMatrix(), 66 cte.localMatrix(),
66 args.fTransformsIn, 67 args.fTransformsIn,
67 args.fTransformsOut); 68 args.fTransformsOut);
68 69
69 if (cte.maskFormat() == kARGB_GrMaskFormat) { 70 if (cte.maskFormat() == kARGB_GrMaskFormat) {
70 fragBuilder->codeAppendf("%s = ", args.fOutputColor); 71 fragBuilder->codeAppendf("%s = ", args.fOutputColor);
71 fragBuilder->appendTextureLookupAndModulate(args.fOutputColor, 72 fragBuilder->appendTextureLookupAndModulate(args.fOutputColor,
72 args.fSamplers[0], 73 args.fSamplers[0],
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 break; 193 break;
193 case 2: 194 case 2:
194 format = kARGB_GrMaskFormat; 195 format = kARGB_GrMaskFormat;
195 break; 196 break;
196 } 197 }
197 198
198 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params, 199 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t exIdx], params,
199 format, GrTest::TestMatrix(d->fRandom), 200 format, GrTest::TestMatrix(d->fRandom),
200 d->fRandom->nextBool()); 201 d->fRandom->nextBool());
201 } 202 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConfigConversionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698