Loading tools/layoutlib/bridge/src/android/animation/AnimationThread.java +0 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import com.android.layoutlib.bridge.impl.RenderSessionImpl; import android.os.Handler; import android.os.Handler_Delegate; import android.os.Handler_Delegate.IHandlerCallback; import android.os.Message; import java.util.PriorityQueue; Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java +17 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,23 @@ public class BridgeRenderSession extends RenderSession { return mSession.getDefaultProperties(); } @Override public Result measure(long timeout) { try { Bridge.prepareThread(); mLastResult = mSession.acquire(timeout); if (mLastResult.isSuccess()) { mSession.invalidateRenderingSize(); mLastResult = mSession.measure(); } } finally { mSession.release(); Bridge.cleanupThread(); } return mLastResult; } @Override public Result render(long timeout, boolean forceMeasure) { try { Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +41 −7 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { /** * Measures the the current layout if needed (see {@link #invalidateRenderingSize}). */ private void measure(@NonNull SessionParams params) { private void measureLayout(@NonNull SessionParams params) { // only do the screen measure when needed. if (mMeasuredScreenWidth != -1) { return; Loading Loading @@ -353,7 +353,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { setActiveToolbar(view, context, params); measure(params); measureLayout(params); measureView(mViewRoot, null /*measuredView*/, mMeasuredScreenWidth, MeasureSpec.EXACTLY, mMeasuredScreenHeight, MeasureSpec.EXACTLY); Loading Loading @@ -390,7 +390,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * @param canvas an optional canvas to render the views to. If null, only the measure and * layout steps will be executed. */ private static Result render(@NonNull BridgeContext context, @NonNull ViewGroup viewRoot, private static Result renderAndBuildResult(@NonNull BridgeContext context, @NonNull ViewGroup viewRoot, @Nullable Canvas canvas, int width, int height) { // measure again with the size we need // This must always be done before the call to layout Loading Loading @@ -428,6 +428,40 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * @see RenderSession#render(long) */ public Result render(boolean freshRender) { return renderAndBuildResult(freshRender, false); } /** * Measures the layout * <p> * {@link #acquire(long)} must have been called before this. * * @throws IllegalStateException if the current context is different than the one owned by * the scene, or if {@link #acquire(long)} was not called. * * @see SessionParams#getRenderingMode() * @see RenderSession#render(long) */ public Result measure() { return renderAndBuildResult(false, true); } /** * Renders the scene. * <p> * {@link #acquire(long)} must have been called before this. * * @param freshRender whether the render is a new one and should erase the existing bitmap (in * the case where bitmaps are reused). This is typically needed when not playing * animations.) * * @throws IllegalStateException if the current context is different than the one owned by * the scene, or if {@link #acquire(long)} was not called. * * @see SessionParams#getRenderingMode() * @see RenderSession#render(long) */ private Result renderAndBuildResult(boolean freshRender, boolean onlyMeasure) { checkLock(); SessionParams params = getParams(); Loading @@ -437,11 +471,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { return ERROR_NOT_INFLATED.createResult(); } measure(params); measureLayout(params); HardwareConfig hardwareConfig = params.getHardwareConfig(); Result renderResult = SUCCESS.createResult(); if (params.isLayoutOnly()) { if (onlyMeasure) { // delete the canvas and image to reset them on the next full rendering mImage = null; mCanvas = null; Loading Loading @@ -509,7 +543,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { long initialTime = System_Delegate.nanoTime(); if (!mFirstFrameExecuted) { // We need to run an initial draw call to initialize the animations render(getContext(), mViewRoot, NOP_CANVAS, mMeasuredScreenWidth, mMeasuredScreenHeight); renderAndBuildResult(getContext(), mViewRoot, NOP_CANVAS, mMeasuredScreenWidth, mMeasuredScreenHeight); // The first frame will initialize the animations Choreographer_Delegate.doFrame(initialTime); Loading @@ -518,7 +552,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { // Second frame will move the animations Choreographer_Delegate.doFrame(initialTime + mElapsedFrameTimeNanos); } renderResult = render(getContext(), mViewRoot, mCanvas, mMeasuredScreenWidth, renderResult = renderAndBuildResult(getContext(), mViewRoot, mCanvas, mMeasuredScreenWidth, mMeasuredScreenHeight); } Loading Loading
tools/layoutlib/bridge/src/android/animation/AnimationThread.java +0 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import com.android.layoutlib.bridge.impl.RenderSessionImpl; import android.os.Handler; import android.os.Handler_Delegate; import android.os.Handler_Delegate.IHandlerCallback; import android.os.Message; import java.util.PriorityQueue; Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java +17 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,23 @@ public class BridgeRenderSession extends RenderSession { return mSession.getDefaultProperties(); } @Override public Result measure(long timeout) { try { Bridge.prepareThread(); mLastResult = mSession.acquire(timeout); if (mLastResult.isSuccess()) { mSession.invalidateRenderingSize(); mLastResult = mSession.measure(); } } finally { mSession.release(); Bridge.cleanupThread(); } return mLastResult; } @Override public Result render(long timeout, boolean forceMeasure) { try { Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +41 −7 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { /** * Measures the the current layout if needed (see {@link #invalidateRenderingSize}). */ private void measure(@NonNull SessionParams params) { private void measureLayout(@NonNull SessionParams params) { // only do the screen measure when needed. if (mMeasuredScreenWidth != -1) { return; Loading Loading @@ -353,7 +353,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { setActiveToolbar(view, context, params); measure(params); measureLayout(params); measureView(mViewRoot, null /*measuredView*/, mMeasuredScreenWidth, MeasureSpec.EXACTLY, mMeasuredScreenHeight, MeasureSpec.EXACTLY); Loading Loading @@ -390,7 +390,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * @param canvas an optional canvas to render the views to. If null, only the measure and * layout steps will be executed. */ private static Result render(@NonNull BridgeContext context, @NonNull ViewGroup viewRoot, private static Result renderAndBuildResult(@NonNull BridgeContext context, @NonNull ViewGroup viewRoot, @Nullable Canvas canvas, int width, int height) { // measure again with the size we need // This must always be done before the call to layout Loading Loading @@ -428,6 +428,40 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * @see RenderSession#render(long) */ public Result render(boolean freshRender) { return renderAndBuildResult(freshRender, false); } /** * Measures the layout * <p> * {@link #acquire(long)} must have been called before this. * * @throws IllegalStateException if the current context is different than the one owned by * the scene, or if {@link #acquire(long)} was not called. * * @see SessionParams#getRenderingMode() * @see RenderSession#render(long) */ public Result measure() { return renderAndBuildResult(false, true); } /** * Renders the scene. * <p> * {@link #acquire(long)} must have been called before this. * * @param freshRender whether the render is a new one and should erase the existing bitmap (in * the case where bitmaps are reused). This is typically needed when not playing * animations.) * * @throws IllegalStateException if the current context is different than the one owned by * the scene, or if {@link #acquire(long)} was not called. * * @see SessionParams#getRenderingMode() * @see RenderSession#render(long) */ private Result renderAndBuildResult(boolean freshRender, boolean onlyMeasure) { checkLock(); SessionParams params = getParams(); Loading @@ -437,11 +471,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { return ERROR_NOT_INFLATED.createResult(); } measure(params); measureLayout(params); HardwareConfig hardwareConfig = params.getHardwareConfig(); Result renderResult = SUCCESS.createResult(); if (params.isLayoutOnly()) { if (onlyMeasure) { // delete the canvas and image to reset them on the next full rendering mImage = null; mCanvas = null; Loading Loading @@ -509,7 +543,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { long initialTime = System_Delegate.nanoTime(); if (!mFirstFrameExecuted) { // We need to run an initial draw call to initialize the animations render(getContext(), mViewRoot, NOP_CANVAS, mMeasuredScreenWidth, mMeasuredScreenHeight); renderAndBuildResult(getContext(), mViewRoot, NOP_CANVAS, mMeasuredScreenWidth, mMeasuredScreenHeight); // The first frame will initialize the animations Choreographer_Delegate.doFrame(initialTime); Loading @@ -518,7 +552,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { // Second frame will move the animations Choreographer_Delegate.doFrame(initialTime + mElapsedFrameTimeNanos); } renderResult = render(getContext(), mViewRoot, mCanvas, mMeasuredScreenWidth, renderResult = renderAndBuildResult(getContext(), mViewRoot, mCanvas, mMeasuredScreenWidth, mMeasuredScreenHeight); } Loading