Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08a68d59 authored by John Reck's avatar John Reck
Browse files

Tweak RenderNode's docs

Bug: 125026642
Test: looked at offline-sdk-docs
Change-Id: I1e03ac2291c31e79489b9cf545d2b7760fb4252d
parent 59a599c1
Loading
Loading
Loading
Loading
+18 −21
Original line number Original line Diff line number Diff line
@@ -70,8 +70,7 @@ import java.lang.annotation.RetentionPolicy;
 *         canvas.drawRect(...);
 *         canvas.drawRect(...);
 *     } finally {
 *     } finally {
 *         renderNode.endRecording();
 *         renderNode.endRecording();
 *     }
 *     }</pre>
 * </pre>
 *
 *
 * <h3>Drawing a RenderNode in a View</h3>
 * <h3>Drawing a RenderNode in a View</h3>
 * <pre class="prettyprint">
 * <pre class="prettyprint">
@@ -84,8 +83,7 @@ import java.lang.annotation.RetentionPolicy;
 *             // Draw the RenderNode into this canvas.
 *             // Draw the RenderNode into this canvas.
 *             canvas.drawRenderNode(myRenderNode);
 *             canvas.drawRenderNode(myRenderNode);
 *         }
 *         }
 *     }
 *     }</pre>
 * </pre>
 *
 *
 * <h3>Releasing resources</h3>
 * <h3>Releasing resources</h3>
 * <p>This step is not mandatory but recommended if you want to release resources
 * <p>This step is not mandatory but recommended if you want to release resources
@@ -93,8 +91,7 @@ import java.lang.annotation.RetentionPolicy;
 * <pre class="prettyprint">
 * <pre class="prettyprint">
 *     // Discards the display list content allowing for any held resources to be released.
 *     // Discards the display list content allowing for any held resources to be released.
 *     // After calling this
 *     // After calling this
 *     renderNode.discardDisplayList();
 *     renderNode.discardDisplayList();</pre>
 * </pre>
 *
 *
 *
 *
 * <h3>Properties</h3>
 * <h3>Properties</h3>
@@ -132,8 +129,7 @@ import java.lang.annotation.RetentionPolicy;
 *          // will be invoked and will execute very quickly
 *          // will be invoked and will execute very quickly
 *          mRenderNode.offsetLeftAndRight(x);
 *          mRenderNode.offsetLeftAndRight(x);
 *          invalidate();
 *          invalidate();
 *     }
 *     }</pre>
 * </pre>
 *
 *
 * <p>A few of the properties may at first appear redundant, such as {@link #setElevation(float)}
 * <p>A few of the properties may at first appear redundant, such as {@link #setElevation(float)}
 * and {@link #setTranslationZ(float)}. The reason for these duplicates are to allow for a
 * and {@link #setTranslationZ(float)}. The reason for these duplicates are to allow for a
@@ -146,24 +142,26 @@ import java.lang.annotation.RetentionPolicy;
 * overlap with {@link #setPosition(Rect)}.
 * overlap with {@link #setPosition(Rect)}.
 *
 *
 * <p>The RenderNode's transform matrix is computed at render time as follows:
 * <p>The RenderNode's transform matrix is computed at render time as follows:
 * First a setTranslate(getTranslationX(), getTranslationY()) is applied to a {@link Matrix}.
 * <pre class="prettyprint">
 * Second a preRotate(getRotationZ(), getPivotX(), getPivotY()) is applied to the matrix. And
 *     Matrix transform = new Matrix();
 * finally a preScale(getScaleX(), getScaleY(), getPivotX(), getPivotY()) is applied. The current
 *     transform.setTranslate(renderNode.getTranslationX(), renderNode.getTranslationY());
 * canvas transform matrix, which is translated to the RenderNode's position,
 *     transform.preRotate(renderNode.getRotationZ(),
 * is then multiplied by the RenderNode's transform matrix. Therefore there is no implicit
 *             renderNode.getPivotX(), renderNode.getPivotY());
 * ordering in setting various RenderNode properties. That is to say that:
 *     transform.preScale(renderNode.getScaleX(), renderNode.getScaleY(),
 *             renderNode.getPivotX(), renderNode.getPivotY());</pre>
 * The current canvas transform matrix, which is translated to the RenderNode's position,
 * is then multiplied by the RenderNode's transform matrix. Therefore the ordering of calling
 * property setters does not affect the result. That is to say that:
 *
 *
 * <pre class="prettyprint">
 * <pre class="prettyprint">
 *     renderNode.setTranslationX(100);
 *     renderNode.setTranslationX(100);
 *     renderNode.setScaleX(100);
 *     renderNode.setScaleX(100);</pre>
 * </pre>
 *
 *
 * is equivalent to
 * is equivalent to:
 *
 *
 * <pre class="prettyprint">
 * <pre class="prettyprint">
 *     renderNode.setScaleX(100);
 *     renderNode.setScaleX(100);
 *     renderNode.setTranslationX(100);
 *     renderNode.setTranslationX(100);</pre>
 * </pre>
 *
 *
 * <h3>Threading</h3>
 * <h3>Threading</h3>
 * <p>RenderNode may be created and used on any thread but they are not thread-safe. Only
 * <p>RenderNode may be created and used on any thread but they are not thread-safe. Only
@@ -182,8 +180,7 @@ import java.lang.annotation.RetentionPolicy;
 *         if (needsUpdate) {
 *         if (needsUpdate) {
 *             myOwningView.invalidate();
 *             myOwningView.invalidate();
 *         }
 *         }
 *     }
 *     }</pre>
 * </pre>
 * This is marginally faster than doing a more explicit up-front check if the value changed by
 * This is marginally faster than doing a more explicit up-front check if the value changed by
 * comparing the desired value against {@link #getTranslationX()} as it minimizes JNI transitions.
 * comparing the desired value against {@link #getTranslationX()} as it minimizes JNI transitions.
 * The actual mechanism of requesting a new frame to be rendered will depend on how this
 * The actual mechanism of requesting a new frame to be rendered will depend on how this