54 const float twoSigmaSqrdX = 2.0f * sigma.
width() * sigma.
width();
55 const float twoSigmaSqrdY = 2.0f * sigma.
height() * sigma.
height();
61 const float sigmaXDenom = radius.
width() > 0 ? 1.0f / twoSigmaSqrdX : 1.f;
62 const float sigmaYDenom = radius.
height() > 0 ? 1.0f / twoSigmaSqrdY : 1.f;
66 float xTerm =
static_cast<float>(
x - radius.
width());
67 xTerm = xTerm * xTerm * sigmaXDenom;
69 float yTerm =
static_cast<float>(
y - radius.
height());
70 float xyTerm = std::exp(-(xTerm + yTerm * yTerm * sigmaYDenom));
78 float scale = 1.0f / sum;
79 for (
size_t i = 0;
i < kernelSize; ++
i) {
83 memset(kernel.
data() + kernelSize, 0,
sizeof(
float)*(kernel.
size() - kernelSize));
88 std::array<SkV4, kMaxSamples/4>& kernel) {
89 static_assert(
sizeof(kernel) ==
sizeof(std::array<float, kMaxSamples>));
90 static_assert(
alignof(
float) ==
alignof(
SkV4));
91 float*
data = kernel[0].ptr();
96 std::array<SkV4, kMaxSamples/2>&
offsets) {
106 offsetView[2*
i+1] =
y;
111 const int lastValidOffset = 2*(kernelArea - 1);
113 offsetView[2*
i] = offsetView[lastValidOffset];
114 offsetView[2*
i+1] = offsetView[lastValidOffset+1];
121 std::array<SkV4, kMaxSamples/2>& offsetsAndKernel) {
132 auto get_new_weight = [](
float* new_w,
float*
offset,
float wi,
float wj) {
141 std::array<float, kMaxKernelWidth> fullKernel;
144 std::array<float, kMaxSamples> kernel;
145 std::array<float, kMaxSamples>
offsets;
148 int halfRadius = halfSize / 2;
149 int lowIndex = halfRadius - 1;
164 get_new_weight(&kernel[halfRadius],
166 fullKernel[index] * 0.5f,
167 fullKernel[index + 1]);
168 kernel[lowIndex] = kernel[halfRadius];
175 kernel[halfRadius] = fullKernel[index];
181 for (
int i = halfRadius + 1;
i < halfSize; index += 2,
i++, lowIndex--) {
182 get_new_weight(&kernel[
i], &
offsets[
i], fullKernel[index], fullKernel[index + 1]);
183 offsets[
i] +=
static_cast<float>(index - radius);
186 kernel[lowIndex] = kernel[
i];
191 memset(kernel.data() + halfSize, 0,
sizeof(
float)*(
kMaxSamples - halfSize));
206 switch(kernelWidth) {
208 case 2: [[fallthrough]];
209 case 3: [[fallthrough]];
211 case 5: [[fallthrough]];
212 case 6: [[fallthrough]];
213 case 7: [[fallthrough]];
215 case 9: [[fallthrough]];
216 case 10: [[fallthrough]];
217 case 11: [[fallthrough]];
219 case 13: [[fallthrough]];
220 case 14: [[fallthrough]];
221 case 15: [[fallthrough]];
223 case 17: [[fallthrough]];
224 case 18: [[fallthrough]];
225 case 19: [[fallthrough]];
228 case 21: [[fallthrough]];
229 case 22: [[fallthrough]];
230 case 23: [[fallthrough]];
231 case 24: [[fallthrough]];
232 case 25: [[fallthrough]];
233 case 26: [[fallthrough]];
234 case 27: [[fallthrough]];
244 static_cast<uint32_t
>(SkKnownRuntimeEffects::StableKey::k1DBlurBase)));
251 static_cast<uint32_t
>(SkKnownRuntimeEffects::StableKey::k2DBlurBase)));
260 const SkIRect& dstRect)
const {
286 if (fastDstRect.
intersect(safeSrcRect)) {
289 if (fastDstRect.
width() * fastDstRect.
height() < 128 * 128) {
310 if (fastDstRect != dstRect) {
319 }
else if (fastDstRect != dstRect) {
324 auto drawBorder = [&](
const SkIRect& r) {
330 drawBorder({dstRect.
left(), dstRect.
top(),
332 drawBorder({fastDstRect.
right(), dstRect.
top(),
334 drawBorder({fastDstRect.
left(), dstRect.
top(),
335 fastDstRect.
right(), fastDstRect.
top()});
336 drawBorder({fastDstRect.
left(), fastDstRect.
bottom(),
340 return device->snapSpecial(subset);
348 const SkIRect& dstRect)
const {
355 builder.uniform(
"kernel") = kernel;
360 std::move(input), srcRect, tileMode, dstRect);
374 builder.uniform(
"offsetsAndKernel") = offsetsAndKernel;
380 std::move(input), srcRect, tileMode, dstRect);
387 const SkIRect& dstRect)
const {
393 if (kernelArea <= kMaxSamples && radiusX > 0 && radiusY > 0) {
395 return this->evalBlur2D(sigma,
403 SkIRect intermediateSrcRect = srcRect;
404 SkIRect intermediateDstRect = dstRect;
415 intermediateDstRect.
outset(0, radiusY);
421 intermediateDstRect.
outset(0, radiusY);
425 if (intermediateDstRect.
fTop >= intermediateDstRect.
fBottom) {
431 src = this->evalBlur1D(sigma.
width(),
437 intermediateDstRect);
442 intermediateDstRect = dstRect.
makeOffset(-intermediateDstRect.
left(),
443 -intermediateDstRect.
top());
453 intermediateDstRect);
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static SkKnownRuntimeEffects::StableKey to_stablekey(int kernelWidth, uint32_t baseKey)
static int64_t sk_64_mul(int64_t a, int64_t b)
sk_sp< T > sk_ref_sp(T *obj)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
static int SigmaToRadius(float sigma)
sk_sp< SkColorSpace > refColorSpace() const
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static const SkMatrix & I()
BuilderChild child(std::string_view name)
sk_sp< SkShader > makeShader(const SkMatrix *localMatrix=nullptr) const
static constexpr int kMaxSamples
static void Compute1DBlurKernel(float sigma, int radius, SkSpan< float > kernel)
static void Compute1DBlurLinearKernel(float sigma, int radius, std::array< SkV4, kMaxSamples/2 > &offsetsAndKernel)
static constexpr float kMaxLinearSigma
virtual sk_sp< SkDevice > makeDevice(const SkImageInfo &) const =0
static void Compute2DBlurOffsets(SkISize radius, std::array< SkV4, kMaxSamples/2 > &offsets)
static constexpr int LinearKernelWidth(int radius)
sk_sp< SkSpecialImage > blur(SkSize sigma, sk_sp< SkSpecialImage > src, const SkIRect &srcRect, SkTileMode tileMode, const SkIRect &dstRect) const override
static const SkRuntimeEffect * GetBlur2DEffect(const SkISize &radii)
static constexpr int KernelWidth(int radius)
static const SkRuntimeEffect * GetLinearBlur1DEffect(int radius)
static void Compute2DBlurKernel(SkSize sigma, SkISize radius, SkSpan< float > kernel)
constexpr T * data() const
constexpr size_t size() const
sk_sp< SkSpecialImage > makeSubset(const SkIRect &subset) const
const SkColorInfo & colorInfo() const
virtual SkISize backingStoreDimensions() const =0
virtual sk_sp< SkShader > asShader(SkTileMode, const SkSamplingOptions &, const SkMatrix &lm, bool strict=true) const
SkColorType colorType() const
static float max(float r, float g, float b)
static float min(float r, float g, float b)
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
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 dir
SIN Vec< N, float > abs(const Vec< N, float > &x)
bool intersect(const SkIRect &r)
int32_t fBottom
larger y-axis bounds
constexpr int32_t top() const
constexpr SkISize size() const
constexpr int32_t bottom() const
constexpr int32_t height() const
constexpr int32_t right() const
int32_t fTop
smaller y-axis bounds
static constexpr SkIRect MakeSize(const SkISize &size)
constexpr int32_t width() const
constexpr SkIRect makeOffset(int32_t dx, int32_t dy) const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
SkIRect makeInset(int32_t dx, int32_t dy) const
void outset(int32_t dx, int32_t dy)
constexpr int32_t left() const
bool contains(int32_t x, int32_t y) const
constexpr int32_t width() const
constexpr int32_t height() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)
std::shared_ptr< const fml::Mapping > data