230 {
245 };
246 const char* filterNames[] = {
247 "Color",
248 "Blur",
249 "Drop Shadow",
250 "Offset",
251 "Dilate",
252 "Erode",
253 "Displacement",
254 "Arithmetic",
255 "Blend",
256 "Convolution",
257 "Matrix Xform",
258 "Lighting",
259 "Tile"
260 };
261 static_assert(std::size(filters) == std::size(filterNames), "filter name length");
262
264 { -20, -20, 100, 100 },
265 { 0, 0, 75, 75 },
266 { 20, 20, 100, 100 },
267 { -20, -20, 50, 50 },
268 { 20, 20, 50, 50 },
269 { 30, 30, 75, 75 }
270 };
271
273
275 if (rContext) {
276 if (!dContext) {
277 *errorMsg = "Requires a direct context.";
278 return DrawResult::kSkip;
279 }
280 if (dContext->abandoned()) {
281 *errorMsg = "Direct context abandoned.";
282 return DrawResult::kSkip;
283 }
284 }
285
286
287
290 if (!mainImage || !auxImage) {
291 return DrawResult::kFail;
292 }
293 SkASSERT(mainImage && (mainImage->isTextureBacked() || !dContext));
294 SkASSERT(auxImage && (auxImage->isTextureBacked() || !dContext));
295
299
300
305 for (size_t i = 0; i < std::size(filterNames); ++i) {
307 }
308
310
311 for (auto clipBound : clipBounds) {
313 for (size_t i = 0; i < std::size(filters); ++i) {
316
317
318
322
323 this->drawImageWithFilter(canvas, mainImage, auxImage, filters[i], clipBound,
324 subset, &outSubset);
325
326
327
328 SkIRect* outSubsetBounds =
nullptr;
329 if (fStrategy != Strategy::kSaveLayer) {
330 outSubsetBounds = &outSubset;
331 }
332 show_bounds(canvas, &clipBound, &subset, outSubsetBounds);
333
335 }
338 }
339 return DrawResult::kOk;
340 }
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
void translate(SkScalar dx, SkScalar dy)
virtual GrRecordingContext * recordingContext() const
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
void setAntiAlias(bool aa)
static sk_sp< SkImageFilter > tile_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static void show_bounds(SkCanvas *canvas, const SkIRect *clip, const SkIRect *inSubset, const SkIRect *outSubset)
static sk_sp< SkImageFilter > drop_shadow_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > lighting_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > dilate_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > blur_filter_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > convolution_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > offset_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > blend_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > erode_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > color_filter_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > matrix_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
sk_sp< SkImageFilter >(* FilterFactory)(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > arithmetic_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
static sk_sp< SkImageFilter > displacement_factory(sk_sp< SkImage > auxImage, const SkIRect *cropRect)
font
Font Metadata and Metrics.
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)