Flutter Engine
The Flutter Engine
SkBlurMask.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
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
8#ifndef SkBlurMask_DEFINED
9#define SkBlurMask_DEFINED
10
13#include "src/core/SkMask.h"
14
15#include <cstdint>
16
17class SkRRect;
18enum SkBlurStyle : int;
19struct SkIPoint;
20struct SkRect;
21
23public:
24 [[nodiscard]] static bool BlurRect(SkScalar sigma, SkMaskBuilder *dst, const SkRect &src,
25 SkBlurStyle, SkIPoint *margin = nullptr,
26 SkMaskBuilder::CreateMode createMode =
28 [[nodiscard]] static bool BlurRRect(SkScalar sigma, SkMaskBuilder *dst, const SkRRect &src,
29 SkBlurStyle, SkIPoint *margin = nullptr,
30 SkMaskBuilder::CreateMode createMode =
32
33 // forceQuality will prevent BoxBlur from falling back to the low quality approach when sigma
34 // is very small -- this can be used predict the margin bump ahead of time without completely
35 // replicating the internal logic. This permits not only simpler caching of blurred results,
36 // but also being able to predict precisely at what pixels the blurred profile of e.g. a
37 // rectangle will lie.
38 //
39 // Calling details:
40 // * calculate margin - if src.fImage is null, then this call only calculates the border.
41 // * failure - if src.fImage is not null, failure is signal with dst->fImage being
42 // null.
43
44 [[nodiscard]] static bool BoxBlur(SkMaskBuilder* dst, const SkMask& src,
45 SkScalar sigma, SkBlurStyle style,
46 SkIPoint* margin = nullptr);
47
48 // the "ground truth" blur does a gaussian convolution; it's slow
49 // but useful for comparison purposes.
50 [[nodiscard]] static bool BlurGroundTruth(SkScalar sigma, SkMaskBuilder* dst,
51 const SkMask& src,
52 SkBlurStyle, SkIPoint* margin = nullptr);
53
54 // If radius > 0, return the corresponding sigma, else return 0
56 // If sigma > 0.5, return the corresponding radius, else return 0
58
59 /* Helper functions for analytic rectangle blurs */
60
61 /** Look up the intensity of the (one dimnensional) blurred half-plane.
62 @param profile The precomputed 1D blur profile; initialized by ComputeBlurProfile below.
63 @param loc the location to look up; The lookup will clamp invalid inputs, but
64 meaningful data are available between 0 and blurred_width
65 @param blurred_width The width of the final, blurred rectangle
66 @param sharp_width The width of the original, unblurred rectangle.
67 */
68 static uint8_t ProfileLookup(const uint8_t* profile, int loc, int blurredWidth, int sharpWidth);
69
70 /** Populate the profile of a 1D blurred halfplane.
71 @param profile The 1D table to fill in
72 @param size Should be 6*sigma bytes
73 @param sigma The standard deviation of the gaussian blur kernel
74 */
75 static void ComputeBlurProfile(uint8_t* profile, int size, SkScalar sigma);
76
77 /** Compute an entire scanline of a blurred step function. This is a 1D helper that
78 will produce both the horizontal and vertical profiles of the blurry rectangle.
79 @param pixels Location to store the resulting pixel data; allocated and managed by caller
80 @param profile Precomputed blur profile computed by ComputeBlurProfile above.
81 @param width Size of the pixels array.
82 @param sigma Standard deviation of the gaussian blur kernel used to compute the profile;
83 this implicitly gives the size of the pixels array.
84 */
85
86 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile,
87 unsigned int width, SkScalar sigma);
88};
89
90#endif
#define SK_SPI
Definition: SkAPI.h:41
SkBlurStyle
Definition: SkBlurTypes.h:11
static void ComputeBlurProfile(uint8_t *profile, int size, SkScalar sigma)
Definition: SkBlurMask.cpp:349
static void ComputeBlurredScanline(uint8_t *pixels, const uint8_t *profile, unsigned int width, SkScalar sigma)
Definition: SkBlurMask.cpp:383
static bool BlurRect(SkScalar sigma, SkMaskBuilder *dst, const SkRect &src, SkBlurStyle, SkIPoint *margin=nullptr, SkMaskBuilder::CreateMode createMode=SkMaskBuilder::kComputeBoundsAndRenderImage_CreateMode)
Definition: SkBlurMask.cpp:407
static bool BlurRRect(SkScalar sigma, SkMaskBuilder *dst, const SkRRect &src, SkBlurStyle, SkIPoint *margin=nullptr, SkMaskBuilder::CreateMode createMode=SkMaskBuilder::kComputeBoundsAndRenderImage_CreateMode)
Definition: SkBlurMask.cpp:504
static SkScalar SK_SPI ConvertSigmaToRadius(SkScalar sigma)
Definition: SkBlurMask.cpp:43
static SkScalar SK_SPI ConvertRadiusToSigma(SkScalar radius)
Definition: SkBlurMask.cpp:39
static bool BlurGroundTruth(SkScalar sigma, SkMaskBuilder *dst, const SkMask &src, SkBlurStyle, SkIPoint *margin=nullptr)
Definition: SkBlurMask.cpp:517
static bool BoxBlur(SkMaskBuilder *dst, const SkMask &src, SkScalar sigma, SkBlurStyle style, SkIPoint *margin=nullptr)
Definition: SkBlurMask.cpp:116
static uint8_t ProfileLookup(const uint8_t *profile, int loc, int blurredWidth, int sharpWidth)
Definition: SkBlurMask.cpp:371
float SkScalar
Definition: extension.cpp:12
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
dst
Definition: cp.py:12
int32_t width
@ kComputeBoundsAndRenderImage_CreateMode
compute bounds, alloc image and render into it
Definition: SkMask.h:301
Definition: SkMask.h:25