Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkColorMatrixFilter.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 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
16
18 if (0xFF == byte) {
19 // want to get this exact
20 return 1;
21 } else {
22 return byte * 0.00392156862745f;
23 }
24}
25
27 const SkColor opaqueAlphaMask = SK_ColorBLACK;
28 // omit the alpha and compare only the RGB values
29 if (0 == (add & ~opaqueAlphaMask)) {
30 return SkColorFilters::Blend(mul | opaqueAlphaMask, SkBlendMode::kModulate);
31 }
32
33 SkColorMatrix matrix;
34 matrix.setScale(byte_to_unit_float(SkColorGetR(mul)),
37 1);
38 matrix.postTranslate(byte_to_unit_float(SkColorGetR(add)),
41 0);
42 return SkColorFilters::Matrix(matrix);
43}
@ kModulate
r = s*d
unsigned U8CPU
Definition SkCPUTypes.h:18
static SkScalar byte_to_unit_float(U8CPU byte)
#define SkColorGetR(color)
Definition SkColor.h:65
#define SkColorGetG(color)
Definition SkColor.h:69
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
#define SkColorGetB(color)
Definition SkColor.h:73
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
static sk_sp< SkColorFilter > Lighting(SkColor mul, SkColor add)
float SkScalar
Definition extension.cpp:12