Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
ImageFiltersGraphGM Class Reference
Inheritance diagram for ImageFiltersGraphGM:
skiagm::GM

Public Member Functions

 ImageFiltersGraphGM ()
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onOnceBeforeDraw () override
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 29 of file imagefiltersgraph.cpp.

Constructor & Destructor Documentation

◆ ImageFiltersGraphGM()

ImageFiltersGraphGM::ImageFiltersGraphGM ( )
inline

Definition at line 31 of file imagefiltersgraph.cpp.

31{}

Member Function Documentation

◆ getISize()

SkISize ImageFiltersGraphGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 36 of file imagefiltersgraph.cpp.

36{ return SkISize::Make(600, 150); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString ImageFiltersGraphGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 34 of file imagefiltersgraph.cpp.

34{ return SkString("imagefiltersgraph"); }

◆ onDraw()

void ImageFiltersGraphGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 42 of file imagefiltersgraph.cpp.

42 {
43 canvas->clear(SK_ColorBLACK);
44 {
48 sk_sp<SkImageFilter> blur(SkImageFilters::Blur(4.0f, 4.0f, std::move(bitmapSource)));
51 std::move(erode)));
53
55 paint.setImageFilter(std::move(merge));
56 canvas->drawPaint(paint);
57 canvas->translate(SkIntToScalar(100), 0);
58 }
59 {
60 sk_sp<SkImageFilter> morph(SkImageFilters::Dilate(5, 5, nullptr));
61
62 float matrix[20] = { 1, 0, 0, 0, 0,
63 0, 1, 0, 0, 0,
64 0, 0, 1, 0, 0,
65 0, 0, 0, 0.5f, 0 };
66
67 sk_sp<SkColorFilter> matrixFilter(SkColorFilters::Matrix(matrix));
68 sk_sp<SkImageFilter> colorMorph(SkImageFilters::ColorFilter(std::move(matrixFilter),
69 std::move(morph)));
72 std::move(colorMorph)));
73
74 DrawClippedImage(canvas, fImage.get(), paint);
75 canvas->translate(SkIntToScalar(100), 0);
76 }
77 {
78 float matrix[20] = { 1, 0, 0, 0, 0,
79 0, 1, 0, 0, 0,
80 0, 0, 1, 0, 0,
81 0, 0, 0, 0.5f, 0 };
83 sk_sp<SkImageFilter> matrixFilter(SkImageFilters::ColorFilter(std::move(matrixCF),
84 nullptr));
85 sk_sp<SkImageFilter> offsetFilter(SkImageFilters::Offset(10.0f, 10.f, matrixFilter));
86
88 paint.setImageFilter(SkImageFilters::Arithmetic(
89 0, 1, 1, 0, true, std::move(matrixFilter), std::move(offsetFilter), nullptr));
90
91 DrawClippedImage(canvas, fImage.get(), paint);
92 canvas->translate(SkIntToScalar(100), 0);
93 }
94 {
95 sk_sp<SkImageFilter> blur(SkImageFilters::Blur(10, 10, nullptr));
96
97 SkIRect cropRect = SkIRect::MakeWH(95, 100);
99 paint.setImageFilter(
100 SkImageFilters::Blend(SkBlendMode::kSrcIn, std::move(blur), nullptr, &cropRect));
101 DrawClippedImage(canvas, fImage.get(), paint);
102 canvas->translate(SkIntToScalar(100), 0);
103 }
104 {
105 // Dilate -> matrix convolution.
106 // This tests that a filter using asFragmentProcessor (matrix
107 // convolution) correctly handles a non-zero source offset
108 // (supplied by the dilate).
109 sk_sp<SkImageFilter> dilate(SkImageFilters::Dilate(5, 5, nullptr));
110
111 SkScalar kernel[9] = { -1, -1, -1,
112 -1, 7, -1,
113 -1, -1, -1 };
114 SkISize kernelSize = SkISize::Make(3, 3);
115 SkScalar gain = 1.0f, bias = 0;
116 SkIPoint kernelOffset = SkIPoint::Make(1, 1);
117 bool convolveAlpha = false;
119 kernelSize, kernel, gain, bias, kernelOffset, SkTileMode::kClamp, convolveAlpha,
120 std::move(dilate)));
121
123 paint.setImageFilter(std::move(convolve));
124 DrawClippedImage(canvas, fImage.get(), paint);
125 canvas->translate(SkIntToScalar(100), 0);
126 }
127 {
128 // Test that crop offsets are absolute, not relative to the parent's crop rect.
131 SkIRect outerRect = SkIRect::MakeXYWH(10, 10, 80, 80);
132 SkIRect innerRect= SkIRect::MakeXYWH(20, 20, 60, 60);
134 std::move(cf1), nullptr, &outerRect));
136 std::move(cf2), std::move(color1), &innerRect));
137
139 paint.setImageFilter(std::move(color2));
140 paint.setColor(SK_ColorRED);
141 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint);
142 canvas->translate(SkIntToScalar(100), 0);
143 }
144 }
SkColor4f color
static void merge(const uint8_t *SK_RESTRICT row, int rowN, const SkAlpha *SK_RESTRICT srcAA, const int16_t *SK_RESTRICT srcRuns, SkAlpha *SK_RESTRICT dstAA, int16_t *SK_RESTRICT dstRuns, int width)
@ kSrcOver
r = s + (1-sa)*d
@ kSrcIn
r = s * da
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
#define SkIntToScalar(x)
Definition SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawPaint(const SkPaint &paint)
void clear(SkColor color)
Definition SkCanvas.h:1199
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
static sk_sp< SkImageFilter > MatrixConvolution(const SkISize &kernelSize, const SkScalar kernel[], SkScalar gain, SkScalar bias, const SkIPoint &kernelOffset, SkTileMode tileMode, bool convolveAlpha, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Merge(sk_sp< SkImageFilter > *const filters, int count, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Arithmetic(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
static sk_sp< SkImageFilter > Blend(SkBlendMode mode, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
T * get() const
Definition SkRefCnt.h:303
const Paint & paint
float SkScalar
Definition extension.cpp:12
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
static constexpr SkIPoint Make(int32_t x, int32_t y)
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

◆ onOnceBeforeDraw()

void ImageFiltersGraphGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 38 of file imagefiltersgraph.cpp.

38 {
39 fImage = ToolUtils::CreateStringImage(100, 100, SK_ColorWHITE, 20, 70, 96, "e");
40 }
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
sk_sp< SkImage > CreateStringImage(int w, int h, SkColor c, int x, int y, int textSize, const char *str)

The documentation for this class was generated from the following file: