Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
SkBlurMaskFilterImpl.cpp File Reference
#include "src/core/SkBlurMaskFilterImpl.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkBlurTypes.h"
#include "include/core/SkFlattenable.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathBuilder.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/effects/SkImageFilters.h"
#include "include/private/base/SkAlign.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkFloatingPoint.h"
#include "include/private/base/SkTemplates.h"
#include "src/base/SkTLazy.h"
#include "src/core/SkBlitter_A8.h"
#include "src/core/SkBlurMask.h"
#include "src/core/SkCachedData.h"
#include "src/core/SkDrawBase.h"
#include "src/core/SkMask.h"
#include "src/core/SkMaskCache.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkResourceCache.h"
#include "src/core/SkWriteBuffer.h"
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <utility>

Go to the source code of this file.

Functions

static bool prepare_to_draw_into_mask (const SkRect &bounds, SkMaskBuilder *mask)
 
template<typename Proc >
bool draw_into_mask (SkMaskBuilder *mask, const SkRect &bounds, Proc proc)
 
static bool draw_rects_into_mask (const SkRect rects[], int count, SkMaskBuilder *mask)
 
static bool draw_rrect_into_mask (const SkRRect rrect, SkMaskBuilder *mask)
 
static bool rect_exceeds (const SkRect &r, SkScalar v)
 
static SkCachedDatacopy_mask_to_cacheddata (SkMaskBuilder *mask)
 
static SkCachedDatafind_cached_rrect (SkTLazy< SkMask > *mask, SkScalar sigma, SkBlurStyle style, const SkRRect &rrect)
 
static SkCachedDataadd_cached_rrect (SkMaskBuilder *mask, SkScalar sigma, SkBlurStyle style, const SkRRect &rrect)
 
static SkCachedDatafind_cached_rects (SkTLazy< SkMask > *mask, SkScalar sigma, SkBlurStyle style, const SkRect rects[], int count)
 
static SkCachedDataadd_cached_rects (SkMaskBuilder *mask, SkScalar sigma, SkBlurStyle style, const SkRect rects[], int count)
 
void sk_register_blur_maskfilter_createproc ()
 

Variables

static const bool c_analyticBlurRRect {true}
 
static const bool c_analyticBlurNinepatch {true}
 

Function Documentation

◆ add_cached_rects()

static SkCachedData * add_cached_rects ( SkMaskBuilder mask,
SkScalar  sigma,
SkBlurStyle  style,
const SkRect  rects[],
int  count 
)
static

Definition at line 233 of file SkBlurMaskFilterImpl.cpp.

234 {
236 if (cache) {
237 SkMaskCache::Add(sigma, style, rects, count, *mask, cache);
238 }
239 return cache;
240}
int count
static SkCachedData * copy_mask_to_cacheddata(SkMaskBuilder *mask)
static void Add(SkScalar sigma, SkBlurStyle style, const SkRRect &rrect, const SkMask &mask, SkCachedData *data, SkResourceCache *localCache=nullptr)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition switches.h:191

◆ add_cached_rrect()

static SkCachedData * add_cached_rrect ( SkMaskBuilder mask,
SkScalar  sigma,
SkBlurStyle  style,
const SkRRect rrect 
)
static

Definition at line 219 of file SkBlurMaskFilterImpl.cpp.

220 {
222 if (cache) {
223 SkMaskCache::Add(sigma, style, rrect, *mask, cache);
224 }
225 return cache;
226}

◆ copy_mask_to_cacheddata()

static SkCachedData * copy_mask_to_cacheddata ( SkMaskBuilder mask)
static

Definition at line 203 of file SkBlurMaskFilterImpl.cpp.

203 {
204 const size_t size = mask->computeTotalImageSize();
206 if (data) {
207 memcpy(data->writable_data(), mask->fImage, size);
209 mask->image() = (uint8_t*)data->writable_data();
210 }
211 return data;
212}
static SkCachedData * NewCachedData(size_t bytes)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h: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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
static void FreeImage(void *image)
Definition SkMask.cpp:57
uint8_t *& image()
Definition SkMask.h:236
uint8_t const *const fImage
Definition SkMask.h:41
size_t computeTotalImageSize() const
Definition SkMask.cpp:34

◆ draw_into_mask()

template<typename Proc >
bool draw_into_mask ( SkMaskBuilder mask,
const SkRect bounds,
Proc  proc 
)

Definition at line 148 of file SkBlurMaskFilterImpl.cpp.

148 {
149 if (!prepare_to_draw_into_mask(bounds, mask)) {
150 return false;
151 }
152
153 const int dx = mask->fBounds.fLeft;
154 const int dy = mask->fBounds.fTop;
155 SkRasterClip rclip(mask->fBounds);
156 rclip.setRect(mask->fBounds.makeOffset(-dx, -dy));
157
159 auto info = SkImageInfo::MakeA8(mask->fBounds.width(), mask->fBounds.height());
160 auto pm = SkPixmap(info, mask->fImage, mask->fRowBytes);
161
163
166 draw.fCTM = &ctm;
167 draw.fDst = pm;
168 draw.fRC = &rclip;
169
171 paint.setAntiAlias(true);
172
173 proc(draw, paint);
174 return true;
175}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
#define SkASSERT(cond)
Definition SkAssert.h:116
SkBlitter * SkA8Blitter_Choose(const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *alloc, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &)
static bool prepare_to_draw_into_mask(const SkRect &bounds, SkMaskBuilder *mask)
#define SkIntToScalar(x)
Definition SkScalar.h:57
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
BlitterChooser * fBlitterChooser
Definition SkDrawBase.h:152
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition SkMatrix.h:91
const Paint & paint
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition SkRecords.h:208
constexpr int32_t height() const
Definition SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
constexpr int32_t width() const
Definition SkRect.h:158
constexpr SkIRect makeOffset(int32_t dx, int32_t dy) const
Definition SkRect.h:300
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33
static SkImageInfo MakeA8(int width, int height)
const uint32_t fRowBytes
Definition SkMask.h:43
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition SkMask.h:28
const SkIRect fBounds
Definition SkMask.h:42
const Format fFormat
Definition SkMask.h:44

◆ draw_rects_into_mask()

static bool draw_rects_into_mask ( const SkRect  rects[],
int  count,
SkMaskBuilder mask 
)
static

Definition at line 177 of file SkBlurMaskFilterImpl.cpp.

177 {
178 return draw_into_mask(mask, rects[0], [&](SkDrawBase& draw, const SkPaint& paint) {
179 if (1 == count) {
180 draw.drawRect(rects[0], paint);
181 } else {
182 // todo: do I need a fast way to do this?
183 SkPath path = SkPathBuilder().addRect(rects[0])
184 .addRect(rects[1])
186 .detach();
187 draw.drawPath(path, paint);
188 }
189 });
190}
bool draw_into_mask(SkMaskBuilder *mask, const SkRect &bounds, Proc proc)
SkPathBuilder & addRect(const SkRect &, SkPathDirection, unsigned startIndex)
SkPathBuilder & setFillType(SkPathFillType ft)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ draw_rrect_into_mask()

static bool draw_rrect_into_mask ( const SkRRect  rrect,
SkMaskBuilder mask 
)
static

Definition at line 192 of file SkBlurMaskFilterImpl.cpp.

192 {
193 return draw_into_mask(mask, rrect.rect(), [&](SkDrawBase& draw, const SkPaint& paint) {
194 draw.drawRRect(rrect, paint);
195 });
196}
const SkRect & rect() const
Definition SkRRect.h:264
SkRRect rrect
Definition SkRecords.h:232

◆ find_cached_rects()

static SkCachedData * find_cached_rects ( SkTLazy< SkMask > *  mask,
SkScalar  sigma,
SkBlurStyle  style,
const SkRect  rects[],
int  count 
)
static

Definition at line 228 of file SkBlurMaskFilterImpl.cpp.

229 {
230 return SkMaskCache::FindAndRef(sigma, style, rects, count, mask);
231}
static SkCachedData * FindAndRef(SkScalar sigma, SkBlurStyle style, const SkRRect &rrect, SkTLazy< SkMask > *mask, SkResourceCache *localCache=nullptr)

◆ find_cached_rrect()

static SkCachedData * find_cached_rrect ( SkTLazy< SkMask > *  mask,
SkScalar  sigma,
SkBlurStyle  style,
const SkRRect rrect 
)
static

Definition at line 214 of file SkBlurMaskFilterImpl.cpp.

215 {
216 return SkMaskCache::FindAndRef(sigma, style, rrect, mask);
217}

◆ prepare_to_draw_into_mask()

static bool prepare_to_draw_into_mask ( const SkRect bounds,
SkMaskBuilder mask 
)
static

Definition at line 134 of file SkBlurMaskFilterImpl.cpp.

134 {
135 SkASSERT(mask != nullptr);
136
137 mask->bounds() = bounds.roundOut();
138 mask->rowBytes() = SkAlign4(mask->fBounds.width());
139 mask->format() = SkMask::kA8_Format;
140 const size_t size = mask->computeImageSize();
142 if (nullptr == mask->fImage) {
143 return false;
144 }
145 return true;
146}
static constexpr T SkAlign4(T x)
Definition SkAlign.h:16
Optional< SkRect > bounds
Definition SkRecords.h:189
@ kZeroInit_Alloc
Definition SkMask.h:293
Format & format()
Definition SkMask.h:239
uint32_t & rowBytes()
Definition SkMask.h:238
static uint8_t * AllocImage(size_t bytes, AllocType=kUninit_Alloc)
Definition SkMask.cpp:45
SkIRect & bounds()
Definition SkMask.h:237
size_t computeImageSize() const
Definition SkMask.cpp:30

◆ rect_exceeds()

static bool rect_exceeds ( const SkRect r,
SkScalar  v 
)
static

Definition at line 198 of file SkBlurMaskFilterImpl.cpp.

198 {
199 return r.fLeft < -v || r.fTop < -v || r.fRight > v || r.fBottom > v ||
200 r.width() > v || r.height() > v;
201}
SkScalar fBottom
larger y-axis bounds
Definition extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition extension.cpp:16
constexpr float height() const
Definition SkRect.h:769
constexpr float width() const
Definition SkRect.h:762
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15

◆ sk_register_blur_maskfilter_createproc()

void sk_register_blur_maskfilter_createproc ( )

Variable Documentation

◆ c_analyticBlurNinepatch

const bool c_analyticBlurNinepatch {true}
static

Definition at line 378 of file SkBlurMaskFilterImpl.cpp.

378{true};

◆ c_analyticBlurRRect

const bool c_analyticBlurRRect {true}
static

Definition at line 242 of file SkBlurMaskFilterImpl.cpp.

242{true};