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

Unified Diff: src/gpu/gl/GrGLXferProcessor.cpp

Issue 873723009: Revert of 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLXferProcessor.cpp
diff --git a/src/gpu/gl/GrGLXferProcessor.cpp b/src/gpu/gl/GrGLXferProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..20ec60d5ec1318a463c3205e3b78ff192ba7dde3
--- /dev/null
+++ b/src/gpu/gl/GrGLXferProcessor.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gl/GrGLXferProcessor.h"
+
+#include "GrXferProcessor.h"
+#include "gl/builders/GrGLFragmentShaderBuilder.h"
+#include "gl/builders/GrGLProgramBuilder.h"
+
+void GrGLXferProcessor::emitCode(const EmitArgs& args) {
+ if (args.fXP.getDstCopyTexture()) {
+
+ bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstCopyTexture()->origin();
+
+ GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+ const char* dstColor = fsBuilder->dstColor();
+
+ const char* dstCopyTopLeftName;
+ const char* dstCopyCoordScaleName;
+
+ fDstCopyTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kVec2f_GrSLType,
+ kDefault_GrSLPrecision,
+ "DstCopyUpperLeft",
+ &dstCopyTopLeftName);
+ fDstCopyScaleUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kVec2f_GrSLType,
+ kDefault_GrSLPrecision,
+ "DstCopyCoordScale",
+ &dstCopyCoordScaleName);
+ const char* fragPos = fsBuilder->fragmentPosition();
+
+ fsBuilder->codeAppend("// Read color from copy of the destination.\n");
+ fsBuilder->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;",
+ fragPos, dstCopyTopLeftName, dstCopyCoordScaleName);
+
+ if (!topDown) {
+ fsBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
+ }
+
+ fsBuilder->codeAppendf("vec4 %s = ", dstColor);
+ fsBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec2f_GrSLType);
+ fsBuilder->codeAppend(";");
+ }
+
+ this->onEmitCode(args);
+}
+
+void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferProcessor& xp) {
+ if (xp.getDstCopyTexture()) {
+ if (fDstCopyTopLeftUni.isValid()) {
+ pdm.set2f(fDstCopyTopLeftUni, static_cast<GrGLfloat>(xp.dstCopyTextureOffset().fX),
+ static_cast<GrGLfloat>(xp.dstCopyTextureOffset().fY));
+ pdm.set2f(fDstCopyScaleUni, 1.f / xp.getDstCopyTexture()->width(),
+ 1.f / xp.getDstCopyTexture()->height());
+ } else {
+ SkASSERT(!fDstCopyScaleUni.isValid());
+ }
+ } else {
+ SkASSERT(!fDstCopyTopLeftUni.isValid());
+ SkASSERT(!fDstCopyScaleUni.isValid());
+ }
+ this->onSetData(pdm, xp);
+}
+
« 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