diff options
author | Brian Osman <brianosman@google.com> | 2017-09-14 14:45:54 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-14 19:08:41 +0000 |
commit | 9e4c164689502dd4ed4d0b37a5b3b874b46a058f (patch) | |
tree | a5608a6763e08ffb2129147004d59efef60ccd55 | |
parent | d375dbf1557de71ce8e348e6002463f076cc3967 (diff) |
Remove unused GPU RGB to YUV code
Bug: skia:
Change-Id: I2e164ef1d7de05e6e1eb1b7d7d4d3efeb785dd43
Reviewed-on: https://skia-review.googlesource.com/46562
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
-rw-r--r-- | src/gpu/effects/GrYUVEffect.cpp | 216 | ||||
-rw-r--r-- | src/gpu/effects/GrYUVEffect.h | 36 |
2 files changed, 5 insertions, 247 deletions
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp index add05cbd19..c45e9b257e 100644 --- a/src/gpu/effects/GrYUVEffect.cpp +++ b/src/gpu/effects/GrYUVEffect.cpp @@ -39,27 +39,6 @@ static const float kRec709ConversionMatrix[16] = { 0.0f, 0.0f, 0.0f, 1.0f} ; -static const float kJPEGInverseConversionMatrix[16] = { - 0.299001f, 0.586998f, 0.114001f, 0.0000821798f, - -0.168736f, -0.331263f, 0.499999f, 0.499954f, - 0.499999f, -0.418686f, -0.0813131f, 0.499941f, - 0.f, 0.f, 0.f, 1.f -}; - -static const float kRec601InverseConversionMatrix[16] = { - 0.256951f, 0.504421f, 0.0977346f, 0.0625f, - -0.148212f, -0.290954f, 0.439166f, 0.5f, - 0.439166f, -0.367886f, -0.0712802f, 0.5f, - 0.f, 0.f, 0.f, 1.f -}; - -static const float kRec709InverseConversionMatrix[16] = { - 0.182663f, 0.614473f, 0.061971f, 0.0625f, - -0.100672f, -0.338658f, 0.43933f, 0.5f, - 0.439142f, -0.39891f, -0.040231f, 0.5f, - 0.f, 0.f, 0.f, 1. -}; - class YUVtoRGBEffect : public GrFragmentProcessor { public: static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> yProxy, @@ -226,171 +205,6 @@ private: typedef GrFragmentProcessor INHERITED; }; - -class RGBToYUVEffect : public GrFragmentProcessor { -public: - enum OutputChannels { - // output color r = y, g = u, b = v, a = a - kYUV_OutputChannels, - // output color rgba = y - kY_OutputChannels, - // output color r = u, g = v, b = 0, a = a - kUV_OutputChannels, - // output color rgba = u - kU_OutputChannels, - // output color rgba = v - kV_OutputChannels - }; - - static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> rgbFP, - SkYUVColorSpace colorSpace, - OutputChannels output) { - return std::unique_ptr<GrFragmentProcessor>( - new RGBToYUVEffect(std::move(rgbFP), colorSpace, output)); - } - - const char* name() const override { return "RGBToYUV"; } - - std::unique_ptr<GrFragmentProcessor> clone() const override { - return Make(this->childProcessor(0).clone(), fColorSpace, fOutputChannels); - } - - SkYUVColorSpace getColorSpace() const { return fColorSpace; } - - OutputChannels outputChannels() const { return fOutputChannels; } - - class GLSLProcessor : public GrGLSLFragmentProcessor { - public: - GLSLProcessor() : fLastColorSpace(-1), fLastOutputChannels(-1) {} - - void emitCode(EmitArgs& args) override { - GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; - OutputChannels oc = args.fFp.cast<RGBToYUVEffect>().outputChannels(); - - SkString outputColor("rgbColor"); - this->emitChild(0, args.fInputColor, &outputColor, args); - - const char* uniName; - switch (oc) { - case kYUV_OutputChannels: - fRGBToYUVUni = args.fUniformHandler->addUniformArray( - kFragment_GrShaderFlag, - kVec4f_GrSLType, kDefault_GrSLPrecision, - "RGBToYUV", 3, &uniName); - fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a," - "dot(rgbColor.rgb, %s[1].rgb) + %s[1].a," - "dot(rgbColor.rgb, %s[2].rgb) + %s[2].a," - "rgbColor.a);", - args.fOutputColor, uniName, uniName, uniName, uniName, - uniName, uniName); - break; - case kUV_OutputChannels: - fRGBToYUVUni = args.fUniformHandler->addUniformArray( - kFragment_GrShaderFlag, - kVec4f_GrSLType, kDefault_GrSLPrecision, - "RGBToUV", 2, &uniName); - fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a," - "dot(rgbColor.rgb, %s[1].rgb) + %s[1].a," - "0.0," - "rgbColor.a);", - args.fOutputColor, uniName, uniName, uniName, uniName); - break; - case kY_OutputChannels: - case kU_OutputChannels: - case kV_OutputChannels: - fRGBToYUVUni = args.fUniformHandler->addUniform( - kFragment_GrShaderFlag, - kVec4f_GrSLType, kDefault_GrSLPrecision, - "RGBToYUorV", &uniName); - fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s.rgb) + %s.a);\n", - args.fOutputColor, uniName, uniName); - break; - } - } - - private: - void onSetData(const GrGLSLProgramDataManager& pdman, - const GrFragmentProcessor& processor) override { - const RGBToYUVEffect& effect = processor.cast<RGBToYUVEffect>(); - OutputChannels oc = effect.outputChannels(); - if (effect.getColorSpace() != fLastColorSpace || oc != fLastOutputChannels) { - - const float* matrix = nullptr; - switch (effect.getColorSpace()) { - case kJPEG_SkYUVColorSpace: - matrix = kJPEGInverseConversionMatrix; - break; - case kRec601_SkYUVColorSpace: - matrix = kRec601InverseConversionMatrix; - break; - case kRec709_SkYUVColorSpace: - matrix = kRec709InverseConversionMatrix; - break; - } - switch (oc) { - case kYUV_OutputChannels: - pdman.set4fv(fRGBToYUVUni, 3, matrix); - break; - case kUV_OutputChannels: - pdman.set4fv(fRGBToYUVUni, 2, matrix + 4); - break; - case kY_OutputChannels: - pdman.set4fv(fRGBToYUVUni, 1, matrix); - break; - case kU_OutputChannels: - pdman.set4fv(fRGBToYUVUni, 1, matrix + 4); - break; - case kV_OutputChannels: - pdman.set4fv(fRGBToYUVUni, 1, matrix + 8); - break; - } - fLastColorSpace = effect.getColorSpace(); - } - } - GrGLSLProgramDataManager::UniformHandle fRGBToYUVUni; - int fLastColorSpace; - int fLastOutputChannels; - - typedef GrGLSLFragmentProcessor INHERITED; - }; - -private: - RGBToYUVEffect(std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace, - OutputChannels output) - // This could advertise kConstantOutputForConstantInput, but doesn't seem useful. - : INHERITED(kPreservesOpaqueInput_OptimizationFlag) - , fColorSpace(colorSpace) - , fOutputChannels(output) { - this->initClassID<RGBToYUVEffect>(); - this->registerChildProcessor(std::move(rgbFP)); - } - - GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { - return new GLSLProcessor; - } - - void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { - // kY, kU, and kV all generate the same code, just upload different coefficients. - if (kU_OutputChannels == fOutputChannels || kV_OutputChannels == fOutputChannels) { - b->add32(kY_OutputChannels); - } else { - b->add32(fOutputChannels); - } - } - - bool onIsEqual(const GrFragmentProcessor& sBase) const override { - const RGBToYUVEffect& s = sBase.cast<RGBToYUVEffect>(); - return fColorSpace == s.getColorSpace() && fOutputChannels == s.outputChannels(); - } - - GrCoordTransform fTransform; - TextureSampler fTextureSampler; - SkYUVColorSpace fColorSpace; - OutputChannels fOutputChannels; - - typedef GrFragmentProcessor INHERITED; -}; - } ////////////////////////////////////////////////////////////////////////////// @@ -402,33 +216,3 @@ std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeYUVToRGB( return YUVtoRGBEffect::Make(std::move(yProxy), std::move(uProxy), std::move(vProxy), sizes, colorSpace, nv12); } - -std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToYUV( - std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) { - SkASSERT(rgbFP); - return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kYUV_OutputChannels); -} - -std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToY( - std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) { - SkASSERT(rgbFP); - return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kY_OutputChannels); -} - -std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToUV( - std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) { - SkASSERT(rgbFP); - return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kUV_OutputChannels); -} - -std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToU( - std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) { - SkASSERT(rgbFP); - return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kU_OutputChannels); -} - -std::unique_ptr<GrFragmentProcessor> GrYUVEffect::MakeRGBToV( - std::unique_ptr<GrFragmentProcessor> rgbFP, SkYUVColorSpace colorSpace) { - SkASSERT(rgbFP); - return RGBToYUVEffect::Make(std::move(rgbFP), colorSpace, RGBToYUVEffect::kV_OutputChannels); -} diff --git a/src/gpu/effects/GrYUVEffect.h b/src/gpu/effects/GrYUVEffect.h index 2ea41bf13c..e111d4e153 100644 --- a/src/gpu/effects/GrYUVEffect.h +++ b/src/gpu/effects/GrYUVEffect.h @@ -14,42 +14,16 @@ class GrFragmentProcessor; class GrTextureProxy; namespace GrYUVEffect { - /** - * Creates an effect that performs color conversion from YUV to RGB. The input textures are - * assumed to be kA8_GrPixelConfig. - */ + +/** + * Creates an effect that performs color conversion from YUV to RGB. The input textures are + * assumed to be kA8_GrPixelConfig. + */ std::unique_ptr<GrFragmentProcessor> MakeYUVToRGB(sk_sp<GrTextureProxy> yProxy, sk_sp<GrTextureProxy> uProxy, sk_sp<GrTextureProxy> vProxy, const SkISize sizes[3], SkYUVColorSpace colorSpace, bool nv12); - -/** - * Creates a processor that performs color conversion from the passed in processor's RGB - * channels to Y, U ,and V channels. The output color is (y, u, v, a) where a is the passed in - * processor's alpha output. - */ -std::unique_ptr<GrFragmentProcessor> MakeRGBToYUV(std::unique_ptr<GrFragmentProcessor>, - SkYUVColorSpace); - -/** - * Creates a processor that performs color conversion from the passed in processor's RGB - * channels to U and V channels. The output color is (u, v, 0, a) where a is the passed in - * processor's alpha output. - */ -std::unique_ptr<GrFragmentProcessor> MakeRGBToUV(std::unique_ptr<GrFragmentProcessor>, - SkYUVColorSpace); -/** - * Creates a processor that performs color conversion from the passed in fragment processors's - * RGB channels to Y, U, or V (replicated across all four output color channels). The alpha - * output of the passed in fragment processor is ignored. - */ -std::unique_ptr<GrFragmentProcessor> MakeRGBToY(std::unique_ptr<GrFragmentProcessor>, - SkYUVColorSpace); -std::unique_ptr<GrFragmentProcessor> MakeRGBToU(std::unique_ptr<GrFragmentProcessor>, - SkYUVColorSpace); -std::unique_ptr<GrFragmentProcessor> MakeRGBToV(std::unique_ptr<GrFragmentProcessor>, - SkYUVColorSpace); }; #endif |