GrLumaColorFilterEffect.fp 728 B

1234567891011121314151617181920212223
  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. @class {
  8. #include "include/private/SkColorData.h"
  9. SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override {
  10. float luma = SK_ITU_BT709_LUM_COEFF_R * input.fR +
  11. SK_ITU_BT709_LUM_COEFF_G * input.fG +
  12. SK_ITU_BT709_LUM_COEFF_B * input.fB;
  13. return { 0, 0, 0, SkTPin(luma, 0.0f, 1.0f) };
  14. }
  15. }
  16. void main() {
  17. const half3 SK_ITU_BT709_LUM_COEFF = half3(0.2126, 0.7152, 0.0722);
  18. half luma = saturate(dot(SK_ITU_BT709_LUM_COEFF, sk_InColor.rgb));
  19. sk_OutColor = half4(0, 0, 0, luma);
  20. }