Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
BackdropSlide Class Reference
Inheritance diagram for BackdropSlide:
ClickHandlerSlide Slide SkRefCnt SkRefCntBase

Public Member Functions

 BackdropSlide ()
 
- Public Member Functions inherited from ClickHandlerSlide
bool onMouse (SkScalar x, SkScalar y, skui::InputState clickState, skui::ModifierKey modifierKeys) final
 
- Public Member Functions inherited from Slide
virtual SkISize getDimensions () const
 
virtual void gpuTeardown ()
 
virtual void draw (SkCanvas *canvas)=0
 
virtual bool animate (double nanos)
 
virtual void load (SkScalar winWidth, SkScalar winHeight)
 
virtual void resize (SkScalar winWidth, SkScalar winHeight)
 
virtual void unload ()
 
virtual bool onChar (SkUnichar c)
 
virtual bool onMouse (SkScalar x, SkScalar y, skui::InputState state, skui::ModifierKey modifiers)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
const SkStringgetName ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

void load (SkScalar, SkScalar) override
 
void draw (SkCanvas *canvas) override
 
bool animate (double nanos) override
 
ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi) override
 
bool onClick (Click *click) override
 
virtual ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi)=0
 
virtual bool onClick (Click *)=0
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 163 of file LayersSlide.cpp.

Constructor & Destructor Documentation

◆ BackdropSlide()

BackdropSlide::BackdropSlide ( )
inline

Definition at line 170 of file LayersSlide.cpp.

170 {
171 fName = "Backdrop";
172 }
SkString fName
Definition: Slide.h:54

Member Function Documentation

◆ animate()

bool BackdropSlide::animate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from Slide.

Definition at line 204 of file LayersSlide.cpp.

204 {
205 fAngle = SkDoubleToScalar(fmod(1e-9 * nanos * 360 / 5, 360));
206 return true;
207 }
#define SkDoubleToScalar(x)
Definition: SkScalar.h:64

◆ draw()

void BackdropSlide::draw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Implements Slide.

Definition at line 182 of file LayersSlide.cpp.

182 {
183 canvas->drawImage(fImage.get(), 0, 0);
184
185 const SkScalar w = 250;
186 const SkScalar h = 150;
187 SkPath path;
188 path.addOval(SkRect::MakeXYWH(-w/2, -h/2, w, h));
189 SkMatrix m;
190 m.setRotate(fAngle);
191 m.postTranslate(fCenter.x(), fCenter.y());
192 path.transform(m);
193
194 canvas->clipPath(path, SkClipOp::kIntersect, true);
195 const SkRect bounds = path.getBounds();
196
198 paint.setAlpha(0xCC);
199 canvas->saveLayer(SkCanvas::SaveLayerRec(&bounds, &paint, fFilter.get(), 0));
200
201 canvas->restore();
202 }
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void restore()
Definition: SkCanvas.cpp:461
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
Definition: SkPath.h:59
T * get() const
Definition: SkRefCnt.h:303
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
Optional< SkRect > bounds
Definition: SkRecords.h:189
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
SkScalar w
SkScalar h
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ load()

void BackdropSlide::load ( SkScalar  ,
SkScalar   
)
inlineoverrideprotectedvirtual

Reimplemented from Slide.

Definition at line 175 of file LayersSlide.cpp.

175 {
176 fCenter.set(200, 150);
177 fAngle = 0;
178 fImage = ToolUtils::GetResourceAsImage("images/mandrill_512.png");
179 fFilter = SkImageFilters::Dilate(8, 8, nullptr);
180 }
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25
void set(float x, float y)
Definition: SkPoint_impl.h:200

◆ onClick()

bool BackdropSlide::onClick ( Click )
inlineoverrideprotectedvirtual

Override to track clicks. Return true as long as you want to track the pen/mouse.

Implements ClickHandlerSlide.

Definition at line 214 of file LayersSlide.cpp.

214 {
215 fCenter = click->fCurr;
216 return true;
217 }

◆ onFindClickHandler()

Click * BackdropSlide::onFindClickHandler ( SkScalar  x,
SkScalar  y,
skui::ModifierKey  modi 
)
inlineoverrideprotectedvirtual

Return a Click object to handle the click. onClick will be called repeatedly with the latest mouse state tracked on the Click object until it returns false.

Implements ClickHandlerSlide.

Definition at line 210 of file LayersSlide.cpp.

210 {
211 return new Click();
212 }

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