Flutter Engine
The Flutter Engine
Enumerations | Functions | Variables
SkBlendModePriv.h File Reference
#include "include/core/SkBlendMode.h"
#include "include/core/SkColor.h"
#include "include/private/SkColorData.h"

Go to the source code of this file.

Enumerations

enum class  SkBlendFastPath { kNormal , kSrcOver , kSkipDrawing }
 

Functions

bool SkBlendMode_SupportsCoverageAsAlpha (SkBlendMode)
 
static bool SkBlendMode_CaresAboutRBOrder (SkBlendMode mode)
 
bool SkBlendMode_ShouldPreScaleCoverage (SkBlendMode, bool rgb_coverage)
 
void SkBlendMode_AppendStages (SkBlendMode, SkRasterPipeline *)
 
SkPMColor4f SkBlendMode_Apply (SkBlendMode, const SkPMColor4f &src, const SkPMColor4f &dst)
 
SkBlendFastPath CheckFastPath (const SkPaint &, bool dstIsOpaque)
 

Variables

constexpr uint8_t kCustom_SkBlendMode = 0xFF
 

Enumeration Type Documentation

◆ SkBlendFastPath

enum class SkBlendFastPath
strong
Enumerator
kNormal 
kSrcOver 
kSkipDrawing 

Definition at line 36 of file SkBlendModePriv.h.

36 {
37 kNormal, // draw normally
38 kSrcOver, //< draw as if in srcover mode
39 kSkipDrawing //< draw nothing
40};
@ kNormal
Default priority level.
Definition: embedder.h:262
@ kSrcOver
r = s + (1-sa)*d

Function Documentation

◆ CheckFastPath()

SkBlendFastPath CheckFastPath ( const SkPaint paint,
bool  dstIsOpaque 
)

Given a paint, determine whether the paint's blend mode can be replaced with kSrcOver or not drawn at all. This can inform drawing optimizations.

Definition at line 208 of file SkBlendMode.cpp.

208 {
209 const auto bm = paint.asBlendMode();
210 if (!bm) {
212 }
213 switch (bm.value()) {
217 if (just_solid_color(paint)) {
219 }
224 if (dstIsOpaque) {
226 }
229 if (dstIsOpaque && just_solid_color(paint)) {
231 }
234 if (just_solid_color(paint)) {
236 }
238 default:
240 }
241}
static bool just_solid_color(const SkPaint &p)
@ kDstIn
r = d * sa
@ kSrcOver
r = s + (1-sa)*d
@ kDstOver
r = d + (1-da)*s
@ kSrcIn
r = s * da
const Paint & paint
Definition: color_source.cc:38

◆ SkBlendMode_AppendStages()

void SkBlendMode_AppendStages ( SkBlendMode  mode,
SkRasterPipeline p 
)

Definition at line 97 of file SkBlendMode.cpp.

97 {
98 auto stage = SkRasterPipelineOp::srcover;
99 switch (mode) {
100 case SkBlendMode::kClear: stage = SkRasterPipelineOp::clear; break;
101 case SkBlendMode::kSrc: return; // This stage is a no-op.
102 case SkBlendMode::kDst: stage = SkRasterPipelineOp::move_dst_src; break;
103 case SkBlendMode::kSrcOver: stage = SkRasterPipelineOp::srcover; break;
104 case SkBlendMode::kDstOver: stage = SkRasterPipelineOp::dstover; break;
105 case SkBlendMode::kSrcIn: stage = SkRasterPipelineOp::srcin; break;
106 case SkBlendMode::kDstIn: stage = SkRasterPipelineOp::dstin; break;
107 case SkBlendMode::kSrcOut: stage = SkRasterPipelineOp::srcout; break;
108 case SkBlendMode::kDstOut: stage = SkRasterPipelineOp::dstout; break;
109 case SkBlendMode::kSrcATop: stage = SkRasterPipelineOp::srcatop; break;
110 case SkBlendMode::kDstATop: stage = SkRasterPipelineOp::dstatop; break;
111 case SkBlendMode::kXor: stage = SkRasterPipelineOp::xor_; break;
112 case SkBlendMode::kPlus: stage = SkRasterPipelineOp::plus_; break;
113 case SkBlendMode::kModulate: stage = SkRasterPipelineOp::modulate; break;
114
115 case SkBlendMode::kScreen: stage = SkRasterPipelineOp::screen; break;
116 case SkBlendMode::kOverlay: stage = SkRasterPipelineOp::overlay; break;
117 case SkBlendMode::kDarken: stage = SkRasterPipelineOp::darken; break;
118 case SkBlendMode::kLighten: stage = SkRasterPipelineOp::lighten; break;
119 case SkBlendMode::kColorDodge: stage = SkRasterPipelineOp::colordodge; break;
120 case SkBlendMode::kColorBurn: stage = SkRasterPipelineOp::colorburn; break;
121 case SkBlendMode::kHardLight: stage = SkRasterPipelineOp::hardlight; break;
122 case SkBlendMode::kSoftLight: stage = SkRasterPipelineOp::softlight; break;
124 case SkBlendMode::kExclusion: stage = SkRasterPipelineOp::exclusion; break;
126
127 case SkBlendMode::kHue: stage = SkRasterPipelineOp::hue; break;
131 }
132 p->append(stage);
133}
@ 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
@ 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
@ 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)
@ 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
@ kClear
r = 0
static size_t difference(size_t minuend, size_t subtrahend)
DlColor color
static void luminosity(float dr, float dg, float db, float *sr, float *sg, float *sb)
Definition: hsl.cpp:130
static void hue(float dr, float dg, float db, float *sr, float *sg, float *sb)
Definition: hsl.cpp:92
static void saturation(float dr, float dg, float db, float *sr, float *sg, float *sb)
Definition: hsl.cpp:105
Int96 multiply(int64_t a, int32_t b)
Definition: Int96.cpp:41
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

◆ SkBlendMode_Apply()

SkPMColor4f SkBlendMode_Apply ( SkBlendMode  mode,
const SkPMColor4f src,
const SkPMColor4f dst 
)

Definition at line 135 of file SkBlendMode.cpp.

135 {
136 // special-case simple/common modes...
137 switch (mode) {
139 case SkBlendMode::kSrc: return src;
140 case SkBlendMode::kDst: return dst;
142 SkPMColor4f r;
143 (skvx::float4::Load(src.vec()) + skvx::float4::Load(dst.vec()) * (1-src.fA)).store(&r);
144 return r;
145 }
146 default:
147 break;
148 }
149
151 SkPMColor4f src_storage = src,
152 dst_storage = dst,
153 res_storage;
154 SkRasterPipeline_MemoryCtx src_ctx = { &src_storage, 0 },
155 dst_ctx = { &dst_storage, 0 },
156 res_ctx = { &res_storage, 0 };
157
158 p.append(SkRasterPipelineOp::load_f32, &dst_ctx);
159 p.append(SkRasterPipelineOp::move_src_dst);
160 p.append(SkRasterPipelineOp::load_f32, &src_ctx);
162 p.append(SkRasterPipelineOp::store_f32, &res_ctx);
163 p.run(0,0, 1,1);
164 return res_storage;
165}
void SkBlendMode_AppendStages(SkBlendMode mode, SkRasterPipeline *p)
Definition: SkBlendMode.cpp:97
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
Definition: SkColorData.h:378
dst
Definition: cp.py:12
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition: SkVx.h:109

◆ SkBlendMode_CaresAboutRBOrder()

static bool SkBlendMode_CaresAboutRBOrder ( SkBlendMode  mode)
inlinestatic

Definition at line 27 of file SkBlendModePriv.h.

27 {
29}
@ kLastSeparableMode
last blend mode operating separately on components

◆ SkBlendMode_ShouldPreScaleCoverage()

bool SkBlendMode_ShouldPreScaleCoverage ( SkBlendMode  mode,
bool  rgb_coverage 
)

Definition at line 21 of file SkBlendMode.cpp.

21 {
22 // The most important things we do here are:
23 // 1) never pre-scale with rgb coverage if the blend mode involves a source-alpha term;
24 // 2) always pre-scale Plus.
25 //
26 // When we pre-scale with rgb coverage, we scale each of source r,g,b, with a distinct value,
27 // and source alpha with one of those three values. This process destructively updates the
28 // source-alpha term, so we can't evaluate blend modes that need its original value.
29 //
30 // Plus always requires pre-scaling as a specific quirk of its implementation in
31 // SkRasterPipeline. This lets us put the clamp inside the blend mode itself rather
32 // than as a separate stage that'd come after the lerp.
33 //
34 // This function is a finer-grained breakdown of SkBlendMode_SupportsCoverageAsAlpha().
35 switch (mode) {
36 case SkBlendMode::kDst: // d --> no sa term, ok!
37 case SkBlendMode::kDstOver: // d + s*inv(da) --> no sa term, ok!
38 case SkBlendMode::kPlus: // clamp(s+d) --> no sa term, ok!
39 return true;
40
41 case SkBlendMode::kDstOut: // d * inv(sa)
42 case SkBlendMode::kSrcATop: // s*da + d*inv(sa)
43 case SkBlendMode::kSrcOver: // s + d*inv(sa)
44 case SkBlendMode::kXor: // s*inv(da) + d*inv(sa)
45 return !rgb_coverage;
46
47 default: break;
48 }
49 return false;
50}

◆ SkBlendMode_SupportsCoverageAsAlpha()

bool SkBlendMode_SupportsCoverageAsAlpha ( SkBlendMode  mode)

Definition at line 53 of file SkBlendMode.cpp.

53 {
55}
bool SkBlendMode_ShouldPreScaleCoverage(SkBlendMode mode, bool rgb_coverage)
Definition: SkBlendMode.cpp:21

Variable Documentation

◆ kCustom_SkBlendMode

constexpr uint8_t kCustom_SkBlendMode = 0xFF
constexpr

Sentinel value for SkBlendMode enum.

Will never be a valid enum value, but will be storable in a byte.

Definition at line 23 of file SkBlendModePriv.h.