Skip to content

Commit 2371a46

Browse files
committed
fix(canvas): flipY handling
1 parent b7b42ae commit 2371a46

File tree

25 files changed

+119
-70
lines changed

25 files changed

+119
-70
lines changed

CanvasNative.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
22

33
s.name = "CanvasNative"
44

5-
s.version = "0.9.18"
5+
s.version = "0.9.19"
66

77
s.summary = "A Canvas library"
88

packages/canvas/Canvas/common.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export abstract class CanvasBase extends View implements ICanvasBase {
143143
let x = 0;
144144
let y = 0;
145145
if (global.isIOS) {
146-
x = event.deltaX + this.__touchStart?.getX() ?? 0;
147-
y = event.deltaY + this.__touchStart?.getY() ?? 0;
146+
x = event.deltaX + this.__touchStart?.getX?.() ?? 0;
147+
y = event.deltaY + this.__touchStart?.getY?.() ?? 0;
148148
} else {
149149
const initial: android.view.MotionEvent = event.android.initial;
150150
const current: android.view.MotionEvent = event.android.current;
@@ -194,6 +194,9 @@ export abstract class CanvasBase extends View implements ICanvasBase {
194194
this._previousY = event.deltaY;
195195
} else if (name === 'touchmove:pinch') {
196196
name = 'touchmove';
197+
if (!this.__touchStart) {
198+
return null;
199+
}
197200
const x = event.getFocusX();
198201
const y = event.getFocusY();
199202
const scale = event.scale;
@@ -213,17 +216,17 @@ export abstract class CanvasBase extends View implements ICanvasBase {
213216
};
214217

215218
pointers.push({
216-
clientX: this.__touchStart?.getX() ?? 0,
217-
clientY: this.__touchStart?.getY() ?? 0,
219+
clientX: this.__touchStart?.getX?.() ?? 0,
220+
clientY: this.__touchStart?.getY?.() ?? 0,
218221
force: 0.0,
219222
identifier: 0,
220-
pageX: this.__touchStart?.getX() ?? 0,
221-
pageY: this.__touchStart?.getY() ?? 0,
223+
pageX: this.__touchStart?.getX?.() ?? 0,
224+
pageY: this.__touchStart?.getY?.() ?? 0,
222225
radiusX: 0,
223226
radiusY: 0,
224227
rotationAngle: 0,
225-
screenX: this.__touchStart?.getX() ?? 0,
226-
screenY: this.__touchStart?.getY() ?? 0,
228+
screenX: this.__touchStart?.getX?.() ?? 0,
229+
screenY: this.__touchStart?.getY?.() ?? 0,
227230
target,
228231
});
229232

@@ -246,7 +249,9 @@ export abstract class CanvasBase extends View implements ICanvasBase {
246249
} else {
247250
const count = event.getAllPointers().length;
248251
const point = event.getActivePointers()[0];
249-
252+
if (!point) {
253+
return null;
254+
}
250255
// mouse event
251256
activePointer = {
252257
clientX: point.getX() * scale,
@@ -303,7 +308,10 @@ export abstract class CanvasBase extends View implements ICanvasBase {
303308
}
304309

305310
_emitEvent(name, event) {
306-
this.notify(this._getTouchEvent(name, event, this));
311+
const data = this._getTouchEvent(name, event, this);
312+
if (data) {
313+
this.notify(data);
314+
}
307315
}
308316

309317
_readyEvent() {

packages/canvas/src-native/canvas-ios/CanvasNative/Dist/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated by Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
1+
// Generated by Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
22
#ifndef CANVASNATIVE_SWIFT_H
33
#define CANVASNATIVE_SWIFT_H
44
#pragma clang diagnostic push
@@ -256,6 +256,8 @@ SWIFT_PROTOCOL("_TtP12CanvasNative17ICanvasColorStyle_")
256256
- (enum CanvasColorStyleType)getStyleType SWIFT_WARN_UNUSED_RESULT;
257257
@end
258258

259+
@class NSNumber;
260+
@class NSString;
259261

260262
SWIFT_CLASS_NAMED("TNSAnimationFrame")
261263
@interface TNSAnimationFrame : NSObject
@@ -264,7 +266,6 @@ SWIFT_CLASS_NAMED("TNSAnimationFrame")
264266
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
265267
@end
266268

267-
@class NSString;
268269
@class TNSDOMMatrix;
269270
@protocol TNSCanvasListener;
270271
@class TNSCanvasRenderingContext;

packages/canvas/src-native/canvas-ios/CanvasNative/Dist/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// swift-interface-format-version: 1.0
2-
// swift-compiler-version: Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
2+
// swift-compiler-version: Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
33
// swift-module-flags: -target arm64-apple-ios10.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name CanvasNative
44
import AVFoundation
55
@_exported import CanvasNative
@@ -140,8 +140,8 @@ import UIKit
140140
@_inheritsConvenienceInitializers @objcMembers @objc(TNSAnimationFrame) public class TNSAnimationFrame : ObjectiveC.NSObject {
141141
@objc public static func requestAnimationFrame(toLoop: @escaping (Swift.Float) -> Swift.Void)
142142
@objc public static func cancelAnimationFrame(id: Swift.String)
143-
@objc deinit
144143
@objc override dynamic public init()
144+
@objc deinit
145145
}
146146
@objc(TNSFillRule) public enum TNSFillRule : Swift.Int, Swift.RawRepresentable {
147147
case NonZero
@@ -216,8 +216,8 @@ import UIKit
216216
@objc public func drawArraysInstancedANGLE(mode: Swift.Int32, first: Swift.Int32, count: Swift.Int32, primcount: Swift.Int32)
217217
@objc public func drawElementsInstancedANGLE(mode: Swift.Int32, count: Swift.Int32, type: Swift.Int32, offset: Swift.Int32, primcount: Swift.Int32)
218218
@objc public func vertexAttribDivisorANGLE(index: Swift.Int32, divisor: Swift.Int32)
219-
@objc deinit
220219
@objc override dynamic public init()
220+
@objc deinit
221221
}
222222
@_inheritsConvenienceInitializers @objcMembers @objc(TNS_EXT_blend_minmax) public class TNS_EXT_blend_minmax : ObjectiveC.NSObject {
223223
@objc override dynamic public init()
@@ -2527,8 +2527,8 @@ extension RangeReplaceableCollection {
25272527
@objc public static func createImage(_ texturecache: CoreVideo.CVOpenGLESTextureCache, _ buffer: CoreVideo.CVImageBuffer, _ textureAttributes: CoreFoundation.CFDictionary?, _ target: OpenGLES.GLenum, _ internalFormat: OpenGLES.GLint, _ width: OpenGLES.GLsizei, _ height: OpenGLES.GLsizei, _ format: OpenGLES.GLenum, _ type: OpenGLES.GLenum, _ planeIndex: Swift.Int) -> CoreVideo.CVOpenGLESTexture?
25282528
@objc public static func setupRender() -> CanvasNative.TNSRender
25292529
@objc public static func drawFrame(_ player: AVFoundation.AVPlayer, _ output: AVFoundation.AVPlayerItemVideoOutput, _ videoSize: CoreGraphics.CGSize, _ render: CanvasNative.TNSRender, _ internalFormat: Swift.Int32, _ format: Swift.Int32, _ flipYWebGL: Swift.Bool)
2530-
@objc deinit
25312530
@objc override dynamic public init()
2531+
@objc deinit
25322532
}
25332533
@objcMembers @objc(TNSWebGLShaderPrecisionFormat) public class TNSWebGLShaderPrecisionFormat : ObjectiveC.NSObject {
25342534
@objc public var rangeMin: Swift.Int32 {
@@ -2780,8 +2780,8 @@ extension RangeReplaceableCollection {
27802780
@objc override dynamic public init(frame: CoreGraphics.CGRect)
27812781
@objc override dynamic public func setNeedsDisplay()
27822782
@objc override dynamic public func setNeedsDisplay(_ rect: CoreGraphics.CGRect)
2783-
@objc deinit
27842783
@objc override dynamic public init(frame: CoreGraphics.CGRect, context: OpenGLES.EAGLContext)
2784+
@objc deinit
27852785
}
27862786
@_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers @objcMembers @objc(CanvasCPUView) public class CanvasCPUView : UIKit.UIView {
27872787
@objc dynamic public init()
@@ -2796,8 +2796,8 @@ public enum ContextType : Swift.Int, Swift.RawRepresentable {
27962796
case none
27972797
case webGL
27982798
case twoD
2799-
public typealias RawValue = Swift.Int
28002799
public init?(rawValue: Swift.Int)
2800+
public typealias RawValue = Swift.Int
28012801
public var rawValue: Swift.Int {
28022802
get
28032803
}
@@ -3130,8 +3130,8 @@ public enum ContextType : Swift.Int, Swift.RawRepresentable {
31303130
@objc public func getStyleType() -> CanvasNative.CanvasColorStyleType
31313131
@objc override dynamic public init()
31323132
}
3133-
@objc deinit
31343133
@objc override dynamic public init()
3134+
@objc deinit
31353135
}
31363136
@_hasMissingDesignatedInitializers @objcMembers @objc(TNSTextMetrics) public class TNSTextMetrics : ObjectiveC.NSObject {
31373137
@objc deinit

0 commit comments

Comments
 (0)