// Class: openfl.display.DisplayObject

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../hxClasses_stub").default;
var $import = require("./../../import_stub").default;
var $extend = require("./../../extend_stub").default;
function openfl_display_IBitmapDrawable() {return require("./../../openfl/display/IBitmapDrawable");}
function openfl_events_EventDispatcher() {return require("./../../openfl/events/EventDispatcher");}
function Std() {return require("./../../Std");}
function openfl_events_MouseEvent() {return require("./../../openfl/events/MouseEvent");}
function openfl_events_TouchEvent() {return require("./../../openfl/events/TouchEvent");}
function openfl_geom_Matrix() {return require("./../../openfl/geom/Matrix");}
function openfl_geom_Rectangle() {return require("./../../openfl/geom/Rectangle");}
function openfl_geom_Point() {return require("./../../openfl/geom/Point");}
function HxOverrides() {return require("./../../HxOverrides");}
function openfl__$internal_renderer_canvas_CanvasBitmap() {return require("./../../openfl/_internal/renderer/canvas/CanvasBitmap");}
function openfl__$internal_renderer_canvas_CanvasDisplayObject() {return require("./../../openfl/_internal/renderer/canvas/CanvasDisplayObject");}
function openfl__$internal_renderer_canvas_CanvasGraphics() {return require("./../../openfl/_internal/renderer/canvas/CanvasGraphics");}
function openfl__$internal_renderer_dom_DOMBitmap() {return require("./../../openfl/_internal/renderer/dom/DOMBitmap");}
function openfl__$internal_renderer_dom_DOMDisplayObject() {return require("./../../openfl/_internal/renderer/dom/DOMDisplayObject");}
function openfl__$internal_renderer_opengl_GLBitmap() {return require("./../../openfl/_internal/renderer/opengl/GLBitmap");}
function openfl__$internal_renderer_opengl_GLDisplayObject() {return require("./../../openfl/_internal/renderer/opengl/GLDisplayObject");}
function openfl_display_BitmapData() {return require("./../../openfl/display/BitmapData");}
function openfl_display_Bitmap() {return require("./../../openfl/display/Bitmap");}
function openfl_geom_ColorTransform() {return require("./../../openfl/geom/ColorTransform");}
function lime_graphics_RendererType() {return require("./../../lime/graphics/RendererType");}
function openfl__$internal_Lib() {return require("./../../openfl/_internal/Lib");}
function openfl_geom_Transform() {return require("./../../openfl/geom/Transform");}
function js__$Boot_HaxeError() {return require("./../../js/_Boot/HaxeError");}
function openfl_errors_TypeError() {return require("./../../openfl/errors/TypeError");}
function haxe_ds_StringMap() {return require("./../../haxe/ds/StringMap");}
function lime_utils_ObjectPool() {return require("./../../lime/utils/ObjectPool");}
function openfl__$Vector_Vector_$Impl_$() {return require("./../../openfl/_Vector/Vector_Impl_");}

// Constructor

var DisplayObject = function() {
	(openfl_events_EventDispatcher().default).call(this);
	if(DisplayObject.__initStage != null) {
		this.stage = DisplayObject.__initStage;
		DisplayObject.__initStage = null;
	}
	this.__alpha = 1;
	this.__blendMode = "normal";
	this.__cacheAsBitmap = false;
	this.__transform = new (openfl_geom_Matrix().default)();
	this.__visible = true;
	this.__rotation = 0;
	this.__rotationSine = 0;
	this.__rotationCosine = 1;
	this.__scaleX = 1;
	this.__scaleY = 1;
	this.__worldAlpha = 1;
	this.__worldBlendMode = "normal";
	this.__worldTransform = new (openfl_geom_Matrix().default)();
	this.__worldColorTransform = new (openfl_geom_ColorTransform().default)();
	this.__renderTransform = new (openfl_geom_Matrix().default)();
	this.__worldVisible = true;
	this.set_name("instance" + ++DisplayObject.__instanceCount);
}

// Meta

DisplayObject.__name__ = ["openfl","display","DisplayObject"];
DisplayObject.__interfaces__ = [(openfl_display_IBitmapDrawable().default)];
DisplayObject.__super__ = (openfl_events_EventDispatcher().default);
DisplayObject.prototype = $extend((openfl_events_EventDispatcher().default).prototype, {
	addEventListener: function(type,listener,useCapture,priority,useWeakReference) {
		if(useWeakReference == null) {
			useWeakReference = false;
		}
		if(priority == null) {
			priority = 0;
		}
		if(useCapture == null) {
			useCapture = false;
		}
		switch(type) {
		case "activate":case "deactivate":case "enterFrame":case "exitFrame":case "frameConstructed":case "render":
			if(!DisplayObject.__broadcastEvents.exists(type)) {
				DisplayObject.__broadcastEvents.set(type,[]);
			}
			var dispatchers = DisplayObject.__broadcastEvents.get(type);
			if(dispatchers.indexOf(this) == -1) {
				dispatchers.push(this);
			}
			break;
		default:
		}
		(openfl_events_EventDispatcher().default).prototype.addEventListener.call(this,type,listener,useCapture,priority,useWeakReference);
	},
	dispatchEvent: function(event) {
		if((Std().default)["is"](event,(openfl_events_MouseEvent().default))) {
			var mouseEvent = event;
			mouseEvent.stageX = this.__getRenderTransform().__transformX(mouseEvent.localX,mouseEvent.localY);
			mouseEvent.stageY = this.__getRenderTransform().__transformY(mouseEvent.localX,mouseEvent.localY);
		} else if((Std().default)["is"](event,(openfl_events_TouchEvent().default))) {
			var touchEvent = event;
			touchEvent.stageX = this.__getRenderTransform().__transformX(touchEvent.localX,touchEvent.localY);
			touchEvent.stageY = this.__getRenderTransform().__transformY(touchEvent.localX,touchEvent.localY);
		}
		return this.__dispatchWithCapture(event);
	},
	getBounds: function(targetCoordinateSpace) {
		var matrix;
		var usingTemp = false;
		if(targetCoordinateSpace != null) {
			matrix = this.__getWorldTransform().clone();
			matrix.concat(targetCoordinateSpace.__getWorldTransform().clone().invert());
		} else {
			usingTemp = true;
			matrix = (openfl_geom_Matrix().default).__pool.get();
			matrix.identity();
		}
		var bounds = new (openfl_geom_Rectangle().default)();
		this.__getBounds(bounds,matrix);
		if(usingTemp) {
			(openfl_geom_Matrix().default).__pool.release(matrix);
		}
		return bounds;
	},
	getRect: function(targetCoordinateSpace) {
		return this.getBounds(targetCoordinateSpace);
	},
	globalToLocal: function(pos) {
		return this.__globalToLocal(pos,new (openfl_geom_Point().default)());
	},
	hitTestObject: function(obj) {
		if(obj != null && obj.parent != null && this.parent != null) {
			var currentBounds = this.getBounds(this);
			var targetBounds = obj.getBounds(this);
			return currentBounds.intersects(targetBounds);
		}
		return false;
	},
	hitTestPoint: function(x,y,shapeFlag) {
		if(shapeFlag == null) {
			shapeFlag = false;
		}
		if(this.stage != null) {
			return this.__hitTest(x,y,shapeFlag,null,true,this);
		} else {
			return false;
		}
	},
	localToGlobal: function(point) {
		return this.__getRenderTransform().transformPoint(point);
	},
	removeEventListener: function(type,listener,useCapture) {
		if(useCapture == null) {
			useCapture = false;
		}
		(openfl_events_EventDispatcher().default).prototype.removeEventListener.call(this,type,listener,useCapture);
		switch(type) {
		case "activate":case "deactivate":case "enterFrame":case "exitFrame":case "frameConstructed":case "render":
			if(!this.hasEventListener(type)) {
				if(DisplayObject.__broadcastEvents.exists(type)) {
					(HxOverrides().default).remove(DisplayObject.__broadcastEvents.get(type),this);
				}
			}
			break;
		default:
		}
	},
	__cleanup: function() {
		this.__cairo = null;
		this.__canvas = null;
		this.__context = null;
		if(this.__graphics != null) {
			this.__graphics.__cleanup();
		}
	},
	__dispatch: function(event) {
		if(this.__eventMap != null && this.hasEventListener(event.type)) {
			var result = (openfl_events_EventDispatcher().default).prototype.__dispatchEvent.call(this,event);
			if(event.__isCanceled) {
				return true;
			}
			return result;
		}
		return true;
	},
	__dispatchChildren: function(event) {
	},
	__dispatchEvent: function(event) {
		var result = (openfl_events_EventDispatcher().default).prototype.__dispatchEvent.call(this,event);
		if(event.__isCanceled) {
			return true;
		}
		if(event.bubbles && this.parent != null && this.parent != this) {
			event.eventPhase = 3;
			if(event.target == null) {
				event.target = this;
			}
			this.parent.__dispatchEvent(event);
		}
		return result;
	},
	__dispatchWithCapture: function(event) {
		if(event.target == null) {
			event.target = this;
		}
		if(this.parent != null) {
			event.eventPhase = 1;
			if(this.parent == this.stage) {
				this.parent.__dispatch(event);
			} else {
				var stack = DisplayObject.__tempStack.get();
				var parent = this.parent;
				var i = 0;
				while(parent != null) {
					stack.set(i,parent);
					parent = parent.parent;
					++i;
				}
				var _g1 = 0;
				var _g = i;
				while(_g1 < _g) {
					var j = _g1++;
					stack.get(i - j - 1).__dispatch(event);
				}
				DisplayObject.__tempStack.release(stack);
			}
		}
		event.eventPhase = 2;
		return this.__dispatchEvent(event);
	},
	__enterFrame: function(deltaTime) {
	},
	__getBounds: function(rect,matrix) {
		if(this.__graphics != null) {
			this.__graphics.__getBounds(rect,matrix);
		}
	},
	__getCursor: function() {
		return null;
	},
	__getFilterBounds: function(rect,matrix) {
		this.__getBounds(rect,matrix);
		if(this.__filters != null && this.__filters.length > 0) {
			var extension = (openfl_geom_Rectangle().default).__pool.get();
			var _g = 0;
			var _g1 = this.__filters;
			while(_g < _g1.length) {
				var filter = _g1[_g];
				++_g;
				extension.__expand(-filter.__leftExtension,-filter.__topExtension,filter.__leftExtension + filter.__rightExtension,filter.__topExtension + filter.__bottomExtension);
			}
			rect.width += extension.width;
			rect.height += extension.height;
			rect.x += extension.x;
			rect.y += extension.y;
			(openfl_geom_Rectangle().default).__pool.release(extension);
		}
	},
	__getInteractive: function(stack) {
		return false;
	},
	__getLocalBounds: function(rect) {
		this.__getBounds(rect,this.__transform);
		rect.x -= this.__transform.tx;
		rect.y -= this.__transform.ty;
	},
	__getRenderBounds: function(rect,matrix) {
		if(this.__scrollRect == null) {
			this.__getBounds(rect,matrix);
		} else {
			var r = (openfl_geom_Rectangle().default).__pool.get();
			r.copyFrom(this.__scrollRect);
			r.__transform(r,matrix);
			rect.__expand(matrix.tx,matrix.ty,r.width,r.height);
			(openfl_geom_Rectangle().default).__pool.release(r);
		}
	},
	__getRenderTransform: function() {
		this.__getWorldTransform();
		return this.__renderTransform;
	},
	__getWorldTransform: function() {
		var transformDirty = this.__transformDirty || this.__worldTransformInvalid;
		if(transformDirty) {
			var list = [];
			var current = this;
			if(this.parent == null) {
				this.__update(true,false);
			} else {
				while(current != this.stage) {
					list.push(current);
					current = current.parent;
					if(current == null) {
						break;
					}
				}
			}
			var i = list.length;
			while(--i >= 0) {
				current = list[i];
				current.__update(true,false);
				current.__worldTransformInvalid = false;
			}
		}
		return this.__worldTransform;
	},
	__globalToLocal: function(global,local) {
		this.__getRenderTransform();
		if(global == local) {
			this.__renderTransform.__transformInversePoint(global);
		} else {
			local.x = this.__renderTransform.__transformInverseX(global.x,global.y);
			local.y = this.__renderTransform.__transformInverseY(global.x,global.y);
		}
		return local;
	},
	__hitTest: function(x,y,shapeFlag,stack,interactiveOnly,hitObject) {
		if(this.__graphics != null) {
			if(!hitObject.get_visible() || this.__isMask) {
				return false;
			}
			if(this.get_mask() != null && !this.get_mask().__hitTestMask(x,y)) {
				return false;
			}
			if(this.__graphics.__hitTest(x,y,shapeFlag,this.__getRenderTransform())) {
				if(stack != null && !interactiveOnly) {
					stack.push(hitObject);
				}
				return true;
			}
		}
		return false;
	},
	__hitTestMask: function(x,y) {
		if(this.__graphics != null) {
			if(this.__graphics.__hitTest(x,y,true,this.__getRenderTransform())) {
				return true;
			}
		}
		return false;
	},
	__readGraphicsData: function(graphicsData,recurse) {
		if(this.__graphics != null) {
			this.__graphics.__readGraphicsData(graphicsData);
		}
	},
	__renderCairo: function(renderSession) {
	},
	__renderCairoMask: function(renderSession) {
	},
	__renderCanvas: function(renderSession) {
		if(this.get_mask() == null || this.get_mask().get_width() > 0 && this.get_mask().get_height() > 0) {
			this.__updateCacheBitmap(renderSession,!this.__worldColorTransform.__isDefault());
			if(this.__cacheBitmap != null && !this.__cacheBitmapRender) {
				(openfl__$internal_renderer_canvas_CanvasBitmap().default).render(this.__cacheBitmap,renderSession);
			} else {
				(openfl__$internal_renderer_canvas_CanvasDisplayObject().default).render(this,renderSession);
			}
		}
	},
	__renderCanvasMask: function(renderSession) {
		if(this.__graphics != null) {
			(openfl__$internal_renderer_canvas_CanvasGraphics().default).renderMask(this.__graphics,renderSession);
		}
	},
	__renderDOM: function(renderSession) {
		this.__updateCacheBitmap(renderSession,!this.__worldColorTransform.__isDefault());
		if(this.__cacheBitmap != null && !this.__cacheBitmapRender) {
			this.__renderDOMClear(renderSession);
			this.__cacheBitmap.stage = this.stage;
			(openfl__$internal_renderer_dom_DOMBitmap().default).render(this.__cacheBitmap,renderSession);
		} else {
			(openfl__$internal_renderer_dom_DOMDisplayObject().default).render(this,renderSession);
		}
	},
	__renderDOMClear: function(renderSession) {
		(openfl__$internal_renderer_dom_DOMDisplayObject().default).clear(this,renderSession);
	},
	__renderGL: function(renderSession) {
		this.__updateCacheBitmap(renderSession,false);
		if(this.__cacheBitmap != null && !this.__cacheBitmapRender) {
			(openfl__$internal_renderer_opengl_GLBitmap().default).render(this.__cacheBitmap,renderSession);
		} else {
			(openfl__$internal_renderer_opengl_GLDisplayObject().default).render(this,renderSession);
		}
	},
	__renderGLMask: function(renderSession) {
		this.__updateCacheBitmap(renderSession,false);
		if(this.__cacheBitmap != null && !this.__cacheBitmapRender) {
			(openfl__$internal_renderer_opengl_GLBitmap().default).renderMask(this.__cacheBitmap,renderSession);
		} else {
			(openfl__$internal_renderer_opengl_GLDisplayObject().default).renderMask(this,renderSession);
		}
	},
	__setParentRenderDirty: function() {
		var renderParent = this.__renderParent != null ? this.__renderParent : this.parent;
		if(renderParent != null && !renderParent.__renderDirty) {
			renderParent.__renderDirty = true;
			renderParent.__setParentRenderDirty();
		}
	},
	__setRenderDirty: function() {
		if(!this.__renderDirty) {
			this.__renderDirty = true;
			this.__setParentRenderDirty();
		}
	},
	__setStageReference: function(stage) {
		this.stage = stage;
	},
	__setTransformDirty: function() {
		if(!this.__transformDirty) {
			this.__transformDirty = true;
			this.__setWorldTransformInvalid();
			this.__setParentRenderDirty();
		}
	},
	__setWorldTransformInvalid: function() {
		this.__worldTransformInvalid = true;
	},
	__stopAllMovieClips: function() {
	},
	__update: function(transformOnly,updateChildren,maskGraphics) {
		var renderParent = this.__renderParent != null ? this.__renderParent : this.parent;
		if(this.__isMask && renderParent == null) {
			renderParent = this.__maskTarget;
		}
		this.__renderable = this.get_visible() && this.__scaleX != 0 && this.__scaleY != 0 && !this.__isMask && (renderParent == null || !renderParent.__isMask);
		this.__updateTransforms();
		this.__transformDirty = false;
		if(maskGraphics != null) {
			this.__updateMask(maskGraphics);
		}
		if(!transformOnly) {
			if(DisplayObject.__supportDOM) {
				this.__renderTransformChanged = !this.__renderTransform.equals(this.__renderTransformCache);
				if(this.__renderTransformCache == null) {
					this.__renderTransformCache = this.__renderTransform.clone();
				} else {
					this.__renderTransformCache.copyFrom(this.__renderTransform);
				}
			}
			if(!this.__worldColorTransform.__equals(this.get_transform().get_colorTransform())) {
				this.__worldColorTransform = this.get_transform().get_colorTransform().__clone();
			}
			if(renderParent != null) {
				if(DisplayObject.__supportDOM) {
					var worldVisible = renderParent.__worldVisible && this.get_visible();
					this.__worldVisibleChanged = this.__worldVisible != worldVisible;
					this.__worldVisible = worldVisible;
					var worldAlpha = this.get_alpha() * renderParent.__worldAlpha;
					this.__worldAlphaChanged = this.__worldAlpha != worldAlpha;
					this.__worldAlpha = worldAlpha;
				} else {
					this.__worldAlpha = this.get_alpha() * renderParent.__worldAlpha;
				}
				this.__worldColorTransform.__combine(renderParent.__worldColorTransform);
				if(this.__blendMode == null || this.__blendMode == "normal") {
					this.__worldBlendMode = renderParent.__blendMode;
				} else {
					this.__worldBlendMode = this.__blendMode;
				}
			} else {
				this.__worldAlpha = this.get_alpha();
				if(DisplayObject.__supportDOM) {
					this.__worldVisibleChanged = this.__worldVisible != this.get_visible();
					this.__worldVisible = this.get_visible();
					this.__worldAlphaChanged = this.__worldAlpha != this.get_alpha();
				}
			}
		}
		if(updateChildren && this.get_mask() != null) {
			this.get_mask().__update(transformOnly,true,maskGraphics);
		}
	},
	__updateCacheBitmap: function(renderSession,force) {
		if(this.__cacheBitmapRender) {
			return false;
		}
		if(this.get_cacheAsBitmap()) {
			var matrix = null;
			var rect = null;
			this.__update(false,true);
			var needRender = this.__cacheBitmap == null || this.__renderDirty && (force || this.__children != null && this.__children.length > 0 || this.__graphics != null && this.__graphics.__dirty) || this.opaqueBackground != this.__cacheBitmapBackground || !this.__cacheBitmapColorTransform.__equals(this.__worldColorTransform);
			var updateTransform = needRender || !this.__cacheBitmap.__worldTransform.equals(this.__worldTransform);
			var hasFilters = this.__filters != null && this.__filters.length > 0;
			if(hasFilters && !needRender) {
				var _g = 0;
				var _g1 = this.__filters;
				while(_g < _g1.length) {
					var filter = _g1[_g];
					++_g;
					if(filter.__renderDirty) {
						needRender = true;
						break;
					}
				}
			}
			var bitmapWidth = 0;
			var bitmapHeight = 0;
			if(updateTransform || needRender) {
				matrix = (openfl_geom_Matrix().default).__pool.get();
				rect = (openfl_geom_Rectangle().default).__pool.get();
				matrix.identity();
				this.__getFilterBounds(rect,this.__renderTransform);
				bitmapWidth = Math.ceil(rect.width);
				bitmapHeight = Math.ceil(rect.height);
				if(!needRender && this.__cacheBitmap != null && (bitmapWidth != this.__cacheBitmap.get_width() || bitmapHeight != this.__cacheBitmap.get_height())) {
					needRender = true;
				}
			}
			if(needRender) {
				this.__cacheBitmapBackground = this.opaqueBackground;
				var color = this.opaqueBackground != null ? -16777216 | this.opaqueBackground : 0;
				if(rect.width >= 0.5 && rect.height >= 0.5) {
					if(this.__cacheBitmap == null || bitmapWidth != this.__cacheBitmap.get_width() || bitmapHeight != this.__cacheBitmap.get_height()) {
						this.__cacheBitmapData = new (openfl_display_BitmapData().default)(bitmapWidth,bitmapHeight,true,color);
						if(this.__cacheBitmap == null) {
							this.__cacheBitmap = new (openfl_display_Bitmap().default)();
						}
						this.__cacheBitmap.__bitmapData = this.__cacheBitmapData;
					} else {
						this.__cacheBitmapData.fillRect(this.__cacheBitmapData.rect,color);
					}
				} else {
					this.__cacheBitmap = null;
					this.__cacheBitmapData = null;
					return true;
				}
			}
			if(updateTransform || needRender) {
				this.__cacheBitmap.__worldTransform.copyFrom(this.__worldTransform);
				this.__cacheBitmap.__renderTransform.identity();
				this.__cacheBitmap.__renderTransform.tx = rect.x;
				this.__cacheBitmap.__renderTransform.ty = rect.y;
				matrix.concat(this.__renderTransform);
				matrix.tx -= Math.round(rect.x);
				matrix.ty -= Math.round(rect.y);
			}
			this.__cacheBitmap.smoothing = renderSession.allowSmoothing;
			this.__cacheBitmap.__renderable = this.__renderable;
			this.__cacheBitmap.__worldAlpha = this.__worldAlpha;
			this.__cacheBitmap.__worldBlendMode = this.__worldBlendMode;
			this.__cacheBitmap.__scrollRect = this.__scrollRect;
			this.__cacheBitmap.set_mask(this.__mask);
			if(needRender) {
				this.__cacheBitmapRender = true;
				this.__cacheBitmapData.__draw(this,matrix,null,null,null,renderSession.allowSmoothing);
				if(hasFilters) {
					var needSecondBitmapData = false;
					var needCopyOfOriginal = false;
					var _g2 = 0;
					var _g11 = this.__filters;
					while(_g2 < _g11.length) {
						var filter1 = _g11[_g2];
						++_g2;
						if(filter1.__needSecondBitmapData) {
							needSecondBitmapData = true;
						}
						if(filter1.__preserveObject) {
							needCopyOfOriginal = true;
						}
					}
					var bitmapData = this.__cacheBitmapData;
					var bitmapData2 = null;
					var bitmapData3 = null;
					if(needSecondBitmapData) {
						bitmapData2 = new (openfl_display_BitmapData().default)(bitmapData.width,bitmapData.height,true,0);
					} else {
						bitmapData2 = bitmapData;
					}
					if(needCopyOfOriginal) {
						bitmapData3 = new (openfl_display_BitmapData().default)(bitmapData.width,bitmapData.height,true,0);
					}
					var sourceRect = bitmapData.rect;
					var destPoint = new (openfl_geom_Point().default)();
					var cacheBitmap;
					var lastBitmap;
					var _g3 = 0;
					var _g12 = this.__filters;
					while(_g3 < _g12.length) {
						var filter2 = _g12[_g3];
						++_g3;
						if(filter2.__preserveObject) {
							bitmapData3.copyPixels(bitmapData,bitmapData.rect,destPoint);
						}
						lastBitmap = filter2.__applyFilter(bitmapData2,bitmapData,sourceRect,destPoint);
						if(filter2.__preserveObject) {
							lastBitmap.draw(bitmapData3,null,this.get_transform().get_colorTransform());
						}
						filter2.__renderDirty = false;
						if(needSecondBitmapData && lastBitmap == bitmapData2) {
							cacheBitmap = bitmapData;
							bitmapData = bitmapData2;
							bitmapData2 = cacheBitmap;
						}
					}
					this.__cacheBitmap.set_bitmapData(bitmapData);
				}
				this.__cacheBitmapRender = false;
				if(this.__cacheBitmapColorTransform == null) {
					this.__cacheBitmapColorTransform = new (openfl_geom_ColorTransform().default)();
				}
				this.__cacheBitmapColorTransform.__copyFrom(this.__worldColorTransform);
				if(!this.__cacheBitmapColorTransform.__isDefault()) {
					this.__cacheBitmapData.colorTransform(this.__cacheBitmapData.rect,this.__cacheBitmapColorTransform);
				}
			}
			if(updateTransform) {
				this.__update(false,true);
				(openfl_geom_Matrix().default).__pool.release(matrix);
				(openfl_geom_Rectangle().default).__pool.release(rect);
				return true;
			} else {
				return false;
			}
		} else if(this.__cacheBitmap != null) {
			if(renderSession.renderType == (lime_graphics_RendererType().default).DOM) {
				this.__cacheBitmap.__renderDOMClear(renderSession);
			}
			this.__cacheBitmap = null;
			this.__cacheBitmapData = null;
			this.__cacheBitmapColorTransform = null;
			return true;
		}
		return false;
	},
	__updateChildren: function(transformOnly) {
		var renderParent = this.__renderParent != null ? this.__renderParent : this.parent;
		this.__renderable = this.get_visible() && this.__scaleX != 0 && this.__scaleY != 0 && !this.__isMask && (renderParent == null || !renderParent.__isMask);
		this.__worldAlpha = this.get_alpha();
		this.__worldBlendMode = this.get_blendMode();
		if(this.__transformDirty) {
			this.__transformDirty = false;
		}
	},
	__updateMask: function(maskGraphics) {
		if(this.__graphics != null) {
			maskGraphics.__commands.overrideMatrix(this.__worldTransform);
			maskGraphics.__commands.append(this.__graphics.__commands);
			maskGraphics.set___dirty(true);
			maskGraphics.__visible = true;
			if(maskGraphics.__bounds == null) {
				maskGraphics.__bounds = new (openfl_geom_Rectangle().default)();
			}
			this.__graphics.__getBounds(maskGraphics.__bounds,(openfl_geom_Matrix().default).__identity);
		}
	},
	__updateTransforms: function(overrideTransform) {
		var overrided = overrideTransform != null;
		var local = overrided ? overrideTransform : this.__transform;
		if(this.__worldTransform == null) {
			this.__worldTransform = new (openfl_geom_Matrix().default)();
		}
		if(this.__renderTransform == null) {
			this.__renderTransform = new (openfl_geom_Matrix().default)();
		}
		var renderParent = this.__renderParent != null ? this.__renderParent : this.parent;
		var parentTransform;
		if(!overrided && this.parent != null) {
			parentTransform = this.parent.__worldTransform;
			this.__worldTransform.a = local.a * parentTransform.a + local.b * parentTransform.c;
			this.__worldTransform.b = local.a * parentTransform.b + local.b * parentTransform.d;
			this.__worldTransform.c = local.c * parentTransform.a + local.d * parentTransform.c;
			this.__worldTransform.d = local.c * parentTransform.b + local.d * parentTransform.d;
			this.__worldTransform.tx = local.tx * parentTransform.a + local.ty * parentTransform.c + parentTransform.tx;
			this.__worldTransform.ty = local.tx * parentTransform.b + local.ty * parentTransform.d + parentTransform.ty;
		} else {
			this.__worldTransform.copyFrom(local);
		}
		if(!overrided && renderParent != null) {
			parentTransform = renderParent.__renderTransform;
			this.__renderTransform.a = local.a * parentTransform.a + local.b * parentTransform.c;
			this.__renderTransform.b = local.a * parentTransform.b + local.b * parentTransform.d;
			this.__renderTransform.c = local.c * parentTransform.a + local.d * parentTransform.c;
			this.__renderTransform.d = local.c * parentTransform.b + local.d * parentTransform.d;
			this.__renderTransform.tx = local.tx * parentTransform.a + local.ty * parentTransform.c + parentTransform.tx;
			this.__renderTransform.ty = local.tx * parentTransform.b + local.ty * parentTransform.d + parentTransform.ty;
		} else {
			this.__renderTransform.copyFrom(local);
		}
		if(this.__scrollRect != null) {
			this.__renderTransform.__translateTransformed(-this.__scrollRect.x,-this.__scrollRect.y);
		}
	},
	get_alpha: function() {
		return this.__alpha;
	},
	set_alpha: function(value) {
		if(value > 1.0) {
			value = 1.0;
		}
		if(value != this.__alpha) {
			this.__setRenderDirty();
		}
		return this.__alpha = value;
	},
	get_blendMode: function() {
		return this.__blendMode;
	},
	set_blendMode: function(value) {
		if(value == null) {
			value = "normal";
		}
		if(value != this.__blendMode) {
			this.__setRenderDirty();
		}
		return this.__blendMode = value;
	},
	get_cacheAsBitmap: function() {
		if(this.__filters == null) {
			return this.__cacheAsBitmap;
		} else {
			return true;
		}
	},
	set_cacheAsBitmap: function(value) {
		this.__setRenderDirty();
		return this.__cacheAsBitmap = value;
	},
	get_cacheAsBitmapMatrix: function() {
		return this.__cacheAsBitmapMatrix;
	},
	set_cacheAsBitmapMatrix: function(value) {
		this.__setRenderDirty();
		return this.__cacheAsBitmapMatrix = value.clone();
	},
	get_filters: function() {
		if(this.__filters == null) {
			return [];
		} else {
			return this.__filters.slice();
		}
	},
	set_filters: function(value) {
		if(value != null && value.length > 0) {
			this.__filters = value;
		} else {
			this.__filters = null;
		}
		this.__setRenderDirty();
		return value;
	},
	get_height: function() {
		var rect = (openfl_geom_Rectangle().default).__pool.get();
		this.__getLocalBounds(rect);
		var height = rect.height;
		(openfl_geom_Rectangle().default).__pool.release(rect);
		return height;
	},
	set_height: function(value) {
		var rect = (openfl_geom_Rectangle().default).__pool.get();
		var matrix = (openfl_geom_Matrix().default).__pool.get();
		matrix.identity();
		this.__getBounds(rect,matrix);
		if(value != rect.height) {
			this.set_scaleY(value / rect.height);
		} else {
			this.set_scaleY(1);
		}
		(openfl_geom_Rectangle().default).__pool.release(rect);
		(openfl_geom_Matrix().default).__pool.release(matrix);
		return value;
	},
	get_loaderInfo: function() {
		if(this.stage != null) {
			return (openfl__$internal_Lib().default).current.__loaderInfo;
		}
		return null;
	},
	get_mask: function() {
		return this.__mask;
	},
	set_mask: function(value) {
		if(value == this.__mask) {
			return value;
		}
		if(value != this.__mask) {
			this.__setTransformDirty();
			this.__setRenderDirty();
		}
		if(this.__mask != null) {
			this.__mask.__isMask = false;
			this.__mask.__maskTarget = null;
			this.__mask.__setTransformDirty();
			this.__mask.__setRenderDirty();
		}
		if(value != null) {
			value.__isMask = true;
			value.__maskTarget = this;
			value.__setWorldTransformInvalid();
		}
		if(this.__cacheBitmap != null && this.__cacheBitmap.get_mask() != value) {
			this.__cacheBitmap.set_mask(value);
		}
		return this.__mask = value;
	},
	get_mouseX: function() {
		var mouseX = this.stage != null ? this.stage.__mouseX : (openfl__$internal_Lib().default).current.stage.__mouseX;
		var mouseY = this.stage != null ? this.stage.__mouseY : (openfl__$internal_Lib().default).current.stage.__mouseY;
		return this.__getRenderTransform().__transformInverseX(mouseX,mouseY);
	},
	get_mouseY: function() {
		var mouseX = this.stage != null ? this.stage.__mouseX : (openfl__$internal_Lib().default).current.stage.__mouseX;
		var mouseY = this.stage != null ? this.stage.__mouseY : (openfl__$internal_Lib().default).current.stage.__mouseY;
		return this.__getRenderTransform().__transformInverseY(mouseX,mouseY);
	},
	get_name: function() {
		return this.__name;
	},
	set_name: function(value) {
		return this.__name = value;
	},
	get_root: function() {
		if(this.stage != null) {
			return (openfl__$internal_Lib().default).current;
		}
		return null;
	},
	get_rotation: function() {
		return this.__rotation;
	},
	set_rotation: function(value) {
		if(value != this.__rotation) {
			this.__rotation = value;
			var radians = this.__rotation * (Math.PI / 180);
			this.__rotationSine = Math.sin(radians);
			this.__rotationCosine = Math.cos(radians);
			this.__transform.a = this.__rotationCosine * this.__scaleX;
			this.__transform.b = this.__rotationSine * this.__scaleX;
			this.__transform.c = -this.__rotationSine * this.__scaleY;
			this.__transform.d = this.__rotationCosine * this.__scaleY;
			this.__setTransformDirty();
		}
		return value;
	},
	get_scaleX: function() {
		return this.__scaleX;
	},
	set_scaleX: function(value) {
		if(value != this.__scaleX) {
			this.__scaleX = value;
			if(this.__transform.b == 0) {
				if(value != this.__transform.a) {
					this.__setTransformDirty();
				}
				this.__transform.a = value;
			} else {
				var a = this.__rotationCosine * value;
				var b = this.__rotationSine * value;
				if(this.__transform.a != a || this.__transform.b != b) {
					this.__setTransformDirty();
				}
				this.__transform.a = a;
				this.__transform.b = b;
			}
		}
		return value;
	},
	get_scaleY: function() {
		return this.__scaleY;
	},
	set_scaleY: function(value) {
		if(value != this.__scaleY) {
			this.__scaleY = value;
			if(this.__transform.c == 0) {
				if(value != this.__transform.d) {
					this.__setTransformDirty();
				}
				this.__transform.d = value;
			} else {
				var c = -this.__rotationSine * value;
				var d = this.__rotationCosine * value;
				if(this.__transform.d != d || this.__transform.c != c) {
					this.__setTransformDirty();
				}
				this.__transform.c = c;
				this.__transform.d = d;
			}
		}
		return value;
	},
	get_scrollRect: function() {
		if(this.__scrollRect == null) {
			return null;
		}
		return this.__scrollRect.clone();
	},
	set_scrollRect: function(value) {
		if(value != this.__scrollRect) {
			this.__setTransformDirty();
			if(DisplayObject.__supportDOM) {
				this.__setRenderDirty();
			}
		}
		return this.__scrollRect = value;
	},
	get_transform: function() {
		if(this.__objectTransform == null) {
			this.__objectTransform = new (openfl_geom_Transform().default)(this);
		}
		return this.__objectTransform;
	},
	set_transform: function(value) {
		if(value == null) {
			throw new (js__$Boot_HaxeError().default)(new (openfl_errors_TypeError().default)("Parameter transform must be non-null."));
		}
		if(this.__objectTransform == null) {
			this.__objectTransform = new (openfl_geom_Transform().default)(this);
		}
		this.__setTransformDirty();
		this.__objectTransform.set_matrix(value.get_matrix());
		this.__objectTransform.set_colorTransform(value.get_colorTransform().__clone());
		return this.__objectTransform;
	},
	get_visible: function() {
		return this.__visible;
	},
	set_visible: function(value) {
		if(value != this.__visible) {
			this.__setRenderDirty();
		}
		return this.__visible = value;
	},
	get_width: function() {
		var rect = (openfl_geom_Rectangle().default).__pool.get();
		this.__getLocalBounds(rect);
		var width = rect.width;
		(openfl_geom_Rectangle().default).__pool.release(rect);
		return width;
	},
	set_width: function(value) {
		var rect = (openfl_geom_Rectangle().default).__pool.get();
		var matrix = (openfl_geom_Matrix().default).__pool.get();
		matrix.identity();
		this.__getBounds(rect,matrix);
		if(value != rect.width) {
			this.set_scaleX(value / rect.width);
		} else {
			this.set_scaleX(1);
		}
		(openfl_geom_Rectangle().default).__pool.release(rect);
		(openfl_geom_Matrix().default).__pool.release(matrix);
		return value;
	},
	get_x: function() {
		return this.__transform.tx;
	},
	set_x: function(value) {
		if(value != this.__transform.tx) {
			this.__setTransformDirty();
		}
		return this.__transform.tx = value;
	},
	get_y: function() {
		return this.__transform.ty;
	},
	set_y: function(value) {
		if(value != this.__transform.ty) {
			this.__setTransformDirty();
		}
		return this.__transform.ty = value;
	}
});
DisplayObject.prototype.__class__ = $hxClasses["openfl.display.DisplayObject"] = DisplayObject;

// Init

Object.defineProperties(DisplayObject.prototype,{ "alpha" : { get : function () { return this.get_alpha (); }, set : function (v) { return this.set_alpha (v); }}, "blendMode" : { get : function () { return this.get_blendMode (); }, set : function (v) { return this.set_blendMode (v); }}, "cacheAsBitmap" : { get : function () { return this.get_cacheAsBitmap (); }, set : function (v) { return this.set_cacheAsBitmap (v); }}, "cacheAsBitmapMatrix" : { get : function () { return this.get_cacheAsBitmapMatrix (); }, set : function (v) { return this.set_cacheAsBitmapMatrix (v); }}, "filters" : { get : function () { return this.get_filters (); }, set : function (v) { return this.set_filters (v); }}, "height" : { get : function () { return this.get_height (); }, set : function (v) { return this.set_height (v); }}, "loaderInfo" : { get : function () { return this.get_loaderInfo (); }}, "mask" : { get : function () { return this.get_mask (); }, set : function (v) { return this.set_mask (v); }}, "mouseX" : { get : function () { return this.get_mouseX (); }}, "mouseY" : { get : function () { return this.get_mouseY (); }}, "name" : { get : function () { return this.get_name (); }, set : function (v) { return this.set_name (v); }}, "root" : { get : function () { return this.get_root (); }}, "rotation" : { get : function () { return this.get_rotation (); }, set : function (v) { return this.set_rotation (v); }}, "scaleX" : { get : function () { return this.get_scaleX (); }, set : function (v) { return this.set_scaleX (v); }}, "scaleY" : { get : function () { return this.get_scaleY (); }, set : function (v) { return this.set_scaleY (v); }}, "scrollRect" : { get : function () { return this.get_scrollRect (); }, set : function (v) { return this.set_scrollRect (v); }}, "transform" : { get : function () { return this.get_transform (); }, set : function (v) { return this.set_transform (v); }}, "visible" : { get : function () { return this.get_visible (); }, set : function (v) { return this.set_visible (v); }}, "width" : { get : function () { return this.get_width (); }, set : function (v) { return this.set_width (v); }}, "x" : { get : function () { return this.get_x (); }, set : function (v) { return this.set_x (v); }}, "y" : { get : function () { return this.get_y (); }, set : function (v) { return this.set_y (v); }}});

// Statics


DisplayObject.__broadcastEvents = new (haxe_ds_StringMap().default)()
DisplayObject.__instanceCount = 0
DisplayObject.__tempStack = new (lime_utils_ObjectPool().default)(function() {
	return (openfl__$Vector_Vector_$Impl_$().default)._new();
},function(stack) {
	stack.set_length(0);
})

// Export

exports.default = DisplayObject;