5#ifndef FLUTTER_DISPLAY_LIST_EFFECTS_DL_IMAGE_FILTER_H_
6#define FLUTTER_DISPLAY_LIST_EFFECTS_DL_IMAGE_FILTER_H_
10#include "flutter/display_list/dl_attributes.h"
11#include "flutter/display_list/dl_sampling_options.h"
12#include "flutter/display_list/dl_tile_mode.h"
13#include "flutter/display_list/effects/dl_color_filter.h"
14#include "flutter/display_list/utils/dl_comparable.h"
15#include "flutter/fml/logging.h"
39class DlBlurImageFilter;
40class DlDilateImageFilter;
41class DlErodeImageFilter;
42class DlMatrixImageFilter;
43class DlLocalMatrixImageFilter;
44class DlComposeImageFilter;
45class DlColorFilterImageFilter;
103 SkRect& output_bounds)
const = 0;
118 SkIRect& output_bounds)
const = 0;
131 SkIRect& input_bounds)
const = 0;
165 return {
x *
abs(ctm[0]) +
y *
abs(ctm[1]),
177 if (ctm.
invert(&inverse)) {
179 local_bounds.
inset(radius_x, radius_y);
180 output_bounds = ctm.
mapRect(local_bounds).roundOut();
181 return &output_bounds;
187 return &output_bounds;
190 output_bounds = input_bounds;
202 if (ctm.
invert(&inverse)) {
204 local_bounds.
outset(radius_x, radius_y);
205 output_bounds = ctm.
mapRect(local_bounds).roundOut();
206 return &output_bounds;
212 return &output_bounds;
215 output_bounds = input_bounds;
227 filter->tile_mode_) {}
245 std::shared_ptr<DlImageFilter>
shared()
const override {
246 return std::make_shared<DlBlurImageFilter>(
this);
250 size_t size()
const override {
return sizeof(*this); }
257 SkRect& output_bounds)
const override {
258 output_bounds = input_bounds.
makeOutset(sigma_x_ * 3.0f, sigma_y_ * 3.0f);
259 return &output_bounds;
264 SkIRect& output_bounds)
const override {
271 SkIRect& input_bounds)
const override {
284 return (sigma_x_ == that->sigma_x_ && sigma_y_ == that->sigma_y_ &&
285 tile_mode_ == that->tile_mode_);
312 std::shared_ptr<DlImageFilter>
shared()
const override {
313 return std::make_shared<DlDilateImageFilter>(
this);
317 size_t size()
const override {
return sizeof(*this); }
324 SkRect& output_bounds)
const override {
325 output_bounds = input_bounds.
makeOutset(radius_x_, radius_y_);
326 return &output_bounds;
331 SkIRect& output_bounds)
const override {
338 SkIRect& input_bounds)
const override {
350 return (radius_x_ == that->radius_x_ && radius_y_ == that->radius_y_);
376 std::shared_ptr<DlImageFilter>
shared()
const override {
377 return std::make_shared<DlErodeImageFilter>(
this);
381 size_t size()
const override {
return sizeof(*this); }
388 SkRect& output_bounds)
const override {
389 output_bounds = input_bounds.
makeInset(radius_x_, radius_y_);
390 return &output_bounds;
395 SkIRect& output_bounds)
const override {
402 SkIRect& input_bounds)
const override {
414 return (radius_x_ == that->radius_x_ && radius_y_ == that->radius_y_);
439 std::shared_ptr<DlImageFilter>
shared()
const override {
440 return std::make_shared<DlMatrixImageFilter>(
this);
444 size_t size()
const override {
return sizeof(*this); }
454 SkRect& output_bounds)
const override {
455 output_bounds = matrix_.
mapRect(input_bounds);
456 return &output_bounds;
461 SkIRect& output_bounds)
const override {
464 output_bounds = input_bounds;
471 output_bounds = device_rect.
roundOut();
472 return &output_bounds;
477 SkIRect& input_bounds)
const override {
481 input_bounds = output_bounds;
486 bounds.set(output_bounds);
488 input_bounds =
bounds.roundOut();
489 return &input_bounds;
496 return (matrix_ == that->matrix_ && sampling_ == that->sampling_);
507 std::shared_ptr<const DlImageFilter>
inner)
518 static std::shared_ptr<const DlImageFilter>
Make(
519 std::shared_ptr<const DlImageFilter>
outer,
520 std::shared_ptr<const DlImageFilter>
inner) {
527 return std::make_shared<DlComposeImageFilter>(
outer,
inner);
530 std::shared_ptr<DlImageFilter>
shared()
const override {
531 return std::make_shared<DlComposeImageFilter>(
this);
537 size_t size()
const override {
return sizeof(*this); }
539 std::shared_ptr<const DlImageFilter>
outer()
const {
return outer_; }
540 std::shared_ptr<const DlImageFilter>
inner()
const {
return inner_; }
545 if (inner_ && inner_->modifies_transparent_black()) {
548 if (outer_ && outer_->modifies_transparent_black()) {
555 SkRect& output_bounds)
const override;
559 SkIRect& output_bounds)
const override;
563 SkIRect& input_bounds)
const override;
566 return std::min(outer_->matrix_capability(), inner_->matrix_capability());
573 return (
Equals(outer_, that->outer_) &&
Equals(inner_, that->inner_));
577 std::shared_ptr<const DlImageFilter> outer_;
578 std::shared_ptr<const DlImageFilter> inner_;
584 : color_filter_(
std::move(filter)) {}
586 : color_filter_(filter->
shared()) {}
588 : color_filter_(filter.
shared()) {}
594 static std::shared_ptr<DlImageFilter>
Make(
595 const std::shared_ptr<const DlColorFilter>& filter) {
597 return std::make_shared<DlColorFilterImageFilter>(filter);
602 std::shared_ptr<DlImageFilter>
shared()
const override {
603 return std::make_shared<DlColorFilterImageFilter>(color_filter_);
609 size_t size()
const override {
return sizeof(*this); }
612 return color_filter_;
621 return color_filter_->modifies_transparent_black();
627 SkRect& output_bounds)
const override {
628 output_bounds = input_bounds;
634 SkIRect& output_bounds)
const override {
635 output_bounds = input_bounds;
641 SkIRect& input_bounds)
const override {
658 return Equals(color_filter_, that->color_filter_);
662 std::shared_ptr<const DlColorFilter> color_filter_;
668 std::shared_ptr<DlImageFilter> filter)
669 : matrix_(
matrix), image_filter_(
std::move(filter)) {}
674 std::shared_ptr<DlImageFilter>
shared()
const override {
675 return std::make_shared<DlLocalMatrixImageFilter>(
this);
681 size_t size()
const override {
return sizeof(*this); }
686 return image_filter_;
694 if (!image_filter_) {
697 return image_filter_->modifies_transparent_black();
701 SkRect& output_bounds)
const override {
702 if (!image_filter_) {
703 output_bounds = input_bounds;
704 return &output_bounds;
706 return image_filter_->map_local_bounds(input_bounds, output_bounds);
711 SkIRect& output_bounds)
const override {
712 if (!image_filter_) {
713 output_bounds = input_bounds;
714 return &output_bounds;
716 return image_filter_->map_device_bounds(
722 SkIRect& input_bounds)
const override {
723 if (!image_filter_) {
724 input_bounds = output_bounds;
725 return &input_bounds;
727 return image_filter_->get_input_device_bounds(
735 return (matrix_ == that->matrix_ &&
736 Equals(image_filter_, that->image_filter_));
741 std::shared_ptr<DlImageFilter> image_filter_;
#define SK_ScalarNearlyZero
SkMatrix & postConcat(const SkMatrix &other)
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
bool invert(SkMatrix *inverse) const
bool hasPerspective() const
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
virtual T type() const =0
bool modifies_transparent_black() const override
DlImageFilterType type() const override
std::shared_ptr< DlImageFilter > shared() const override
DlBlurImageFilter(SkScalar sigma_x, SkScalar sigma_y, DlTileMode tile_mode)
SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const override
static std::shared_ptr< DlImageFilter > Make(SkScalar sigma_x, SkScalar sigma_y, DlTileMode tile_mode)
SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const override
SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const override
bool equals_(const DlImageFilter &other) const override
const DlBlurImageFilter * asBlur() const override
size_t size() const override
DlBlurImageFilter(const DlBlurImageFilter *filter)
DlTileMode tile_mode() const
DlBlurImageFilter(const DlBlurImageFilter &filter)
DlColorFilterImageFilter(const DlColorFilterImageFilter *filter)
MatrixCapability matrix_capability() const override
static std::shared_ptr< DlImageFilter > Make(const std::shared_ptr< const DlColorFilter > &filter)
const std::shared_ptr< const DlColorFilter > color_filter() const
bool modifies_transparent_black() const override
DlColorFilterImageFilter(const DlColorFilterImageFilter &filter)
SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const override
SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const override
DlColorFilterImageFilter(std::shared_ptr< const DlColorFilter > filter)
SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const override
DlImageFilterType type() const override
size_t size() const override
std::shared_ptr< DlImageFilter > makeWithLocalMatrix(const SkMatrix &matrix) const override
const DlColorFilterImageFilter * asColorFilter() const override
DlColorFilterImageFilter(const DlColorFilter &filter)
bool equals_(const DlImageFilter &other) const override
DlColorFilterImageFilter(const DlColorFilter *filter)
std::shared_ptr< DlImageFilter > shared() const override
DlComposeImageFilter(const DlComposeImageFilter *filter)
DlComposeImageFilter(const DlComposeImageFilter &filter)
DlComposeImageFilter(const DlImageFilter *outer, const DlImageFilter *inner)
std::shared_ptr< DlImageFilter > shared() const override
DlComposeImageFilter(const DlImageFilter &outer, const DlImageFilter &inner)
MatrixCapability matrix_capability() const override
const DlComposeImageFilter * asCompose() const override
SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const override
DlComposeImageFilter(std::shared_ptr< const DlImageFilter > outer, std::shared_ptr< const DlImageFilter > inner)
std::shared_ptr< const DlImageFilter > outer() const
SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const override
SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const override
std::shared_ptr< const DlImageFilter > inner() const
bool modifies_transparent_black() const override
bool equals_(const DlImageFilter &other) const override
static std::shared_ptr< const DlImageFilter > Make(std::shared_ptr< const DlImageFilter > outer, std::shared_ptr< const DlImageFilter > inner)
size_t size() const override
DlImageFilterType type() const override
SkScalar radius_y() const
SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const override
SkScalar radius_x() const
DlDilateImageFilter(SkScalar radius_x, SkScalar radius_y)
bool modifies_transparent_black() const override
SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const override
const DlDilateImageFilter * asDilate() const override
SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const override
std::shared_ptr< DlImageFilter > shared() const override
DlImageFilterType type() const override
static std::shared_ptr< DlImageFilter > Make(SkScalar radius_x, SkScalar radius_y)
bool equals_(const DlImageFilter &other) const override
size_t size() const override
DlDilateImageFilter(const DlDilateImageFilter &filter)
DlDilateImageFilter(const DlDilateImageFilter *filter)
bool equals_(const DlImageFilter &other) const override
SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const override
const DlErodeImageFilter * asErode() const override
static std::shared_ptr< DlImageFilter > Make(SkScalar radius_x, SkScalar radius_y)
std::shared_ptr< DlImageFilter > shared() const override
SkScalar radius_y() const
size_t size() const override
DlImageFilterType type() const override
DlErodeImageFilter(SkScalar radius_x, SkScalar radius_y)
SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const override
bool modifies_transparent_black() const override
SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const override
DlErodeImageFilter(const DlErodeImageFilter &filter)
SkScalar radius_x() const
DlErodeImageFilter(const DlErodeImageFilter *filter)
virtual const DlLocalMatrixImageFilter * asLocalMatrix() const
virtual const DlColorFilterImageFilter * asColorFilter() const
virtual SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const =0
static SkIRect * outset_device_bounds(const SkIRect &input_bounds, SkScalar radius_x, SkScalar radius_y, const SkMatrix &ctm, SkIRect &output_bounds)
virtual const DlMatrixImageFilter * asMatrix() const
virtual bool modifies_transparent_black() const =0
static SkIRect * inset_device_bounds(const SkIRect &input_bounds, SkScalar radius_x, SkScalar radius_y, const SkMatrix &ctm, SkIRect &output_bounds)
virtual const DlComposeImageFilter * asCompose() const
virtual SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const =0
virtual SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const =0
virtual MatrixCapability matrix_capability() const
virtual const DlBlurImageFilter * asBlur() const
static SkVector map_vectors_affine(const SkMatrix &ctm, SkScalar x, SkScalar y)
virtual const DlDilateImageFilter * asDilate() const
virtual const DlErodeImageFilter * asErode() const
virtual std::shared_ptr< DlImageFilter > makeWithLocalMatrix(const SkMatrix &matrix) const
size_t size() const override
const SkMatrix & matrix() const
DlLocalMatrixImageFilter(const DlLocalMatrixImageFilter &filter)
SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const override
const DlLocalMatrixImageFilter * asLocalMatrix() const override
bool equals_(const DlImageFilter &other) const override
bool modifies_transparent_black() const override
DlLocalMatrixImageFilter(const DlLocalMatrixImageFilter *filter)
DlImageFilterType type() const override
DlLocalMatrixImageFilter(const SkMatrix &matrix, std::shared_ptr< DlImageFilter > filter)
SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const override
const std::shared_ptr< DlImageFilter > image_filter() const
std::shared_ptr< DlImageFilter > shared() const override
SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const override
DlMatrixImageFilter(const DlMatrixImageFilter *filter)
const DlMatrixImageFilter * asMatrix() const override
DlMatrixImageFilter(const DlMatrixImageFilter &filter)
DlImageFilterType type() const override
SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const override
std::shared_ptr< DlImageFilter > shared() const override
bool modifies_transparent_black() const override
SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const override
const SkMatrix & matrix() const
static std::shared_ptr< DlImageFilter > Make(const SkMatrix &matrix, DlImageSampling sampling)
size_t size() const override
DlImageSampling sampling() const
DlMatrixImageFilter(const SkMatrix &matrix, DlImageSampling sampling)
bool equals_(const DlImageFilter &other) const override
SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const override
#define FML_DCHECK(condition)
static float min(float r, float g, float b)
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
bool Equals(const T *a, const T *b)
SINT bool isfinite(const Vec< N, T > &v)
SIN Vec< N, float > abs(const Vec< N, float > &x)
SIN Vec< N, float > floor(const Vec< N, float > &x)
SIN Vec< N, float > ceil(const Vec< N, float > &x)
SkIRect makeOutset(int32_t dx, int32_t dy) const
SkIRect makeInset(int32_t dx, int32_t dy) const
static SkRect Make(const SkISize &size)
void inset(float dx, float dy)
void outset(float dx, float dy)
SkRect makeOutset(float dx, float dy) const
SkRect makeInset(float dx, float dy) const
void roundOut(SkIRect *dst) const