Skip to content

Commit 54e8c3e

Browse files
author
David
committed
Fixed issues with cache bounds
1 parent 60c8eec commit 54e8c3e

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

extras/SVGExporter/SVGExporter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@
291291
var img = this._getImage(o.cacheCanvas, "cache");
292292
if (!img) { return; }
293293
// don't forget cache offset & scale
294-
return this.exportCommon(img, o, "cache", o._cacheOffsetX, o._cacheOffsetY, o._cacheScale);
294+
var cache = o.bitmapCache;
295+
return this.exportCommon(img, o, "cache", cache._filterOffX, cache._filterOffY, cache.scale);
295296
};
296297

297298
p.exportContainer = function(o) {

src/easeljs/display/DisplayObject.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,10 +1144,9 @@ this.createjs = this.createjs||{};
11441144
**/
11451145
p.getBounds = function() {
11461146
if (this._bounds) { return this._rectangle.copy(this._bounds); }
1147-
var cacheCanvas = this.cacheCanvas;
1148-
if (cacheCanvas) {
1149-
var scale = this._cacheScale;
1150-
return this._rectangle.setValues(this._cacheOffsetX, this._cacheOffsetY, cacheCanvas.width/scale, cacheCanvas.height/scale);
1147+
var cache = this.bitmapCache;
1148+
if (cache) {
1149+
return cache.getBounds();
11511150
}
11521151
return null;
11531152
};

src/easeljs/filters/BitmapCache.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ this.createjs = this.createjs||{};
193193
* @default 0
194194
**/
195195
this._drawHeight = 0;
196+
197+
/**
198+
* Internal tracking of the last requested bounds, may happen repeadtedly so stored to avoid object creation
199+
* @property _boundRect
200+
* @protected
201+
* @type {Rectangle}
202+
* @default 0
203+
**/
204+
this._boundRect = new createjs.Rectangle();
196205
}
197206
var p = BitmapCache.prototype;
198207

@@ -401,6 +410,19 @@ this.createjs = this.createjs||{};
401410
return true;
402411
};
403412

413+
/**
414+
* Determine the bounds of the shape in local space.
415+
* @method getBounds
416+
* @returns {Rectangle}
417+
*/
418+
p.getBounds = function() {
419+
var scale = this.scale;
420+
return this._boundRect.setValue(
421+
this._filterOffX/scale, this._filterOffY/scale,
422+
this.width/scale, this.height/scale
423+
);
424+
};
425+
404426
// private methods:
405427
/**
406428
* Create or resize the invisible canvas/surface that is needed for the display object(s) to draw to,

0 commit comments

Comments
 (0)