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

Unified Diff: src/gpu/effects/GrSimpleTextureEffect.cpp

Issue 2180803005: Add color gamut xform helpers to GrGLSLShaderBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@xform-storage
Patch Set: Rebase Created 4 years, 3 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
Index: src/gpu/effects/GrSimpleTextureEffect.cpp
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index a452d3e6fdf064038996a9c2983ac5c9aa8f6904..8e452814b9567af72ceab292ee8957d1533a25bc 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -8,23 +8,46 @@
#include "GrSimpleTextureEffect.h"
#include "GrInvariantOutput.h"
#include "GrTexture.h"
+#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrGLSimpleTextureEffect : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs& args) override {
+ const GrSimpleTextureEffect& textureEffect = args.fFp.cast<GrSimpleTextureEffect>();
+ GrGLSLColorSpaceXformHelper colorSpaceHelper(args.fUniformHandler,
+ textureEffect.colorSpaceXform(),
+ &fColorSpaceXformUni);
+
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("%s = ", args.fOutputColor);
fragBuilder->appendTextureLookupAndModulate(args.fInputColor,
- args.fTexSamplers[0],
- args.fCoords[0].c_str(),
- args.fCoords[0].getType());
+ args.fTexSamplers[0],
+ args.fCoords[0].c_str(),
+ args.fCoords[0].getType(),
+ &colorSpaceHelper);
fragBuilder->codeAppend(";");
}
+ static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrSimpleTextureEffect& textureEffect = effect.cast<GrSimpleTextureEffect>();
+ b->add32(GrColorSpaceXform::XformKey(textureEffect.colorSpaceXform()));
+ }
+
+protected:
+ void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& processor) override {
+ const GrSimpleTextureEffect& textureEffect = processor.cast<GrSimpleTextureEffect>();
+ if (SkToBool(textureEffect.colorSpaceXform())) {
+ pdman.setMatrix4f(fColorSpaceXformUni, textureEffect.colorSpaceXform()->srcToDst());
+ }
+ }
+
private:
typedef GrGLSLFragmentProcessor INHERITED;
+
+ UniformHandle fColorSpaceXformUni;
};
///////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698