Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
flutter::DlGradientColorSourceBase Class Referenceabstract

#include <dl_color_source.h>

Inheritance diagram for flutter::DlGradientColorSourceBase:
flutter::DlMatrixColorSourceBase flutter::DlColorSource flutter::DlAttribute< DlColorSource, DlColorSourceType > flutter::DlConicalGradientColorSource flutter::DlLinearGradientColorSource flutter::DlRadialGradientColorSource flutter::DlSweepGradientColorSource

Public Member Functions

bool is_opaque () const override
 
bool isGradient () const override
 If the underlying platform data represents a gradient. More...
 
DlTileMode tile_mode () const
 
int stop_count () const
 
const DlColorcolors () const
 
const float * stops () const
 
- Public Member Functions inherited from flutter::DlMatrixColorSourceBase
const SkMatrixmatrix () const
 
const SkMatrixmatrix_ptr () const
 
- Public Member Functions inherited from flutter::DlColorSource
virtual bool is_opaque () const =0
 
virtual bool isUIThreadSafe () const =0
 If the underlying platform data held by this object is held in a way that it can be stored and potentially released from the UI thread, this method returns true. More...
 
virtual bool isGradient () const
 If the underlying platform data represents a gradient. More...
 
virtual const DlColorColorSourceasColor () const
 
virtual const DlImageColorSourceasImage () const
 
virtual const DlLinearGradientColorSourceasLinearGradient () const
 
virtual const DlRadialGradientColorSourceasRadialGradient () const
 
virtual const DlConicalGradientColorSourceasConicalGradient () const
 
virtual const DlSweepGradientColorSourceasSweepGradient () const
 
virtual const DlRuntimeEffectColorSourceasRuntimeEffect () const
 
- Public Member Functions inherited from flutter::DlAttribute< DlColorSource, DlColorSourceType >
virtual DlColorSourceType type () const=0
 
virtual size_t size () const=0
 
virtual std::shared_ptr< DlColorSourceshared () const=0
 
bool operator== (DlColorSource const &other) const
 
bool operator!= (DlColorSource const &other) const
 
virtual ~DlAttribute ()=default
 

Protected Member Functions

 DlGradientColorSourceBase (uint32_t stop_count, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
 
size_t vector_sizes () const
 
virtual const void * pod () const =0
 
bool base_equals_ (DlGradientColorSourceBase const *other_base) const
 
void store_color_stops (void *pod, const DlColor *color_data, const float *stop_data)
 
- Protected Member Functions inherited from flutter::DlMatrixColorSourceBase
 DlMatrixColorSourceBase (const SkMatrix *matrix)
 
- Protected Member Functions inherited from flutter::DlColorSource
 DlColorSource ()=default
 
- Protected Member Functions inherited from flutter::DlAttribute< DlColorSource, DlColorSourceType >
virtual bool equals_ (DlColorSource const &other) const=0
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::DlColorSource
static std::shared_ptr< DlLinearGradientColorSourceMakeLinear (const SkPoint start_point, const SkPoint end_point, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
 
static std::shared_ptr< DlRadialGradientColorSourceMakeRadial (SkPoint center, SkScalar radius, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
 
static std::shared_ptr< DlConicalGradientColorSourceMakeConical (SkPoint start_center, SkScalar start_radius, SkPoint end_center, SkScalar end_radius, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
 
static std::shared_ptr< DlSweepGradientColorSourceMakeSweep (SkPoint center, SkScalar start, SkScalar end, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
 
static std::shared_ptr< DlRuntimeEffectColorSourceMakeRuntimeEffect (sk_sp< DlRuntimeEffect > runtime_effect, std::vector< std::shared_ptr< DlColorSource > > samplers, std::shared_ptr< std::vector< uint8_t > > uniform_data)
 

Detailed Description

Definition at line 285 of file dl_color_source.h.

Constructor & Destructor Documentation

◆ DlGradientColorSourceBase()

flutter::DlGradientColorSourceBase::DlGradientColorSourceBase ( uint32_t  stop_count,
DlTileMode  tile_mode,
const SkMatrix matrix = nullptr 
)
inlineprotected

Definition at line 312 of file dl_color_source.h.

316 mode_(tile_mode),
317 stop_count_(stop_count) {}
const SkMatrix & matrix() const
DlMatrixColorSourceBase(const SkMatrix *matrix)

Member Function Documentation

◆ base_equals_()

bool flutter::DlGradientColorSourceBase::base_equals_ ( DlGradientColorSourceBase const *  other_base) const
inlineprotected

Definition at line 325 of file dl_color_source.h.

325 {
326 if (mode_ != other_base->mode_ || matrix() != other_base->matrix() ||
327 stop_count_ != other_base->stop_count_) {
328 return false;
329 }
330 static_assert(sizeof(colors()[0]) == 4);
331 static_assert(sizeof(stops()[0]) == 4);
332 int num_bytes = stop_count_ * 4;
333 return (memcmp(colors(), other_base->colors(), num_bytes) == 0 &&
334 memcmp(stops(), other_base->stops(), num_bytes) == 0);
335 }
const DlColor * colors() const

◆ colors()

const DlColor * flutter::DlGradientColorSourceBase::colors ( ) const
inline

Definition at line 304 of file dl_color_source.h.

304 {
305 return reinterpret_cast<const DlColor*>(pod());
306 }
virtual const void * pod() const =0
flutter::DlColor DlColor

◆ is_opaque()

bool flutter::DlGradientColorSourceBase::is_opaque ( ) const
inlineoverridevirtual

Implements flutter::DlColorSource.

Definition at line 287 of file dl_color_source.h.

287 {
288 if (mode_ == DlTileMode::kDecal) {
289 return false;
290 }
291 const DlColor* my_colors = colors();
292 for (uint32_t i = 0; i < stop_count_; i++) {
293 if (my_colors[i].getAlpha() < 255) {
294 return false;
295 }
296 }
297 return true;
298 }

◆ isGradient()

bool flutter::DlGradientColorSourceBase::isGradient ( ) const
inlineoverridevirtual

If the underlying platform data represents a gradient.

        TODO(matanl): Remove this flag when the Skia backend is
        removed, https://github.com/flutter/flutter/issues/112498.
Returns
True if the class represents the output of a gradient.

Reimplemented from flutter::DlColorSource.

Definition at line 300 of file dl_color_source.h.

300{ return true; }

◆ pod()

virtual const void * flutter::DlGradientColorSourceBase::pod ( ) const
protectedpure virtual

◆ stop_count()

int flutter::DlGradientColorSourceBase::stop_count ( ) const
inline

Definition at line 303 of file dl_color_source.h.

303{ return stop_count_; }

◆ stops()

const float * flutter::DlGradientColorSourceBase::stops ( ) const
inline

Definition at line 307 of file dl_color_source.h.

307 {
308 return reinterpret_cast<const float*>(colors() + stop_count());
309 }

◆ store_color_stops()

void flutter::DlGradientColorSourceBase::store_color_stops ( void *  pod,
const DlColor color_data,
const float *  stop_data 
)
inlineprotected

Definition at line 337 of file dl_color_source.h.

339 {
340 DlColor* color_storage = reinterpret_cast<DlColor*>(pod);
341 memcpy(color_storage, color_data, stop_count_ * sizeof(*color_data));
342 float* stop_storage = reinterpret_cast<float*>(color_storage + stop_count_);
343 if (stop_data) {
344 memcpy(stop_storage, stop_data, stop_count_ * sizeof(*stop_data));
345 } else {
346 float div = stop_count_ - 1;
347 if (div <= 0) {
348 div = 1;
349 }
350 for (uint32_t i = 0; i < stop_count_; i++) {
351 stop_storage[i] = i / div;
352 }
353 }
354 }

◆ tile_mode()

DlTileMode flutter::DlGradientColorSourceBase::tile_mode ( ) const
inline

Definition at line 302 of file dl_color_source.h.

302{ return mode_; }

◆ vector_sizes()

size_t flutter::DlGradientColorSourceBase::vector_sizes ( ) const
inlineprotected

Definition at line 319 of file dl_color_source.h.

319 {
320 return stop_count_ * (sizeof(DlColor) + sizeof(float));
321 }

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