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

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

Issue 1132093004: Move DstCoordTexture to GrXP, rename and remove the word "copy" from dstcopytexture names. (Closed) Base URL: https://skia.googlesource.com/skia.git@copy
Patch Set: remove asserts Created 5 years, 6 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/GrGLXferProcessor.h ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.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 "gl/GrGLXferProcessor.h" 8 #include "gl/GrGLXferProcessor.h"
9 9
10 #include "GrXferProcessor.h" 10 #include "GrXferProcessor.h"
11 #include "gl/builders/GrGLFragmentShaderBuilder.h" 11 #include "gl/builders/GrGLFragmentShaderBuilder.h"
12 #include "gl/builders/GrGLProgramBuilder.h" 12 #include "gl/builders/GrGLProgramBuilder.h"
13 13
14 void GrGLXferProcessor::emitCode(const EmitArgs& args) { 14 void GrGLXferProcessor::emitCode(const EmitArgs& args) {
15 if (args.fXP.getDstCopyTexture()) { 15 if (args.fXP.getDstTexture()) {
16 bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstCopyTexture()- >origin(); 16 bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstTexture()->ori gin();
17 17
18 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 18 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
19 19
20 if (args.fXP.readsCoverage()) { 20 if (args.fXP.readsCoverage()) {
21 // We don't think any shaders actually output negative coverage, but just as a safety 21 // We don't think any shaders actually output negative coverage, but just as a safety
22 // check for floating point precision errors we compare with <= here 22 // check for floating point precision errors we compare with <= here
23 fsBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {" 23 fsBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {"
24 " discard;" 24 " discard;"
25 "}", args.fInputCoverage); 25 "}", args.fInputCoverage);
26 } 26 }
27 27
28 const char* dstColor = fsBuilder->dstColor(); 28 const char* dstColor = fsBuilder->dstColor();
29 29
30 const char* dstCopyTopLeftName; 30 const char* dstTopLeftName;
31 const char* dstCopyCoordScaleName; 31 const char* dstCoordScaleName;
32 32
33 fDstCopyTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_ Visibility, 33 fDstTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visi bility,
34 kVec2f_GrSLType, 34 kVec2f_GrSLType,
35 kDefault_GrSLPrecision, 35 kDefault_GrSLPrecision,
36 "DstCopyUpperLeft", 36 "DstTextureUpperLeft",
37 &dstCopyTopLeftName); 37 &dstTopLeftName);
38 fDstCopyScaleUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vi sibility, 38 fDstScaleUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibi lity,
39 kVec2f_GrSLType, 39 kVec2f_GrSLType,
40 kDefault_GrSLPrecision, 40 kDefault_GrSLPrecision,
41 "DstCopyCoordScale", 41 "DstTextureCoordScale",
42 &dstCopyCoordScaleName); 42 &dstCoordScaleName);
43 const char* fragPos = fsBuilder->fragmentPosition(); 43 const char* fragPos = fsBuilder->fragmentPosition();
44 44
45 fsBuilder->codeAppend("// Read color from copy of the destination.\n"); 45 fsBuilder->codeAppend("// Read color from copy of the destination.\n");
46 fsBuilder->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;", 46 fsBuilder->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;",
47 fragPos, dstCopyTopLeftName, dstCopyCoordScaleNam e); 47 fragPos, dstTopLeftName, dstCoordScaleName);
48 48
49 if (!topDown) { 49 if (!topDown) {
50 fsBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;"); 50 fsBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
51 } 51 }
52 52
53 fsBuilder->codeAppendf("vec4 %s = ", dstColor); 53 fsBuilder->codeAppendf("vec4 %s = ", dstColor);
54 fsBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec2f _GrSLType); 54 fsBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec2f _GrSLType);
55 fsBuilder->codeAppend(";"); 55 fsBuilder->codeAppend(";");
56 } 56 }
57 57
58 this->onEmitCode(args); 58 this->onEmitCode(args);
59 } 59 }
60 60
61 void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferP rocessor& xp) { 61 void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferP rocessor& xp) {
62 if (xp.getDstCopyTexture()) { 62 if (xp.getDstTexture()) {
63 if (fDstCopyTopLeftUni.isValid()) { 63 if (fDstTopLeftUni.isValid()) {
64 pdm.set2f(fDstCopyTopLeftUni, static_cast<GrGLfloat>(xp.dstCopyTextu reOffset().fX), 64 pdm.set2f(fDstTopLeftUni, static_cast<GrGLfloat>(xp.dstTextureOffset ().fX),
65 static_cast<GrGLfloat>(xp.dstCopyTextureOffset().fY)); 65 static_cast<GrGLfloat>(xp.dstTextureOffset().fY));
66 pdm.set2f(fDstCopyScaleUni, 1.f / xp.getDstCopyTexture()->width(), 66 pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(),
67 1.f / xp.getDstCopyTexture()->height()); 67 1.f / xp.getDstTexture()->height());
68 } else { 68 } else {
69 SkASSERT(!fDstCopyScaleUni.isValid()); 69 SkASSERT(!fDstScaleUni.isValid());
70 } 70 }
71 } else { 71 } else {
72 SkASSERT(!fDstCopyTopLeftUni.isValid()); 72 SkASSERT(!fDstTopLeftUni.isValid());
73 SkASSERT(!fDstCopyScaleUni.isValid()); 73 SkASSERT(!fDstScaleUni.isValid());
74 } 74 }
75 this->onSetData(pdm, xp); 75 this->onSetData(pdm, xp);
76 } 76 }
77 77
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLXferProcessor.h ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698