Skip to content

Commit 0078b1e

Browse files
authored
Merge pull request #46 from MassiveHeights/v0.6.x-dev
v0.5.6-stable
2 parents bc45286 + f54043d commit 0078b1e

File tree

6 files changed

+106
-42
lines changed

6 files changed

+106
-42
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Black Engine: Changelog
22
=======================
33

4+
# v0.5.6
5+
### New features
6+
- Added `Graphics#cacheAsBitmapDynamic` property allowing to disable auto refresh of bitmap cache
7+
8+
### Bug Fixes
9+
- Fixed few Cache As Bitmap bugs causing Graphics and tiling sprite to render incorrectly
10+
- Fixed incorrect rendering of cached slice9grid texture
11+
- Fixed incorrect rendering of tiled texture from texture atlas
12+
13+
### Examples & Docs
14+
- Added "Cache As Bitmap Dynamic" example
15+
416
# v0.5.5
517
### New features
618
- Added support for Black Vector Graphics (beta)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "black",
3-
"version": "0.5.5",
3+
"version": "0.5.6",
44
"description": "",
55
"main": "dist/black-es6-module.js",
66
"directories": {},

src/display/DisplayObject.js

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class DisplayObject extends GameObject {
2727
/** @private @type {boolean} */
2828
this.mCacheAsBitmap = false;
2929

30+
/** @private @type {boolean} */
31+
this.mCacheAsBitmapDynamic = true;
32+
3033
/** @private @type {boolean} */
3134
this.mCacheAsBitmapDirty = true;
3235

@@ -45,11 +48,11 @@ class DisplayObject extends GameObject {
4548
/** @protected @type {boolean} */
4649
this.mSnapToPixels = false;
4750

48-
/** @protected @type {DisplayObject|null} */
49-
this.mMask = null;
51+
// /** @protected @type {DisplayObject|null} */
52+
// this.mMask = null;
5053

51-
/** @protected @type {boolean} */
52-
this.mIsMask = false;
54+
// /** @protected @type {boolean} */
55+
// this.mIsMask = false;
5356
}
5457

5558
/**
@@ -255,6 +258,24 @@ class DisplayObject extends GameObject {
255258
}
256259
}
257260

261+
/**
262+
* Gets/sets whenever cache as bitmap should be automatically refreshed.
263+
*
264+
* @returns {boolean}
265+
*/
266+
get cacheAsBitmapDynamic() {
267+
return this.mCacheAsBitmapDynamic;
268+
}
269+
270+
/**
271+
* @ignore
272+
* @param {boolean} value
273+
* @return {void}
274+
*/
275+
set cacheAsBitmapDynamic(value) {
276+
this.mCacheAsBitmapDynamic = value;
277+
}
278+
258279
/**
259280
* Gets/Sets the opacity of the object.
260281
* Baked objects may change behavior.
@@ -359,29 +380,29 @@ class DisplayObject extends GameObject {
359380
this.mSnapToPixels = value;
360381
}
361382

362-
/**
363-
* Gets/sets a display object which will act like a mask for this display object.
364-
* Mask should be a part on the stage.
365-
* @returns {DisplayObject|null}
366-
*/
367-
get mask() {
368-
return this.mMask;
369-
}
370-
371-
/**
372-
* @ignore
373-
* @param {DisplayObject|null}
374-
*/
375-
set mask(value) {
376-
if (this.mMask === value)
377-
return;
378-
379-
if (this.mMask !== null)
380-
this.mMask.mIsMask = false;
381-
382-
if (value !== null)
383-
value.mIsMask = true;
384-
385-
this.mMask = value;
386-
}
383+
// /**
384+
// * Gets/sets a display object which will act like a mask for this display object.
385+
// * Mask should be a part on the stage.
386+
// * @returns {DisplayObject|null}
387+
// */
388+
// get mask() {
389+
// return this.mMask;
390+
// }
391+
392+
// /**
393+
// * @ignore
394+
// * @param {DisplayObject|null}
395+
// */
396+
// set mask(value) {
397+
// if (this.mMask === value)
398+
// return;
399+
400+
// if (this.mMask !== null)
401+
// this.mMask.mIsMask = false;
402+
403+
// if (value !== null)
404+
// value.mIsMask = true;
405+
406+
// this.mMask = value;
407+
// }
387408
}

src/drivers/canvas/DisplayObjectRendererCanvas.js

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @extends Renderer
55
* @cat drivers.canvas
66
*/
7+
78
/* @echo EXPORT */
89
class DisplayObjectRendererCanvas extends Renderer {
910
constructor() {
@@ -23,6 +24,11 @@ class DisplayObjectRendererCanvas extends Renderer {
2324

2425
/** @private @type {boolean} */
2526
this.mIsClipped = false;
27+
28+
this.mIsCached = false;
29+
30+
/** @private @type {Matrix|null} */
31+
this.mBakeInvertedMatrix = null;
2632
}
2733

2834
/** @inheritDoc */
@@ -33,15 +39,28 @@ class DisplayObjectRendererCanvas extends Renderer {
3339
this.endPassRequired = this.mIsClipped;
3440

3541
if (gameObject.mCacheAsBitmap === true) {
36-
let isStatic = gameObject.checkStatic(true);
37-
if (isStatic === true && this.mCacheAsBitmapDirty === true) {
38-
gameObject.setTransformDirty();
39-
this.__refreshBitmapCache();
40-
this.mCacheAsBitmapDirty = false;
41-
this.endPassRequired = false;
42-
} else if (isStatic === false) {
43-
this.mCacheAsBitmapDirty = true;
44-
gameObject.mDirty |= DirtyFlag.RENDER;
42+
if (gameObject.mCacheAsBitmapDynamic === false) {
43+
if (this.mIsCached === false) {
44+
this.mIsCached = true;
45+
gameObject.setTransformDirty();
46+
this.__refreshBitmapCache();
47+
this.mCacheAsBitmapDirty = false;
48+
this.endPassRequired = false;
49+
} else {
50+
gameObject.mDirty |= DirtyFlag.RENDER;
51+
}
52+
} else {
53+
let isStatic = gameObject.checkStatic(true);
54+
55+
if (isStatic === true && this.mCacheAsBitmapDirty === true) {
56+
gameObject.setTransformDirty();
57+
this.__refreshBitmapCache();
58+
this.mCacheAsBitmapDirty = false;
59+
this.endPassRequired = false;
60+
} else if (isStatic === false) {
61+
this.mCacheAsBitmapDirty = true;
62+
gameObject.mDirty |= DirtyFlag.RENDER;
63+
}
4564
}
4665
}
4766

@@ -78,9 +97,18 @@ class DisplayObjectRendererCanvas extends Renderer {
7897
let gameObject = /** @type {DisplayObject} */ (this.gameObject);
7998
let transform = gameObject.worldTransformation;
8099

81-
if (this.skipChildren === true)
100+
if (this.skipChildren === true) {
82101
transform = this.mCacheAsBitmapMatrixCache;
83102

103+
if (gameObject.mCacheAsBitmapDynamic === false) {
104+
transform = new Matrix()
105+
.append(this.gameObject.worldTransformation)
106+
.append(this.mBakeInvertedMatrix)
107+
.append(this.mCacheAsBitmapMatrixCache)
108+
}
109+
}
110+
111+
84112
if (this.skipChildren === true || this.endPassRequired === true) {
85113
driver.setSnapToPixels(gameObject.snapToPixels);
86114
driver.setTransform(transform);
@@ -135,6 +163,7 @@ class DisplayObjectRendererCanvas extends Renderer {
135163
this.mCacheAsBitmapMatrixCache.data[4] = -this.mCacheAsBitmapMatrixCache.data[4];
136164
this.mCacheAsBitmapMatrixCache.data[5] = -this.mCacheAsBitmapMatrixCache.data[5];
137165

166+
this.mBakeInvertedMatrix = this.gameObject.worldTransformation.clone().invert();
138167
//this.mCacheTexture.__dumpToDocument();
139168
}
140169
}

src/parsers/BVGStyle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class BVGStyle {
134134
* @public
135135
* @param {BVGStyle} style Parent style
136136
*
137-
* @returns void
137+
* @returns {void}
138138
*/
139139
merge(style) {
140140
if (style.hasOwnProperty('F'))
@@ -176,7 +176,7 @@ class BVGStyle {
176176
*
177177
* @public
178178
*
179-
* @returns void
179+
* @returns {void}
180180
*/
181181
compute() {
182182
this.needsFill = this.F !== '-';

src/timers/Timer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
22
* Timer component.
33
*
4+
* @cat timers
5+
*
46
* @fires Timer#complete
57
* @fires Timer#tick
68
*

0 commit comments

Comments
 (0)