Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ deps = {
# and not have to specific specific hashes.

'src/third_party/tonic':
Var('fuchsia_git') + '/tonic' + '@' + '02f9d8dd18dd259e3c5efe1fbe713819a730b6e0',
Var('fuchsia_git') + '/tonic' + '@' + '2919ef4751621fabecb721c153ea9a3b72af995d',

'src/third_party/benchmark':
Var('fuchsia_git') + '/third_party/benchmark' + '@' + '21f1eb3fe269ea43eba862bf6b699cde46587ade',
Expand Down
4 changes: 3 additions & 1 deletion ci/licenses_golden/licenses_third_party
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: cb9e296575fc050579bacb3a1c06c9b5
Signature: b4f8888f322c420b204e79450f0692ae

UNUSED LICENSES:

Expand Down Expand Up @@ -18086,6 +18086,7 @@ FILE: ../../../third_party/tonic/scopes/dart_isolate_scope.cc
FILE: ../../../third_party/tonic/scopes/dart_isolate_scope.h
FILE: ../../../third_party/tonic/typed_data/dart_byte_data.h
FILE: ../../../third_party/tonic/typed_data/int32_list.h
FILE: ../../../third_party/tonic/typed_data/uint16_list.h
FILE: ../../../third_party/tonic/typed_data/uint8_list.h
----------------------------------------------------------------------------------------------------
Copyright 2016 The Fuchsia Authors. All rights reserved.
Expand Down Expand Up @@ -18223,6 +18224,7 @@ FILE: ../../../third_party/tonic/typed_data/float32_list.h
FILE: ../../../third_party/tonic/typed_data/float64_list.cc
FILE: ../../../third_party/tonic/typed_data/float64_list.h
FILE: ../../../third_party/tonic/typed_data/int32_list.cc
FILE: ../../../third_party/tonic/typed_data/uint16_list.cc
FILE: ../../../third_party/tonic/typed_data/uint8_list.cc
----------------------------------------------------------------------------------------------------
Copyright 2015 The Fuchsia Authors. All rights reserved.
Expand Down
16 changes: 9 additions & 7 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2913,20 +2913,21 @@ class Vertices extends NativeFieldWrapperClass2 {
final Int32List encodedColors = colors != null
? _encodeColorList(colors)
: null;
final Int32List encodedIndices = indices != null
? new Int32List.fromList(indices)
final Uint16List encodedIndices = indices != null
? new Uint16List.fromList(indices)
: null;

_constructor();
_init(mode.index, encodedPositions, encodedTextureCoordinates, encodedColors, encodedIndices);
if (!_init(mode.index, encodedPositions, encodedTextureCoordinates, encodedColors, encodedIndices))
throw new ArgumentError('Invalid configuration for vertices.');
}

Vertices.raw(
VertexMode mode,
Float32List positions, {
Float32List textureCoordinates,
Int32List colors,
Int32List indices,
Uint16List indices,
}) : assert(mode != null),
assert(positions != null) {
if (textureCoordinates != null && textureCoordinates.length != positions.length)
Expand All @@ -2937,16 +2938,17 @@ class Vertices extends NativeFieldWrapperClass2 {
throw new ArgumentError('"indices" values must be valid indices in the positions list.');

_constructor();
_init(mode.index, positions, textureCoordinates, colors, indices);
if (!_init(mode.index, positions, textureCoordinates, colors, indices))
throw new ArgumentError('Invalid configuration for vertices.');
}

void _constructor() native 'Vertices_constructor';

void _init(int mode,
bool _init(int mode,
Float32List positions,
Float32List textureCoordinates,
Int32List colors,
Int32List indices) native 'Vertices_init';
Uint16List indices) native 'Vertices_init';
}

/// Defines how a list of points is interpreted when drawing a set of points.
Expand Down
17 changes: 13 additions & 4 deletions lib/ui/painting/vertices.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "flutter/lib/ui/painting/vertices.h"

#include <algorithm>

#include "third_party/tonic/dart_binding_macros.h"
#include "third_party/tonic/dart_library_natives.h"

Expand Down Expand Up @@ -47,11 +49,11 @@ fml::RefPtr<Vertices> Vertices::Create() {
return fml::MakeRefCounted<Vertices>();
}

void Vertices::init(SkVertices::VertexMode vertex_mode,
bool Vertices::init(SkVertices::VertexMode vertex_mode,
const tonic::Float32List& positions,
const tonic::Float32List& texture_coordinates,
const tonic::Int32List& colors,
const tonic::Int32List& indices) {
const tonic::Uint16List& indices) {
uint32_t builderFlags = 0;
if (texture_coordinates.data())
builderFlags |= SkVertices::kHasTexCoords_BuilderFlag;
Expand All @@ -61,6 +63,9 @@ void Vertices::init(SkVertices::VertexMode vertex_mode,
SkVertices::Builder builder(vertex_mode, positions.num_elements() / 2,
indices.num_elements(), builderFlags);

if (!builder.isValid())
return false;

// positions are required for SkVertices::Builder
FML_DCHECK(positions.data());
if (positions.data())
Expand All @@ -77,10 +82,14 @@ void Vertices::init(SkVertices::VertexMode vertex_mode,
DecodeInts<SkColor>(colors, builder.colors());
}

if (indices.data())
DecodeInts<uint16_t>(indices, builder.indices());
if (indices.data()) {
std::copy(indices.data(), indices.data() + indices.num_elements(),
builder.indices());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return false if the data is not present?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indices is an optional argument


vertices_ = builder.detach();

return true;
}

} // namespace flutter
5 changes: 3 additions & 2 deletions lib/ui/painting/vertices.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "third_party/skia/include/core/SkVertices.h"
#include "third_party/tonic/typed_data/float32_list.h"
#include "third_party/tonic/typed_data/int32_list.h"
#include "third_party/tonic/typed_data/uint16_list.h"

namespace tonic {
class DartLibraryNatives;
Expand All @@ -27,11 +28,11 @@ class Vertices : public RefCountedDartWrappable<Vertices> {

static fml::RefPtr<Vertices> Create();

void init(SkVertices::VertexMode vertex_mode,
bool init(SkVertices::VertexMode vertex_mode,
const tonic::Float32List& positions,
const tonic::Float32List& texture_coordinates,
const tonic::Int32List& colors,
const tonic::Int32List& indices);
const tonic::Uint16List& indices);

const sk_sp<SkVertices>& vertices() const { return vertices_; }

Expand Down