Ethan Nicholas | 130fb3f | 2018-02-01 12:14:34 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 | |
Ethan Nicholas | 14efcbf | 2017-11-07 09:23:38 -0500 | [diff] [blame] | 8 | @class { |
| 9 | #include "SkColorData.h" |
| 10 | |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 11 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override { |
| 12 | float luma = SK_ITU_BT709_LUM_COEFF_R * input.fR + |
| 13 | SK_ITU_BT709_LUM_COEFF_G * input.fG + |
| 14 | SK_ITU_BT709_LUM_COEFF_B * input.fB; |
| 15 | return { 0, 0, 0, luma }; |
Ethan Nicholas | 14efcbf | 2017-11-07 09:23:38 -0500 | [diff] [blame] | 16 | } |
| 17 | } |
| 18 | |
| 19 | void main() { |
| 20 | const half3 SK_ITU_BT709_LUM_COEFF = half3(0.2126, 0.7152, 0.0722); |
| 21 | half luma = dot(SK_ITU_BT709_LUM_COEFF, sk_InColor.rgb); |
| 22 | sk_OutColor = half4(0, 0, 0, luma); |
| 23 | } |