Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SvgOpacityAndFilterLayerMergePass Struct Reference

Public Types

typedef Pattern< Is< SaveLayer >, Is< Save >, Is< ClipRect >, Is< SaveLayer >, Is< Restore >, Is< Restore >, 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 216 of file SkRecordOpts.cpp.

Member Typedef Documentation

◆ Match

typedef Pattern<Is<SaveLayer>, Is<Save>, Is<ClipRect>, Is<SaveLayer>, Is<Restore>, Is<Restore>, Is<Restore> > SvgOpacityAndFilterLayerMergePass::Match

Definition at line 218 of file SkRecordOpts.cpp.

Member Function Documentation

◆ KillSaveLayerAndRestore()

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

Definition at line 255 of file SkRecordOpts.cpp.

255 {
256 record->replace<NoOp>(saveLayerIndex); // SaveLayer
257 record->replace<NoOp>(saveLayerIndex + 6); // Restore
258 return true;
259 }
T * replace(int i)
Definition: SkRecord.h:83

◆ onMatch()

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

Definition at line 220 of file SkRecordOpts.cpp.

220 {
221 if (match->first<SaveLayer>()->backdrop) {
222 // can't throw away the layer if we have a backdrop
223 return false;
224 }
225
226 if (!match->first<SaveLayer>()->filters.empty() ||
227 !match->fourth<SaveLayer>()->filters.empty()) {
228 // Our optimizations don't handle the filter list correctly - don't bother trying
229 return false;
230 }
231
232 SkPaint* opacityPaint = match->first<SaveLayer>()->paint;
233 if (nullptr == opacityPaint) {
234 // There wasn't really any point to this SaveLayer at all.
235 return KillSaveLayerAndRestore(record, begin);
236 }
237
238 // This layer typically contains a filter, but this should work for layers with for other
239 // purposes too.
240 SkPaint* filterLayerPaint = match->fourth<SaveLayer>()->paint;
241 if (filterLayerPaint == nullptr) {
242 // We can just give the inner SaveLayer the paint of the outer SaveLayer.
243 // TODO(mtklein): figure out how to do this clearly
244 return false;
245 }
246
247 if (!fold_opacity_layer_color_to_paint(opacityPaint, true /*isSaveLayer*/,
248 filterLayerPaint)) {
249 return false;
250 }
251
252 return KillSaveLayerAndRestore(record, begin);
253 }
static bool fold_opacity_layer_color_to_paint(const SkPaint *layerPaint, bool isSaveLayer, SkPaint *paint)
const Paint & paint
Definition: color_source.cc:38
static const char * begin(const StringSlice &s)
Definition: editor.cpp:252
def match(bench, filt)
Definition: benchmark.py:23
static bool KillSaveLayerAndRestore(SkRecord *record, int saveLayerIndex)

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