Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
SkBlenders Class Reference

#include <SkBlenders.h>

Static Public Member Functions

static sk_sp< SkBlenderArithmetic (float k1, float k2, float k3, float k4, bool enforcePremul)
 

Detailed Description

Definition at line 13 of file SkBlenders.h.

Member Function Documentation

◆ Arithmetic()

sk_sp< SkBlender > SkBlenders::Arithmetic ( float  k1,
float  k2,
float  k3,
float  k4,
bool  enforcePremul 
)
static

Create a blender that implements the following: k1 * src * dst + k2 * src + k3 * dst + k4

Parameters
k1,k2,k3,k4The four coefficients.
enforcePMColorIf true, the RGB channels will be clamped to the calculated alpha.

Definition at line 20 of file SkBlenders.cpp.

21 {
22 using namespace SkKnownRuntimeEffects;
23
24 if (!SkIsFinite(k1, k2, k3, k4)) {
25 return nullptr;
26 }
27
28 // Are we nearly a SkBlendMode?
29 const struct {
30 float k1, k2, k3, k4;
32 } table[] = {
33 { 0, 1, 0, 0, SkBlendMode::kSrc },
34 { 0, 0, 1, 0, SkBlendMode::kDst },
35 { 0, 0, 0, 0, SkBlendMode::kClear },
36 };
37 for (const auto& t : table) {
38 if (SkScalarNearlyEqual(k1, t.k1) &&
39 SkScalarNearlyEqual(k2, t.k2) &&
40 SkScalarNearlyEqual(k3, t.k3) &&
41 SkScalarNearlyEqual(k4, t.k4)) {
42 return SkBlender::Mode(t.mode);
43 }
44 }
45
46 // If we get here, we need the actual blender effect.
47 const SkRuntimeEffect* arithmeticEffect = GetKnownRuntimeEffect(StableKey::kArithmetic);
48
49 const float array[] = {
50 k1, k2, k3, k4,
51 enforcePremul ? 0.0f : 1.0f,
52 };
53 return arithmeticEffect->makeBlender(SkData::MakeWithCopy(array, sizeof(array)));
54}
SkBlendMode
Definition SkBlendMode.h:38
@ kClear
r = 0
static bool SkIsFinite(T x, Pack... values)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:107
SI F table(const skcms_Curve *curve, F v)
static sk_sp< SkBlender > Mode(SkBlendMode mode)
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition SkData.cpp:111
sk_sp< SkBlender > makeBlender(sk_sp< const SkData > uniforms, SkSpan< const ChildPtr > children={}) const
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition switches.h:228

The documentation for this class was generated from the following files: