public override void render(AsRenderSupport support, float parentAlpha) { float alpha = parentAlpha * this.getAlpha(); int numChildren = (int)(mChildren.getLength()); String blendMode = support.getBlendMode(); int i = 0; for (; i < numChildren; ++i) { AsDisplayObject child = mChildren[i]; if (child.getHasVisibleArea()) { AsFragmentFilter filter = child.getFilter(); support.pushMatrix(); support.transformMatrix(child); support.setBlendMode(child.getBlendMode()); if (filter != null) { filter.render(child, support, alpha); } else { child.render(support, alpha); } support.setBlendMode(blendMode); support.popMatrix(); } } }
public virtual AsDisplayObject addChildAt(AsDisplayObject child, int index) { int numChildren = (int)(mChildren.getLength()); if(index >= 0 && index <= numChildren) { child.removeFromParent(); if(index == numChildren) { mChildren.push(child); } else { mChildren.splice(index, (uint)(0), child); } child.setParent(this); child.dispatchEventWith(AsEvent.ADDED, true); if(getStage() != null) { AsDisplayObjectContainer container = child as AsDisplayObjectContainer; if(container != null) { container.broadcastEventWith(AsEvent.ADDED_TO_STAGE); } else { child.dispatchEventWith(AsEvent.ADDED_TO_STAGE); } } return child; } else { throw new AsRangeError("Invalid child index"); } }
public virtual AsDisplayObject removeChildAt(int index, bool dispose) { if (index >= 0 && index < getNumChildren()) { AsDisplayObject child = mChildren[index]; child.dispatchEventWith(AsEvent.REMOVED, true); if (getStage() != null) { AsDisplayObjectContainer container = child as AsDisplayObjectContainer; if (container != null) { container.broadcastEventWith(AsEvent.REMOVED_FROM_STAGE); } else { child.dispatchEventWith(AsEvent.REMOVED_FROM_STAGE); } } child.setParent(null); index = mChildren.indexOf(child); if (index >= 0) { mChildren.splice(index, (uint)(1)); } if (dispose) { child.dispose(); } return(child); } else { throw new AsRangeError("Invalid child index"); } }
public virtual void swapChildrenAt(int index1, int index2) { AsDisplayObject child1 = getChildAt(index1); AsDisplayObject child2 = getChildAt(index2); mChildren[index1] = child2; mChildren[index2] = child1; }
public virtual AsDisplayObject get_base() { AsDisplayObject currentObject = this; while (currentObject.mParent != null) { currentObject = currentObject.mParent; } return(currentObject); }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if (resultRect == null) { resultRect = new AsRectangle(); } AsMatrix transformationMatrix = targetSpace == this ? null : getTransformationMatrix(targetSpace, sHelperMatrix); return(mVertexData.getBounds(transformationMatrix, 0, mNumQuads * 4, resultRect)); }
public virtual AsDisplayObject removeChild(AsDisplayObject child, bool dispose) { int childIndex = getChildIndex(child); if (childIndex != -1) { removeChildAt(childIndex, dispose); } return(child); }
public AsTouch(int id, float globalX, float globalY, String phase, AsDisplayObject target) { mID = id; mGlobalX = mPreviousGlobalX = globalX; mGlobalY = mPreviousGlobalY = globalY; mTapCount = 0; mPhase = phase; mTarget = target; mPressure = mWidth = mHeight = 1.0f; mBubbleChain = new AsVector<AsEventDispatcher>(); }
public virtual void setChildIndex(AsDisplayObject child, int index) { int oldIndex = getChildIndex(child); if (oldIndex == -1) { throw new AsArgumentError("Not a child of this container"); } mChildren.splice(oldIndex, (uint)(1)); mChildren.splice(index, (uint)(0), child); }
public virtual void swapChildren(AsDisplayObject child1, AsDisplayObject child2) { int index1 = getChildIndex(child1); int index2 = getChildIndex(child2); if (index1 == -1 || index2 == -1) { throw new AsArgumentError("Not a child of this container"); } swapChildrenAt(index1, index2); }
public virtual bool contains(AsDisplayObject child) { while (child != null) { if (child == this) { return(true); } else { child = child.getParent(); } } return(false); }
public AsTextField(int width, int height, String text, String fontName, float fontSize, uint color, bool bold) { mText = text != null ? text : ""; mFontSize = fontSize; mColor = color; mHAlign = AsHAlign.CENTER; mVAlign = AsVAlign.CENTER; mBorder = null; mKerning = true; mBold = bold; this.setFontName(fontName); mHitArea = new AsQuad(width, height); mHitArea.setAlpha(0.0f); addChild(mHitArea); addEventListener(AsEvent.FLATTEN, onFlatten); }
public AsTextField(int width, int height, String text, String fontName, float fontSize, uint color, bool bold) { mText = text != null ? text : ""; mFontSize = fontSize; mColor = color; mHAlign = AsHAlign.CENTER; mVAlign = AsVAlign.CENTER; mBorder = null; mKerning = true; mBold = bold; this.setFontName(fontName); mHitArea = new AsQuad(width, height); mHitArea.setAlpha(0.0f); addChild(mHitArea); addEventListener(AsEvent.FLATTEN, onFlatten); }
public virtual AsDisplayObject getRoot() { AsDisplayObject currentObject = this; while (currentObject.mParent != null) { if (currentObject.mParent is AsStage) { return(currentObject); } else { currentObject = currentObject.getParent(); } } return(null); }
public virtual void setParent(AsDisplayObjectContainer _value) { AsDisplayObject ancestor = _value; while (ancestor != this && ancestor != null) { ancestor = ancestor.mParent; } if (ancestor == this) { throw new AsArgumentError("An object cannot be added as a child to itself or one " + "of its children (or children's children, etc.)"); } else { mParent = _value; } }
public override AsDisplayObject hitTest(AsPoint localPoint, bool forTouch) { if (forTouch && (!getVisible() || !getTouchable())) { return(null); } if (localPoint.x < 0 || localPoint.x > mWidth || localPoint.y < 0 || localPoint.y > mHeight) { return(null); } AsDisplayObject target = base.hitTest(localPoint, forTouch); if (target == null) { target = this; } return(target); }
private void getChildEventListeners(AsDisplayObject _object, String eventType, AsVector <AsDisplayObject> listeners) { AsDisplayObjectContainer container = _object as AsDisplayObjectContainer; if (_object.hasEventListener(eventType)) { listeners.push(_object); } if (container != null) { AsVector <AsDisplayObject> children = container.mChildren; int numChildren = (int)(children.getLength()); int i = 0; for (; i < numChildren; ++i) { getChildEventListeners(children[i], eventType, listeners); } } }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if (resultRect == null) { resultRect = new AsRectangle(); } int numChildren = (int)(mChildren.getLength()); if (numChildren == 0) { getTransformationMatrix(targetSpace, sHelperMatrix); AsMatrixUtil.transformCoords(sHelperMatrix, 0.0f, 0.0f, sHelperPoint); resultRect.setTo(sHelperPoint.x, sHelperPoint.y, 0, 0); return(resultRect); } else { if (numChildren == 1) { return(mChildren[0].getBounds(targetSpace, resultRect)); } else { float minX = AsNumber.MAX_VALUE; float maxX = -AsNumber.MAX_VALUE; float minY = AsNumber.MAX_VALUE; float maxY = -AsNumber.MAX_VALUE; int i = 0; for (; i < numChildren; ++i) { mChildren[i].getBounds(targetSpace, resultRect); minX = minX < resultRect.x ? minX : resultRect.x; maxX = maxX > resultRect.getRight() ? maxX : resultRect.getRight(); minY = minY < resultRect.y ? minY : resultRect.y; maxY = maxY > resultRect.getBottom() ? maxY : resultRect.getBottom(); } resultRect.setTo(minX, minY, maxX - minX, maxY - minY); return(resultRect); } } }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if (resultRect == null) { resultRect = new AsRectangle(); } if (targetSpace == this) { mVertexData.getPosition(3, sHelperPoint); resultRect.setTo(0.0f, 0.0f, sHelperPoint.x, sHelperPoint.y); } else { if (targetSpace == getParent() && getRotation() == 0.0f) { float scaleX = this.getScaleX(); float scaleY = this.getScaleY(); mVertexData.getPosition(3, sHelperPoint); resultRect.setTo(getX() - getPivotX() * scaleX, getY() - getPivotY() * scaleY, sHelperPoint.x * scaleX, sHelperPoint.y * scaleY); if (scaleX < 0) { resultRect.width = resultRect.width * -1; resultRect.x = resultRect.x - resultRect.width; } if (scaleY < 0) { resultRect.height = resultRect.height * -1; resultRect.y = resultRect.y - resultRect.height; } } else { getTransformationMatrix(targetSpace, sHelperMatrix); mVertexData.getBounds(sHelperMatrix, 0, 4, resultRect); } } return(resultRect); }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if(resultRect == null) { resultRect = new AsRectangle(); } if(targetSpace == this) { mVertexData.getPosition(3, sHelperPoint); resultRect.setTo(0.0f, 0.0f, sHelperPoint.x, sHelperPoint.y); } else { if(targetSpace == getParent() && getRotation() == 0.0f) { float scaleX = this.getScaleX(); float scaleY = this.getScaleY(); mVertexData.getPosition(3, sHelperPoint); resultRect.setTo(getX() - getPivotX() * scaleX, getY() - getPivotY() * scaleY, sHelperPoint.x * scaleX, sHelperPoint.y * scaleY); if(scaleX < 0) { resultRect.width = resultRect.width * -1; resultRect.x = resultRect.x - resultRect.width; } if(scaleY < 0) { resultRect.height = resultRect.height * -1; resultRect.y = resultRect.y - resultRect.height; } } else { getTransformationMatrix(targetSpace, sHelperMatrix); mVertexData.getBounds(sHelperMatrix, 0, 4, resultRect); } } return resultRect; }
public virtual AsDisplayObject addChildAt(AsDisplayObject child, int index) { int numChildren = (int)(mChildren.getLength()); if (index >= 0 && index <= numChildren) { child.removeFromParent(); if (index == numChildren) { mChildren.push(child); } else { mChildren.splice(index, (uint)(0), child); } child.setParent(this); child.dispatchEventWith(AsEvent.ADDED, true); if (getStage() != null) { AsDisplayObjectContainer container = child as AsDisplayObjectContainer; if (container != null) { container.broadcastEventWith(AsEvent.ADDED_TO_STAGE); } else { child.dispatchEventWith(AsEvent.ADDED_TO_STAGE); } } return(child); } else { throw new AsRangeError("Invalid child index"); } }
public override AsDisplayObject hitTest(AsPoint localPoint, bool forTouch) { if (forTouch && (!getVisible() || !getTouchable())) { return(null); } float localX = localPoint.x; float localY = localPoint.y; int numChildren = (int)(mChildren.getLength()); int i = numChildren - 1; for (; i >= 0; --i) { AsDisplayObject child = mChildren[i]; getTransformationMatrix(child, sHelperMatrix); AsMatrixUtil.transformCoords(sHelperMatrix, localX, localY, sHelperPoint); AsDisplayObject target = child.hitTest(sHelperPoint, forTouch); if (target != null) { return(target); } } return(null); }
public virtual int getChildIndex(AsDisplayObject child) { return(mChildren.indexOf(child)); }
private void getChildEventListeners(AsDisplayObject _object, String eventType, AsVector<AsDisplayObject> listeners) { AsDisplayObjectContainer container = _object as AsDisplayObjectContainer; if(_object.hasEventListener(eventType)) { listeners.push(_object); } if(container != null) { AsVector<AsDisplayObject> children = container.mChildren; int numChildren = (int)(children.getLength()); int i = 0; for (; i < numChildren; ++i) { getChildEventListeners(children[i], eventType, listeners); } } }
public virtual void setChildIndex(AsDisplayObject child, int index) { int oldIndex = getChildIndex(child); if(oldIndex == -1) { throw new AsArgumentError("Not a child of this container"); } mChildren.splice(oldIndex, (uint)(1)); mChildren.splice(index, (uint)(0), child); }
public virtual AsDisplayObject removeChild(AsDisplayObject child, bool dispose) { int childIndex = getChildIndex(child); if(childIndex != -1) { removeChildAt(childIndex, dispose); } return child; }
public virtual AsMatrix getTransformationMatrix(AsDisplayObject targetSpace) { return(getTransformationMatrix(targetSpace, null)); }
public virtual AsPoint getLocation(AsDisplayObject space, AsPoint resultPoint) { if(resultPoint == null) { resultPoint = new AsPoint(); } mTarget.get_base().getTransformationMatrix(space, sHelperMatrix); return AsMatrixUtil.transformCoords(sHelperMatrix, mGlobalX, mGlobalY, resultPoint); }
public virtual void setTarget(AsDisplayObject _value) { mTarget = _value; updateBubbleChain(); }
private static int compileObject(AsDisplayObject _object, AsVector<AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix, float alpha, String blendMode, bool ignoreCurrentFilter) { int i = 0; AsQuadBatch quadBatch = null; bool isRootObject = false; float objectAlpha = _object.getAlpha(); AsDisplayObjectContainer container = _object as AsDisplayObjectContainer; AsQuad quad = _object as AsQuad; AsQuadBatch batch = _object as AsQuadBatch; AsFragmentFilter filter = _object.getFilter(); if(quadBatchID == -1) { isRootObject = true; quadBatchID = 0; objectAlpha = 1.0f; blendMode = _object.getBlendMode(); if(quadBatches.getLength() == 0) { quadBatches.push(new AsQuadBatch()); } else { quadBatches[0].reset(); } } if(filter != null && !ignoreCurrentFilter) { if(filter.getMode() == AsFragmentFilterMode.ABOVE) { quadBatchID = compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, true); } quadBatchID = compileObject(filter.compile(_object), quadBatches, quadBatchID, transformationMatrix, alpha, blendMode); if(filter.getMode() == AsFragmentFilterMode.BELOW) { quadBatchID = compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, true); } } else { if(container != null) { int numChildren = container.getNumChildren(); AsMatrix childMatrix = new AsMatrix(); for (i = 0; i < numChildren; ++i) { AsDisplayObject child = container.getChildAt(i); bool childVisible = child.getAlpha() != 0.0f && child.getVisible() && child.getScaleX() != 0.0f && child.getScaleY() != 0.0f; if(childVisible) { String childBlendMode = child.getBlendMode() == AsBlendMode.AUTO ? blendMode : child.getBlendMode(); childMatrix.copyFrom(transformationMatrix); AsRenderSupport.transformMatrixForObject(childMatrix, child); quadBatchID = compileObject(child, quadBatches, quadBatchID, childMatrix, alpha * objectAlpha, childBlendMode); } } } else { if(quad != null || batch != null) { AsTexture texture = null; String smoothing = null; bool tinted = false; int numQuads = 0; if(quad != null) { AsImage image = quad as AsImage; texture = image != null ? image.getTexture() : null; smoothing = image != null ? image.getSmoothing() : null; tinted = quad.getTinted(); numQuads = 1; } else { texture = batch.mTexture; smoothing = batch.mSmoothing; tinted = batch.mTinted; numQuads = batch.mNumQuads; } quadBatch = quadBatches[quadBatchID]; if(quadBatch.isStateChange(tinted, alpha * objectAlpha, texture, smoothing, blendMode, numQuads)) { quadBatchID++; if(quadBatches.getLength() <= quadBatchID) { quadBatches.push(new AsQuadBatch()); } quadBatch = quadBatches[quadBatchID]; quadBatch.reset(); } if(quad != null) { quadBatch.addQuad(quad, alpha, texture, smoothing, transformationMatrix, blendMode); } else { quadBatch.addQuadBatch(batch, alpha, transformationMatrix, blendMode); } } else { throw new AsError("Unsupported display object: " + AsGlobal.getQualifiedClassName(_object)); } } } if(isRootObject) { for (i = (int)(quadBatches.getLength() - 1); i > quadBatchID; --i) { quadBatches.pop().dispose(); } } return quadBatchID; }
public virtual AsMatrix getTransformationMatrix(AsDisplayObject targetSpace, AsMatrix resultMatrix) { AsDisplayObject commonParent = null; AsDisplayObject currentObject = null; if (resultMatrix != null) { resultMatrix.identity(); } else { resultMatrix = new AsMatrix(); } if (targetSpace == this) { return(resultMatrix); } else { if (targetSpace == mParent || (targetSpace == null && mParent == null)) { resultMatrix.copyFrom(getTransformationMatrix()); return(resultMatrix); } else { if (targetSpace == null || targetSpace == get_base()) { currentObject = this; while (currentObject != targetSpace) { resultMatrix.concat(currentObject.getTransformationMatrix()); currentObject = currentObject.mParent; } return(resultMatrix); } else { if (targetSpace.mParent == this) { targetSpace.getTransformationMatrix(this, resultMatrix); resultMatrix.invert(); return(resultMatrix); } } } } commonParent = null; currentObject = this; while (currentObject != null) { sAncestors.push(currentObject); currentObject = currentObject.mParent; } currentObject = targetSpace; while (currentObject != null && sAncestors.indexOf(currentObject) == -1) { currentObject = currentObject.mParent; } sAncestors.setLength(0); if (currentObject != null) { commonParent = currentObject; } else { throw new AsArgumentError("Object not connected to target"); } currentObject = this; while (currentObject != commonParent) { resultMatrix.concat(currentObject.getTransformationMatrix()); currentObject = currentObject.mParent; } if (commonParent == targetSpace) { return(resultMatrix); } sHelperMatrix.identity(); currentObject = targetSpace; while (currentObject != commonParent) { sHelperMatrix.concat(currentObject.getTransformationMatrix()); currentObject = currentObject.mParent; } sHelperMatrix.invert(); resultMatrix.concat(sHelperMatrix); return(resultMatrix); }
public virtual AsDisplayObject removeChild(AsDisplayObject child) { return(removeChild(child, false)); }
public virtual AsQuadBatch compile(AsDisplayObject _object) { if(mCache != null) { return mCache; } else { AsRenderSupport renderSupport = null; AsStage stage = _object.getStage(); if(stage == null) { throw new AsError("Filtered object must be on the stage."); } renderSupport = new AsRenderSupport(); _object.getTransformationMatrix(stage, renderSupport.getModelViewMatrix()); return renderPasses(_object, renderSupport, 1.0f, true); } }
public virtual void render(AsDisplayObject _object, AsRenderSupport support, float parentAlpha) { if(getMode() == AsFragmentFilterMode.ABOVE) { _object.render(support, parentAlpha); } if(mCacheRequested) { mCacheRequested = false; mCache = renderPasses(_object, support, 1.0f, true); disposePassTextures(); } if(mCache != null) { mCache.render(support, _object.getAlpha() * parentAlpha); } else { renderPasses(_object, support, parentAlpha, false); } if(getMode() == AsFragmentFilterMode.BELOW) { _object.render(support, parentAlpha); } }
public virtual AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { throw new AsAbstractMethodError("Method needs to be implemented in subclass"); return(null); }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if(resultRect == null) { resultRect = new AsRectangle(); } AsMatrix transformationMatrix = targetSpace == this ? null : getTransformationMatrix(targetSpace, sHelperMatrix); return mVertexData.getBounds(transformationMatrix, 0, mNumQuads * 4, resultRect); }
private AsQuadBatch renderPasses(AsDisplayObject _object, AsRenderSupport support, float parentAlpha, bool intoCache) { AsTexture cacheTexture = null; AsStage stage = _object.getStage(); AsContext3D context = AsStarling.getContext(); float scale = AsStarling.getCurrent().getContentScaleFactor(); if(stage == null) { throw new AsError("Filtered object must be on the stage."); } if(context == null) { throw new AsMissingContextError(); } support.finishQuadBatch(); support.raiseDrawCount((uint)(mNumPasses)); support.pushMatrix(); support.setBlendMode(AsBlendMode.NORMAL); AsRenderSupport.setBlendFactors(PMA); mProjMatrix.copyFrom(support.getProjectionMatrix()); AsTexture previousRenderTarget = support.getRenderTarget(); if(previousRenderTarget != null) { throw new AsIllegalOperationError("It's currently not possible to stack filters! " + "This limitation will be removed in a future Stage3D version."); } calculateBounds(_object, stage, sBounds); updateBuffers(context, sBounds); updatePassTextures((int)(sBounds.width), (int)(sBounds.height), mResolution * scale); if(intoCache) { cacheTexture = AsTexture.empty((int)(sBounds.width), (int)(sBounds.height), PMA, true, mResolution * scale); } support.setRenderTarget(mPassTextures[0]); support.clear(); support.setOrthographicProjection(sBounds.x, sBounds.y, sBounds.width, sBounds.height); _object.render(support, parentAlpha); support.finishQuadBatch(); AsRenderSupport.setBlendFactors(PMA); support.loadIdentity(); context.setVertexBufferAt(0, mVertexBuffer, AsVertexData.POSITION_OFFSET, AsContext3DVertexBufferFormat.FLOAT_2); context.setVertexBufferAt(1, mVertexBuffer, AsVertexData.TEXCOORD_OFFSET, AsContext3DVertexBufferFormat.FLOAT_2); int i = 0; for (; i < mNumPasses; ++i) { if(i < mNumPasses - 1) { support.setRenderTarget(getPassTexture(i + 1)); support.clear(); } else { if(intoCache) { support.setRenderTarget(cacheTexture); support.clear(); } else { support.setRenderTarget(previousRenderTarget); support.getProjectionMatrix().copyFrom(mProjMatrix); support.translateMatrix(mOffsetX, mOffsetY); support.setBlendMode(_object.getBlendMode()); support.applyBlendMode(PMA); } } AsTexture passTexture = getPassTexture(i); context.setProgramConstantsFromMatrix(AsContext3DProgramType.VERTEX, 0, support.getMvpMatrix3D(), true); context.setTextureAt(0, passTexture.get_base()); activate(i, context, passTexture); context.drawTriangles(mIndexBuffer, 0, 2); deactivate(i, context, passTexture); } context.setVertexBufferAt(0, null); context.setVertexBufferAt(1, null); context.setTextureAt(0, null); support.popMatrix(); if(intoCache) { support.setRenderTarget(previousRenderTarget); support.getProjectionMatrix().copyFrom(mProjMatrix); AsQuadBatch quadBatch = new AsQuadBatch(); AsImage image = new AsImage(cacheTexture); stage.getTransformationMatrix(_object, sTransformationMatrix); AsMatrixUtil.prependTranslation(sTransformationMatrix, sBounds.x + mOffsetX, sBounds.y + mOffsetY); quadBatch.addImage(image, 1.0f, sTransformationMatrix); return quadBatch; } else { return null; } }
private static int compileObject(AsDisplayObject _object, AsVector<AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix) { return compileObject(_object, quadBatches, quadBatchID, transformationMatrix, 1.0f, null, false); }
private AsVector<AsEventDispatcher> getBubbleChain(AsDisplayObject target, AsVector<AsEventDispatcher> result) { AsDisplayObject element = target; int length = 1; result.setLength(length); result[0] = target; while((element = element.getParent()) != null) { result[length++] = element; } return result; }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { if(resultRect == null) { resultRect = new AsRectangle(); } int numChildren = (int)(mChildren.getLength()); if(numChildren == 0) { getTransformationMatrix(targetSpace, sHelperMatrix); AsMatrixUtil.transformCoords(sHelperMatrix, 0.0f, 0.0f, sHelperPoint); resultRect.setTo(sHelperPoint.x, sHelperPoint.y, 0, 0); return resultRect; } else { if(numChildren == 1) { return mChildren[0].getBounds(targetSpace, resultRect); } else { float minX = AsNumber.MAX_VALUE; float maxX = -AsNumber.MAX_VALUE; float minY = AsNumber.MAX_VALUE; float maxY = -AsNumber.MAX_VALUE; int i = 0; for (; i < numChildren; ++i) { mChildren[i].getBounds(targetSpace, resultRect); minX = minX < resultRect.x ? minX : resultRect.x; maxX = maxX > resultRect.getRight() ? maxX : resultRect.getRight(); minY = minY < resultRect.y ? minY : resultRect.y; maxY = maxY > resultRect.getBottom() ? maxY : resultRect.getBottom(); } resultRect.setTo(minX, minY, maxX - minX, maxY - minY); return resultRect; } } }
public virtual AsPoint getLocation(AsDisplayObject space) { return getLocation(space, null); }
private AsQuadBatch renderPasses(AsDisplayObject _object, AsRenderSupport support, float parentAlpha) { return renderPasses(_object, support, parentAlpha, false); }
public virtual bool contains(AsDisplayObject child) { while(child != null) { if(child == this) { return true; } else { child = child.getParent(); } } return false; }
private static int compileObject(AsDisplayObject _object, AsVector <AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix, float alpha, String blendMode) { return(compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, false)); }
public virtual int getChildIndex(AsDisplayObject child) { return mChildren.indexOf(child); }
private static int compileObject(AsDisplayObject _object, AsVector <AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix) { return(compileObject(_object, quadBatches, quadBatchID, transformationMatrix, 1.0f, null, false)); }
public virtual AsDisplayObject removeChild(AsDisplayObject child) { return removeChild(child, false); }
public override AsRectangle getBounds(AsDisplayObject targetSpace, AsRectangle resultRect) { return(mHitArea.getBounds(targetSpace, resultRect)); }
public virtual void swapChildren(AsDisplayObject child1, AsDisplayObject child2) { int index1 = getChildIndex(child1); int index2 = getChildIndex(child2); if(index1 == -1 || index2 == -1) { throw new AsArgumentError("Not a child of this container"); } swapChildrenAt(index1, index2); }
public virtual AsRectangle getBounds(AsDisplayObject targetSpace) { return(getBounds(targetSpace, null)); }
public virtual AsDisplayObject addChild(AsDisplayObject child) { addChildAt(child, getNumChildren()); return child; }
public virtual AsDisplayObject addChild(AsDisplayObject child) { addChildAt(child, getNumChildren()); return(child); }
public virtual AsPoint getMovement(AsDisplayObject space, AsPoint resultPoint) { if(resultPoint == null) { resultPoint = new AsPoint(); } getLocation(space, resultPoint); float x = resultPoint.x; float y = resultPoint.y; getPreviousLocation(space, resultPoint); resultPoint.setTo(x - resultPoint.x, y - resultPoint.y); return resultPoint; }
public virtual AsPoint getMovement(AsDisplayObject space) { return getMovement(space, null); }
public virtual AsRectangle getBounds(AsDisplayObject targetSpace) { return getBounds(targetSpace, null); }
private void calculateBounds(AsDisplayObject _object, AsStage stage, AsRectangle resultRect) { if(_object == stage || _object == AsStarling.getCurrent().getRoot()) { resultRect.setTo(0, 0, stage.getStageWidth(), stage.getStageHeight()); } else { _object.getBounds(stage, resultRect); } float deltaMargin = mResolution == 1.0f ? 0.0f : 1.0f / mResolution; resultRect.x = resultRect.x - mMarginX + deltaMargin; resultRect.y = resultRect.y - mMarginY + deltaMargin; resultRect.width = resultRect.width + 2 * (mMarginX + deltaMargin); resultRect.height = resultRect.height + 2 * (mMarginY + deltaMargin); resultRect.width = AsGlobal.getNextPowerOfTwo((int)(resultRect.width * mResolution)) / mResolution; resultRect.height = AsGlobal.getNextPowerOfTwo((int)(resultRect.height * mResolution)) / mResolution; }
private static int compileObject(AsDisplayObject _object, AsVector<AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix, float alpha, String blendMode) { return compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, false); }
public static void compile(AsDisplayObject _object, AsVector <AsQuadBatch> quadBatches) { compileObject(_object, quadBatches, -1, new AsMatrix()); }
public static void compile(AsDisplayObject _object, AsVector<AsQuadBatch> quadBatches) { compileObject(_object, quadBatches, -1, new AsMatrix()); }
private static int compileObject(AsDisplayObject _object, AsVector <AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix, float alpha, String blendMode, bool ignoreCurrentFilter) { int i = 0; AsQuadBatch quadBatch = null; bool isRootObject = false; float objectAlpha = _object.getAlpha(); AsDisplayObjectContainer container = _object as AsDisplayObjectContainer; AsQuad quad = _object as AsQuad; AsQuadBatch batch = _object as AsQuadBatch; AsFragmentFilter filter = _object.getFilter(); if (quadBatchID == -1) { isRootObject = true; quadBatchID = 0; objectAlpha = 1.0f; blendMode = _object.getBlendMode(); if (quadBatches.getLength() == 0) { quadBatches.push(new AsQuadBatch()); } else { quadBatches[0].reset(); } } if (filter != null && !ignoreCurrentFilter) { if (filter.getMode() == AsFragmentFilterMode.ABOVE) { quadBatchID = compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, true); } quadBatchID = compileObject(filter.compile(_object), quadBatches, quadBatchID, transformationMatrix, alpha, blendMode); if (filter.getMode() == AsFragmentFilterMode.BELOW) { quadBatchID = compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, true); } } else { if (container != null) { int numChildren = container.getNumChildren(); AsMatrix childMatrix = new AsMatrix(); for (i = 0; i < numChildren; ++i) { AsDisplayObject child = container.getChildAt(i); bool childVisible = child.getAlpha() != 0.0f && child.getVisible() && child.getScaleX() != 0.0f && child.getScaleY() != 0.0f; if (childVisible) { String childBlendMode = child.getBlendMode() == AsBlendMode.AUTO ? blendMode : child.getBlendMode(); childMatrix.copyFrom(transformationMatrix); AsRenderSupport.transformMatrixForObject(childMatrix, child); quadBatchID = compileObject(child, quadBatches, quadBatchID, childMatrix, alpha * objectAlpha, childBlendMode); } } } else { if (quad != null || batch != null) { AsTexture texture = null; String smoothing = null; bool tinted = false; int numQuads = 0; if (quad != null) { AsImage image = quad as AsImage; texture = image != null?image.getTexture() : null; smoothing = image != null?image.getSmoothing() : null; tinted = quad.getTinted(); numQuads = 1; } else { texture = batch.mTexture; smoothing = batch.mSmoothing; tinted = batch.mTinted; numQuads = batch.mNumQuads; } quadBatch = quadBatches[quadBatchID]; if (quadBatch.isStateChange(tinted, alpha * objectAlpha, texture, smoothing, blendMode, numQuads)) { quadBatchID++; if (quadBatches.getLength() <= quadBatchID) { quadBatches.push(new AsQuadBatch()); } quadBatch = quadBatches[quadBatchID]; quadBatch.reset(); } if (quad != null) { quadBatch.addQuad(quad, alpha, texture, smoothing, transformationMatrix, blendMode); } else { quadBatch.addQuadBatch(batch, alpha, transformationMatrix, blendMode); } } else { throw new AsError("Unsupported display object: " + AsGlobal.getQualifiedClassName(_object)); } } } if (isRootObject) { for (i = (int)(quadBatches.getLength() - 1); i > quadBatchID; --i) { quadBatches.pop().dispose(); } } return(quadBatchID); }