Skip to content

Commit 3716a84

Browse files
committed
fix: rewrote HWA handling
enabled by default on >=28
1 parent 92e76fe commit 3716a84

File tree

5 files changed

+18
-24
lines changed

5 files changed

+18
-24
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
"@nativescript/types-android": "7.0.4",
4343
"@nativescript/types-ios": "7.0.4",
4444
"@nativescript/webpack": "3.0.5",
45-
"@nativescript-community/ui-canvas": "4.0.17",
46-
"@nativescript-community/gesturehandler": "^0.1.22",
47-
"@nativescript-community/tween": "0.0.11",
45+
"@nativescript-community/ui-canvas": "4.0.25",
46+
"@nativescript-community/gesturehandler": "^0.1.23",
47+
"@nativescript-community/tween": "0.0.12",
4848
"@tweenjs/tween.js": "18.6.0",
4949
"@types/node": "^14.6.4",
5050
"@types/tween.js": "^18.5.1",
@@ -68,4 +68,4 @@
6868
]
6969
},
7070
"dependencies": {}
71-
}
71+
}

plugin/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
"main": "charts/index.js",
2929
"typings": "charts/index.d.ts",
3030
"dependencies": {
31-
"@nativescript-community/gesturehandler": "^0.1.22",
32-
"@nativescript-community/tween": "0.0.11",
33-
"@nativescript-community/ui-canvas": "^4.0.17",
31+
"@nativescript-community/gesturehandler": "^0.1.23",
32+
"@nativescript-community/tween": "0.0.12",
33+
"@nativescript-community/ui-canvas": "^4.0.25",
3434
"downsample": "^1.3.0",
3535
"number-format.js": "^2.0.9"
3636
}
37-
}
37+
}

src/charting/charts/BarLineChartBase.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,6 @@ export abstract class BarLineChartBase<U extends Entry, D extends IBarLineScatte
13511351

13521352
public getHighestVisibleX() {
13531353
this.getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(this.mViewPortHandler.contentRight(), this.mViewPortHandler.contentBottom(), this.posForGetHighestVisibleX);
1354-
// console.log('getHighestVisibleX', this.mViewPortHandler.contentRight(), this.mViewPortHandler.contentBottom(), this.posForGetHighestVisibleX, this.mXAxis.mAxisMaximum);
13551354
const result = Math.min(this.mXAxis.mAxisMaximum, this.posForGetHighestVisibleX.x);
13561355

13571356
return result;

src/charting/charts/Chart.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ export abstract class Chart<U extends Entry, D extends IDataSet<U>, T extends Ch
149149
*/
150150
constructor() {
151151
super();
152-
// disable by default. Render is so much better!
153-
this.hardwareAccelerated = false;
154152
this.init();
155153
}
156154

@@ -1593,7 +1591,7 @@ export abstract class Chart<U extends Entry, D extends IDataSet<U>, T extends Ch
15931591
* @param enabled
15941592
*/
15951593
public setHardwareAccelerationEnabled(enabled) {
1596-
Utils.setHardwareAccelerationEnabled(this.nativeViewProtected, enabled);
1594+
this.hardwareAccelerated = enabled;
15971595
}
15981596

15991597
// protected onDetachedFromWindow() {

src/charting/utils/Utils.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ if (global.isAndroid) {
1212
FloatConstructor = interop.sizeof(interop.types.id) === 4 ? Float32Array : Float64Array;
1313
}
1414

15+
16+
let SDK_INT = -1;
17+
function getSDK() {
18+
if (SDK_INT === -1) {
19+
SDK_INT = android.os.Build.VERSION.SDK_INT;
20+
}
21+
return SDK_INT;
22+
}
1523
/**
1624
* Utilities class that has some helper methods. Needs to be initialized by
1725
* calling Utils.init(...) before usage. Inside the Chart.init() method, this is
@@ -616,9 +624,6 @@ export namespace Utils {
616624
};
617625
}
618626

619-
//export function getSDKInt() {
620-
// return android.os.Build.VERSION.SDK_INT;
621-
// }
622627

623628
export function logMethod(target, key, descriptor) {
624629
// save a reference to the original method this way we keep the values currently in the
@@ -706,18 +711,10 @@ export namespace Utils {
706711

707712
export function clipPathSupported() {
708713
if (global.isAndroid) {
709-
return android.os.Build.VERSION.SDK_INT >= 18;
714+
return getSDK() >= 18;
710715
}
711716
return false;
712717
}
713-
export function setHardwareAccelerationEnabled(view: android.view.View, enabled) {
714-
if (global.isAndroid) {
715-
if (view) {
716-
if (enabled) view.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
717-
else view.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
718-
}
719-
}
720-
}
721718

722719
/**
723720
* Calculates the sum across all values of the given array.

0 commit comments

Comments
 (0)