blob: 524928b48af8f7ed5ede927d418cf127087753a3 [file] [log] [blame]
bsalomonf267c1e2016-02-01 13:16:14 -08001/*
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
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -050013class GrContext;
bsalomonf267c1e2016-02-01 13:16:14 -080014class GrFragmentProcessor;
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -050015class GrTextureProxy;
bsalomonf267c1e2016-02-01 13:16:14 -080016
17namespace 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 */
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -050022 sk_sp<GrFragmentProcessor> MakeYUVToRGB(GrContext* context,
23 sk_sp<GrTextureProxy> yProxy,
24 sk_sp<GrTextureProxy> uProxy,
25 sk_sp<GrTextureProxy> vProxy, const SkISize sizes[3],
jbaumanb445a572016-06-09 13:24:48 -070026 SkYUVColorSpace colorSpace, bool nv12);
bsalomonf267c1e2016-02-01 13:16:14 -080027
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 */
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -050033 sk_sp<GrFragmentProcessor> MakeRGBToYUV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace);
bsalomonf267c1e2016-02-01 13:16:14 -080034
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 */
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -050040 sk_sp<GrFragmentProcessor> MakeRGBToUV(sk_sp<GrFragmentProcessor>, SkYUVColorSpace);
bsalomonf267c1e2016-02-01 13:16:14 -080041 /**
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 */
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -050046 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);
bsalomonf267c1e2016-02-01 13:16:14 -080049};
50
51#endif