Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/openfl/display/BitmapData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import lime.math.ColorMatrix;
import lime.math.Rectangle in LimeRectangle;
import lime.math.Vector2;
import lime.utils.Float32Array;
import lime.utils.ObjectPool;
import lime.utils.UInt8Array;
// import openfl.Lib;
import openfl._internal.renderer.canvas.CanvasBlendModeManager;
Expand Down Expand Up @@ -100,6 +101,7 @@ class BitmapData implements IBitmapDrawable {
private static var __tempVector:Vector2 = new Vector2 ();
private static var __textureFormat:Int;
private static var __textureInternalFormat:Int;
private static var __colorTransformPool = new ObjectPool<ColorTransform> (function () { return new ColorTransform (); }, function (colorTransform) { colorTransform.__identity (); });

public var height (default, null):Int;
public var image (default, null):Image;
Expand Down Expand Up @@ -570,6 +572,9 @@ class BitmapData implements IBitmapDrawable {

}

var matrixCacheColorTransform = __colorTransformPool.get ();
matrixCacheColorTransform.__copyFrom (source.__worldColorTransform);
source.__worldColorTransform.__identity ();
var matrixCache = Matrix.__pool.get ();
matrixCache.copyFrom (source.__worldTransform);
var cacheAlpha = source.__alpha;
Expand All @@ -578,6 +583,8 @@ class BitmapData implements IBitmapDrawable {
source.__updateChildren (false);
source.__renderCanvas (renderSession);
source.__alpha = cacheAlpha;
source.__worldColorTransform.__copyFrom (matrixCacheColorTransform);
__colorTransformPool.release (matrixCacheColorTransform);
source.__updateTransforms (matrixCache);
Matrix.__pool.release (matrixCache);
source.__updateChildren (true);
Expand Down Expand Up @@ -652,6 +659,9 @@ class BitmapData implements IBitmapDrawable {

}

var matrixCacheColorTransform = __colorTransformPool.get ();
matrixCacheColorTransform.__copyFrom (source.__worldColorTransform);
source.__worldColorTransform.__identity ();
var matrixCache = Matrix.__pool.get ();
matrixCache.copyFrom (source.__worldTransform);
var cacheAlpha = source.__alpha;
Expand All @@ -660,6 +670,8 @@ class BitmapData implements IBitmapDrawable {
source.__updateChildren (false);
source.__renderCairo (renderSession);
source.__alpha = cacheAlpha;
source.__worldColorTransform.__copyFrom (matrixCacheColorTransform);
__colorTransformPool.release (matrixCacheColorTransform);
source.__updateTransforms (matrixCache);
Matrix.__pool.release (matrixCache);
source.__updateChildren (true);
Expand Down Expand Up @@ -1820,6 +1832,9 @@ class BitmapData implements IBitmapDrawable {

}

var matrixCacheColorTransform = __colorTransformPool.get ();
matrixCacheColorTransform.__copyFrom (source.__worldColorTransform);
source.__worldColorTransform.__identity ();
var matrixCache = Matrix.__pool.get ();
matrixCache.copyFrom (source.__worldTransform);
var cacheAlpha = source.__alpha;
Expand All @@ -1837,7 +1852,8 @@ class BitmapData implements IBitmapDrawable {
source.__renderCanvas (renderSession);
source.__renderable = cacheRenderable;
source.__alpha = cacheAlpha;

source.__worldColorTransform.__copyFrom (matrixCacheColorTransform);
__colorTransformPool.release (matrixCacheColorTransform);
source.__updateTransforms (matrixCache);
Matrix.__pool.release (matrixCache);
source.__updateChildren (true);
Expand Down Expand Up @@ -1911,6 +1927,9 @@ class BitmapData implements IBitmapDrawable {

}

var matrixCacheColorTransform = __colorTransformPool.get ();
matrixCacheColorTransform.__copyFrom (source.__worldColorTransform);
source.__worldColorTransform.__identity ();
var matrixCache = Matrix.__pool.get ();
matrixCache.copyFrom (source.__worldTransform);
var cacheAlpha = source.__alpha;
Expand All @@ -1930,7 +1949,8 @@ class BitmapData implements IBitmapDrawable {
source.__renderCairo (renderSession);
source.__renderable = cacheRenderable;
source.__alpha = cacheAlpha;

source.__worldColorTransform.__copyFrom (matrixCacheColorTransform);
__colorTransformPool.release (matrixCacheColorTransform);
source.__updateTransforms (matrixCache);
Matrix.__pool.release (matrixCache);
source.__updateChildren (true);
Expand Down
23 changes: 14 additions & 9 deletions src/openfl/display/DisplayObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1113,9 +1113,9 @@ class DisplayObject extends EventDispatcher implements IBitmapDrawable #if openf
var rect = null;

//if (!renderSession.lockTransform) __getWorldTransform ();

var needRender = (__cacheBitmap == null || (__renderDirty && (force || (__children != null && __children.length > 0) || (__graphics!= null && __graphics.__dirty))) || opaqueBackground != __cacheBitmapBackground || !__cacheBitmapColorTransform.__equals (__worldColorTransform));
var updateTransform = (needRender || (!__cacheBitmap.__worldTransform.equals (__worldTransform)));
var isGL = renderSession.renderType == OPENGL;
var needRender = (__cacheBitmap == null || (__renderDirty && (force || (__children != null && __children.length > 0) || (__graphics!= null && __graphics.__dirty))) || opaqueBackground != __cacheBitmapBackground || (!isGL && !__cacheBitmapColorTransform.__equals (__worldColorTransform)));
var updateTransform = (needRender || (!__cacheBitmap.__worldTransform.equals (__worldTransform))) || (isGL && !__cacheBitmap.__worldColorTransform.__equals (__worldColorTransform));
var hasFilters = __hasFilters ();
var pixelRatio = renderSession.pixelRatio;

Expand Down Expand Up @@ -1189,6 +1189,7 @@ class DisplayObject extends EventDispatcher implements IBitmapDrawable #if openf

if (updateTransform || needRender) {

__cacheBitmap.__worldColorTransform.__copyFrom (__worldColorTransform);
__cacheBitmap.__worldTransform.copyFrom (__worldTransform);

__cacheBitmap.__renderTransform.identity ();
Expand Down Expand Up @@ -1264,7 +1265,7 @@ class DisplayObject extends EventDispatcher implements IBitmapDrawable #if openf
lastBitmap = filter.__applyFilter (bitmapData2, bitmapData, sourceRect, destPoint);

if (filter.__preserveObject) {
lastBitmap.draw (bitmapData3, null, transform.colorTransform);
lastBitmap.draw (bitmapData3, null, null);
}
filter.__renderDirty = false;

Expand All @@ -1285,12 +1286,16 @@ class DisplayObject extends EventDispatcher implements IBitmapDrawable #if openf

__cacheBitmapRender = false;

if (__cacheBitmapColorTransform == null) __cacheBitmapColorTransform = new ColorTransform ();
__cacheBitmapColorTransform.__copyFrom (__worldColorTransform);

if (!__cacheBitmapColorTransform.__isDefault ()) {
if (!isGL) {
if (__cacheBitmapColorTransform == null) __cacheBitmapColorTransform = new ColorTransform ();
__cacheBitmapColorTransform.__copyFrom (__worldColorTransform);

__cacheBitmapData.colorTransform (__cacheBitmapData.rect, __cacheBitmapColorTransform);
if (!__cacheBitmapColorTransform.__isDefault ()) {

__cacheBitmapData.colorTransform (__cacheBitmapData.rect, __worldColorTransform);

}

}

Expand Down
2 changes: 1 addition & 1 deletion src/openfl/text/TextField.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ class TextField extends InteractiveObject implements IShaderDrawable {
}
__forceCachedBitmapUpdate = __forceCachedBitmapUpdate || __dirty;

CanvasTextField.render (this, renderSession, __worldTransform);
if (!__cacheBitmapRender) CanvasTextField.render (this, renderSession, __worldTransform);

if (__textEngine.antiAliasType == ADVANCED && __textEngine.gridFitType == PIXEL) {

Expand Down