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

Side by Side Diff: src/gpu/gl/GrGLPrimitiveProcessor.cpp

Issue 920863002: A simple change to move a bunch of stuff out of Gr*Geometry.h (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clang fix Created 5 years, 10 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/gl/GrGLPrimitiveProcessor.h ('k') | src/gpu/gl/GrGLProgram.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrGLPrimitiveProcessor.h"
9
10 #include "builders/GrGLProgramBuilder.h"
11
12 SkMatrix GrGLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatrix,
13 const GrCoordTransform& coor dTransform) {
14 SkMatrix combined;
15 // We only apply the localmatrix to localcoords
16 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
17 combined.setConcat(coordTransform.getMatrix(), localMatrix);
18 } else {
19 combined = coordTransform.getMatrix();
20 }
21 if (coordTransform.reverseY()) {
22 // combined.postScale(1,-1);
23 // combined.postTranslate(0,1);
24 combined.set(SkMatrix::kMSkewY,
25 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]);
26 combined.set(SkMatrix::kMScaleY,
27 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]);
28 combined.set(SkMatrix::kMTransY,
29 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]);
30 }
31 return combined;
32 }
33
34 void
35 GrGLPrimitiveProcessor::setupColorPassThrough(GrGLGPBuilder* pb,
36 GrGPInput inputType,
37 const char* outputName,
38 const GrGeometryProcessor::Attribu te* colorAttr,
39 UniformHandle* colorUniform) {
40 GrGLGPFragmentBuilder* fs = pb->getFragmentShaderBuilder();
41 if (kUniform_GrGPInput == inputType) {
42 SkASSERT(colorUniform);
43 const char* stagedLocalVarName;
44 *colorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
45 kVec4f_GrSLType,
46 kDefault_GrSLPrecision,
47 "Color",
48 &stagedLocalVarName);
49 fs->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
50 } else if (kAttribute_GrGPInput == inputType) {
51 SkASSERT(colorAttr);
52 pb->addPassThroughAttribute(colorAttr, outputName);
53 } else if (kAllOnes_GrGPInput == inputType) {
54 fs->codeAppendf("%s = vec4(1);", outputName);
55 }
56 }
57
58 void GrGLPrimitiveProcessor::addUniformViewMatrix(GrGLGPBuilder* pb) {
59 fViewMatrixUniform = pb->addUniform(GrGLProgramBuilder::kVertex_Visibility,
60 kMat33f_GrSLType, kDefault_GrSLPrecision ,
61 "uViewM",
62 &fViewMatrixName);
63 }
64
65 void GrGLPrimitiveProcessor::setUniformViewMatrix(const GrGLProgramDataManager& pdman,
66 const SkMatrix& viewMatrix) {
67 if (!fViewMatrix.cheapEqualTo(viewMatrix)) {
68 SkASSERT(fViewMatrixUniform.isValid());
69 fViewMatrix = viewMatrix;
70
71 GrGLfloat viewMatrix[3 * 3];
72 GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
73 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
74 }
75 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPrimitiveProcessor.h ('k') | src/gpu/gl/GrGLProgram.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698