forked from firka/flutter
Fix invalid usage of typed data detected via dart_debug=true (flutter/engine#31745)
This commit is contained in:
@@ -55,7 +55,7 @@ void FragmentProgram::init(std::string sksl, bool debugPrintSksl) {
|
||||
|
||||
fml::RefPtr<FragmentShader> FragmentProgram::shader(
|
||||
Dart_Handle shader,
|
||||
const tonic::Float32List& uniforms,
|
||||
tonic::Float32List& uniforms,
|
||||
Dart_Handle samplers) {
|
||||
auto sampler_shaders =
|
||||
tonic::DartConverter<std::vector<ImageShader*>>::FromDart(samplers);
|
||||
@@ -69,6 +69,7 @@ fml::RefPtr<FragmentShader> FragmentProgram::shader(
|
||||
for (size_t i = 0; i < uniform_count; i++) {
|
||||
uniform_floats[i] = uniforms[i];
|
||||
}
|
||||
uniforms.Release();
|
||||
std::vector<sk_sp<SkShader>> sk_samplers(sampler_shaders.size());
|
||||
for (size_t i = 0; i < sampler_shaders.size(); i++) {
|
||||
ImageShader* image_shader = sampler_shaders[i];
|
||||
|
||||
@@ -31,7 +31,7 @@ class FragmentProgram : public RefCountedDartWrappable<FragmentProgram> {
|
||||
void init(std::string sksl, bool debugPrintSksl);
|
||||
|
||||
fml::RefPtr<FragmentShader> shader(Dart_Handle shader,
|
||||
const tonic::Float32List& uniforms,
|
||||
tonic::Float32List& uniforms,
|
||||
Dart_Handle samplers);
|
||||
|
||||
static void RegisterNatives(tonic::DartLibraryNatives* natives);
|
||||
|
||||
@@ -253,16 +253,17 @@ void CanvasPath::addPathWithMatrix(CanvasPath* path,
|
||||
double dy,
|
||||
tonic::Float64List& matrix4) {
|
||||
if (!path) {
|
||||
matrix4.Release();
|
||||
Dart_ThrowException(
|
||||
ToDart("Path.addPathWithMatrix called with non-genuine Path."));
|
||||
return;
|
||||
}
|
||||
|
||||
SkMatrix matrix = ToSkMatrix(matrix4);
|
||||
matrix4.Release();
|
||||
matrix.setTranslateX(matrix.getTranslateX() + dx);
|
||||
matrix.setTranslateY(matrix.getTranslateY() + dy);
|
||||
mutable_path().addPath(path->path(), matrix, SkPath::kAppend_AddPathMode);
|
||||
matrix4.Release();
|
||||
resetVolatility();
|
||||
}
|
||||
|
||||
@@ -281,16 +282,17 @@ void CanvasPath::extendWithPathAndMatrix(CanvasPath* path,
|
||||
double dy,
|
||||
tonic::Float64List& matrix4) {
|
||||
if (!path) {
|
||||
matrix4.Release();
|
||||
Dart_ThrowException(
|
||||
ToDart("Path.addPathWithMatrix called with non-genuine Path."));
|
||||
return;
|
||||
}
|
||||
|
||||
SkMatrix matrix = ToSkMatrix(matrix4);
|
||||
matrix4.Release();
|
||||
matrix.setTranslateX(matrix.getTranslateX() + dx);
|
||||
matrix.setTranslateY(matrix.getTranslateY() + dy);
|
||||
mutable_path().addPath(path->path(), matrix, SkPath::kExtend_AddPathMode);
|
||||
matrix4.Release();
|
||||
resetVolatility();
|
||||
}
|
||||
|
||||
@@ -317,10 +319,11 @@ void CanvasPath::shift(Dart_Handle path_handle, double dx, double dy) {
|
||||
|
||||
void CanvasPath::transform(Dart_Handle path_handle,
|
||||
tonic::Float64List& matrix4) {
|
||||
auto sk_matrix = ToSkMatrix(matrix4);
|
||||
matrix4.Release();
|
||||
fml::RefPtr<CanvasPath> path = CanvasPath::Create(path_handle);
|
||||
auto& other_mutable_path = path->mutable_path();
|
||||
mutable_path().transform(ToSkMatrix(matrix4), &other_mutable_path);
|
||||
matrix4.Release();
|
||||
mutable_path().transform(sk_matrix, &other_mutable_path);
|
||||
}
|
||||
|
||||
tonic::Float32List CanvasPath::getBounds() {
|
||||
|
||||
@@ -45,10 +45,10 @@ void Vertices::RegisterNatives(tonic::DartLibraryNatives* natives) {
|
||||
|
||||
bool 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) {
|
||||
tonic::Float32List& positions,
|
||||
tonic::Float32List& texture_coordinates,
|
||||
tonic::Int32List& colors,
|
||||
tonic::Uint16List& indices) {
|
||||
UIDartState::ThrowIfUIOperationsProhibited();
|
||||
uint32_t builderFlags = 0;
|
||||
if (texture_coordinates.data()) {
|
||||
@@ -76,6 +76,7 @@ bool Vertices::init(Dart_Handle vertices_handle,
|
||||
FML_DCHECK(positions.num_elements() == texture_coordinates.num_elements());
|
||||
DecodePoints(texture_coordinates, builder.texCoords());
|
||||
}
|
||||
|
||||
if (colors.data()) {
|
||||
// SkVertices::Builder assumes equal numbers of elements
|
||||
FML_DCHECK(positions.num_elements() / 2 == colors.num_elements());
|
||||
@@ -87,6 +88,11 @@ bool Vertices::init(Dart_Handle vertices_handle,
|
||||
builder.indices());
|
||||
}
|
||||
|
||||
positions.Release();
|
||||
texture_coordinates.Release();
|
||||
colors.Release();
|
||||
indices.Release();
|
||||
|
||||
auto vertices = fml::MakeRefCounted<Vertices>();
|
||||
vertices->vertices_ = builder.detach();
|
||||
vertices->AssociateWithDartWrapper(vertices_handle);
|
||||
|
||||
@@ -26,10 +26,10 @@ class Vertices : public RefCountedDartWrappable<Vertices> {
|
||||
|
||||
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);
|
||||
tonic::Float32List& positions,
|
||||
tonic::Float32List& texture_coordinates,
|
||||
tonic::Int32List& colors,
|
||||
tonic::Uint16List& indices);
|
||||
|
||||
const sk_sp<SkVertices>& vertices() const { return vertices_; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user