Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SkImageFilter_Base::Common Class Reference

#include <SkImageFilter_Base.h>

Public Member Functions

bool unflatten (SkReadBuffer &, int expectedInputs)
 
std::optional< SkRectcropRect () const
 
int inputCount () const
 
sk_sp< SkImageFilter > * inputs ()
 
sk_sp< SkImageFiltergetInput (int index)
 

Detailed Description

Definition at line 147 of file SkImageFilter_Base.h.

Member Function Documentation

◆ cropRect()

std::optional< SkRect > SkImageFilter_Base::Common::cropRect ( ) const
inline

Definition at line 159 of file SkImageFilter_Base.h.

159{ return fCropRect; }

◆ getInput()

sk_sp< SkImageFilter > SkImageFilter_Base::Common::getInput ( int  index)
inline

Definition at line 164 of file SkImageFilter_Base.h.

164{ return fInputs[index]; }

◆ inputCount()

int SkImageFilter_Base::Common::inputCount ( ) const
inline

Definition at line 161 of file SkImageFilter_Base.h.

161{ return fInputs.size(); }
int size() const
Definition SkTArray.h:416

◆ inputs()

sk_sp< SkImageFilter > * SkImageFilter_Base::Common::inputs ( )
inline

Definition at line 162 of file SkImageFilter_Base.h.

162{ return fInputs.begin(); }

◆ unflatten()

bool SkImageFilter_Base::Common::unflatten ( SkReadBuffer buffer,
int  expectedInputs 
)

Attempt to unflatten the expected number of input filters. If any number of input filters is valid, pass -1. If this fails (i.e. corrupt buffer or contents) then return false and common will be left uninitialized. If this returns true, then inputCount() is the number of found input filters, each of which may be NULL or a valid imagefilter.

Definition at line 177 of file SkImageFilter.cpp.

177 {
178 const int count = buffer.readInt();
179 if (!buffer.validate(count >= 0)) {
180 return false;
181 }
182 if (!buffer.validate(expectedCount < 0 || count == expectedCount)) {
183 return false;
184 }
185
186#if defined(SK_BUILD_FOR_FUZZER)
187 if (count > 4) {
188 return false;
189 }
190#endif
191
192 SkASSERT(fInputs.empty());
193 for (int i = 0; i < count; i++) {
194 fInputs.push_back(buffer.readBool() ? buffer.readImageFilter() : nullptr);
195 if (!buffer.isValid()) {
196 return false;
197 }
198 }
199
201 static constexpr uint32_t kHasAll_CropEdge = 0x0F;
202 SkRect rect;
203 buffer.readRect(&rect);
204 if (!buffer.isValid() || !buffer.validate(SkIsValidRect(rect))) {
205 return false;
206 }
207
208 uint32_t flags = buffer.readUInt();
209 if (!buffer.isValid() ||
210 !buffer.validate(flags == 0x0 || flags == kHasAll_CropEdge)) {
211 return false;
212 }
213 if (flags == kHasAll_CropEdge) {
214 fCropRect = rect;
215 }
216 }
217 return buffer.isValid();
218}
int count
#define SkASSERT(cond)
Definition SkAssert.h:116
static bool SkIsValidRect(const SkRect &rect)
bool empty() const
Definition SkTArray.h:194
FlutterSemanticsFlag flags
static const uint8_t buffer[]
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350

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