diff --git a/packages/canvas/platforms/android/canvas-release.aar b/packages/canvas/platforms/android/canvas-release.aar index 88495d24..50833423 100644 Binary files a/packages/canvas/platforms/android/canvas-release.aar and b/packages/canvas/platforms/android/canvas-release.aar differ diff --git a/packages/canvas/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp b/packages/canvas/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp index 706f605c..9ea76f19 100644 --- a/packages/canvas/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +++ b/packages/canvas/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp @@ -7,13 +7,55 @@ #include "OneByteStringResource.h" -v8::CFunction CanvasRenderingContext2DImpl::fast_close_path_(v8::CFunction::Make(CanvasRenderingContext2DImpl::FastClosePath)); +v8::CFunction CanvasRenderingContext2DImpl::fast_close_path_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastClosePath)); -v8::CFunction CanvasRenderingContext2DImpl::fast_begin_path_(v8::CFunction::Make(CanvasRenderingContext2DImpl::FastBeginPath)); +v8::CFunction CanvasRenderingContext2DImpl::fast_begin_path_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastBeginPath)); -v8::CFunction CanvasRenderingContext2DImpl::fast_arc_(v8::CFunction::Make(CanvasRenderingContext2DImpl::FastArc)); +v8::CFunction CanvasRenderingContext2DImpl::fast_arc_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastArc)); -//v8::CFunction CanvasRenderingContext2DImpl::fast_fill_(v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFill)); +v8::CFunction CanvasRenderingContext2DImpl::fast_arc_to_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastArcTo)); + + +v8::CFunction CanvasRenderingContext2DImpl::fast_save_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastSave)); + +v8::CFunction CanvasRenderingContext2DImpl::fast_restore_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastRestore)); + + +v8::CFunction CanvasRenderingContext2DImpl::fast_translate_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastTranslate)); + +v8::CFunction CanvasRenderingContext2DImpl::fast_clear_rect_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastClearRect)); + + +v8::CFunction CanvasRenderingContext2DImpl::fast_fill_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFill)); + +v8::CFunction CanvasRenderingContext2DImpl::fast_fill_one_path_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastFillOnePath)); + +const v8::CFunction fast_fill_overloads_[] = { + CanvasRenderingContext2DImpl::fast_fill_, + CanvasRenderingContext2DImpl::fast_fill_one_path_ +}; + + +v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStroke)); + +v8::CFunction CanvasRenderingContext2DImpl::fast_stroke_path_( + v8::CFunction::Make(CanvasRenderingContext2DImpl::FastStrokePath)); + +const v8::CFunction fast_stroke_overloads_[] = { + CanvasRenderingContext2DImpl::fast_stroke_, + CanvasRenderingContext2DImpl::fast_stroke_path_ +}; CanvasRenderingContext2DImpl::CanvasRenderingContext2DImpl( @@ -64,7 +106,6 @@ v8::Local CanvasRenderingContext2DImpl::GetCtor(v8::Isolat } v8::Local ctorTmpl = v8::FunctionTemplate::New(isolate); - ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1); ctorTmpl->SetClassName(ConvertToV8String(isolate, "CanvasRenderingContext2D")); auto tmpl = ctorTmpl->InstanceTemplate(); @@ -124,10 +165,13 @@ v8::Local CanvasRenderingContext2DImpl::GetCtor(v8::Isolat SetFastMethod(isolate, tmpl, "arc", Arc, &fast_arc_, v8::Local()); - tmpl->Set(ConvertToV8String(isolate, "arcTo"), v8::FunctionTemplate::New(isolate, &ArcTo)); + SetFastMethod(isolate, tmpl, "arcTo", ArcTo, &fast_arc_to_, v8::Local()); + + // tmpl->Set(ConvertToV8String(isolate, "arcTo"), v8::FunctionTemplate::New(isolate, &ArcTo)); // tmpl->Set(ConvertToV8String(isolate, "beginPath"), // v8::FunctionTemplate::New(isolate, &BeginPath)); + SetFastMethod(isolate, tmpl, "beginPath", BeginPath, &fast_begin_path_, v8::Local()); @@ -135,8 +179,12 @@ v8::Local CanvasRenderingContext2DImpl::GetCtor(v8::Isolat v8::FunctionTemplate::New(isolate, &BezierCurveTo)); tmpl->Set(ConvertToV8String(isolate, "clearHitRegions"), v8::FunctionTemplate::New(isolate, &ClearHitRegions)); - tmpl->Set(ConvertToV8String(isolate, "clearRect"), - v8::FunctionTemplate::New(isolate, &ClearRect)); +// tmpl->Set(ConvertToV8String(isolate, "clearRect"), +// v8::FunctionTemplate::New(isolate, &ClearRect)); + + SetFastMethod(isolate, tmpl, "clearRect", ClearRect, &fast_clear_rect_, v8::Local()); + + tmpl->Set(ConvertToV8String(isolate, "clip"), v8::FunctionTemplate::New(isolate, &Clip)); // tmpl->Set(ConvertToV8String(isolate, "closePath"), // v8::FunctionTemplate::New(isolate, &ClosePath)); @@ -162,9 +210,10 @@ v8::Local CanvasRenderingContext2DImpl::GetCtor(v8::Isolat tmpl->Set(ConvertToV8String(isolate, "drawImage"), v8::FunctionTemplate::New(isolate, &DrawImage)); tmpl->Set(ConvertToV8String(isolate, "ellipse"), v8::FunctionTemplate::New(isolate, &Ellipse)); - tmpl->Set(ConvertToV8String(isolate, "fill"), v8::FunctionTemplate::New(isolate, &Fill)); + // tmpl->Set(ConvertToV8String(isolate, "fill"), v8::FunctionTemplate::New(isolate, &Fill)); -// SetFastMethod(isolate, tmpl, "fill", Fill, &fast_fill_, v8::Local()); + SetFastMethodWithOverLoads(isolate, tmpl, "fill", Fill, fast_fill_overloads_, + v8::Local()); tmpl->Set(ConvertToV8String(isolate, "fillRect"), v8::FunctionTemplate::New(isolate, &FillRect)); @@ -193,9 +242,17 @@ v8::Local CanvasRenderingContext2DImpl::GetCtor(v8::Isolat v8::FunctionTemplate::New(isolate, &RemoveHitRegion)); tmpl->Set(ConvertToV8String(isolate, "resetTransform"), v8::FunctionTemplate::New(isolate, &ResetTransform)); - tmpl->Set(ConvertToV8String(isolate, "restore"), v8::FunctionTemplate::New(isolate, &Restore)); + + SetFastMethod(isolate, tmpl, "restore", Restore, &fast_restore_, v8::Local()); + + // tmpl->Set(ConvertToV8String(isolate, "restore"), v8::FunctionTemplate::New(isolate, &Restore)); tmpl->Set(ConvertToV8String(isolate, "rotate"), v8::FunctionTemplate::New(isolate, &Rotate)); - tmpl->Set(ConvertToV8String(isolate, "save"), v8::FunctionTemplate::New(isolate, &Save)); + + + SetFastMethod(isolate, tmpl, "save", Save, &fast_save_, v8::Local()); + //tmpl->Set(ConvertToV8String(isolate, "save"), v8::FunctionTemplate::New(isolate, &Save)); + + tmpl->Set(ConvertToV8String(isolate, "scale"), v8::FunctionTemplate::New(isolate, &Scale)); tmpl->Set(ConvertToV8String(isolate, "scrollPathIntoView"), v8::FunctionTemplate::New(isolate, &ScrollPathIntoView)); @@ -203,15 +260,24 @@ v8::Local CanvasRenderingContext2DImpl::GetCtor(v8::Isolat v8::FunctionTemplate::New(isolate, &SetLineDash)); tmpl->Set(ConvertToV8String(isolate, "setTransform"), v8::FunctionTemplate::New(isolate, &SetTransform)); - tmpl->Set(ConvertToV8String(isolate, "stroke"), v8::FunctionTemplate::New(isolate, &Stroke)); + // tmpl->Set(ConvertToV8String(isolate, "stroke"), v8::FunctionTemplate::New(isolate, &Stroke)); + + SetFastMethodWithOverLoads(isolate, tmpl, "stroke", Stroke, fast_stroke_overloads_, + v8::Local()); + + tmpl->Set(ConvertToV8String(isolate, "strokeRect"), v8::FunctionTemplate::New(isolate, &StrokeRect)); tmpl->Set(ConvertToV8String(isolate, "strokeText"), v8::FunctionTemplate::New(isolate, &StrokeText)); tmpl->Set(ConvertToV8String(isolate, "transform"), v8::FunctionTemplate::New(isolate, &Transform)); - tmpl->Set(ConvertToV8String(isolate, "translate"), - v8::FunctionTemplate::New(isolate, &Translate)); + + + SetFastMethod(isolate, tmpl, "translate", Translate, &fast_translate_, v8::Local()); + +// tmpl->Set(ConvertToV8String(isolate, "translate"), +// v8::FunctionTemplate::New(isolate, &Translate)); tmpl->Set(ConvertToV8String(isolate, "__toDataURL"), v8::FunctionTemplate::New(isolate, &__ToDataURL)); diff --git a/packages/canvas/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h b/packages/canvas/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h index cf822192..229898f6 100644 --- a/packages/canvas/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +++ b/packages/canvas/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h @@ -220,7 +220,21 @@ class CanvasRenderingContext2DImpl : ObjectWrapperImpl { static v8::CFunction fast_begin_path_; static v8::CFunction fast_arc_; -// static v8::CFunction fast_fill_; + static v8::CFunction fast_arc_to_; + static v8::CFunction fast_clear_rect_; + + static v8::CFunction fast_fill_; + static v8::CFunction fast_fill_one_path_; + + static v8::CFunction fast_stroke_; + static v8::CFunction fast_stroke_path_; + + + static v8::CFunction fast_restore_; + + static v8::CFunction fast_save_; + + static v8::CFunction fast_translate_; static void AddHitRegion(const v8::FunctionCallbackInfo &args); @@ -268,6 +282,25 @@ class CanvasRenderingContext2DImpl : ObjectWrapperImpl { static void ArcTo(const v8::FunctionCallbackInfo &args); + static void FastArcTo(v8::Local receiver_obj, double x1, + double y1, + double x2, + double y2, + double radius) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + if (ptr == nullptr) { + return; + } + + canvas_native_context_arc_to( + ptr->GetContext(), static_cast(x1), + static_cast(y1), + static_cast(x2), + static_cast(y2), + static_cast(radius) + ); + } + static void BeginPath(const v8::FunctionCallbackInfo &args); static void BeginPathImpl(CanvasRenderingContext2D *receiver_obj) { @@ -289,6 +322,24 @@ class CanvasRenderingContext2DImpl : ObjectWrapperImpl { static void ClearRect(const v8::FunctionCallbackInfo &args); + + static void FastClearRect(v8::Local receiver_obj, double x, double y, double width, + double height) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + if (ptr == nullptr) { + return; + } + + canvas_native_context_clear_rect( + ptr->GetContext(), + static_cast(x), + static_cast(y), + static_cast(width), + static_cast(height) + ); + ptr->UpdateInvalidateState(); + } + static void Clip(const v8::FunctionCallbackInfo &args); static void ClosePath(const v8::FunctionCallbackInfo &args); @@ -330,6 +381,106 @@ class CanvasRenderingContext2DImpl : ObjectWrapperImpl { static void Fill(const v8::FunctionCallbackInfo &args); + /* todo when fast string is supported + static void FastFillTwo(v8::Local receiver_obj, v8::Local path, string) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + if (ptr == nullptr) { + return; + } + + auto object = Path2D::GetPointer(path); + + if (object != nullptr) { + auto data = ConvertFromV8String(isolate, args[1]); + canvas_native_context_fill_with_path( + ptr->GetContext(), + object->GetPath(), + data.c_str()); + ptr->UpdateInvalidateState(); + } + } + + */ + + static void FastFillOnePath(v8::Local receiver_obj, v8::Local path) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + if (ptr == nullptr) { + return; + } + + auto object = Path2D::GetPointer(path); + + std::string rule("nonzero"); + canvas_native_context_fill_with_path( + ptr->GetContext(), + object->GetPath(), rule.c_str()); + ptr->UpdateInvalidateState(); + } + + // todo when fast string is supported + /* + static void FastFillOneString(v8::Local receiver_obj) { + CanvasRenderingContext2DImpl *ptr = GetPointer(args.This()); + if (ptr == nullptr) { + return; + } + auto isolate = args.GetIsolate(); + + auto count = args.Length(); + auto value = args[0]; + if (count == 2) { + auto type = GetNativeType(isolate, value.As()); + if (type == NativeType::Path2D) { + auto object = Path2D::GetPointer(value.As()); + + if (object != nullptr) { + auto data = ConvertFromV8String(isolate, args[1]); + canvas_native_context_fill_with_path( + ptr->GetContext(), + object->GetPath(), + data.c_str()); + ptr->UpdateInvalidateState(); + } + } + + } else if (count == 1) { + if (value->IsString()) { + auto rule = ConvertFromV8String(isolate, value); + canvas_native_context_fill( + ptr->GetContext(), rule.c_str()); + ptr->UpdateInvalidateState(); + } else if (value->IsObject()) { + auto type = GetNativeType(isolate, value.As()); + if (type == NativeType::Path2D) { + auto object = Path2D::GetPointer(value.As()); + + std::string rule("nonzero"); + canvas_native_context_fill_with_path( + ptr->GetContext(), + object->GetPath(), rule.c_str()); + ptr->UpdateInvalidateState(); + } + } + } else { + std::string rule("nonzero"); + canvas_native_context_fill( + ptr->GetContext(), rule.c_str()); + ptr->UpdateInvalidateState(); + } + } +*/ + static void FastFill(v8::Local receiver_obj) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + if (ptr == nullptr) { + return; + } + + std::string rule("nonzero"); + canvas_native_context_fill( + ptr->GetContext(), rule.c_str()); + ptr->UpdateInvalidateState(); + } + static void FillRect(const v8::FunctionCallbackInfo &args); static void FillText(const v8::FunctionCallbackInfo &args); @@ -362,10 +513,30 @@ class CanvasRenderingContext2DImpl : ObjectWrapperImpl { static void Restore(const v8::FunctionCallbackInfo &args); + static void FastRestore(v8::Local receiver_obj) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + if (ptr == nullptr) { + return; + } + + canvas_native_context_restore( + ptr->GetContext()); + } + static void Rotate(const v8::FunctionCallbackInfo &args); static void Save(const v8::FunctionCallbackInfo &args); + static void FastSave(v8::Local receiver_obj) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + if (ptr == nullptr) { + return; + } + + canvas_native_context_save( + ptr->GetContext()); + } + static void Scale(const v8::FunctionCallbackInfo &args); static void ScrollPathIntoView(const v8::FunctionCallbackInfo &args); @@ -376,6 +547,26 @@ class CanvasRenderingContext2DImpl : ObjectWrapperImpl { static void Stroke(const v8::FunctionCallbackInfo &args); + static void FastStroke(v8::Local receiver_obj) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + + canvas_native_context_stroke( + ptr->GetContext()); + ptr->UpdateInvalidateState(); + } + + static void FastStrokePath(v8::Local receiver_obj, v8::Local path_obj) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + + auto path = Path2D::GetPointer(path_obj); + if (path != nullptr) { + canvas_native_context_stroke_with_path( + ptr->GetContext(), + path->GetPath()); + ptr->UpdateInvalidateState(); + } + } + static void StrokeRect(const v8::FunctionCallbackInfo &args); static void StrokeText(const v8::FunctionCallbackInfo &args); @@ -384,6 +575,13 @@ class CanvasRenderingContext2DImpl : ObjectWrapperImpl { static void Translate(const v8::FunctionCallbackInfo &args); + static void FastTranslate(v8::Local receiver_obj, double x, double y) { + CanvasRenderingContext2DImpl *ptr = GetPointer(receiver_obj); + canvas_native_context_translate( + ptr->GetContext(), x, y); + } + + static void __ToDataURL(const v8::FunctionCallbackInfo &args); ~CanvasRenderingContext2DImpl(); diff --git a/packages/canvas/platforms/ios/src/cpp/canvas2d/Path2D.cpp b/packages/canvas/platforms/ios/src/cpp/canvas2d/Path2D.cpp index 62ba483b..bf9cc18c 100644 --- a/packages/canvas/platforms/ios/src/cpp/canvas2d/Path2D.cpp +++ b/packages/canvas/platforms/ios/src/cpp/canvas2d/Path2D.cpp @@ -53,6 +53,20 @@ v8::CFunction Path2D::fast_rect_(v8::CFunction::Make(Path2D::FastRect)); //v8::CFunction Path2D::fast_round_rect_(v8::CFunction::Make(Path2D::FastRoundRect)); + +v8::CFunction Path2D::fast_round_rect_( + v8::CFunction::Make(Path2D::FastRoundRect)); + +v8::CFunction Path2D::fast_round_rect_array_( + v8::CFunction::Make(Path2D::FastRoundRectArray)); + +const v8::CFunction fast_round_rect_overloads_[] = { + Path2D::fast_round_rect_, + Path2D::fast_round_rect_array_ +}; + + + //v8::CFunction Path2D::fast_to_svg_(v8::CFunction::Make(Path2D::FastToSVG)); void Path2D::Ctor(const v8::FunctionCallbackInfo &args) { @@ -410,14 +424,6 @@ v8::Local Path2D::GetCtor(v8::Isolate *isolate) { tmpl->SetInternalFieldCount(1); -// tmpl->Set( -// ConvertToV8String(isolate, "addPath"), -// v8::FunctionTemplate::New(isolate, &AddPath)); - -// tmpl->Set( -// ConvertToV8String(isolate, "arc"), -// v8::FunctionTemplate::New(isolate, &Arc)); - tmpl->Set( ConvertToV8String(isolate, "arcTo"), v8::FunctionTemplate::New(isolate, &ArcTo)); @@ -434,8 +440,16 @@ v8::Local Path2D::GetCtor(v8::Isolate *isolate) { SetFastMethod(isolate, tmpl, "quadraticCurveTo", QuadraticCurveTo, &fast_quadratic_curve_to_, v8::Local()); SetFastMethod(isolate, tmpl, "rect", Rect, &fast_rect_, v8::Local()); -// SetFastMethod(isolate, tmpl, "roundRect", RoundRect, &fast_round_rect_, v8::Local()); -// SetFastMethod(isolate, tmpl, "__toSVG", __toSVG, &fast_to_svg_, v8::Local()); + SetFastMethodWithOverLoads(isolate, tmpl, "roundRect", RoundRect, + fast_round_rect_overloads_, v8::Local()); + + // tmpl->Set( +// ConvertToV8String(isolate, "addPath"), +// v8::FunctionTemplate::New(isolate, &AddPath)); + +// tmpl->Set( +// ConvertToV8String(isolate, "arc"), +// v8::FunctionTemplate::New(isolate, &Arc)); // tmpl->Set( @@ -470,9 +484,9 @@ v8::Local Path2D::GetCtor(v8::Isolate *isolate) { // ConvertToV8String(isolate, "rect"), // v8::FunctionTemplate::New(isolate, &Rect)); - tmpl->Set( - ConvertToV8String(isolate, "roundRect"), - v8::FunctionTemplate::New(isolate, &RoundRect)); +// tmpl->Set( +// ConvertToV8String(isolate, "roundRect"), +// v8::FunctionTemplate::New(isolate, &RoundRect)); tmpl->Set( ConvertToV8String(isolate, "__toSVG"), diff --git a/packages/canvas/platforms/ios/src/cpp/canvas2d/Path2D.h b/packages/canvas/platforms/ios/src/cpp/canvas2d/Path2D.h index 991d66c3..6182535f 100644 --- a/packages/canvas/platforms/ios/src/cpp/canvas2d/Path2D.h +++ b/packages/canvas/platforms/ios/src/cpp/canvas2d/Path2D.h @@ -61,6 +61,7 @@ class Path2D : ObjectWrapperImpl { static v8::CFunction fast_quadratic_curve_to_; static v8::CFunction fast_rect_; static v8::CFunction fast_round_rect_; + static v8::CFunction fast_round_rect_array_; // static v8::CFunction fast_to_svg_; // todo after v8 upgrade @@ -307,7 +308,8 @@ class Path2D : ObjectWrapperImpl { ); } - static void FastRect(v8::Local receiver_obj, double x, double y, double width, double height) { + static void + FastRect(v8::Local receiver_obj, double x, double y, double width, double height) { Path2D *ptr = GetPointer(receiver_obj); if (ptr == nullptr) { return; @@ -323,115 +325,49 @@ class Path2D : ObjectWrapperImpl { } -/* - static void RoundRectImpl(Path *receiver_obj,v8::CTypeInfo()) { - Path2D *ptr = GetPointer(args.This()); + static void FastRoundRect(v8::Local receiver_obj, double x, double y, double width, + double height, double radii) { + Path2D *ptr = GetPointer(receiver_obj); if (ptr == nullptr) { return; } - auto isolate = args.GetIsolate(); - auto context = isolate->GetCurrentContext(); - - - if (args.Length() == 5) { - auto x = static_cast(args[0]->NumberValue(context).ToChecked()); - auto y = static_cast(args[1]->NumberValue(context).ToChecked()); - auto width = static_cast(args[2]->NumberValue(context).ToChecked()); - auto height = static_cast(args[3]->NumberValue(context).ToChecked()); - auto objectOrNumber = args[4]; - if (objectOrNumber->IsObject()) { - auto radii = objectOrNumber.As(); - if (radii->IsArray()) { - auto array = radii.As(); - auto size = array->Length(); - - if (size > 1) { - std::vector store; - store.reserve(size); - for (int i = 0; - i < size; i++) { - store[i] = (float) array->Get(context, i).ToLocalChecked()->NumberValue( - context).ToChecked(); - } - - canvas_native_path_round_rect( - ptr->GetPath(), - x, y, - width, - height, store.data(), - store.size()); - - } - } - } else { - auto radii = (float) objectOrNumber->NumberValue(context).ToChecked(); - canvas_native_path_round_rect_tl_tr_br_bl( - ptr->GetPath(), x, y, - width, - height, radii, radii, - radii, radii); - - } - } + canvas_native_path_round_rect_tl_tr_br_bl( + ptr->GetPath(), static_cast(x), static_cast(y), + static_cast(width), + static_cast(height), static_cast(radii), static_cast(radii), + static_cast(radii), static_cast(radii)); - args.GetReturnValue().SetUndefined(); } - static void RoundRectImpl2(Path *receiver_obj) { - Path2D *ptr = GetPointer(args.This()); + static void + FastRoundRectArray(v8::Local receiver_obj, double x, double y, double width, + double height, v8::Local value) { + Path2D *ptr = GetPointer(receiver_obj); if (ptr == nullptr) { return; } - auto isolate = args.GetIsolate(); - auto context = isolate->GetCurrentContext(); - - - if (args.Length() == 5) { - auto x = static_cast(args[0]->NumberValue(context).ToChecked()); - auto y = static_cast(args[1]->NumberValue(context).ToChecked()); - auto width = static_cast(args[2]->NumberValue(context).ToChecked()); - auto height = static_cast(args[3]->NumberValue(context).ToChecked()); - auto objectOrNumber = args[4]; - if (objectOrNumber->IsObject()) { - auto radii = objectOrNumber.As(); - if (radii->IsArray()) { - auto array = radii.As(); - auto size = array->Length(); - - if (size > 1) { - std::vector store; - store.reserve(size); - for (int i = 0; - i < size; i++) { - store[i] = (float) array->Get(context, i).ToLocalChecked()->NumberValue( - context).ToChecked(); - } - - canvas_native_path_round_rect( - ptr->GetPath(), - x, y, - width, - height, store.data(), - store.size()); - - } - } - } else { - auto radii = (float) objectOrNumber->NumberValue(context).ToChecked(); - canvas_native_path_round_rect_tl_tr_br_bl( - ptr->GetPath(), x, y, + auto len = value->Length(); + std::vector buf; + buf.reserve(len); + + auto copied = v8::TryToCopyAndConvertArrayToCppBuffer::Build().GetId(), float>( + value, nullptr, len); + + if (copied) { + if (len > 1) { + + canvas_native_path_round_rect( + ptr->GetPath(), + x, y, width, - height, radii, radii, - radii, radii); + height, buf.data(), + buf.size()); } } - - args.GetReturnValue().SetUndefined(); } -*/ /* diff --git a/packages/canvas/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h b/packages/canvas/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h index 85f728db..38f8390a 100644 --- a/packages/canvas/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +++ b/packages/canvas/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h @@ -110,7 +110,6 @@ class WebGLRenderingContext : public WebGLRenderingContextBase { static v8::CFunction fast_uniform_4fv_array_; - static v8::Local NewInstance(v8::Isolate *isolate, WebGLRenderingContext *renderingContext) { auto context = isolate->GetCurrentContext(); @@ -492,7 +491,6 @@ class WebGLRenderingContext : public WebGLRenderingContextBase { static void Uniform1fv(const v8::FunctionCallbackInfo &args); - static void FastUniform1fv(v8::Local receiver_obj, v8::Local location_obj, const v8::FastApiTypedArray &value) { @@ -543,8 +541,6 @@ class WebGLRenderingContext : public WebGLRenderingContextBase { } - - static void Uniform1i(const v8::FunctionCallbackInfo &args); @@ -690,10 +686,6 @@ class WebGLRenderingContext : public WebGLRenderingContextBase { } - - - - static void Uniform3i(const v8::FunctionCallbackInfo &args); static void Uniform4f(const v8::FunctionCallbackInfo &args); @@ -742,11 +734,14 @@ class WebGLRenderingContext : public WebGLRenderingContextBase { auto copied = v8::TryToCopyAndConvertArrayToCppBuffer::Build().GetId(), float>( value, nullptr, len); - canvas_native_webgl_uniform4fv( - location->GetUniformLocation(), - buf.data(), - buf.size(), - ptr->GetState()); + if (copied) { + canvas_native_webgl_uniform4fv( + location->GetUniformLocation(), + buf.data(), + buf.size(), + ptr->GetState()); + } + } } @@ -813,10 +808,6 @@ class WebGLRenderingContext : public WebGLRenderingContextBase { } - - - - static void UniformMatrix3fv(const v8::FunctionCallbackInfo &args); @@ -877,11 +868,6 @@ class WebGLRenderingContext : public WebGLRenderingContextBase { } - - - - - static void UniformMatrix4fv(const v8::FunctionCallbackInfo &args); static void diff --git a/tools/demo/canvas/index.ts b/tools/demo/canvas/index.ts index 450cca48..4444a1bb 100644 --- a/tools/demo/canvas/index.ts +++ b/tools/demo/canvas/index.ts @@ -629,7 +629,7 @@ export class DemoSharedCanvas extends DemoSharedBase { //arcToAnimation(this.canvas); // ellipse(this.canvas); //fillPath(this.canvas); - //flappyBird(this.canvas); + // flappyBird(this.canvas); //imageBlock(this.canvas); //scale(this.canvas); //pattern(this.canvas); @@ -644,7 +644,7 @@ export class DemoSharedCanvas extends DemoSharedBase { // ctx.fillRect(0,0,400,400) //ellipse(this.canvas); //this.drawPatternWithCanvas(this.canvas); - //this.clock(this.canvas); + this.clock(this.canvas); //this.solar(this.canvas); //console.log('ready ??'); //this.coloredParticles(this.canvas); @@ -680,7 +680,7 @@ export class DemoSharedCanvas extends DemoSharedBase { // setTimeout(() => { //draw_instanced(this.canvas); //draw_image_space(this.canvas); - fog(this.canvas); + //fog(this.canvas); //environmentMap(this.canvas); //cubeRotationRotation(this.canvas); //main(this.canvas); @@ -1742,12 +1742,13 @@ export class DemoSharedCanvas extends DemoSharedBase { clock(canvas) { let scale = false; var ctx = canvas.getContext('2d'); - ctx.scale(3, 3); + ctx.scale(.1, .1); + ctx.translate(100, 100); function clock() { var now = new Date(); ctx.save(); - ctx.clearRect(0, 0, 150, 150); + ctx.clearRect(100, 100, 150, 150); ctx.translate(75, 75); ctx.scale(0.4, 0.4); ctx.rotate(-Math.PI / 2);