Flutter Engine
The Flutter Engine
Typedefs | Functions | Variables
SkMaskBlurFilter.cpp File Reference
#include "src/core/SkMaskBlurFilter.h"
#include "include/core/SkColorPriv.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/base/SkTPin.h"
#include "include/private/base/SkTemplates.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkArenaAlloc.h"
#include "src/base/SkVx.h"
#include "src/core/SkGaussFilter.h"
#include <cmath>
#include <climits>

Go to the source code of this file.

Typedefs

using ToA8 = decltype(bw_to_a8)
 
using fp88 = skvx::Vec< 8, uint16_t >
 
using BlurX = decltype(blur_x_radius_1)
 
using BlurY = decltype(blur_y_radius_1)
 

Functions

static void bw_to_a8 (uint8_t *a8, const uint8_t *from, int width)
 
static void lcd_to_a8 (uint8_t *a8, const uint8_t *from, int width)
 
static void argb32_to_a8 (uint8_t *a8, const uint8_t *from, int width)
 
static fp88 load (const uint8_t *from, int width, ToA8 *toA8)
 
static void store (uint8_t *to, const fp88 &v, int width)
 
static void blur_x_radius_1 (const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &, const fp88 &, const fp88 &, fp88 *d0, fp88 *d8)
 
static void blur_x_radius_2 (const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &, const fp88 &, fp88 *d0, fp88 *d8)
 
static void blur_x_radius_3 (const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &, fp88 *d0, fp88 *d8)
 
static void blur_x_radius_4 (const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &g4, fp88 *d0, fp88 *d8)
 
static void blur_row (BlurX blur, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &g4, const uint8_t *src, int srcW, uint8_t *dst, int dstW)
 
static void blur_x_rect (BlurX blur, uint16_t *gauss, const uint8_t *src, size_t srcStride, int srcW, uint8_t *dst, size_t dstStride, int dstW, int dstH)
 
static void direct_blur_x (int radius, uint16_t *gauss, const uint8_t *src, size_t srcStride, int srcW, uint8_t *dst, size_t dstStride, int dstW, int dstH)
 
static fp88 blur_y_radius_1 (const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &, const fp88 &, const fp88 &, fp88 *d01, fp88 *d12, fp88 *, fp88 *, fp88 *, fp88 *, fp88 *, fp88 *)
 
static fp88 blur_y_radius_2 (const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &, const fp88 &, fp88 *d01, fp88 *d12, fp88 *d23, fp88 *d34, fp88 *, fp88 *, fp88 *, fp88 *)
 
static fp88 blur_y_radius_3 (const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &, fp88 *d01, fp88 *d12, fp88 *d23, fp88 *d34, fp88 *d45, fp88 *d56, fp88 *, fp88 *)
 
static fp88 blur_y_radius_4 (const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &g4, fp88 *d01, fp88 *d12, fp88 *d23, fp88 *d34, fp88 *d45, fp88 *d56, fp88 *d67, fp88 *d78)
 
static void blur_column (ToA8 toA8, BlurY blur, int radius, int width, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &g4, const uint8_t *src, size_t srcRB, int srcH, uint8_t *dst, size_t dstRB)
 
static void blur_y_rect (ToA8 toA8, const int strideOf8, BlurY blur, int radius, uint16_t *gauss, const uint8_t *src, size_t srcRB, int srcW, int srcH, uint8_t *dst, size_t dstRB)
 
static void direct_blur_y (ToA8 toA8, const int strideOf8, int radius, uint16_t *gauss, const uint8_t *src, size_t srcRB, int srcW, int srcH, uint8_t *dst, size_t dstRB)
 
static SkIPoint small_blur (double sigmaX, double sigmaY, const SkMask &src, SkMaskBuilder *dst)
 

Variables

static constexpr uint16_t _____ = 0u
 
static constexpr uint16_t kHalf = 0x80u
 

Typedef Documentation

◆ BlurX

using BlurX = decltype(blur_x_radius_1)

Definition at line 545 of file SkMaskBlurFilter.cpp.

◆ BlurY

using BlurY = decltype(blur_y_radius_1)

Definition at line 761 of file SkMaskBlurFilter.cpp.

◆ fp88

using fp88 = skvx::Vec<8, uint16_t>

Definition at line 297 of file SkMaskBlurFilter.cpp.

◆ ToA8

using ToA8 = decltype(bw_to_a8)

Definition at line 295 of file SkMaskBlurFilter.cpp.

Function Documentation

◆ argb32_to_a8()

static void argb32_to_a8 ( uint8_t *  a8,
const uint8_t *  from,
int  width 
)
static

Definition at line 288 of file SkMaskBlurFilter.cpp.

288 {
289 SkASSERT(0 < width && width <= 8);
290 for (int i = 0; i < width; ++i) {
291 uint32_t rgba = reinterpret_cast<const uint32_t*>(from)[i];
292 a8[i] = SkGetPackedA32(rgba);
293 }
294}
static const uint32_t rgba[kNumPixels]
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkGetPackedA32(packed)
Definition: SkColorPriv.h:92
int32_t width

◆ blur_column()

static void blur_column ( ToA8  toA8,
BlurY  blur,
int  radius,
int  width,
const fp88 g0,
const fp88 g1,
const fp88 g2,
const fp88 g3,
const fp88 g4,
const uint8_t *  src,
size_t  srcRB,
int  srcH,
uint8_t *  dst,
size_t  dstRB 
)
static

Definition at line 764 of file SkMaskBlurFilter.cpp.

769 {
770 fp88 d01(kHalf), d12(kHalf), d23(kHalf), d34(kHalf),
771 d45(kHalf), d56(kHalf), d67(kHalf), d78(kHalf);
772
773 auto flush = [&](uint8_t* to, const fp88& v0, const fp88& v1) {
774 store(to, v0, width);
775 to += dstRB;
776 store(to, v1, width);
777 return to + dstRB;
778 };
779
780 for (int y = 0; y < srcH; y += 1) {
781 auto s = load(src, width, toA8);
782 auto b = blur(s,
783 g0, g1, g2, g3, g4,
784 &d01, &d12, &d23, &d34, &d45, &d56, &d67, &d78);
785 store(dst, b, width);
786 src += srcRB;
787 dst += dstRB;
788 }
789
790 if (radius >= 1) {
791 dst = flush(dst, d01, d12);
792 }
793 if (radius >= 2) {
794 dst = flush(dst, d23, d34);
795 }
796 if (radius >= 3) {
797 dst = flush(dst, d45, d56);
798 }
799 if (radius >= 4) {
800 flush(dst, d67, d78);
801 }
802}
static constexpr uint16_t kHalf
static fp88 load(const uint8_t *from, int width, ToA8 *toA8)
static void store(uint8_t *to, const fp88 &v, int width)
static bool b
struct MyStruct s
double y
dst
Definition: cp.py:12
Definition: SkVx.h:83

◆ blur_row()

static void blur_row ( BlurX  blur,
const fp88 g0,
const fp88 g1,
const fp88 g2,
const fp88 g3,
const fp88 g4,
const uint8_t *  src,
int  srcW,
uint8_t *  dst,
int  dstW 
)
static

Definition at line 548 of file SkMaskBlurFilter.cpp.

552 {
553 // Clear the buffer to handle summing wider than source.
554 fp88 d0(kHalf), d8(kHalf);
555
556 // Go by multiples of 8 in src.
557 int x = 0;
558 for (; x <= srcW - 8; x += 8) {
559 blur(load(src, 8, nullptr), g0, g1, g2, g3, g4, &d0, &d8);
560
561 store(dst, d0, 8);
562
563 d0 = d8;
564 d8 = fp88(kHalf);
565
566 src += 8;
567 dst += 8;
568 }
569
570 // There are src values left, but the remainder of src values is not a multiple of 8.
571 int srcTail = srcW - x;
572 if (srcTail > 0) {
573
574 blur(load(src, srcTail, nullptr), g0, g1, g2, g3, g4, &d0, &d8);
575
576 int dstTail = std::min(8, dstW - x);
577 store(dst, d0, dstTail);
578
579 d0 = d8;
580 dst += dstTail;
581 x += dstTail;
582 }
583
584 // There are dst mask values to complete.
585 int dstTail = dstW - x;
586 if (dstTail > 0) {
587 store(dst, d0, dstTail);
588 }
589}
skvx::Vec< 8, uint16_t > fp88
static float min(float r, float g, float b)
Definition: hsl.cpp:48
double x

◆ blur_x_radius_1()

static void blur_x_radius_1 ( const fp88 s0,
const fp88 g0,
const fp88 g1,
const fp88 ,
const fp88 ,
const fp88 ,
fp88 d0,
fp88 d8 
)
static

Definition at line 414 of file SkMaskBlurFilter.cpp.

417 {
418
419 auto v1 = mulhi(s0, g1);
420 auto v0 = mulhi(s0, g0);
421
422 // D[n..n+7] += S[n..n+7] * G[1]
423 *d0 += v1;
424
425 //D[n..n+8] += {0, S[n..n+7] * G[0]}
426 *d0 += fp88{_____, v0[0], v0[1], v0[2], v0[3], v0[4], v0[5], v0[6]};
427 *d8 += fp88{v0[7], _____, _____, _____, _____, _____, _____, _____};
428
429 // D[n..n+9] += {0, 0, S[n..n+7] * G[1]}
430 *d0 += fp88{_____, _____, v1[0], v1[1], v1[2], v1[3], v1[4], v1[5]};
431 *d8 += fp88{v1[6], v1[7], _____, _____, _____, _____, _____, _____};
432
433}
static constexpr uint16_t _____
SIN Vec< N, uint16_t > mulhi(const Vec< N, uint16_t > &x, const Vec< N, uint16_t > &y)
Definition: SkVx.h:938

◆ blur_x_radius_2()

static void blur_x_radius_2 ( const fp88 s0,
const fp88 g0,
const fp88 g1,
const fp88 g2,
const fp88 ,
const fp88 ,
fp88 d0,
fp88 d8 
)
static

Definition at line 435 of file SkMaskBlurFilter.cpp.

438 {
439 auto v0 = mulhi(s0, g0);
440 auto v1 = mulhi(s0, g1);
441 auto v2 = mulhi(s0, g2);
442
443 // D[n..n+7] += S[n..n+7] * G[2]
444 *d0 += v2;
445
446 // D[n..n+8] += {0, S[n..n+7] * G[1]}
447 *d0 += fp88{_____, v1[0], v1[1], v1[2], v1[3], v1[4], v1[5], v1[6]};
448 *d8 += fp88{v1[7], _____, _____, _____, _____, _____, _____, _____};
449
450 // D[n..n+9] += {0, 0, S[n..n+7] * G[0]}
451 *d0 += fp88{_____, _____, v0[0], v0[1], v0[2], v0[3], v0[4], v0[5]};
452 *d8 += fp88{v0[6], v0[7], _____, _____, _____, _____, _____, _____};
453
454 // D[n..n+10] += {0, 0, 0, S[n..n+7] * G[1]}
455 *d0 += fp88{_____, _____, _____, v1[0], v1[1], v1[2], v1[3], v1[4]};
456 *d8 += fp88{v1[5], v1[6], v1[7], _____, _____, _____, _____, _____};
457
458 // D[n..n+11] += {0, 0, 0, 0, S[n..n+7] * G[2]}
459 *d0 += fp88{_____, _____, _____, _____, v2[0], v2[1], v2[2], v2[3]};
460 *d8 += fp88{v2[4], v2[5], v2[6], v2[7], _____, _____, _____, _____};
461}
Vec2Value v2

◆ blur_x_radius_3()

static void blur_x_radius_3 ( const fp88 s0,
const fp88 g0,
const fp88 g1,
const fp88 g2,
const fp88 g3,
const fp88 ,
fp88 d0,
fp88 d8 
)
static

Definition at line 463 of file SkMaskBlurFilter.cpp.

466 {
467 auto v0 = mulhi(s0, g0);
468 auto v1 = mulhi(s0, g1);
469 auto v2 = mulhi(s0, g2);
470 auto v3 = mulhi(s0, g3);
471
472 // D[n..n+7] += S[n..n+7] * G[3]
473 *d0 += v3;
474
475 // D[n..n+8] += {0, S[n..n+7] * G[2]}
476 *d0 += fp88{_____, v2[0], v2[1], v2[2], v2[3], v2[4], v2[5], v2[6]};
477 *d8 += fp88{v2[7], _____, _____, _____, _____, _____, _____, _____};
478
479 // D[n..n+9] += {0, 0, S[n..n+7] * G[1]}
480 *d0 += fp88{_____, _____, v1[0], v1[1], v1[2], v1[3], v1[4], v1[5]};
481 *d8 += fp88{v1[6], v1[7], _____, _____, _____, _____, _____, _____};
482
483 // D[n..n+10] += {0, 0, 0, S[n..n+7] * G[0]}
484 *d0 += fp88{_____, _____, _____, v0[0], v0[1], v0[2], v0[3], v0[4]};
485 *d8 += fp88{v0[5], v0[6], v0[7], _____, _____, _____, _____, _____};
486
487 // D[n..n+11] += {0, 0, 0, 0, S[n..n+7] * G[1]}
488 *d0 += fp88{_____, _____, _____, _____, v1[0], v1[1], v1[2], v1[3]};
489 *d8 += fp88{v1[4], v1[5], v1[6], v1[7], _____, _____, _____, _____};
490
491 // D[n..n+12] += {0, 0, 0, 0, 0, S[n..n+7] * G[2]}
492 *d0 += fp88{_____, _____, _____, _____, _____, v2[0], v2[1], v2[2]};
493 *d8 += fp88{v2[3], v2[4], v2[5], v2[6], v2[7], _____, _____, _____};
494
495 // D[n..n+13] += {0, 0, 0, 0, 0, 0, S[n..n+7] * G[3]}
496 *d0 += fp88{_____, _____, _____, _____, _____, _____, v3[0], v3[1]};
497 *d8 += fp88{v3[2], v3[3], v3[4], v3[5], v3[6], v3[7], _____, _____};
498}

◆ blur_x_radius_4()

static void blur_x_radius_4 ( const fp88 s0,
const fp88 g0,
const fp88 g1,
const fp88 g2,
const fp88 g3,
const fp88 g4,
fp88 d0,
fp88 d8 
)
static

Definition at line 500 of file SkMaskBlurFilter.cpp.

503 {
504 auto v0 = mulhi(s0, g0);
505 auto v1 = mulhi(s0, g1);
506 auto v2 = mulhi(s0, g2);
507 auto v3 = mulhi(s0, g3);
508 auto v4 = mulhi(s0, g4);
509
510 // D[n..n+7] += S[n..n+7] * G[4]
511 *d0 += v4;
512
513 // D[n..n+8] += {0, S[n..n+7] * G[3]}
514 *d0 += fp88{_____, v3[0], v3[1], v3[2], v3[3], v3[4], v3[5], v3[6]};
515 *d8 += fp88{v3[7], _____, _____, _____, _____, _____, _____, _____};
516
517 // D[n..n+9] += {0, 0, S[n..n+7] * G[2]}
518 *d0 += fp88{_____, _____, v2[0], v2[1], v2[2], v2[3], v2[4], v2[5]};
519 *d8 += fp88{v2[6], v2[7], _____, _____, _____, _____, _____, _____};
520
521 // D[n..n+10] += {0, 0, 0, S[n..n+7] * G[1]}
522 *d0 += fp88{_____, _____, _____, v1[0], v1[1], v1[2], v1[3], v1[4]};
523 *d8 += fp88{v1[5], v1[6], v1[7], _____, _____, _____, _____, _____};
524
525 // D[n..n+11] += {0, 0, 0, 0, S[n..n+7] * G[0]}
526 *d0 += fp88{_____, _____, _____, _____, v0[0], v0[1], v0[2], v0[3]};
527 *d8 += fp88{v0[4], v0[5], v0[6], v0[7], _____, _____, _____, _____};
528
529 // D[n..n+12] += {0, 0, 0, 0, 0, S[n..n+7] * G[1]}
530 *d0 += fp88{_____, _____, _____, _____, _____, v1[0], v1[1], v1[2]};
531 *d8 += fp88{v1[3], v1[4], v1[5], v1[6], v1[7], _____, _____, _____};
532
533 // D[n..n+13] += {0, 0, 0, 0, 0, 0, S[n..n+7] * G[2]}
534 *d0 += fp88{_____, _____, _____, _____, _____, _____, v2[0], v2[1]};
535 *d8 += fp88{v2[2], v2[3], v2[4], v2[5], v2[6], v2[7], _____, _____};
536
537 // D[n..n+14] += {0, 0, 0, 0, 0, 0, 0, S[n..n+7] * G[3]}
538 *d0 += fp88{_____, _____, _____, _____, _____, _____, _____, v3[0]};
539 *d8 += fp88{v3[1], v3[2], v3[3], v3[4], v3[5], v3[6], v3[7], _____};
540
541 // D[n..n+15] += {0, 0, 0, 0, 0, 0, 0, 0, S[n..n+7] * G[4]}
542 *d8 += v4;
543}
static SkV4 v4(SkV3 v, SkScalar w)
Definition: SkM44.cpp:329

◆ blur_x_rect()

static void blur_x_rect ( BlurX  blur,
uint16_t *  gauss,
const uint8_t *  src,
size_t  srcStride,
int  srcW,
uint8_t *  dst,
size_t  dstStride,
int  dstW,
int  dstH 
)
static

Definition at line 592 of file SkMaskBlurFilter.cpp.

595 {
596
597 fp88 g0(gauss[0]),
598 g1(gauss[1]),
599 g2(gauss[2]),
600 g3(gauss[3]),
601 g4(gauss[4]);
602
603 // Blur *ALL* the rows.
604 for (int y = 0; y < dstH; y++) {
605 blur_row(blur, g0, g1, g2, g3, g4, src, srcW, dst, dstW);
606 src += srcStride;
607 dst += dstStride;
608 }
609}
static void blur_row(BlurX blur, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &g4, const uint8_t *src, int srcW, uint8_t *dst, int dstW)

◆ blur_y_radius_1()

static fp88 blur_y_radius_1 ( const fp88 s0,
const fp88 g0,
const fp88 g1,
const fp88 ,
const fp88 ,
const fp88 ,
fp88 d01,
fp88 d12,
fp88 ,
fp88 ,
fp88 ,
fp88 ,
fp88 ,
fp88  
)
static

Definition at line 687 of file SkMaskBlurFilter.cpp.

690 {
691 auto v0 = mulhi(s0, g0);
692 auto v1 = mulhi(s0, g1);
693
694 fp88 answer = *d01 + v1;
695 *d01 = *d12 + v0;
696 *d12 = v1 + kHalf;
697
698 return answer;
699}

◆ blur_y_radius_2()

static fp88 blur_y_radius_2 ( const fp88 s0,
const fp88 g0,
const fp88 g1,
const fp88 g2,
const fp88 ,
const fp88 ,
fp88 d01,
fp88 d12,
fp88 d23,
fp88 d34,
fp88 ,
fp88 ,
fp88 ,
fp88  
)
static

Definition at line 701 of file SkMaskBlurFilter.cpp.

704 {
705 auto v0 = mulhi(s0, g0);
706 auto v1 = mulhi(s0, g1);
707 auto v2 = mulhi(s0, g2);
708
709 fp88 answer = *d01 + v2;
710 *d01 = *d12 + v1;
711 *d12 = *d23 + v0;
712 *d23 = *d34 + v1;
713 *d34 = v2 + kHalf;
714
715 return answer;
716}

◆ blur_y_radius_3()

static fp88 blur_y_radius_3 ( const fp88 s0,
const fp88 g0,
const fp88 g1,
const fp88 g2,
const fp88 g3,
const fp88 ,
fp88 d01,
fp88 d12,
fp88 d23,
fp88 d34,
fp88 d45,
fp88 d56,
fp88 ,
fp88  
)
static

Definition at line 718 of file SkMaskBlurFilter.cpp.

721 {
722 auto v0 = mulhi(s0, g0);
723 auto v1 = mulhi(s0, g1);
724 auto v2 = mulhi(s0, g2);
725 auto v3 = mulhi(s0, g3);
726
727 fp88 answer = *d01 + v3;
728 *d01 = *d12 + v2;
729 *d12 = *d23 + v1;
730 *d23 = *d34 + v0;
731 *d34 = *d45 + v1;
732 *d45 = *d56 + v2;
733 *d56 = v3 + kHalf;
734
735 return answer;
736}

◆ blur_y_radius_4()

static fp88 blur_y_radius_4 ( const fp88 s0,
const fp88 g0,
const fp88 g1,
const fp88 g2,
const fp88 g3,
const fp88 g4,
fp88 d01,
fp88 d12,
fp88 d23,
fp88 d34,
fp88 d45,
fp88 d56,
fp88 d67,
fp88 d78 
)
static

Definition at line 738 of file SkMaskBlurFilter.cpp.

741 {
742 auto v0 = mulhi(s0, g0);
743 auto v1 = mulhi(s0, g1);
744 auto v2 = mulhi(s0, g2);
745 auto v3 = mulhi(s0, g3);
746 auto v4 = mulhi(s0, g4);
747
748 fp88 answer = *d01 + v4;
749 *d01 = *d12 + v3;
750 *d12 = *d23 + v2;
751 *d23 = *d34 + v1;
752 *d34 = *d45 + v0;
753 *d45 = *d56 + v1;
754 *d56 = *d67 + v2;
755 *d67 = *d78 + v3;
756 *d78 = v4 + kHalf;
757
758 return answer;
759}

◆ blur_y_rect()

static void blur_y_rect ( ToA8  toA8,
const int  strideOf8,
BlurY  blur,
int  radius,
uint16_t *  gauss,
const uint8_t *  src,
size_t  srcRB,
int  srcW,
int  srcH,
uint8_t *  dst,
size_t  dstRB 
)
static

Definition at line 805 of file SkMaskBlurFilter.cpp.

808 {
809
810 fp88 g0(gauss[0]),
811 g1(gauss[1]),
812 g2(gauss[2]),
813 g3(gauss[3]),
814 g4(gauss[4]);
815
816 int x = 0;
817 for (; x <= srcW - 8; x += 8) {
818 blur_column(toA8, blur, radius, 8,
819 g0, g1, g2, g3, g4,
820 src, srcRB, srcH,
821 dst, dstRB);
822 src += strideOf8;
823 dst += 8;
824 }
825
826 int xTail = srcW - x;
827 if (xTail > 0) {
828 blur_column(toA8, blur, radius, xTail,
829 g0, g1, g2, g3, g4,
830 src, srcRB, srcH,
831 dst, dstRB);
832 }
833}
static void blur_column(ToA8 toA8, BlurY blur, int radius, int width, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &g4, const uint8_t *src, size_t srcRB, int srcH, uint8_t *dst, size_t dstRB)

◆ bw_to_a8()

static void bw_to_a8 ( uint8_t *  a8,
const uint8_t *  from,
int  width 
)
static

Definition at line 268 of file SkMaskBlurFilter.cpp.

268 {
269 SkASSERT(0 < width && width <= 8);
270
271 uint8_t masks = *from;
272 for (int i = 0; i < width; ++i) {
273 a8[i] = (masks >> (7 - i)) & 1 ? 0xFF
274 : 0x00;
275 }
276}

◆ direct_blur_x()

static void direct_blur_x ( int  radius,
uint16_t *  gauss,
const uint8_t *  src,
size_t  srcStride,
int  srcW,
uint8_t *  dst,
size_t  dstStride,
int  dstW,
int  dstH 
)
static

Definition at line 611 of file SkMaskBlurFilter.cpp.

613 {
614
615 switch (radius) {
616 case 1:
617 blur_x_rect(blur_x_radius_1, gauss, src, srcStride, srcW, dst, dstStride, dstW, dstH);
618 break;
619
620 case 2:
621 blur_x_rect(blur_x_radius_2, gauss, src, srcStride, srcW, dst, dstStride, dstW, dstH);
622 break;
623
624 case 3:
625 blur_x_rect(blur_x_radius_3, gauss, src, srcStride, srcW, dst, dstStride, dstW, dstH);
626 break;
627
628 case 4:
629 blur_x_rect(blur_x_radius_4, gauss, src, srcStride, srcW, dst, dstStride, dstW, dstH);
630 break;
631
632 default:
633 SkASSERTF(false, "The radius %d is not handled\n", radius);
634 }
635}
#define SkASSERTF(cond, fmt,...)
Definition: SkAssert.h:117
static void blur_x_radius_3(const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &, fp88 *d0, fp88 *d8)
static void blur_x_rect(BlurX blur, uint16_t *gauss, const uint8_t *src, size_t srcStride, int srcW, uint8_t *dst, size_t dstStride, int dstW, int dstH)
static void blur_x_radius_4(const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &g4, fp88 *d0, fp88 *d8)
static void blur_x_radius_2(const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &, const fp88 &, fp88 *d0, fp88 *d8)
static void blur_x_radius_1(const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &, const fp88 &, const fp88 &, fp88 *d0, fp88 *d8)

◆ direct_blur_y()

static void direct_blur_y ( ToA8  toA8,
const int  strideOf8,
int  radius,
uint16_t *  gauss,
const uint8_t *  src,
size_t  srcRB,
int  srcW,
int  srcH,
uint8_t *  dst,
size_t  dstRB 
)
static

Definition at line 835 of file SkMaskBlurFilter.cpp.

838 {
839
840 switch (radius) {
841 case 1:
842 blur_y_rect(toA8, strideOf8, blur_y_radius_1, 1, gauss,
843 src, srcRB, srcW, srcH,
844 dst, dstRB);
845 break;
846
847 case 2:
848 blur_y_rect(toA8, strideOf8, blur_y_radius_2, 2, gauss,
849 src, srcRB, srcW, srcH,
850 dst, dstRB);
851 break;
852
853 case 3:
854 blur_y_rect(toA8, strideOf8, blur_y_radius_3, 3, gauss,
855 src, srcRB, srcW, srcH,
856 dst, dstRB);
857 break;
858
859 case 4:
860 blur_y_rect(toA8, strideOf8, blur_y_radius_4, 4, gauss,
861 src, srcRB, srcW, srcH,
862 dst, dstRB);
863 break;
864
865 default:
866 SkASSERTF(false, "The radius %d is not handled\n", radius);
867 }
868}
static fp88 blur_y_radius_2(const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &, const fp88 &, fp88 *d01, fp88 *d12, fp88 *d23, fp88 *d34, fp88 *, fp88 *, fp88 *, fp88 *)
static fp88 blur_y_radius_4(const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &g4, fp88 *d01, fp88 *d12, fp88 *d23, fp88 *d34, fp88 *d45, fp88 *d56, fp88 *d67, fp88 *d78)
static fp88 blur_y_radius_1(const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &, const fp88 &, const fp88 &, fp88 *d01, fp88 *d12, fp88 *, fp88 *, fp88 *, fp88 *, fp88 *, fp88 *)
static fp88 blur_y_radius_3(const fp88 &s0, const fp88 &g0, const fp88 &g1, const fp88 &g2, const fp88 &g3, const fp88 &, fp88 *d01, fp88 *d12, fp88 *d23, fp88 *d34, fp88 *d45, fp88 *d56, fp88 *, fp88 *)
static void blur_y_rect(ToA8 toA8, const int strideOf8, BlurY blur, int radius, uint16_t *gauss, const uint8_t *src, size_t srcRB, int srcW, int srcH, uint8_t *dst, size_t dstRB)

◆ lcd_to_a8()

static void lcd_to_a8 ( uint8_t *  a8,
const uint8_t *  from,
int  width 
)
static

Definition at line 277 of file SkMaskBlurFilter.cpp.

277 {
278 SkASSERT(0 < width && width <= 8);
279
280 for (int i = 0; i < width; ++i) {
281 unsigned rgb = reinterpret_cast<const uint16_t*>(from)[i],
282 r = SkPacked16ToR32(rgb),
283 g = SkPacked16ToG32(rgb),
284 b = SkPacked16ToB32(rgb);
285 a8[i] = (r + g + b) / 3;
286 }
287}
#define SkPacked16ToG32(c)
Definition: SkColorData.h:47
#define SkPacked16ToR32(c)
Definition: SkColorData.h:46
#define SkPacked16ToB32(c)
Definition: SkColorData.h:48

◆ load()

static fp88 load ( const uint8_t *  from,
int  width,
ToA8 toA8 
)
static

Definition at line 299 of file SkMaskBlurFilter.cpp.

299 {
300 // Our fast path is a full 8-byte load of A8.
301 // So we'll conditionally handle the two slow paths using tmp:
302 // - if we have a function to convert another mask to A8, use it;
303 // - if not but we have less than 8 bytes to load, load them one at a time.
304 uint8_t tmp[8] = {0,0,0,0, 0,0,0,0};
305 if (toA8) {
306 toA8(tmp, from, width);
307 from = tmp;
308 } else if (width < 8) {
309 for (int i = 0; i < width; ++i) {
310 tmp[i] = from[i];
311 }
312 from = tmp;
313 }
314
315 // Load A8 and convert to 8.8 fixed-point.
316 return skvx::cast<uint16_t>(skvx::byte8::Load(from)) << 8;
317}
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition: SkVx.h:109

◆ small_blur()

static SkIPoint small_blur ( double  sigmaX,
double  sigmaY,
const SkMask src,
SkMaskBuilder dst 
)
static

Definition at line 870 of file SkMaskBlurFilter.cpp.

870 {
871 SkASSERT(sigmaX == sigmaY); // TODO
872 SkASSERT(0.01 <= sigmaX && sigmaX < 2);
873 SkASSERT(0.01 <= sigmaY && sigmaY < 2);
874
875 SkGaussFilter filterX{sigmaX},
876 filterY{sigmaY};
877
878 int radiusX = filterX.radius(),
879 radiusY = filterY.radius();
880
881 SkASSERT(radiusX <= 4 && radiusY <= 4);
882
883 auto prepareGauss = [](const SkGaussFilter& filter, uint16_t* factors) {
884 int i = 0;
885 for (double d : filter) {
886 factors[i++] = static_cast<uint16_t>(round(d * (1 << 16)));
887 }
888 };
889
890 uint16_t gaussFactorsX[SkGaussFilter::kGaussArrayMax],
891 gaussFactorsY[SkGaussFilter::kGaussArrayMax];
892
893 prepareGauss(filterX, gaussFactorsX);
894 prepareGauss(filterY, gaussFactorsY);
895
896 *dst = SkMaskBuilder::PrepareDestination(radiusX, radiusY, src);
897 if (src.fImage == nullptr) {
898 return {SkTo<int32_t>(radiusX), SkTo<int32_t>(radiusY)};
899 }
900 if (dst->fImage == nullptr) {
901 dst->bounds().setEmpty();
902 return {0, 0};
903 }
904
905 int srcW = src.fBounds.width(),
906 srcH = src.fBounds.height();
907
908 int dstW = dst->fBounds.width(),
909 dstH = dst->fBounds.height();
910
911 size_t srcRB = src.fRowBytes,
912 dstRB = dst->fRowBytes;
913
914 //TODO: handle bluring in only one direction.
915
916 // Blur vertically and copy to destination.
917 switch (src.fFormat) {
920 radiusY, gaussFactorsY,
921 src.fImage, srcRB, srcW, srcH,
922 dst->image() + radiusX, dstRB);
923 break;
925 direct_blur_y(nullptr, 8,
926 radiusY, gaussFactorsY,
927 src.fImage, srcRB, srcW, srcH,
928 dst->image() + radiusX, dstRB);
929 break;
932 radiusY, gaussFactorsY,
933 src.fImage, srcRB, srcW, srcH,
934 dst->image() + radiusX, dstRB);
935 break;
937 direct_blur_y(lcd_to_a8, 16, radiusY, gaussFactorsY,
938 src.fImage, srcRB, srcW, srcH,
939 dst->image() + radiusX, dstRB);
940 break;
941 default:
942 SK_ABORT("Unhandled format.");
943 }
944
945 // Blur horizontally in place.
946 direct_blur_x(radiusX, gaussFactorsX,
947 dst->fImage + radiusX, dstRB, srcW,
948 dst->image(), dstRB, dstW, dstH);
949
950 return {radiusX, radiusY};
951}
static void round(SkPoint *p)
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
static void direct_blur_y(ToA8 toA8, const int strideOf8, int radius, uint16_t *gauss, const uint8_t *src, size_t srcRB, int srcW, int srcH, uint8_t *dst, size_t dstRB)
static void bw_to_a8(uint8_t *a8, const uint8_t *from, int width)
static void direct_blur_x(int radius, uint16_t *gauss, const uint8_t *src, size_t srcStride, int srcW, uint8_t *dst, size_t dstStride, int dstW, int dstH)
static void argb32_to_a8(uint8_t *a8, const uint8_t *from, int width)
static void lcd_to_a8(uint8_t *a8, const uint8_t *from, int width)
static constexpr int kGaussArrayMax
Definition: SkGaussFilter.h:17
int radius() const
Definition: SkGaussFilter.h:22
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
static SkMaskBuilder PrepareDestination(int radiusX, int radiusY, const SkMask &src)
Definition: SkMask.cpp:61
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
@ kLCD16_Format
565 alpha for r/g/b
Definition: SkMask.h:31
@ kARGB32_Format
SkPMColor.
Definition: SkMask.h:30
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition: SkMask.h:27

◆ store()

static void store ( uint8_t *  to,
const fp88 v,
int  width 
)
static

Definition at line 319 of file SkMaskBlurFilter.cpp.

319 {
320 skvx::byte8 b = skvx::cast<uint8_t>(v >> 8);
321 if (width == 8) {
322 b.store(to);
323 } else {
324 uint8_t buffer[8];
325 b.store(buffer);
326 for (int i = 0; i < width; i++) {
327 to[i] = buffer[i];
328 }
329 }
330}
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 buffer
Definition: switches.h:126

Variable Documentation

◆ _____

constexpr uint16_t _____ = 0u
staticconstexpr

Definition at line 332 of file SkMaskBlurFilter.cpp.

◆ kHalf

constexpr uint16_t kHalf = 0x80u
staticconstexpr

Definition at line 333 of file SkMaskBlurFilter.cpp.