Flutter Engine
flutter::Vertices Class Reference

#include <vertices.h>

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

Public Member Functions

 ~Vertices () override
 
const sk_sp< SkVertices > & vertices () const
 
size_t GetAllocationSize () const override
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Vertices >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< Vertices >
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
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Static Public Member Functions

static void RegisterNatives (tonic::DartLibraryNatives *natives)
 
static bool init (Dart_Handle vertices_handle, SkVertices::VertexMode vertex_mode, const tonic::Float32List &positions, const tonic::Float32List &texture_coordinates, const tonic::Int32List &colors, const tonic::Uint16List &indices)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex,
  kWrapperInfoIndex,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< Vertices >
 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 18 of file vertices.h.

Constructor & Destructor Documentation

◆ ~Vertices()

flutter::Vertices::~Vertices ( )
override

Definition at line 40 of file vertices.cc.

40 {}

Member Function Documentation

◆ GetAllocationSize()

size_t flutter::Vertices::GetAllocationSize ( ) const
overridevirtual

Reimplemented from tonic::DartWrappable.

Definition at line 97 of file vertices.cc.

Referenced by flutter::testing::TEST_F().

97  {
98  return sizeof(Vertices) + vertices_->approximateSize();
99 }

◆ init()

bool flutter::Vertices::init ( Dart_Handle  vertices_handle,
SkVertices::VertexMode  vertex_mode,
const tonic::Float32List &  positions,
const tonic::Float32List &  texture_coordinates,
const tonic::Int32List &  colors,
const tonic::Uint16List &  indices 
)
static

Definition at line 46 of file vertices.cc.

References FML_DCHECK, flutter::UIDartState::ThrowIfUIOperationsProhibited(), and vertices().

51  {
53  uint32_t builderFlags = 0;
54  if (texture_coordinates.data()) {
55  builderFlags |= SkVertices::kHasTexCoords_BuilderFlag;
56  }
57  if (colors.data()) {
58  builderFlags |= SkVertices::kHasColors_BuilderFlag;
59  }
60 
61  SkVertices::Builder builder(vertex_mode, positions.num_elements() / 2,
62  indices.num_elements(), builderFlags);
63 
64  if (!builder.isValid()) {
65  return false;
66  }
67 
68  // positions are required for SkVertices::Builder
69  FML_DCHECK(positions.data());
70  if (positions.data()) {
71  DecodePoints(positions, builder.positions());
72  }
73 
74  if (texture_coordinates.data()) {
75  // SkVertices::Builder assumes equal numbers of elements
76  FML_DCHECK(positions.num_elements() == texture_coordinates.num_elements());
77  DecodePoints(texture_coordinates, builder.texCoords());
78  }
79  if (colors.data()) {
80  // SkVertices::Builder assumes equal numbers of elements
81  FML_DCHECK(positions.num_elements() / 2 == colors.num_elements());
82  DecodeInts<SkColor>(colors, builder.colors());
83  }
84 
85  if (indices.data()) {
86  std::copy(indices.data(), indices.data() + indices.num_elements(),
87  builder.indices());
88  }
89 
90  auto vertices = fml::MakeRefCounted<Vertices>();
91  vertices->vertices_ = builder.detach();
92  vertices->AssociateWithDartWrapper(vertices_handle);
93 
94  return true;
95 }
#define FML_DCHECK(condition)
Definition: logging.h:86
const sk_sp< SkVertices > & vertices() const
Definition: vertices.h:34
static void ThrowIfUIOperationsProhibited()

◆ RegisterNatives()

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

Definition at line 42 of file vertices.cc.

References DART_REGISTER_NATIVE, FOR_EACH_BINDING, and tonic::DartLibraryNatives::Register().

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

42  {
44 }
#define FOR_EACH_BINDING(V)
Definition: vertices.cc:34
void Register(std::initializer_list< Entry > entries)
#define DART_REGISTER_NATIVE(CLASS, METHOD)

◆ vertices()

const sk_sp<SkVertices>& flutter::Vertices::vertices ( ) const
inline

Definition at line 34 of file vertices.h.

Referenced by flutter::Canvas::drawVertices(), and init().

34 { return vertices_; }

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