Skip to content

Commit c80235d

Browse files
committed
Do not change the Android layer types (hardware/software)
1 parent b6d5510 commit c80235d

File tree

4 files changed

+2
-61
lines changed

4 files changed

+2
-61
lines changed

tns-core-modules/ui/animation/animation.android.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
translateXProperty, translateYProperty, scaleXProperty, scaleYProperty
99
} from "../styling/style-properties";
1010

11-
import { CacheLayerType, layout } from "../../utils/utils";
11+
import { layout } from "../../utils/utils";
1212
import lazy from "../../utils/lazy";
1313

1414
export * from "./animation-common";
@@ -161,8 +161,6 @@ export class Animation extends AnimationBase {
161161
}
162162
}
163163

164-
this._enableHardwareAcceleration();
165-
166164
if (traceEnabled()) {
167165
traceWrite("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), traceCategories.Animation);
168166
}
@@ -190,7 +188,6 @@ export class Animation extends AnimationBase {
190188
}
191189

192190
this._propertyUpdateCallbacks.forEach(v => v());
193-
this._disableHardwareAcceleration();
194191
this._resolveAnimationFinishedPromise();
195192

196193
if (this._target) {
@@ -200,7 +197,6 @@ export class Animation extends AnimationBase {
200197

201198
private _onAndroidAnimationCancel() { // tslint:disable-line
202199
this._propertyResetCallbacks.forEach(v => v());
203-
this._disableHardwareAcceleration();
204200
this._rejectAnimationFinishedPromise();
205201

206202
if (this._target) {
@@ -465,27 +461,4 @@ export class Animation extends AnimationBase {
465461
private static _getAndroidRepeatCount(iterations: number): number {
466462
return (iterations === Number.POSITIVE_INFINITY) ? android.view.animation.Animation.INFINITE : iterations - 1;
467463
}
468-
469-
private _enableHardwareAcceleration() {
470-
for (let i = 0, length = this._propertyAnimations.length; i < length; i++) {
471-
let cache = <CacheLayerType>this._propertyAnimations[i].target.nativeViewProtected;
472-
if (cache) {
473-
let layerType = cache.getLayerType();
474-
if (layerType !== android.view.View.LAYER_TYPE_HARDWARE) {
475-
cache.layerType = layerType;
476-
cache.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
477-
}
478-
}
479-
}
480-
}
481-
482-
private _disableHardwareAcceleration() {
483-
for (let i = 0, length = this._propertyAnimations.length; i < length; i++) {
484-
let cache = <CacheLayerType>this._propertyAnimations[i].target.nativeViewProtected;
485-
if (cache && cache.layerType !== undefined) {
486-
cache.setLayerType(cache.layerType, null);
487-
cache.layerType = undefined;
488-
}
489-
}
490-
}
491464
}

tns-core-modules/ui/core/view/view.android.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Definitions.
22
import { Point, CustomLayoutView as CustomLayoutViewDefinition, dip } from ".";
33
import { GestureTypes, GestureEventData } from "../../gestures";
4-
import { CacheLayerType } from "../../../utils/utils";
54

65
// Types.
76
import { Background, ad as androidBackground } from "../../styling/background";
@@ -510,11 +509,6 @@ export class View extends ViewCommon {
510509
}
511510

512511
(<any>nativeView).background = undefined;
513-
const cache = <CacheLayerType><any>nativeView;
514-
if (cache.layerType !== undefined) {
515-
cache.setLayerType(cache.layerType, null);
516-
cache.layerType = undefined;
517-
}
518512
}
519513
}
520514
}

tns-core-modules/ui/styling/background.android.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { View } from "../core/view";
2-
import { CacheLayerType, isDataURI, isFileOrResourcePath, layout, RESOURCE_PREFIX, FILE_PREFIX } from "../../utils/utils";
2+
import { isDataURI, isFileOrResourcePath, layout, RESOURCE_PREFIX, FILE_PREFIX } from "../../utils/utils";
33
import { parse } from "../../css-value";
44
import { path, knownFolders } from "../../file-system";
55
import * as application from "../../application";
@@ -37,7 +37,6 @@ export module ad {
3737
}
3838

3939
const background = view.style.backgroundInternal;
40-
const cache = <CacheLayerType>view.nativeViewProtected;
4140
const drawable = nativeView.getBackground();
4241
const androidView = <any>view as AndroidView;
4342
// use undefined as not set. getBackground will never return undefined only Drawable or null;
@@ -67,16 +66,6 @@ export module ad {
6766
} else {
6867
refreshBorderDrawable(view, backgroundDrawable);
6968
}
70-
71-
// This should be done only when backgroundImage is set!!!
72-
if ((background.hasBorderWidth() || background.hasBorderRadius() || background.clipPath) && getSDK() < 18) {
73-
// Switch to software because of unsupported canvas methods if hardware acceleration is on:
74-
// http://developer.android.com/guide/topics/graphics/hardware-accel.html
75-
if (cache.layerType === undefined) {
76-
cache.layerType = cache.getLayerType();
77-
cache.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
78-
}
79-
}
8069
} else {
8170
const cachedDrawable = androidView._cachedDrawable;
8271
let defaultDrawable: android.graphics.drawable.Drawable;
@@ -91,11 +80,6 @@ export module ad {
9180
org.nativescript.widgets.ViewHelper.setBackground(nativeView, defaultDrawable);
9281
// TODO: Do we need to clear the drawable here? Can't we just reuse it again?
9382
androidView._cachedDrawable = undefined;
94-
95-
if (cache.layerType !== undefined) {
96-
cache.setLayerType(cache.layerType, null);
97-
cache.layerType = undefined;
98-
}
9983
}
10084

10185
// TODO: Can we move BorderWidths as separate native setter?

tns-core-modules/utils/utils.d.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ export const FILE_PREFIX: string;
1515
interface Owned {
1616
owner: any;
1717
}
18-
19-
/**
20-
* Used to cache and restore Android views' layer type, i.e. android.view.View.getLayerType and android.view.View.setLayerType.
21-
* @private
22-
*/
23-
interface CacheLayerType {
24-
layerType: number;
25-
setLayerType(layerType: number, paint: any): void;
26-
getLayerType(): number;
27-
}
2818
//@endprivate
2919

3020
/**

0 commit comments

Comments
 (0)