Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SaveLayerDrawRestoreNooper Struct Reference

Public Types

typedef Pattern< Is< SaveLayer >, IsSingleDraw, Is< Restore > > Match
 

Public Member Functions

bool onMatch (SkRecord *record, Match *match, int begin, int end)
 

Static Public Member Functions

static bool KillSaveLayerAndRestore (SkRecord *record, int saveLayerIndex)
 

Detailed Description

Definition at line 156 of file SkRecordOpts.cpp.

Member Typedef Documentation

◆ Match

typedef Pattern<Is<SaveLayer>, IsSingleDraw, Is<Restore> > SaveLayerDrawRestoreNooper::Match

Definition at line 160 of file SkRecordOpts.cpp.

Member Function Documentation

◆ KillSaveLayerAndRestore()

static bool SaveLayerDrawRestoreNooper::KillSaveLayerAndRestore ( SkRecord record,
int  saveLayerIndex 
)
inlinestatic

Definition at line 195 of file SkRecordOpts.cpp.

195 {
196 record->replace<NoOp>(saveLayerIndex); // SaveLayer
197 record->replace<NoOp>(saveLayerIndex+2); // Restore
198 return true;
199 }
T * replace(int i)
Definition SkRecord.h:83

◆ onMatch()

bool SaveLayerDrawRestoreNooper::onMatch ( SkRecord record,
Match match,
int  begin,
int  end 
)
inline

Definition at line 162 of file SkRecordOpts.cpp.

162 {
163 if (match->first<SaveLayer>()->backdrop) {
164 // can't throw away the layer if we have a backdrop
165 return false;
166 }
167
168 if (!match->first<SaveLayer>()->filters.empty()) {
169 // Our optimizations don't handle the filter list correctly - don't bother trying
170 return false;
171 }
172
173 // A SaveLayer's bounds field is just a hint, so we should be free to ignore it.
174 SkPaint* layerPaint = match->first<SaveLayer>()->paint;
175 SkPaint* drawPaint = match->second<SkPaint>();
176
177 if (nullptr == layerPaint && effectively_srcover(drawPaint)) {
178 // There wasn't really any point to this SaveLayer at all.
179 return KillSaveLayerAndRestore(record, begin);
180 }
181
182 if (drawPaint == nullptr) {
183 // We can just give the draw the SaveLayer's paint.
184 // TODO(mtklein): figure out how to do this clearly
185 return false;
186 }
187
188 if (!fold_opacity_layer_color_to_paint(layerPaint, false /*isSaveLayer*/, drawPaint)) {
189 return false;
190 }
191
192 return KillSaveLayerAndRestore(record, begin);
193 }
static bool match(const char *needle, const char *haystack)
Definition DM.cpp:1132
static bool fold_opacity_layer_color_to_paint(const SkPaint *layerPaint, bool isSaveLayer, SkPaint *paint)
static bool effectively_srcover(const SkPaint *paint)
static const char * begin(const StringSlice &s)
Definition editor.cpp:252
Optional< SkPaint > paint
Definition SkRecords.h:190
static bool KillSaveLayerAndRestore(SkRecord *record, int saveLayerIndex)

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