Flutter Engine
The Flutter Engine
Functions
SkMaskFilter.cpp File Reference
#include "include/core/SkMaskFilter.h"
#include "include/core/SkFlattenable.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkRegion.h"
#include "include/core/SkStrokeRec.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkTemplates.h"
#include "src/base/SkAutoMalloc.h"
#include "src/base/SkTLazy.h"
#include "src/core/SkBlitter.h"
#include "src/core/SkCachedData.h"
#include "src/core/SkDraw.h"
#include "src/core/SkMask.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkPathPriv.h"
#include "src/core/SkRasterClip.h"
#include <algorithm>
#include <cstdint>

Go to the source code of this file.

Functions

static SkMask extractMaskSubset (const SkMask &src, SkIRect bounds, int32_t newX, int32_t newY)
 
static void blitClippedMask (SkBlitter *blitter, const SkMask &mask, const SkIRect &bounds, const SkIRect &clipR)
 
static void blitClippedRect (SkBlitter *blitter, const SkIRect &rect, const SkIRect &clipR)
 
static void draw_nine_clipped (const SkMask &mask, const SkIRect &outerR, const SkIPoint &center, bool fillCenter, const SkIRect &clipR, SkBlitter *blitter)
 
static void draw_nine (const SkMask &mask, const SkIRect &outerR, const SkIPoint &center, bool fillCenter, const SkRasterClip &clip, SkBlitter *blitter)
 
static int countNestedRects (const SkPath &path, SkRect rects[2])
 

Function Documentation

◆ blitClippedMask()

static void blitClippedMask ( SkBlitter blitter,
const SkMask mask,
const SkIRect bounds,
const SkIRect clipR 
)
static

Definition at line 66 of file SkMaskFilter.cpp.

67 {
68 SkIRect r;
69 if (r.intersect(bounds, clipR)) {
70 blitter->blitMask(mask, r);
71 }
72}
virtual void blitMask(const SkMask &, const SkIRect &clip)
Definition: SkBlitter.cpp:201
Optional< SkRect > bounds
Definition: SkRecords.h:189
Definition: SkRect.h:32
bool intersect(const SkIRect &r)
Definition: SkRect.h:513

◆ blitClippedRect()

static void blitClippedRect ( SkBlitter blitter,
const SkIRect rect,
const SkIRect clipR 
)
static

Definition at line 74 of file SkMaskFilter.cpp.

74 {
75 SkIRect r;
76 if (r.intersect(rect, clipR)) {
77 blitter->blitRect(r.left(), r.top(), r.width(), r.height());
78 }
79}
virtual void blitRect(int x, int y, int width, int height)
Blit a solid rectangle one or more pixels wide.
Definition: SkBlitter.cpp:133
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
constexpr int32_t top() const
Definition: SkRect.h:120
constexpr int32_t height() const
Definition: SkRect.h:165
constexpr int32_t width() const
Definition: SkRect.h:158
constexpr int32_t left() const
Definition: SkRect.h:113

◆ countNestedRects()

static int countNestedRects ( const SkPath path,
SkRect  rects[2] 
)
static

Definition at line 206 of file SkMaskFilter.cpp.

206 {
208 return 2;
209 }
210 return path.isRect(&rects[0]);
211}
static bool IsNestedFillRects(const SkPath &, SkRect rect[2], SkPathDirection dirs[2]=nullptr)
Definition: SkPath.cpp:3780
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_nine()

static void draw_nine ( const SkMask mask,
const SkIRect outerR,
const SkIPoint center,
bool  fillCenter,
const SkRasterClip clip,
SkBlitter blitter 
)
static

Definition at line 189 of file SkMaskFilter.cpp.

190 {
191 // if we get here, we need to (possibly) resolve the clip and blitter
192 SkAAClipBlitterWrapper wrapper(clip, blitter);
193 blitter = wrapper.getBlitter();
194
195 SkRegion::Cliperator clipper(wrapper.getRgn(), outerR);
196
197 if (!clipper.done()) {
198 const SkIRect& cr = clipper.rect();
199 do {
200 draw_nine_clipped(mask, outerR, center, fillCenter, cr, blitter);
201 clipper.next();
202 } while (!clipper.done());
203 }
204}
static void draw_nine_clipped(const SkMask &mask, const SkIRect &outerR, const SkIPoint &center, bool fillCenter, const SkIRect &clipR, SkBlitter *blitter)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
static SkScalar center(float pos0, float pos1)

◆ draw_nine_clipped()

static void draw_nine_clipped ( const SkMask mask,
const SkIRect outerR,
const SkIPoint center,
bool  fillCenter,
const SkIRect clipR,
SkBlitter blitter 
)
static

Definition at line 81 of file SkMaskFilter.cpp.

83 {
84 int cx = center.x();
85 int cy = center.y();
87
88 // top-left
89 bounds = mask.fBounds;
90 bounds.fRight = cx;
91 bounds.fBottom = cy;
92 if (bounds.width() > 0 && bounds.height() > 0) {
93 SkMask m = extractMaskSubset(mask, bounds, outerR.left(), outerR.top());
94 blitClippedMask(blitter, m, m.fBounds, clipR);
95 }
96
97 // top-right
98 bounds = mask.fBounds;
99 bounds.fLeft = cx + 1;
100 bounds.fBottom = cy;
101 if (bounds.width() > 0 && bounds.height() > 0) {
102 SkMask m = extractMaskSubset(mask, bounds, outerR.right() - bounds.width(), outerR.top());
103 blitClippedMask(blitter, m, m.fBounds, clipR);
104 }
105
106 // bottom-left
107 bounds = mask.fBounds;
108 bounds.fRight = cx;
109 bounds.fTop = cy + 1;
110 if (bounds.width() > 0 && bounds.height() > 0) {
111 SkMask m = extractMaskSubset(mask, bounds, outerR.left(), outerR.bottom() - bounds.height());
112 blitClippedMask(blitter, m, m.fBounds, clipR);
113 }
114
115 // bottom-right
116 bounds = mask.fBounds;
117 bounds.fLeft = cx + 1;
118 bounds.fTop = cy + 1;
119 if (bounds.width() > 0 && bounds.height() > 0) {
120 SkMask m = extractMaskSubset(mask, bounds, outerR.right() - bounds.width(),
121 outerR.bottom() - bounds.height());
122 blitClippedMask(blitter, m, m.fBounds, clipR);
123 }
124
125 SkIRect innerR;
126 innerR.setLTRB(outerR.left() + cx - mask.fBounds.left(),
127 outerR.top() + cy - mask.fBounds.top(),
128 outerR.right() + (cx + 1 - mask.fBounds.right()),
129 outerR.bottom() + (cy + 1 - mask.fBounds.bottom()));
130 if (fillCenter) {
131 blitClippedRect(blitter, innerR, clipR);
132 }
133
134 const int innerW = innerR.width();
135 size_t storageSize = (innerW + 1) * (sizeof(int16_t) + sizeof(uint8_t));
136 SkAutoSMalloc<4*1024> storage(storageSize);
137 int16_t* runs = (int16_t*)storage.get();
138 uint8_t* alpha = (uint8_t*)(runs + innerW + 1);
139
140 SkIRect r;
141 // top
142 r.setLTRB(innerR.left(), outerR.top(), innerR.right(), innerR.top());
143 if (r.intersect(clipR)) {
144 int startY = std::max(0, r.top() - outerR.top());
145 int stopY = startY + r.height();
146 int width = r.width();
147 for (int y = startY; y < stopY; ++y) {
148 runs[0] = width;
149 runs[width] = 0;
150 alpha[0] = *mask.getAddr8(cx, mask.fBounds.top() + y);
151 blitter->blitAntiH(r.left(), outerR.top() + y, alpha, runs);
152 }
153 }
154 // bottom
155 r.setLTRB(innerR.left(), innerR.bottom(), innerR.right(), outerR.bottom());
156 if (r.intersect(clipR)) {
157 int startY = outerR.bottom() - r.bottom();
158 int stopY = startY + r.height();
159 int width = r.width();
160 for (int y = startY; y < stopY; ++y) {
161 runs[0] = width;
162 runs[width] = 0;
163 alpha[0] = *mask.getAddr8(cx, mask.fBounds.bottom() - y - 1);
164 blitter->blitAntiH(r.left(), outerR.bottom() - y - 1, alpha, runs);
165 }
166 }
167 // left
168 r.setLTRB(outerR.left(), innerR.top(), innerR.left(), innerR.bottom());
169 if (r.intersect(clipR)) {
170 SkMask leftMask(mask.getAddr8(mask.fBounds.left() + r.left() - outerR.left(),
171 mask.fBounds.top() + cy),
172 r,
173 0, // so we repeat the scanline for our height
175 blitter->blitMask(leftMask, r);
176 }
177 // right
178 r.setLTRB(innerR.right(), innerR.top(), outerR.right(), innerR.bottom());
179 if (r.intersect(clipR)) {
180 SkMask rightMask(mask.getAddr8(mask.fBounds.right() - outerR.right() + r.left(),
181 mask.fBounds.top() + cy),
182 r,
183 0, // so we repeat the scanline for our height
185 blitter->blitMask(rightMask, r);
186 }
187}
static SkMask extractMaskSubset(const SkMask &src, SkIRect bounds, int32_t newX, int32_t newY)
static void blitClippedRect(SkBlitter *blitter, const SkIRect &rect, const SkIRect &clipR)
static void blitClippedMask(SkBlitter *blitter, const SkMask &mask, const SkIRect &bounds, const SkIRect &clipR)
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])=0
static float max(float r, float g, float b)
Definition: hsl.cpp:49
double y
int32_t width
constexpr int32_t bottom() const
Definition: SkRect.h:134
constexpr int32_t right() const
Definition: SkRect.h:127
void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
Definition: SkRect.h:253
Definition: SkMask.h:25
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
const uint8_t * getAddr8(int x, int y) const
Definition: SkMask.h:79
const SkIRect fBounds
Definition: SkMask.h:42

◆ extractMaskSubset()

static SkMask extractMaskSubset ( const SkMask src,
SkIRect  bounds,
int32_t  newX,
int32_t  newY 
)
static

Definition at line 54 of file SkMaskFilter.cpp.

54 {
55 SkASSERT(src.fBounds.contains(bounds));
56
57 const int dx = bounds.left() - src.fBounds.left();
58 const int dy = bounds.top() - src.fBounds.top();
59 bounds.offsetTo(newX, newY);
60 return SkMask(src.fImage + dy * src.fRowBytes + dx,
61 bounds,
62 src.fRowBytes,
63 src.fFormat);
64}
#define SkASSERT(cond)
Definition: SkAssert.h:116
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208