OLD | NEW |
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 "GrYUVEffect.h" | 8 #include "GrYUVEffect.h" |
9 | 9 |
10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 public: | 101 public: |
102 void emitCode(EmitArgs& args) override { | 102 void emitCode(EmitArgs& args) override { |
103 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 103 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
104 const YUVtoRGBEffect& effect = args.fFp.cast<YUVtoRGBEffect>(); | 104 const YUVtoRGBEffect& effect = args.fFp.cast<YUVtoRGBEffect>(); |
105 | 105 |
106 const char* colorSpaceMatrix = nullptr; | 106 const char* colorSpaceMatrix = nullptr; |
107 fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag
, | 107 fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag
, |
108 kMat44f_GrSLType, kDef
ault_GrSLPrecision, | 108 kMat44f_GrSLType, kDef
ault_GrSLPrecision, |
109 "ColorSpaceMatrix", &c
olorSpaceMatrix); | 109 "ColorSpaceMatrix", &c
olorSpaceMatrix); |
110 fragBuilder->codeAppendf("%s = vec4(", args.fOutputColor); | 110 fragBuilder->codeAppendf("%s = vec4(", args.fOutputColor); |
111 fragBuilder->appendTextureLookup(args.fTexSamplers[0], args.fCoords[
0].c_str(), | 111 fragBuilder->appendTextureLookup(args.fTexSamplers[0], |
112 args.fCoords[0].getType()); | 112 args.fTransformedCoords[0].c_str(), |
| 113 args.fTransformedCoords[0].getType(
)); |
113 fragBuilder->codeAppend(".r,"); | 114 fragBuilder->codeAppend(".r,"); |
114 fragBuilder->appendTextureLookup(args.fTexSamplers[1], args.fCoords[
1].c_str(), | 115 fragBuilder->appendTextureLookup(args.fTexSamplers[1], |
115 args.fCoords[1].getType()); | 116 args.fTransformedCoords[1].c_str(), |
| 117 args.fTransformedCoords[1].getType(
)); |
116 if (effect.fNV12) { | 118 if (effect.fNV12) { |
117 fragBuilder->codeAppendf(".rg,"); | 119 fragBuilder->codeAppendf(".rg,"); |
118 } else { | 120 } else { |
119 fragBuilder->codeAppend(".r,"); | 121 fragBuilder->codeAppend(".r,"); |
120 fragBuilder->appendTextureLookup(args.fTexSamplers[2], args.fCoo
rds[2].c_str(), | 122 fragBuilder->appendTextureLookup(args.fTexSamplers[2], |
121 args.fCoords[2].getType()); | 123 args.fTransformedCoords[2].c_st
r(), |
| 124 args.fTransformedCoords[2].getT
ype()); |
122 fragBuilder->codeAppendf(".g,"); | 125 fragBuilder->codeAppendf(".g,"); |
123 } | 126 } |
124 fragBuilder->codeAppendf("1.0) * %s;", colorSpaceMatrix); | 127 fragBuilder->codeAppendf("1.0) * %s;", colorSpaceMatrix); |
125 } | 128 } |
126 | 129 |
127 protected: | 130 protected: |
128 void onSetData(const GrGLSLProgramDataManager& pdman, | 131 void onSetData(const GrGLSLProgramDataManager& pdman, |
129 const GrProcessor& processor) override { | 132 const GrProcessor& processor) override { |
130 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); | 133 const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); |
131 switch (yuvEffect.getColorSpace()) { | 134 switch (yuvEffect.getColorSpace()) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 return sk_sp<GrFragmentProcessor>( | 398 return sk_sp<GrFragmentProcessor>( |
396 new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kU_Outp
utChannels)); | 399 new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kU_Outp
utChannels)); |
397 } | 400 } |
398 | 401 |
399 sk_sp<GrFragmentProcessor> | 402 sk_sp<GrFragmentProcessor> |
400 GrYUVEffect::MakeRGBToV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorS
pace) { | 403 GrYUVEffect::MakeRGBToV(sk_sp<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorS
pace) { |
401 SkASSERT(rgbFP); | 404 SkASSERT(rgbFP); |
402 return sk_sp<GrFragmentProcessor>( | 405 return sk_sp<GrFragmentProcessor>( |
403 new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kV_Outp
utChannels)); | 406 new RGBToYUVEffect(std::move(rgbFP), colorSpace, RGBToYUVEffect::kV_Outp
utChannels)); |
404 } | 407 } |
OLD | NEW |