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

Side by Side Diff: src/gpu/glsl/GrGLSLXferProcessor.cpp

Issue 1471293003: Create a static instances of SrcOver XferProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Build 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/gl/builders/GrGLProgramBuilder.cpp ('k') | no next file » | 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 "glsl/GrGLSLXferProcessor.h" 8 #include "glsl/GrGLSLXferProcessor.h"
9 9
10 #include "GrXferProcessor.h" 10 #include "GrXferProcessor.h"
11 #include "glsl/GrGLSLFragmentShaderBuilder.h" 11 #include "glsl/GrGLSLFragmentShaderBuilder.h"
12 #include "glsl/GrGLSLProgramBuilder.h" 12 #include "glsl/GrGLSLProgramBuilder.h"
13 #include "glsl/GrGLSLProgramDataManager.h" 13 #include "glsl/GrGLSLProgramDataManager.h"
14 14
15 void GrGLSLXferProcessor::emitCode(const EmitArgs& args) { 15 void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
16 if (!args.fXP.willReadDstColor()) { 16 if (!args.fXP.willReadDstColor()) {
17 this->emitOutputsForBlendState(args); 17 this->emitOutputsForBlendState(args);
18 return; 18 return;
19 } 19 }
20 20
21 GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder; 21 GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder;
22 const char* dstColor = fragBuilder->dstColor(); 22 const char* dstColor = fragBuilder->dstColor();
23 23
24 if (args.fXP.getDstTexture()) { 24 if (args.fXP.getDstTexture()) {
25 bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstTexture()->ori gin(); 25 bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstTexture()->ori gin();
26 26
27 if (args.fXP.readsCoverage()) { 27 if (args.fInputCoverage) {
28 // We don't think any shaders actually output negative coverage, but just as a safety 28 // We don't think any shaders actually output negative coverage, but just as a safety
29 // check for floating point precision errors we compare with <= here 29 // check for floating point precision errors we compare with <= here
30 fragBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {" 30 fragBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {"
31 " discard;" 31 " discard;"
32 "}", args.fInputCoverage); 32 "}", args.fInputCoverage);
33 } 33 }
34 34
35 const char* dstTopLeftName; 35 const char* dstTopLeftName;
36 const char* dstCoordScaleName; 36 const char* dstCoordScaleName;
37 37
(...skipping 24 matching lines...) Expand all
62 62
63 this->emitBlendCodeForDstRead(args.fPB, 63 this->emitBlendCodeForDstRead(args.fPB,
64 fragBuilder, 64 fragBuilder,
65 args.fInputColor, 65 args.fInputColor,
66 dstColor, 66 dstColor,
67 args.fOutputPrimary, 67 args.fOutputPrimary,
68 args.fXP); 68 args.fXP);
69 69
70 // Apply coverage. 70 // Apply coverage.
71 if (args.fXP.dstReadUsesMixedSamples()) { 71 if (args.fXP.dstReadUsesMixedSamples()) {
72 if (args.fXP.readsCoverage()) { 72 if (args.fInputCoverage) {
73 fragBuilder->codeAppendf("%s *= %s;", args.fOutputPrimary, args.fInp utCoverage); 73 fragBuilder->codeAppendf("%s *= %s;", args.fOutputPrimary, args.fInp utCoverage);
74 fragBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, args.fIn putCoverage); 74 fragBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, args.fIn putCoverage);
75 } else { 75 } else {
76 fragBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputSecondary); 76 fragBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputSecondary);
77 } 77 }
78 } else if (args.fXP.readsCoverage()) { 78 } else if (args.fInputCoverage) {
79 fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;", 79 fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
80 args.fOutputPrimary, args.fInputCoverage, 80 args.fOutputPrimary, args.fInputCoverage,
81 args.fOutputPrimary, args.fInputCoverage, dstCo lor); 81 args.fOutputPrimary, args.fInputCoverage, dstCo lor);
82 } 82 }
83 } 83 }
84 84
85 void GrGLSLXferProcessor::setData(const GrGLSLProgramDataManager& pdm, const GrX ferProcessor& xp) { 85 void GrGLSLXferProcessor::setData(const GrGLSLProgramDataManager& pdm, const GrX ferProcessor& xp) {
86 if (xp.getDstTexture()) { 86 if (xp.getDstTexture()) {
87 if (fDstTopLeftUni.isValid()) { 87 if (fDstTopLeftUni.isValid()) {
88 pdm.set2f(fDstTopLeftUni, static_cast<float>(xp.dstTextureOffset().f X), 88 pdm.set2f(fDstTopLeftUni, static_cast<float>(xp.dstTextureOffset().f X),
89 static_cast<float>(xp.dstTextureOffset().fY)); 89 static_cast<float>(xp.dstTextureOffset().fY));
90 pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(), 90 pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(),
91 1.f / xp.getDstTexture()->height()); 91 1.f / xp.getDstTexture()->height());
92 } else { 92 } else {
93 SkASSERT(!fDstScaleUni.isValid()); 93 SkASSERT(!fDstScaleUni.isValid());
94 } 94 }
95 } else { 95 } else {
96 SkASSERT(!fDstTopLeftUni.isValid()); 96 SkASSERT(!fDstTopLeftUni.isValid());
97 SkASSERT(!fDstScaleUni.isValid()); 97 SkASSERT(!fDstScaleUni.isValid());
98 } 98 }
99 this->onSetData(pdm, xp); 99 this->onSetData(pdm, xp);
100 } 100 }
101 101
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698