Flutter Engine
flutter::CanvasGradient Class Reference

#include <gradient.h>

Inheritance diagram for flutter::CanvasGradient:
flutter::Shader flutter::RefCountedDartWrappable< Shader > fml::RefCountedThreadSafe< Shader > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 ~CanvasGradient () override
 
void initLinear (const tonic::Float32List &end_points, const tonic::Int32List &colors, const tonic::Float32List &color_stops, SkTileMode tile_mode, const tonic::Float64List &matrix4)
 
void initRadial (double center_x, double center_y, double radius, const tonic::Int32List &colors, const tonic::Float32List &color_stops, SkTileMode tile_mode, const tonic::Float64List &matrix4)
 
void initSweep (double center_x, double center_y, const tonic::Int32List &colors, const tonic::Float32List &color_stops, SkTileMode tile_mode, double start_angle, double end_angle, const tonic::Float64List &matrix4)
 
void initTwoPointConical (double start_x, double start_y, double start_radius, double end_x, double end_y, double end_radius, const tonic::Int32List &colors, const tonic::Float32List &color_stops, SkTileMode tile_mode, const tonic::Float64List &matrix4)
 
- Public Member Functions inherited from flutter::Shader
 ~Shader () override
 
sk_sp< SkShader > shader ()
 
void set_shader (flutter::SkiaGPUObject< SkShader > shader)
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Shader >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< Shader >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
virtual size_t GetAllocationSize () const
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Static Public Member Functions

static fml::RefPtr< CanvasGradientCreate ()
 
static void RegisterNatives (tonic::DartLibraryNatives *natives)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex,
  kWrapperInfoIndex,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from flutter::Shader
 Shader (flutter::SkiaGPUObject< SkShader > shader={})
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< Shader >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 23 of file gradient.h.

Constructor & Destructor Documentation

◆ ~CanvasGradient()

flutter::CanvasGradient::~CanvasGradient ( )
overridedefault

Referenced by initTwoPointConical().

Member Function Documentation

◆ Create()

fml::RefPtr< CanvasGradient > flutter::CanvasGradient::Create ( )
static

Definition at line 37 of file gradient.cc.

Referenced by flutter::Gradient_constructor().

37  {
38  return fml::MakeRefCounted<CanvasGradient>();
39 }

◆ initLinear()

void flutter::CanvasGradient::initLinear ( const tonic::Float32List &  end_points,
const tonic::Int32List &  colors,
const tonic::Float32List &  color_stops,
SkTileMode  tile_mode,
const tonic::Float64List &  matrix4 
)

Definition at line 41 of file gradient.cc.

References flutter::UIDartState::CreateGPUObject(), FML_DCHECK, flutter::Shader::set_shader(), and flutter::ToSkMatrix().

45  {
46  FML_DCHECK(end_points.num_elements() == 4);
47  FML_DCHECK(colors.num_elements() == color_stops.num_elements() ||
48  color_stops.data() == nullptr);
49 
50  static_assert(sizeof(SkPoint) == sizeof(float) * 2,
51  "SkPoint doesn't use floats.");
52  static_assert(sizeof(SkColor) == sizeof(int32_t),
53  "SkColor doesn't use int32_t.");
54 
55  SkMatrix sk_matrix;
56  bool has_matrix = matrix4.data() != nullptr;
57  if (has_matrix) {
58  sk_matrix = ToSkMatrix(matrix4);
59  }
60 
61  set_shader(UIDartState::CreateGPUObject(SkGradientShader::MakeLinear(
62  reinterpret_cast<const SkPoint*>(end_points.data()),
63  reinterpret_cast<const SkColor*>(colors.data()), color_stops.data(),
64  colors.num_elements(), tile_mode, 0, has_matrix ? &sk_matrix : nullptr)));
65 }
#define FML_DCHECK(condition)
Definition: logging.h:86
void set_shader(flutter::SkiaGPUObject< SkShader > shader)
Definition: shader.h:24
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20
static flutter::SkiaGPUObject< T > CreateGPUObject(sk_sp< T > object)
Definition: ui_dart_state.h:78

◆ initRadial()

void flutter::CanvasGradient::initRadial ( double  center_x,
double  center_y,
double  radius,
const tonic::Int32List &  colors,
const tonic::Float32List &  color_stops,
SkTileMode  tile_mode,
const tonic::Float64List &  matrix4 
)

Definition at line 67 of file gradient.cc.

References flutter::UIDartState::CreateGPUObject(), FML_DCHECK, flutter::Shader::set_shader(), and flutter::ToSkMatrix().

73  {
74  FML_DCHECK(colors.num_elements() == color_stops.num_elements() ||
75  color_stops.data() == nullptr);
76 
77  static_assert(sizeof(SkColor) == sizeof(int32_t),
78  "SkColor doesn't use int32_t.");
79 
80  SkMatrix sk_matrix;
81  bool has_matrix = matrix4.data() != nullptr;
82  if (has_matrix) {
83  sk_matrix = ToSkMatrix(matrix4);
84  }
85 
86  set_shader(UIDartState::CreateGPUObject(SkGradientShader::MakeRadial(
87  SkPoint::Make(center_x, center_y), radius,
88  reinterpret_cast<const SkColor*>(colors.data()), color_stops.data(),
89  colors.num_elements(), tile_mode, 0, has_matrix ? &sk_matrix : nullptr)));
90 }
#define FML_DCHECK(condition)
Definition: logging.h:86
void set_shader(flutter::SkiaGPUObject< SkShader > shader)
Definition: shader.h:24
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20
static flutter::SkiaGPUObject< T > CreateGPUObject(sk_sp< T > object)
Definition: ui_dart_state.h:78

◆ initSweep()

void flutter::CanvasGradient::initSweep ( double  center_x,
double  center_y,
const tonic::Int32List &  colors,
const tonic::Float32List &  color_stops,
SkTileMode  tile_mode,
double  start_angle,
double  end_angle,
const tonic::Float64List &  matrix4 
)

Definition at line 92 of file gradient.cc.

References flutter::UIDartState::CreateGPUObject(), FML_DCHECK, flutter::Shader::set_shader(), and flutter::ToSkMatrix().

99  {
100  FML_DCHECK(colors.num_elements() == color_stops.num_elements() ||
101  color_stops.data() == nullptr);
102 
103  static_assert(sizeof(SkColor) == sizeof(int32_t),
104  "SkColor doesn't use int32_t.");
105 
106  SkMatrix sk_matrix;
107  bool has_matrix = matrix4.data() != nullptr;
108  if (has_matrix) {
109  sk_matrix = ToSkMatrix(matrix4);
110  }
111 
112  set_shader(UIDartState::CreateGPUObject(SkGradientShader::MakeSweep(
113  center_x, center_y, reinterpret_cast<const SkColor*>(colors.data()),
114  color_stops.data(), colors.num_elements(), tile_mode,
115  start_angle * 180.0 / M_PI, end_angle * 180.0 / M_PI, 0,
116  has_matrix ? &sk_matrix : nullptr)));
117 }
#define FML_DCHECK(condition)
Definition: logging.h:86
void set_shader(flutter::SkiaGPUObject< SkShader > shader)
Definition: shader.h:24
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20
static flutter::SkiaGPUObject< T > CreateGPUObject(sk_sp< T > object)
Definition: ui_dart_state.h:78

◆ initTwoPointConical()

void flutter::CanvasGradient::initTwoPointConical ( double  start_x,
double  start_y,
double  start_radius,
double  end_x,
double  end_y,
double  end_radius,
const tonic::Int32List &  colors,
const tonic::Float32List &  color_stops,
SkTileMode  tile_mode,
const tonic::Float64List &  matrix4 
)

Definition at line 119 of file gradient.cc.

References flutter::UIDartState::CreateGPUObject(), FML_DCHECK, flutter::Shader::set_shader(), flutter::ToSkMatrix(), and ~CanvasGradient().

128  {
129  FML_DCHECK(colors.num_elements() == color_stops.num_elements() ||
130  color_stops.data() == nullptr);
131 
132  static_assert(sizeof(SkColor) == sizeof(int32_t),
133  "SkColor doesn't use int32_t.");
134 
135  SkMatrix sk_matrix;
136  bool has_matrix = matrix4.data() != nullptr;
137  if (has_matrix) {
138  sk_matrix = ToSkMatrix(matrix4);
139  }
140 
141  set_shader(UIDartState::CreateGPUObject(SkGradientShader::MakeTwoPointConical(
142  SkPoint::Make(start_x, start_y), start_radius,
143  SkPoint::Make(end_x, end_y), end_radius,
144  reinterpret_cast<const SkColor*>(colors.data()), color_stops.data(),
145  colors.num_elements(), tile_mode, 0, has_matrix ? &sk_matrix : nullptr)));
146 }
#define FML_DCHECK(condition)
Definition: logging.h:86
void set_shader(flutter::SkiaGPUObject< SkShader > shader)
Definition: shader.h:24
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20
static flutter::SkiaGPUObject< T > CreateGPUObject(sk_sp< T > object)
Definition: ui_dart_state.h:78

◆ RegisterNatives()

void flutter::CanvasGradient::RegisterNatives ( tonic::DartLibraryNatives natives)
static

Definition at line 32 of file gradient.cc.

References DART_REGISTER_NATIVE, FOR_EACH_BINDING, and flutter::Gradient_constructor().

Referenced by flutter::DartUI::InitForGlobal().

32  {
33  natives->Register({{"Gradient_constructor", Gradient_constructor, 1, true},
35 }
static void Gradient_constructor(Dart_NativeArguments args)
Definition: gradient.cc:17
void Register(std::initializer_list< Entry > entries)
#define FOR_EACH_BINDING(V)
Definition: gradient.cc:24
#define DART_REGISTER_NATIVE(CLASS, METHOD)

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