|
@@ -46,6 +46,8 @@ export class Control {
|
|
/** @hidden */
|
|
/** @hidden */
|
|
protected _isDirty = true;
|
|
protected _isDirty = true;
|
|
/** @hidden */
|
|
/** @hidden */
|
|
|
|
+ protected _wasDirty = false;
|
|
|
|
+ /** @hidden */
|
|
public _tempParentMeasure = Measure.Empty();
|
|
public _tempParentMeasure = Measure.Empty();
|
|
/** @hidden */
|
|
/** @hidden */
|
|
protected _cachedParentMeasure = Measure.Empty();
|
|
protected _cachedParentMeasure = Measure.Empty();
|
|
@@ -111,6 +113,13 @@ export class Control {
|
|
/** Gets or sets a boolean indicating if the children are clipped to the current control bounds */
|
|
/** Gets or sets a boolean indicating if the children are clipped to the current control bounds */
|
|
public clipChildren = true;
|
|
public clipChildren = true;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
|
|
|
|
+ */
|
|
|
|
+ public useBitmapCache = false;
|
|
|
|
+
|
|
|
|
+ private _cacheData: Nullable<ImageData>;
|
|
|
|
+
|
|
private _shadowOffsetX = 0;
|
|
private _shadowOffsetX = 0;
|
|
/** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
|
|
/** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
|
|
public get shadowOffsetX() {
|
|
public get shadowOffsetX() {
|
|
@@ -1193,6 +1202,7 @@ export class Control {
|
|
|
|
|
|
context.restore();
|
|
context.restore();
|
|
|
|
|
|
|
|
+ this._wasDirty = this._isDirty;
|
|
this._isDirty = false;
|
|
this._isDirty = false;
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -1408,7 +1418,16 @@ export class Control {
|
|
this.onBeforeDrawObservable.notifyObservers(this);
|
|
this.onBeforeDrawObservable.notifyObservers(this);
|
|
}
|
|
}
|
|
|
|
|
|
- this._draw(context);
|
|
|
|
|
|
+ if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
|
|
|
|
+ context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
|
|
|
|
+ } else {
|
|
|
|
+ this._draw(context);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.useBitmapCache && this._wasDirty) {
|
|
|
|
+ this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
|
|
|
|
+ }
|
|
|
|
+
|
|
this._renderHighlight(context);
|
|
this._renderHighlight(context);
|
|
|
|
|
|
if (this.onAfterDrawObservable.hasObservers()) {
|
|
if (this.onAfterDrawObservable.hasObservers()) {
|