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 AsTouch getTouch(AsDisplayObject target, String phase) { AsVector <AsTouch> touchesFound = getTouches(target, phase); if (touchesFound.getLength() > 0) { return(touchesFound[0]); } else { return(null); } }
public virtual AsTouch getTouch(AsDisplayObject target, String phase) { getTouches(target, phase, sTouches); if (sTouches.getLength() != 0) { AsTouch touch = sTouches[0]; sTouches.setLength(0); return(touch); } else { return(null); } }
public virtual void dispatchEvent(AsEvent _event) { AsVector <AsEventListenerCallback> listeners = (AsVector <AsEventListenerCallback>)(mEventListeners != null ? mEventListeners[_event.getType()] : null); if (listeners == null && !_event.getBubbles()) { return; } AsEventDispatcher previousTarget = _event.getTarget(); if (previousTarget == null || _event.getCurrentTarget() != null) { _event.setTarget(this); } bool stopImmediatePropagation = false; uint numListeners = (uint)(listeners == null ? 0 : listeners.getLength()); if (numListeners != 0) { _event.setCurrentTarget(this); int i = 0; for (; i < numListeners; ++i) { AsEventListenerCallback listener = listeners[i]; listener(_event); if (_event.getStopsImmediatePropagation()) { stopImmediatePropagation = true; break; } } } if (!stopImmediatePropagation && _event.getBubbles() && !_event.getStopsPropagation() && this is AsDisplayObject) { AsDisplayObject targetDisplayObject = this as AsDisplayObject; if (targetDisplayObject.getParent() != null) { _event.setCurrentTarget(null); targetDisplayObject.getParent().dispatchEvent(_event); } } if (previousTarget != null) { _event.setTarget(previousTarget); } }
public virtual AsVector <AsTouch> getTouches(AsDisplayObject target, String phase) { AsVector <AsTouch> touchesFound = new AsVector <AsTouch>(); int numTouches = (int)(mTouches.getLength()); int i = 0; for (; i < numTouches; ++i) { AsTouch touch = mTouches[i]; bool correctTarget = (touch.getTarget() == target) || ((target is AsDisplayObjectContainer) && target as AsDisplayObjectContainer.contains(touch.getTarget())); bool correctPhase = phase == null || phase == touch.getPhase(); if (correctTarget && correctPhase) { touchesFound.push(touch); } } return(touchesFound); }
private void updateBubbleChain() { if (mTarget != null) { int length = 1; AsDisplayObject element = mTarget; mBubbleChain.setLength(0); mBubbleChain[0] = element; while ((element = element.getParent()) != null) { mBubbleChain[length++] = element; } } else { mBubbleChain.setLength(0); } }
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; }
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 bool interactsWith(AsDisplayObject target) { if (getTouch(target) == null) { return(false); } else { AsVector <AsTouch> touches = getTouches(target); int i = (int)(touches.getLength() - 1); for (; i >= 0; --i) { if (touches[i].getPhase() != AsTouchPhase.ENDED) { return(true); } } return(false); } }
public virtual AsVector <AsTouch> getTouches(AsDisplayObject target, String phase, AsVector <AsTouch> result) { if (result == null) { result = new AsVector <AsTouch>(); } AsVector <AsTouch> allTouches = getData() as AsVector <AsTouch>; int numTouches = (int)(allTouches.getLength()); int i = 0; for (; i < numTouches; ++i) { AsTouch touch = allTouches[i]; bool correctTarget = (touch.getTarget() == target) || ((target is AsDisplayObjectContainer) && target as AsDisplayObjectContainer.contains(touch.getTarget())); bool correctPhase = phase == null || phase == touch.getPhase(); if (correctTarget && correctPhase) { result.push(touch); } } return(result); }
public virtual void draw(AsDisplayObject _object) { draw(_object, null, 1.0f, 0); }
public virtual void setTarget(AsDisplayObject _value) { mTarget = _value; updateBubbleChain(); }
public virtual void transformMatrix(AsDisplayObject _object) { AsMatrixUtil.prependMatrix(mModelViewMatrix, _object.getTransformationMatrix()); }
public static void transformMatrixForObject(AsMatrix matrix, AsDisplayObject _object) { AsMatrixUtil.prependMatrix(matrix, _object.getTransformationMatrix()); }
public virtual AsTouch getTouch(AsDisplayObject target) { return(getTouch(target, null)); }
private AsQuadBatch renderPasses(AsDisplayObject _object, AsRenderSupport support, float parentAlpha) { return(renderPasses(_object, support, parentAlpha, false)); }
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); } }
public AsTouchData(AsTouch touch, AsDisplayObject target) { this.touch = touch; this.target = target; }
public virtual AsVector <AsTouch> getTouches(AsDisplayObject target) { return(getTouches(target, null)); }