Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
MSKPPlayer::DrawLayerCmd Struct Reference
Inheritance diagram for MSKPPlayer::DrawLayerCmd:
MSKPPlayer::Cmd

Public Member Functions

bool isFullRedraw (SkCanvas *canvas) const override
 
void draw (SkCanvas *canvas, const LayerMap &, LayerStateMap *) const override
 
int layerID () const override
 
- Public Member Functions inherited from MSKPPlayer::Cmd
virtual ~Cmd ()=default
 
virtual bool isFullRedraw (SkCanvas *) const =0
 
virtual void draw (SkCanvas *canvas, const LayerMap &, LayerStateMap *) const =0
 
virtual int layerID () const
 

Public Attributes

int fLayerId
 
size_t fLayerCmdCnt
 
SkRect fSrcRect
 
SkRect fDstRect
 
SkSamplingOptions fSampling
 
SkCanvas::SrcRectConstraint fConstraint
 
SkTLazy< SkPaintfPaint
 

Detailed Description

Definition at line 64 of file MSKPPlayer.cpp.

Member Function Documentation

◆ draw()

void MSKPPlayer::DrawLayerCmd::draw ( SkCanvas canvas,
const LayerMap &  layerMap,
LayerStateMap *  layerStateMap 
) const
overridevirtual

Implements MSKPPlayer::Cmd.

Definition at line 78 of file MSKPPlayer.cpp.

80 {
81 const LayerCmds& layer = layerMap.at(fLayerId);
82 LayerState* layerState = &(*layerStateMap)[fLayerId];
83 if (!layerState->fSurface) {
84 layerState->fCurrCmd = 0;
85 layerState->fSurface = MSKPPlayer::MakeSurfaceForLayer(layer, canvas);
86 if (!layerState->fSurface) {
87 SkDebugf("Couldn't create surface for layer");
88 return;
89 }
90 }
91 size_t cmd = layerState->fCurrCmd;
92 if (cmd > fLayerCmdCnt) {
93 // If the layer contains contents from later commands then replay from the beginning.
94 cmd = 0;
95 }
96 SkCanvas* layerCanvas = layerState->fSurface->getCanvas();
97 // Check if there is a full redraw between cmd and fLayerCmdCnt and if so jump to it and ensure
98 // we clear the canvas if starting from a full redraw.
99 for (size_t checkCmd = fLayerCmdCnt - 1; checkCmd > cmd; --checkCmd) {
100 if (layer.fCmds[checkCmd]->isFullRedraw(layerCanvas)) {
101 cmd = checkCmd;
102 break;
103 }
104 }
105 for (; cmd < fLayerCmdCnt; ++cmd) {
106 if (cmd == 0 || layer.fCmds[cmd]->isFullRedraw(layerCanvas)) {
107 layerState->fSurface->getCanvas()->clear(SK_ColorTRANSPARENT);
108 }
109 layer.fCmds[cmd]->draw(layerCanvas, layerMap, layerStateMap);
110 }
111 layerState->fCurrCmd = fLayerCmdCnt;
112 const SkPaint* paint = fPaint.isValid() ? fPaint.get() : nullptr;
113 canvas->drawImageRect(layerState->fSurface->makeImageSnapshot(),
114 fSrcRect,
115 fDstRect,
116 fSampling,
117 paint,
119}
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
T * get()
Definition: SkTLazy.h:83
bool isValid() const
Definition: SkTLazy.h:77
const Paint & paint
Definition: color_source.cc:38
SkCanvas::SrcRectConstraint fConstraint
Definition: MSKPPlayer.cpp:70
SkTLazy< SkPaint > fPaint
Definition: MSKPPlayer.cpp:71
SkSamplingOptions fSampling
Definition: MSKPPlayer.cpp:69

◆ isFullRedraw()

bool MSKPPlayer::DrawLayerCmd::isFullRedraw ( SkCanvas canvas) const
inlineoverridevirtual

Implements MSKPPlayer::Cmd.

Definition at line 73 of file MSKPPlayer.cpp.

73{ return false; }

◆ layerID()

int MSKPPlayer::DrawLayerCmd::layerID ( ) const
inlineoverridevirtual

Reimplemented from MSKPPlayer::Cmd.

Definition at line 75 of file MSKPPlayer.cpp.

75{ return fLayerId; }

Member Data Documentation

◆ fConstraint

SkCanvas::SrcRectConstraint MSKPPlayer::DrawLayerCmd::fConstraint

Definition at line 70 of file MSKPPlayer.cpp.

◆ fDstRect

SkRect MSKPPlayer::DrawLayerCmd::fDstRect

Definition at line 68 of file MSKPPlayer.cpp.

◆ fLayerCmdCnt

size_t MSKPPlayer::DrawLayerCmd::fLayerCmdCnt

Definition at line 66 of file MSKPPlayer.cpp.

◆ fLayerId

int MSKPPlayer::DrawLayerCmd::fLayerId

Definition at line 65 of file MSKPPlayer.cpp.

◆ fPaint

SkTLazy<SkPaint> MSKPPlayer::DrawLayerCmd::fPaint

Definition at line 71 of file MSKPPlayer.cpp.

◆ fSampling

SkSamplingOptions MSKPPlayer::DrawLayerCmd::fSampling

Definition at line 69 of file MSKPPlayer.cpp.

◆ fSrcRect

SkRect MSKPPlayer::DrawLayerCmd::fSrcRect

Definition at line 67 of file MSKPPlayer.cpp.


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