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

Side by Side Diff: src/gpu/glsl/GrGLSLPrimitiveProcessor.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/glsl/GrGLSLPrimitiveProcessor.h ('k') | src/gpu/glsl/GrGLSLProgramBuilder.h » ('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 2014 Google Inc. 2 * Copyright 2014 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 "GrGLSLPrimitiveProcessor.h" 8 #include "GrGLSLPrimitiveProcessor.h"
9 9
10 #include "glsl/GrGLSLProgramBuilder.h" 10 #include "GrCoordTransform.h"
11 #include "glsl/GrGLSLFragmentShaderBuilder.h" 11 #include "glsl/GrGLSLFragmentShaderBuilder.h"
12 #include "glsl/GrGLSLUniformHandler.h"
13 #include "glsl/GrGLSLVertexShaderBuilder.h"
12 14
13 SkMatrix GrGLSLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatri x, 15 SkMatrix GrGLSLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatri x,
14 const GrCoordTransform& co ordTransform) { 16 const GrCoordTransform& co ordTransform) {
15 SkMatrix combined; 17 SkMatrix combined;
16 // We only apply the localmatrix to localcoords 18 // We only apply the localmatrix to localcoords
17 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { 19 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
18 combined.setConcat(coordTransform.getMatrix(), localMatrix); 20 combined.setConcat(coordTransform.getMatrix(), localMatrix);
19 } else { 21 } else {
20 combined = coordTransform.getMatrix(); 22 combined = coordTransform.getMatrix();
21 } 23 }
22 if (coordTransform.reverseY()) { 24 if (coordTransform.reverseY()) {
23 // combined.postScale(1,-1); 25 // combined.postScale(1,-1);
24 // combined.postTranslate(0,1); 26 // combined.postTranslate(0,1);
25 combined.set(SkMatrix::kMSkewY, 27 combined.set(SkMatrix::kMSkewY,
26 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]); 28 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]);
27 combined.set(SkMatrix::kMScaleY, 29 combined.set(SkMatrix::kMScaleY,
28 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]); 30 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]);
29 combined.set(SkMatrix::kMTransY, 31 combined.set(SkMatrix::kMTransY,
30 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); 32 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]);
31 } 33 }
32 return combined; 34 return combined;
33 } 35 }
34 36
35 void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLGPBuilder* pb, 37 void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLFragmentBuilder* fragBuil der,
36 GrGLSLFragmentBuilder* fragBuil der, 38 GrGLSLUniformHandler* uniformHa ndler,
37 const char* outputName, 39 const char* outputName,
38 UniformHandle* colorUniform) { 40 UniformHandle* colorUniform) {
39 SkASSERT(colorUniform); 41 SkASSERT(colorUniform);
40 const char* stagedLocalVarName; 42 const char* stagedLocalVarName;
41 *colorUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, 43 *colorUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_V isibility,
42 kVec4f_GrSLType, 44 kVec4f_GrSLType,
43 kDefault_GrSLPrecision, 45 kDefault_GrSLPrecision,
44 "Color", 46 "Color",
45 &stagedLocalVarName); 47 &stagedLocalVarName);
46 fragBuilder->codeAppendf("%s = %s;", outputName, stagedLocalVarName); 48 fragBuilder->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
47 } 49 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLPrimitiveProcessor.h ('k') | src/gpu/glsl/GrGLSLProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698