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 #ifndef GrYUVEffect_DEFINED 9 #define GrYUVEffect_DEFINED 10 11 #include "SkImageInfo.h" 12 13 class GrResourceProvider; 14 class GrFragmentProcessor; 15 class GrTextureProxy; 16 17 namespace GrYUVEffect { 18 /** 19 * Creates an effect that performs color conversion from YUV to RGB. The input textures are 20 * assumed to be kA8_GrPixelConfig. 21 */ 22 sk_sp<GrFragmentProcessor> MakeYUVToRGB(GrResourceProvider* resourceProvider, 23 sk_sp<GrTextureProxy> yProxy, 24 sk_sp<GrTextureProxy> uProxy, 25 sk_sp<GrTextureProxy> vProxy, const SkISize sizes[3], 26 SkYUVColorSpace colorSpace, bool nv12); 27 28 /** 29 * Creates a processor that performs color conversion from the passed in processor's RGB 30 * channels to Y, U ,and V channels. The output color is (y, u, v, a) where a is the passed in 31 * processor's alpha output. 32 */ 33 sk_sp<GrFragmentProcessor> MakeRGBToYUV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace); 34 35 /** 36 * Creates a processor that performs color conversion from the passed in processor's RGB 37 * channels to U and V channels. The output color is (u, v, 0, a) where a is the passed in 38 * processor's alpha output. 39 */ 40 sk_sp<GrFragmentProcessor> MakeRGBToUV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace); 41 /** 42 * Creates a processor that performs color conversion from the passed in fragment processors's 43 * RGB channels to Y, U, or V (replicated across all four output color channels). The alpha 44 * output of the passed in fragment processor is ignored. 45 */ 46 sk_sp<GrFragmentProcessor> MakeRGBToY(sk_sp<GrFragmentProcessor>, SkYUVColorSpace); 47 sk_sp<GrFragmentProcessor> MakeRGBToU(sk_sp<GrFragmentProcessor>, SkYUVColorSpace); 48 sk_sp<GrFragmentProcessor> MakeRGBToV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace); 49 }; 50 51 #endif 52