Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SKPSlide Class Reference

#include <SKPSlide.h>

Inheritance diagram for SKPSlide:
Slide SkRefCnt SkRefCntBase

Public Member Functions

 SKPSlide (const SkString &name, const SkString &path)
 
 SKPSlide (const SkString &name, std::unique_ptr< SkStream >)
 
 ~SKPSlide () override
 
SkISize getDimensions () const override
 
void draw (SkCanvas *canvas) override
 
void load (SkScalar winWidth, SkScalar winHeight) override
 
void unload () override
 
- 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
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 24 of file SKPSlide.h.

Constructor & Destructor Documentation

◆ SKPSlide() [1/2]

SKPSlide::SKPSlide ( const SkString name,
const SkString path 
)

Definition at line 19 of file SKPSlide.cpp.

21}
SKPSlide(const SkString &name, const SkString &path)
Definition: SKPSlide.cpp:19
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
Definition: SkStream.cpp:922
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
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ SKPSlide() [2/2]

SKPSlide::SKPSlide ( const SkString name,
std::unique_ptr< SkStream stream 
)

Definition at line 23 of file SKPSlide.cpp.

24 : fStream(std::move(stream)) {
25 fName = name;
26}
SkString fName
Definition: Slide.h:54

◆ ~SKPSlide()

SKPSlide::~SKPSlide ( )
override

Definition at line 28 of file SKPSlide.cpp.

28{}

Member Function Documentation

◆ draw()

void SKPSlide::draw ( SkCanvas canvas)
overridevirtual

Implements Slide.

Definition at line 30 of file SKPSlide.cpp.

30 {
31 if (fPic) {
32 bool isOffset = SkToBool(fCullRect.left() | fCullRect.top());
33 if (isOffset) {
34 canvas->save();
35 canvas->translate(SkIntToScalar(-fCullRect.left()), SkIntToScalar(-fCullRect.top()));
36 }
37
38 canvas->drawPicture(fPic.get());
39
40 if (isOffset) {
41 canvas->restore();
42 }
43 }
44}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawPicture(const SkPicture *picture)
Definition: SkCanvas.h:1961
T * get() const
Definition: SkRefCnt.h:303
constexpr int32_t top() const
Definition: SkRect.h:120
constexpr int32_t left() const
Definition: SkRect.h:113

◆ getDimensions()

SkISize SKPSlide::getDimensions ( ) const
inlineoverridevirtual

A slide may have a content dimensions that is independent of the current window size. An empty size indicates that the Slide's dimensions are equal to the window's dimensions.

Reimplemented from Slide.

Definition at line 30 of file SKPSlide.h.

30{ return fCullRect.size(); }
constexpr SkISize size() const
Definition: SkRect.h:172

◆ load()

void SKPSlide::load ( SkScalar  winWidth,
SkScalar  winHeight 
)
overridevirtual

Reimplemented from Slide.

Definition at line 46 of file SKPSlide.cpp.

46 {
47 if (!fStream) {
48 SkDebugf("No skp stream for slide %s.\n", fName.c_str());
49 return;
50 }
51 fStream->rewind();
52 fPic = SkPicture::MakeFromStream(fStream.get());
53 if (!fPic) {
54 SkDebugf("Could not parse SkPicture from skp stream for slide %s.\n", fName.c_str());
55 return;
56 }
57 fCullRect = fPic->cullRect().roundOut();
58}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
virtual SkRect cullRect() const =0
static sk_sp< SkPicture > MakeFromStream(SkStream *stream, const SkDeserialProcs *procs=nullptr)
Definition: SkPicture.cpp:147
const char * c_str() const
Definition: SkString.h:133
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241

◆ unload()

void SKPSlide::unload ( )
overridevirtual

Reimplemented from Slide.

Definition at line 60 of file SKPSlide.cpp.

60 {
61 fPic.reset(nullptr);
62}
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310

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