@nativescript/canvas 2.0.0-alpha.24 → 2.0.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +19 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +19 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +2 -2
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +13 -62
- package/platforms/ios/src/cpp/ImageBitmapImpl.h +15 -3
- package/platforms/ios/src/cpp/OneByteStringResource.cpp +26 -2
- package/platforms/ios/src/cpp/OneByteStringResource.h +14 -3
- package/platforms/ios/src/cpp/TextDecoderImpl.cpp +8 -9
- package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +257 -268
- package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +8 -2
- package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +1 -1
- package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +72 -94
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.cpp +2 -2
- package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +4 -3
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.cpp +1 -5
- package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +5 -5
- package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +103 -113
package/package.json
CHANGED
|
Binary file
|
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<key>DebugSymbolsPath</key>
|
|
9
9
|
<string>dSYMs</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>CanvasNative.framework</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
+
<string>x86_64</string>
|
|
17
18
|
</array>
|
|
18
19
|
<key>SupportedPlatform</key>
|
|
19
20
|
<string>ios</string>
|
|
21
|
+
<key>SupportedPlatformVariant</key>
|
|
22
|
+
<string>simulator</string>
|
|
20
23
|
</dict>
|
|
21
24
|
<dict>
|
|
22
25
|
<key>DebugSymbolsPath</key>
|
|
23
26
|
<string>dSYMs</string>
|
|
24
27
|
<key>LibraryIdentifier</key>
|
|
25
|
-
<string>ios-
|
|
28
|
+
<string>ios-arm64</string>
|
|
26
29
|
<key>LibraryPath</key>
|
|
27
30
|
<string>CanvasNative.framework</string>
|
|
28
31
|
<key>SupportedArchitectures</key>
|
|
29
32
|
<array>
|
|
30
33
|
<string>arm64</string>
|
|
31
|
-
<string>x86_64</string>
|
|
32
34
|
</array>
|
|
33
35
|
<key>SupportedPlatform</key>
|
|
34
36
|
<string>ios</string>
|
|
35
|
-
<key>SupportedPlatformVariant</key>
|
|
36
|
-
<string>simulator</string>
|
|
37
37
|
</dict>
|
|
38
38
|
</array>
|
|
39
39
|
<key>CFBundlePackageType</key>
|
package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative
CHANGED
|
Binary file
|
|
@@ -89,6 +89,8 @@ typedef enum WebGLResultType {
|
|
|
89
89
|
|
|
90
90
|
typedef struct ANGLE_instanced_arrays ANGLE_instanced_arrays;
|
|
91
91
|
|
|
92
|
+
typedef struct CCow CCow;
|
|
93
|
+
|
|
92
94
|
typedef struct CanvasRenderingContext2D CanvasRenderingContext2D;
|
|
93
95
|
|
|
94
96
|
typedef struct ContextAttributes ContextAttributes;
|
|
@@ -1099,6 +1101,23 @@ const char *canvas_native_text_decoder_decode(const struct TextDecoder *decoder,
|
|
|
1099
1101
|
const uint8_t *data,
|
|
1100
1102
|
uintptr_t size);
|
|
1101
1103
|
|
|
1104
|
+
void canvas_native_ccow_destroy(struct CCow *cow);
|
|
1105
|
+
|
|
1106
|
+
const uint8_t *canvas_native_ccow_get_bytes(const struct CCow *cow);
|
|
1107
|
+
|
|
1108
|
+
uintptr_t canvas_native_ccow_get_length(const struct CCow *cow);
|
|
1109
|
+
|
|
1110
|
+
struct CCow *canvas_native_text_decoder_decode_as_cow(const struct TextDecoder *decoder,
|
|
1111
|
+
const uint8_t *data,
|
|
1112
|
+
uintptr_t size);
|
|
1113
|
+
|
|
1114
|
+
struct U8Buffer *canvas_native_text_decoder_decode_as_bytes(const struct TextDecoder *decoder,
|
|
1115
|
+
const uint8_t *data,
|
|
1116
|
+
uintptr_t size);
|
|
1117
|
+
|
|
1118
|
+
const char *canvas_native_text_decoder_decode_c_string(const struct TextDecoder *decoder,
|
|
1119
|
+
const int8_t *data);
|
|
1120
|
+
|
|
1102
1121
|
const char *canvas_native_text_decoder_get_encoding(const struct TextDecoder *decoder);
|
|
1103
1122
|
|
|
1104
1123
|
struct TextEncoder *canvas_native_text_encoder_create(const char *encoding);
|
|
Binary file
|
|
Binary file
|
|
@@ -89,6 +89,8 @@ typedef enum WebGLResultType {
|
|
|
89
89
|
|
|
90
90
|
typedef struct ANGLE_instanced_arrays ANGLE_instanced_arrays;
|
|
91
91
|
|
|
92
|
+
typedef struct CCow CCow;
|
|
93
|
+
|
|
92
94
|
typedef struct CanvasRenderingContext2D CanvasRenderingContext2D;
|
|
93
95
|
|
|
94
96
|
typedef struct ContextAttributes ContextAttributes;
|
|
@@ -1099,6 +1101,23 @@ const char *canvas_native_text_decoder_decode(const struct TextDecoder *decoder,
|
|
|
1099
1101
|
const uint8_t *data,
|
|
1100
1102
|
uintptr_t size);
|
|
1101
1103
|
|
|
1104
|
+
void canvas_native_ccow_destroy(struct CCow *cow);
|
|
1105
|
+
|
|
1106
|
+
const uint8_t *canvas_native_ccow_get_bytes(const struct CCow *cow);
|
|
1107
|
+
|
|
1108
|
+
uintptr_t canvas_native_ccow_get_length(const struct CCow *cow);
|
|
1109
|
+
|
|
1110
|
+
struct CCow *canvas_native_text_decoder_decode_as_cow(const struct TextDecoder *decoder,
|
|
1111
|
+
const uint8_t *data,
|
|
1112
|
+
uintptr_t size);
|
|
1113
|
+
|
|
1114
|
+
struct U8Buffer *canvas_native_text_decoder_decode_as_bytes(const struct TextDecoder *decoder,
|
|
1115
|
+
const uint8_t *data,
|
|
1116
|
+
uintptr_t size);
|
|
1117
|
+
|
|
1118
|
+
const char *canvas_native_text_decoder_decode_c_string(const struct TextDecoder *decoder,
|
|
1119
|
+
const int8_t *data);
|
|
1120
|
+
|
|
1102
1121
|
const char *canvas_native_text_decoder_get_encoding(const struct TextDecoder *decoder);
|
|
1103
1122
|
|
|
1104
1123
|
struct TextEncoder *canvas_native_text_encoder_create(const char *encoding);
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</data>
|
|
19
19
|
<key>Headers/canvas_native.h</key>
|
|
20
20
|
<data>
|
|
21
|
-
|
|
21
|
+
0JjcreRw0wOPRjXB8+82Lb40u0s=
|
|
22
22
|
</data>
|
|
23
23
|
<key>Info.plist</key>
|
|
24
24
|
<data>
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
<dict>
|
|
109
109
|
<key>hash2</key>
|
|
110
110
|
<data>
|
|
111
|
-
|
|
111
|
+
zWqFhnejCTn0DtFssxe5T9TrSIbwRJEpJPfV/T1dtK0=
|
|
112
112
|
</data>
|
|
113
113
|
</dict>
|
|
114
114
|
<key>Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo</key>
|
|
Binary file
|
|
@@ -193,13 +193,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
193
193
|
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
194
194
|
v8::Context::Scope context_scope(context);
|
|
195
195
|
|
|
196
|
-
auto ret = ImageBitmapImpl::
|
|
197
|
-
context).ToLocalChecked()->NewInstance(
|
|
198
|
-
context).ToLocalChecked();
|
|
199
|
-
|
|
200
|
-
SetNativeType(isolate, ret, NativeType::ImageBitmap);
|
|
201
|
-
|
|
202
|
-
ret->SetInternalField(0, cbData);
|
|
196
|
+
auto ret = ImageBitmapImpl::NewInstance(isolate, cbData);
|
|
203
197
|
|
|
204
198
|
v8::Local<v8::Value> args[2];
|
|
205
199
|
|
|
@@ -304,7 +298,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
304
298
|
auto store = arrayBuffer->GetBackingStore();
|
|
305
299
|
auto dataBuffer = (uint8_t *) store->Data();
|
|
306
300
|
v8::Global<v8::ArrayBuffer> ab(isolate, arrayBuffer);
|
|
307
|
-
|
|
301
|
+
|
|
308
302
|
std::thread thread(
|
|
309
303
|
[&dataBuffer, jsi_callback, &options, store, shared_asset, current_queue](
|
|
310
304
|
v8::Global<v8::ArrayBuffer> ab, size_t size
|
|
@@ -325,7 +319,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
325
319
|
|
|
326
320
|
auto main_task = [jsi_callback, current_queue, done]() {
|
|
327
321
|
|
|
328
|
-
|
|
322
|
+
|
|
329
323
|
v8::Isolate *isolate = jsi_callback->isolate_;
|
|
330
324
|
v8::Locker locker(isolate);
|
|
331
325
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
@@ -336,13 +330,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
336
330
|
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
337
331
|
v8::Context::Scope context_scope(context);
|
|
338
332
|
|
|
339
|
-
auto ret = ImageBitmapImpl::
|
|
340
|
-
context).ToLocalChecked()->NewInstance(
|
|
341
|
-
context).ToLocalChecked();
|
|
342
|
-
|
|
343
|
-
SetNativeType(isolate, ret, NativeType::ImageBitmap);
|
|
344
|
-
|
|
345
|
-
ret->SetInternalField(0, cbData);
|
|
333
|
+
auto ret = ImageBitmapImpl::NewInstance(isolate, cbData);
|
|
346
334
|
|
|
347
335
|
v8::Local<v8::Value> args[2];
|
|
348
336
|
|
|
@@ -358,7 +346,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
358
346
|
|
|
359
347
|
|
|
360
348
|
callback->Call(context, context->Global(), 2, args);
|
|
361
|
-
|
|
349
|
+
|
|
362
350
|
|
|
363
351
|
delete jsi_callback;
|
|
364
352
|
delete current_queue;
|
|
@@ -415,13 +403,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
415
403
|
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
416
404
|
v8::Context::Scope context_scope(context);
|
|
417
405
|
|
|
418
|
-
|
|
419
|
-
context).ToLocalChecked()->NewInstance(
|
|
420
|
-
context).ToLocalChecked();
|
|
421
|
-
|
|
422
|
-
SetNativeType(isolate, ret, NativeType::ImageBitmap);
|
|
423
|
-
|
|
424
|
-
ret->SetInternalField(0, cbData);
|
|
406
|
+
auto ret = ImageBitmapImpl::NewInstance(isolate, cbData);
|
|
425
407
|
|
|
426
408
|
v8::Local<v8::Value> args[2];
|
|
427
409
|
|
|
@@ -489,13 +471,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
489
471
|
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
490
472
|
v8::Context::Scope context_scope(context);
|
|
491
473
|
|
|
492
|
-
auto ret = ImageBitmapImpl::
|
|
493
|
-
context).ToLocalChecked()->NewInstance(
|
|
494
|
-
context).ToLocalChecked();
|
|
495
|
-
|
|
496
|
-
SetNativeType(isolate, ret, NativeType::ImageBitmap);
|
|
497
|
-
|
|
498
|
-
ret->SetInternalField(0, cbData);
|
|
474
|
+
auto ret = ImageBitmapImpl::NewInstance(isolate, cbData);
|
|
499
475
|
|
|
500
476
|
v8::Local<v8::Value> args[2];
|
|
501
477
|
|
|
@@ -749,13 +725,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
749
725
|
v8::Local<v8::Context> context = callback->GetCreationContextChecked();
|
|
750
726
|
v8::Context::Scope context_scope(context);
|
|
751
727
|
|
|
752
|
-
|
|
753
|
-
context).ToLocalChecked()->NewInstance(
|
|
754
|
-
context).ToLocalChecked();
|
|
755
|
-
|
|
756
|
-
SetNativeType(isolate, ret, NativeType::ImageBitmap);
|
|
757
|
-
|
|
758
|
-
ret->SetInternalField(0, cbData);
|
|
728
|
+
auto ret = ImageBitmapImpl::NewInstance(isolate, cbData);
|
|
759
729
|
|
|
760
730
|
v8::Local<v8::Value> args[2];
|
|
761
731
|
|
|
@@ -821,12 +791,8 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
821
791
|
|
|
822
792
|
auto bitmap = new ImageBitmapImpl(ret);
|
|
823
793
|
auto data = v8::External::New(isolate, bitmap);
|
|
824
|
-
auto object = ImageBitmapImpl::GetCtor(isolate)->GetFunction(
|
|
825
|
-
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
826
|
-
|
|
827
|
-
object->SetInternalField(0, data);
|
|
828
794
|
|
|
829
|
-
|
|
795
|
+
auto object = ImageBitmapImpl::NewInstance(isolate, data);
|
|
830
796
|
|
|
831
797
|
retArgs[1] = object;
|
|
832
798
|
}
|
|
@@ -845,12 +811,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
845
811
|
|
|
846
812
|
auto bitmap = new ImageBitmapImpl(ret);
|
|
847
813
|
auto data = v8::External::New(isolate, bitmap);
|
|
848
|
-
auto object = ImageBitmapImpl::
|
|
849
|
-
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
850
|
-
|
|
851
|
-
object->SetInternalField(0, data);
|
|
852
|
-
|
|
853
|
-
SetNativeType(isolate, object, NativeType::ImageBitmap);
|
|
814
|
+
auto object = ImageBitmapImpl::NewInstance(isolate, data);
|
|
854
815
|
|
|
855
816
|
retArgs[1] = object;
|
|
856
817
|
|
|
@@ -892,12 +853,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
892
853
|
|
|
893
854
|
auto bitmap = new ImageBitmapImpl(ret);
|
|
894
855
|
auto data = v8::External::New(isolate, bitmap);
|
|
895
|
-
auto object = ImageBitmapImpl::
|
|
896
|
-
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
897
|
-
|
|
898
|
-
object->SetInternalField(0, data);
|
|
899
|
-
|
|
900
|
-
SetNativeType(isolate, object, NativeType::ImageBitmap);
|
|
856
|
+
auto object = ImageBitmapImpl::NewInstance(isolate, data);
|
|
901
857
|
|
|
902
858
|
retArgs[1] = object;
|
|
903
859
|
}
|
|
@@ -920,12 +876,7 @@ void CanvasJSIModule::CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value
|
|
|
920
876
|
|
|
921
877
|
auto bitmap = new ImageBitmapImpl(ret);
|
|
922
878
|
auto data = v8::External::New(isolate, bitmap);
|
|
923
|
-
auto object = ImageBitmapImpl::
|
|
924
|
-
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
925
|
-
|
|
926
|
-
object->SetInternalField(0, data);
|
|
927
|
-
|
|
928
|
-
SetNativeType(isolate, object, NativeType::ImageBitmap);
|
|
879
|
+
auto object = ImageBitmapImpl::NewInstance(isolate, data);
|
|
929
880
|
|
|
930
881
|
retArgs[1] = object;
|
|
931
882
|
|
|
@@ -1130,7 +1081,7 @@ void CanvasJSIModule::ReadFile(const v8::FunctionCallbackInfo<v8::Value> &args)
|
|
|
1130
1081
|
|
|
1131
1082
|
|
|
1132
1083
|
auto buf = (void*)canvas_native_u8_buffer_get_bytes_mut(vec);
|
|
1133
|
-
|
|
1084
|
+
|
|
1134
1085
|
auto size = (size_t)canvas_native_u8_buffer_get_length(vec);
|
|
1135
1086
|
|
|
1136
1087
|
auto store = v8::ArrayBuffer::NewBackingStore(buf, size,
|
|
@@ -20,12 +20,24 @@ struct Options {
|
|
|
20
20
|
|
|
21
21
|
class ImageBitmapImpl {
|
|
22
22
|
public:
|
|
23
|
-
ImageBitmapImpl(ImageAsset*
|
|
23
|
+
ImageBitmapImpl(ImageAsset *asset);
|
|
24
|
+
|
|
24
25
|
~ImageBitmapImpl();
|
|
25
26
|
|
|
27
|
+
|
|
28
|
+
static v8::Local<v8::Object> NewInstance(v8::Isolate *isolate, v8::Local<v8::External> asset) {
|
|
29
|
+
auto context = isolate->GetCurrentContext();
|
|
30
|
+
v8::EscapableHandleScope scope(isolate);
|
|
31
|
+
auto object = ImageBitmapImpl::GetCtor(isolate)->GetFunction(
|
|
32
|
+
context).ToLocalChecked()->NewInstance(context).ToLocalChecked();
|
|
33
|
+
SetNativeType(isolate, object, NativeType::ImageBitmap);
|
|
34
|
+
object->SetInternalField(0, asset);
|
|
35
|
+
return scope.Escape(object);
|
|
36
|
+
}
|
|
37
|
+
|
|
26
38
|
static Options HandleOptions(v8::Isolate *isolate, const v8::Local<v8::Value> &options);
|
|
27
39
|
|
|
28
|
-
ImageAsset*
|
|
40
|
+
ImageAsset *GetImageAsset();
|
|
29
41
|
|
|
30
42
|
static void Init(v8::Local<v8::Object> canvasModule, v8::Isolate *isolate);
|
|
31
43
|
|
|
@@ -42,6 +54,6 @@ public:
|
|
|
42
54
|
static void Close(const v8::FunctionCallbackInfo<v8::Value> &args);
|
|
43
55
|
|
|
44
56
|
private:
|
|
45
|
-
ImageAsset*
|
|
57
|
+
ImageAsset *bitmap_;
|
|
46
58
|
bool closed_ = false;
|
|
47
59
|
};
|
|
@@ -9,9 +9,32 @@ OneByteStringResource::OneByteStringResource(char *string) : string_(string),
|
|
|
9
9
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
OneByteStringResource::OneByteStringResource(U8Buffer *buffer) : buffer_(buffer) {
|
|
13
|
+
string_ = (char *) canvas_native_u8_buffer_get_bytes(buffer);
|
|
14
|
+
length_ = canvas_native_u8_buffer_get_length(buffer);
|
|
15
|
+
usingBuffer_ = true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
OneByteStringResource::OneByteStringResource(CCow *cow) : cow_(cow) {
|
|
19
|
+
string_ = (char *) canvas_native_ccow_get_bytes(cow);
|
|
20
|
+
length_ = canvas_native_ccow_get_length(cow);
|
|
21
|
+
usingCow_ = true;
|
|
22
|
+
}
|
|
23
|
+
|
|
12
24
|
OneByteStringResource::~OneByteStringResource() {
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
if (usingBuffer_) {
|
|
26
|
+
canvas_native_u8_buffer_destroy(buffer_);
|
|
27
|
+
this->string_ = nullptr;
|
|
28
|
+
this->length_ = 0;
|
|
29
|
+
}else if(usingCow_){
|
|
30
|
+
canvas_native_ccow_destroy(cow_);
|
|
31
|
+
this->string_ = nullptr;
|
|
32
|
+
this->length_ = 0;
|
|
33
|
+
} else {
|
|
34
|
+
canvas_native_string_destroy((char *) this->string_);
|
|
35
|
+
this->string_ = nullptr;
|
|
36
|
+
this->length_ = 0;
|
|
37
|
+
}
|
|
15
38
|
}
|
|
16
39
|
|
|
17
40
|
const char *OneByteStringResource::data() const {
|
|
@@ -23,3 +46,4 @@ size_t OneByteStringResource::length() const {
|
|
|
23
46
|
}
|
|
24
47
|
|
|
25
48
|
|
|
49
|
+
|
|
@@ -3,19 +3,30 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
#pragma once
|
|
6
|
+
|
|
6
7
|
#include "Common.h"
|
|
7
8
|
|
|
8
9
|
class OneByteStringResource : public v8::String::ExternalOneByteStringResource {
|
|
9
10
|
public:
|
|
10
|
-
OneByteStringResource(char*
|
|
11
|
+
OneByteStringResource(char *string);
|
|
12
|
+
|
|
13
|
+
OneByteStringResource(U8Buffer *buffer);
|
|
11
14
|
|
|
15
|
+
OneByteStringResource(CCow *cow);
|
|
16
|
+
|
|
12
17
|
~OneByteStringResource();
|
|
13
18
|
|
|
14
|
-
const char*
|
|
19
|
+
const char *data() const override;
|
|
20
|
+
|
|
15
21
|
size_t length() const override;
|
|
16
22
|
|
|
17
23
|
private:
|
|
18
|
-
const char*
|
|
24
|
+
const char *string_;
|
|
19
25
|
size_t length_;
|
|
26
|
+
U8Buffer *buffer_ = nullptr;
|
|
27
|
+
CCow *cow_ = nullptr;
|
|
28
|
+
// todo enum
|
|
29
|
+
bool usingBuffer_ = false;
|
|
30
|
+
bool usingCow_ = false;
|
|
20
31
|
};
|
|
21
32
|
|
|
@@ -109,7 +109,6 @@ void TextDecoderImpl::Decode(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
auto isolate = args.GetIsolate();
|
|
112
|
-
auto context = isolate->GetCurrentContext();
|
|
113
112
|
|
|
114
113
|
if (args.Length() == 1) {
|
|
115
114
|
auto value = args[0];
|
|
@@ -146,13 +145,13 @@ void TextDecoderImpl::Decode(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
146
145
|
if (buf->IsArrayBufferView()) {
|
|
147
146
|
|
|
148
147
|
auto buffer = buf.As<v8::ArrayBufferView>();
|
|
149
|
-
|
|
148
|
+
|
|
150
149
|
|
|
151
150
|
auto store = buffer->Buffer()->GetBackingStore();
|
|
152
151
|
auto buffer_data = static_cast<uint8_t *>(store->Data()) + buffer->ByteOffset();
|
|
153
|
-
|
|
152
|
+
|
|
154
153
|
auto len = buffer->ByteLength();
|
|
155
|
-
|
|
154
|
+
|
|
156
155
|
// v8::Local<v8::Value> size;
|
|
157
156
|
//
|
|
158
157
|
// buf->Get(context, ConvertToV8String(isolate, "BYTES_PER_ELEMENT")).ToLocal(&size);
|
|
@@ -162,16 +161,16 @@ void TextDecoderImpl::Decode(const v8::FunctionCallbackInfo<v8::Value> &args) {
|
|
|
162
161
|
// if(!size.IsEmpty()){
|
|
163
162
|
// len = buffer->Length() * (size_t)size->NumberValue(context).FromMaybe(0);
|
|
164
163
|
// }
|
|
165
|
-
|
|
164
|
+
|
|
166
165
|
// auto len = buffer->ByteLength();
|
|
167
|
-
|
|
168
|
-
auto decoded =
|
|
166
|
+
|
|
167
|
+
auto decoded = canvas_native_text_decoder_decode_as_cow(
|
|
169
168
|
ptr->GetTextDecoder(),
|
|
170
169
|
buffer_data, len);
|
|
171
|
-
|
|
170
|
+
|
|
172
171
|
|
|
173
172
|
// args.GetReturnValue().Set(ConvertToV8String(isolate, decoded.c_str()));
|
|
174
|
-
auto returnValue = new OneByteStringResource(
|
|
173
|
+
auto returnValue = new OneByteStringResource(decoded);
|
|
175
174
|
auto ret = v8::String::NewExternalOneByte(isolate, returnValue);
|
|
176
175
|
args.GetReturnValue().Set(ret.ToLocalChecked());
|
|
177
176
|
return;
|