aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrLumaColorFilterEffect.fp
blob: 17f270b1536efd6fdfa7b68c30806a7727493c96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

@class {
    #include "SkColorData.h"

    GrColor4f constantOutputForConstantInput(GrColor4f input) const override {
        float luma = SK_ITU_BT709_LUM_COEFF_R * input.fRGBA[0] +
                     SK_ITU_BT709_LUM_COEFF_G * input.fRGBA[1] +
                     SK_ITU_BT709_LUM_COEFF_B * input.fRGBA[2];
        return GrColor4f(0, 0, 0, luma);
    }
}

void main() {
    const half3 SK_ITU_BT709_LUM_COEFF = half3(0.2126, 0.7152, 0.0722);
    half luma = dot(SK_ITU_BT709_LUM_COEFF, sk_InColor.rgb);
    sk_OutColor = half4(0, 0, 0, luma);
}