Flutter Engine
The Flutter Engine
Utils.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 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
9
10namespace jetski {
11namespace utils {
12
13SkSamplingOptions SamplingOptions(jint desc, jfloat coeffB, jfloat coeffC) {
14 if (desc & 0x01) {
15 return SkSamplingOptions(SkCubicResampler{coeffB, coeffC});
16 }
17
18 const auto fm = static_cast<SkFilterMode>((desc >> 1) & 0x01);
20 const auto mm = static_cast<SkMipmapMode>((desc >> 2) & 0x03);
22
23 return SkSamplingOptions(fm, mm);
24}
25
27 // to catch Skia API changes
28 static_assert(static_cast<int>(SkTileMode::kClamp ) == 0);
29 static_assert(static_cast<int>(SkTileMode::kRepeat) == 1);
30 static_assert(static_cast<int>(SkTileMode::kMirror) == 2);
31 static_assert(static_cast<int>(SkTileMode::kDecal ) == 3);
32
33 return static_cast<SkTileMode>(tm);
34}
35
37 // catch API changes
38 static_assert(0 == static_cast<int>(SkBlendMode::kClear));
39 static_assert(1 == static_cast<int>(SkBlendMode::kSrc));
40 static_assert(2 == static_cast<int>(SkBlendMode::kDst));
41 static_assert(3 == static_cast<int>(SkBlendMode::kSrcOver));
42 static_assert(4 == static_cast<int>(SkBlendMode::kDstOver));
43 static_assert(5 == static_cast<int>(SkBlendMode::kSrcIn));
44 static_assert(6 == static_cast<int>(SkBlendMode::kDstIn));
45 static_assert(7 == static_cast<int>(SkBlendMode::kSrcOut));
46 static_assert(8 == static_cast<int>(SkBlendMode::kDstOut));
47 static_assert(9 == static_cast<int>(SkBlendMode::kSrcATop));
48 static_assert(10 == static_cast<int>(SkBlendMode::kDstATop));
49 static_assert(11 == static_cast<int>(SkBlendMode::kXor));
50 static_assert(12 == static_cast<int>(SkBlendMode::kPlus));
51 static_assert(13 == static_cast<int>(SkBlendMode::kModulate));
52 static_assert(14 == static_cast<int>(SkBlendMode::kScreen));
53
54 static_assert(15 == static_cast<int>(SkBlendMode::kOverlay));
55 static_assert(16 == static_cast<int>(SkBlendMode::kDarken));
56 static_assert(17 == static_cast<int>(SkBlendMode::kLighten));
57 static_assert(18 == static_cast<int>(SkBlendMode::kColorDodge));
58 static_assert(19 == static_cast<int>(SkBlendMode::kColorBurn));
59 static_assert(20 == static_cast<int>(SkBlendMode::kHardLight));
60 static_assert(21 == static_cast<int>(SkBlendMode::kSoftLight));
61 static_assert(22 == static_cast<int>(SkBlendMode::kDifference));
62 static_assert(23 == static_cast<int>(SkBlendMode::kExclusion));
63 static_assert(24 == static_cast<int>(SkBlendMode::kMultiply));
64
65 static_assert(25 == static_cast<int>(SkBlendMode::kHue));
66 static_assert(26 == static_cast<int>(SkBlendMode::kSaturation));
67 static_assert(27 == static_cast<int>(SkBlendMode::kColor));
68 static_assert(28 == static_cast<int>(SkBlendMode::kLuminosity));
69
70
71 return static_cast<SkBlendMode>(bm);
72}
73
74} // namespace utils
75} // namespace jetski
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkBlendMode
Definition: SkBlendMode.h:38
@ kSrcOut
r = s * (1-da)
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kPlus
r = min(s + d, 1)
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kDstIn
r = d * sa
@ kModulate
r = s*d
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kScreen
r = s + d - s*d
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kSrcIn
r = s * da
@ kClear
r = 0
SkFilterMode
SkMipmapMode
SkTileMode
Definition: SkTileMode.h:13
SkTileMode TileMode(jint tm)
Definition: Utils.cpp:26
SkBlendMode BlendMode(jint bm)
Definition: Utils.cpp:36
SkSamplingOptions SamplingOptions(jint desc, jfloat coeffB, jfloat coeffC)
Definition: Utils.cpp:13
Definition: Utils.cpp:10
SkSamplingOptions(SkFilterMode::kLinear))
Definition: utils.py:1