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

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

Issue 901663007: Revert of Move DstCopy on gpu into the GrXferProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/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
(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 "gl/GrGLXferProcessor.h"
9
10 #include "GrXferProcessor.h"
11 #include "gl/builders/GrGLFragmentShaderBuilder.h"
12 #include "gl/builders/GrGLProgramBuilder.h"
13
14 void GrGLXferProcessor::emitCode(const EmitArgs& args) {
15 if (args.fXP.getDstCopyTexture()) {
16
17 bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstCopyTexture()- >origin();
18
19 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
20 const char* dstColor = fsBuilder->dstColor();
21
22 const char* dstCopyTopLeftName;
23 const char* dstCopyCoordScaleName;
24
25 fDstCopyTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_ Visibility,
26 kVec2f_GrSLType,
27 kDefault_GrSLPrecision,
28 "DstCopyUpperLeft",
29 &dstCopyTopLeftName);
30 fDstCopyScaleUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vi sibility,
31 kVec2f_GrSLType,
32 kDefault_GrSLPrecision,
33 "DstCopyCoordScale",
34 &dstCopyCoordScaleName);
35 const char* fragPos = fsBuilder->fragmentPosition();
36
37 fsBuilder->codeAppend("// Read color from copy of the destination.\n");
38 fsBuilder->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;",
39 fragPos, dstCopyTopLeftName, dstCopyCoordScaleNam e);
40
41 if (!topDown) {
42 fsBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
43 }
44
45 fsBuilder->codeAppendf("vec4 %s = ", dstColor);
46 fsBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec2f _GrSLType);
47 fsBuilder->codeAppend(";");
48 }
49
50 this->onEmitCode(args);
51 }
52
53 void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferP rocessor& xp) {
54 if (xp.getDstCopyTexture()) {
55 if (fDstCopyTopLeftUni.isValid()) {
56 pdm.set2f(fDstCopyTopLeftUni, static_cast<GrGLfloat>(xp.dstCopyTextu reOffset().fX),
57 static_cast<GrGLfloat>(xp.dstCopyTextureOffset().fY));
58 pdm.set2f(fDstCopyScaleUni, 1.f / xp.getDstCopyTexture()->width(),
59 1.f / xp.getDstCopyTexture()->height());
60 } else {
61 SkASSERT(!fDstCopyScaleUni.isValid());
62 }
63 } else {
64 SkASSERT(!fDstCopyTopLeftUni.isValid());
65 SkASSERT(!fDstCopyScaleUni.isValid());
66 }
67 this->onSetData(pdm, xp);
68 }
69
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