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

Public Member Functions

 PictureImageFilterGM ()
 
- 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
 
sk_sp< SkImageFiltermake (sk_sp< SkPicture > pic, SkRect r, const SkSamplingOptions &sampling)
 
sk_sp< SkImageFiltermake (const SkSamplingOptions &sampling)
 
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 65 of file pictureimagefilter.cpp.

Constructor & Destructor Documentation

◆ PictureImageFilterGM()

PictureImageFilterGM::PictureImageFilterGM ( )
inline

Definition at line 67 of file pictureimagefilter.cpp.

67{ }

Member Function Documentation

◆ getISize()

SkISize PictureImageFilterGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 72 of file pictureimagefilter.cpp.

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

◆ getName()

SkString PictureImageFilterGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 70 of file pictureimagefilter.cpp.

70{ return SkString("pictureimagefilter"); }

◆ make() [1/2]

sk_sp< SkImageFilter > PictureImageFilterGM::make ( const SkSamplingOptions sampling)
inlineprotected

Definition at line 85 of file pictureimagefilter.cpp.

85 {
86 return make(fPicture, fPicture->cullRect(), sampling);
87 }
sk_sp< SkImageFilter > make(sk_sp< SkPicture > pic, SkRect r, const SkSamplingOptions &sampling)
virtual SkRect cullRect() const =0

◆ make() [2/2]

sk_sp< SkImageFilter > PictureImageFilterGM::make ( sk_sp< SkPicture pic,
SkRect  r,
const SkSamplingOptions sampling 
)
inlineprotected

Definition at line 79 of file pictureimagefilter.cpp.

79 {
82 pic, dim, nullptr, nullptr, SkImages::BitDepth::kU8, SkColorSpace::MakeSRGB());
83 return SkImageFilters::Image(img, r, r, sampling);
84 }
#define SkScalarRoundToInt(x)
Definition SkScalar.h:37
static sk_sp< SkColorSpace > MakeSRGB()
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
SK_API sk_sp< SkImage > DeferredFromPicture(sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace, SkSurfaceProps props)
@ kU8
uses 8-bit unsigned int per color component
constexpr float height() const
Definition SkRect.h:769
constexpr float width() const
Definition SkRect.h:762

◆ onDraw()

void PictureImageFilterGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 89 of file pictureimagefilter.cpp.

89 {
90 canvas->clear(SK_ColorGRAY);
91 {
92 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30);
93 SkRect emptyRect = SkRect::MakeXYWH(20, 20, 0, 0);
94 SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100);
95 sk_sp<SkImageFilter> pictureSource(SkImageFilters::Picture(fPicture));
96 sk_sp<SkImageFilter> pictureSourceSrcRect(SkImageFilters::Picture(fPicture, srcRect));
97 sk_sp<SkImageFilter> pictureSourceEmptyRect(SkImageFilters::Picture(fPicture,
98 emptyRect));
100 sk_sp<SkImageFilter> pictureSourcePixelated = make(SkSamplingOptions());
101
102 canvas->save();
103 // Draw the picture unscaled.
104 fill_rect_filtered(canvas, bounds, pictureSource);
105 canvas->translate(SkIntToScalar(100), 0);
106
107 // Draw an unscaled subset of the source picture.
108 fill_rect_filtered(canvas, bounds, pictureSourceSrcRect);
109 canvas->translate(SkIntToScalar(100), 0);
110
111 // Draw the picture to an empty rect (should draw nothing).
112 fill_rect_filtered(canvas, bounds, pictureSourceEmptyRect);
113 canvas->translate(SkIntToScalar(100), 0);
114
115 // Draw the LCD picture to a layer
116 {
117 SkPaint stroke;
119
120 canvas->drawRect(bounds, stroke);
121
123 paint.setImageFilter(make(fLCDPicture, fPicture->cullRect(), SkSamplingOptions()));
124
125 canvas->scale(4, 4);
126 canvas->translate(-0.9f*srcRect.fLeft, -2.45f*srcRect.fTop);
127
128 canvas->saveLayer(&bounds, &paint);
129 canvas->restore();
130 }
131
132 canvas->restore();
133
134 // Draw the picture scaled
135 canvas->translate(0, SkIntToScalar(100));
136 canvas->scale(200 / srcRect.width(), 200 / srcRect.height());
137 canvas->translate(-srcRect.fLeft, -srcRect.fTop);
138 fill_rect_filtered(canvas, srcRect, pictureSource);
139
140 // Draw the picture scaled, but rasterized at original resolution
141 canvas->translate(srcRect.width(), 0);
142 fill_rect_filtered(canvas, srcRect, pictureSourceResampled);
143
144 // Draw the picture scaled, pixelated
145 canvas->translate(srcRect.width(), 0);
146 fill_rect_filtered(canvas, srcRect, pictureSourcePixelated);
147 }
148 }
constexpr SkColor SK_ColorGRAY
Definition SkColor.h:113
#define SkIntToScalar(x)
Definition SkScalar.h:57
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition SkCanvas.cpp:500
void drawRect(const SkRect &rect, const SkPaint &paint)
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
void clear(SkColor color)
Definition SkCanvas.h:1199
int save()
Definition SkCanvas.cpp:451
void scale(SkScalar sx, SkScalar sy)
static sk_sp< SkImageFilter > Picture(sk_sp< SkPicture > pic, const SkRect &targetRect)
void setStyle(Style style)
Definition SkPaint.cpp:105
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
const Paint & paint
Optional< SkRect > bounds
Definition SkRecords.h:189
static void fill_rect_filtered(SkCanvas *canvas, const SkRect &clipRect, sk_sp< SkImageFilter > filter)
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15

◆ onOnceBeforeDraw()

void PictureImageFilterGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 74 of file pictureimagefilter.cpp.

74 {
75 fPicture = make_picture();
76 fLCDPicture = make_LCD_picture();
77 }
static sk_sp< SkPicture > make_picture()
static sk_sp< SkPicture > make_LCD_picture()

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