Class RenderProperties
- Direct Known Subclasses:
RenderNode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
getAlpha()
Returns the translucency level of this RenderNode.Returns the previously set animation matrix.int
Gets the bottom position for the RenderNode.float
Returns the distance in Z of the camera for this RenderNodeboolean
Returns whether the RenderNode is clipping to its bounds.float
boolean
Indicates whether the content of this RenderNode overlaps.int
Gets the height of the RenderNode, which is the bottom - top.Gets the current transform inverted.int
Returns the alpha value if a compositing layer is used.Returns the blend mode if a compositing layer is used.int
getLeft()
Gets the left position for the RenderNode.Gets the current transform matrix.float
Returns the pivot value for this RenderNode on the X axis, in pixels.float
Returns the pivot value for this RenderNode on the Y axis, in pixels.int
getRight()
Gets the right position for the RenderNode.float
Returns the rotation value for this RenderNode around the X axis, in degrees.float
Returns the rotation value for this RenderNode around the Y axis, in degrees.float
Returns the rotation value for this RenderNode around the Z axis, in degrees.float
Returns the scale value for this RenderNode on the X axis.float
Returns the scale value for this RenderNode on the Y axis.int
getTop()
Gets the top position for the RenderNode.float
Returns the translation value for this RenderNode on the X axis, in pixels.float
Returns the translation value for this RenderNode on the Y axis, in pixels.float
Returns the translation value for this RenderNode on the Z axis.boolean
Gets whether a compositing layer is forced to be used.boolean
Gets whether a compositing layer should be used.int
getWidth()
Gets the width of the RenderNode, which is the right - left.float
getX()
The visual x position of this view, in pixels.float
getY()
The visual y position of this view, in pixels.float
getZ()
The visual z position of this view, in pixels.boolean
boolean
boolean
offsetLeftAndRight
(int offset) Offsets the left and right positions for the RenderNodeboolean
offsetTopAndBottom
(int offset) Offsets the top and bottom values for the RenderNodeboolean
Clears any camera distance previously set by a call tosetCameraDistance(float)
.boolean
Clears any pivot previously set by a call tosetPivotX(float)
orsetPivotY(float)
.boolean
setAlpha
(float alpha) Sets the translucency level for the RenderNode.boolean
setAnimationMatrix
(Matrix matrix) Set the animation matrix on the RenderNode.boolean
setBottom
(int bottom) Sets the bottom position for the RenderNode.boolean
setCameraDistance
(float distance) Sets the distance along the Z axis (orthogonal to the X/Y plane on which RenderNodes are drawn) from the camera to this RenderNode.boolean
setClipBounds
(Rect clipBounds) Sets an additional clip on the RenderNode.boolean
setClipToBounds
(boolean clipToBounds) Set whether the RenderNode should clip itself to its bounds.boolean
setElevation
(float lift) Sets the base elevation of this RenderNode in pixelsboolean
setHasOverlappingRendering
(boolean hasOverlappingRendering) Sets whether the RenderNode renders content which overlaps.boolean
setLeft
(int left) Sets the left position for the RenderNode.boolean
setPivotX
(float pivotX) Sets the pivot value for the RenderNode on the X axisboolean
setPivotY
(float pivotY) Sets the pivot value for the RenderNode on the Y axisboolean
setPosition
(int left, int top, int right, int bottom) Sets the position of the RenderNode.boolean
setPosition
(Rect position) Sets the position of the RenderNode.boolean
setRight
(int right) Sets the right position for the RenderNode.boolean
setRotationX
(float rotationX) Sets the rotation value for the RenderNode around the X axis.boolean
setRotationY
(float rotationY) Sets the rotation value for the RenderNode around the Y axis.boolean
setRotationZ
(float rotationZ) Sets the rotation value for the RenderNode around the Z axis.boolean
setScaleX
(float scaleX) Sets the scale value for the RenderNode on the X axis.boolean
setScaleY
(float scaleY) Sets the scale value for the RenderNode on the Y axis.boolean
setTop
(int top) Sets the top position for the RenderNode.boolean
setTranslationX
(float translationX) Sets the translation value for the RenderNode on the X axis.boolean
setTranslationY
(float translationY) Sets the translation value for the RenderNode on the Y axis.boolean
setTranslationZ
(float translationZ) Sets the translation value for the RenderNode on the Z axis.boolean
setUseCompositingLayer
(boolean forceToLayer, Paint paint) Controls whether to force this RenderNode to render to an intermediate render target.boolean
setX
(float x) Sets the visual x position of this view, in pixels.boolean
setY
(float y) Sets the visual y position of this view, in pixels.boolean
setZ
(float z) Sets the visual z position of this view, in pixels.
-
Constructor Details
-
RenderProperties
public RenderProperties()
-
-
Method Details
-
getMatrix
Gets the current transform matrix. The return value may be null, indicating that it is identity. Note that the returned matrix is READ-ONLY currently. If you want to record this matrix, you need to make a copy.- Returns:
- The current transform matrix, may be null
-
getInverseMatrix
Gets the current transform inverted. The return value may be null, indicating that it is identity. Note that the returned matrix is READ-ONLY currently. If you want to record this matrix, you need to make a copy.- Returns:
- The inverse of current transform matrix, may be null
-
setUseCompositingLayer
Controls whether to force this RenderNode to render to an intermediate render target. Internally RenderNode will already promote itself to a composition layer if it's useful for performance or required for the current combination ofsetAlpha(float)
andsetHasOverlappingRendering(boolean)
.The usage of this is instead to allow for either overriding of the internal behavior if it's measured to be necessary for the particular rendering content in question or, more usefully, to add a composition effect to the RenderNode via the optional paint parameter.
Note: When a RenderNode is using a compositing layer it will also result in clipToBounds=true behavior.
- Parameters:
forceToLayer
- if true this forces the RenderNode to use an intermediate buffer. Default invalid input: '&' generally recommended value is false.paint
- The blend mode, alpha, and ColorFilter to apply to the compositing layer. Only applies if forceToLayer is true. The paint's alpha is multiplied withgetAlpha()
to resolve the final alpha of the RenderNode. If null then no additional composition effects are applied on top of the composition layer.- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
getUseCompositingLayer
public boolean getUseCompositingLayer()Gets whether a compositing layer is forced to be used. The default invalid input: '&' recommended is false, as it is typically faster to avoid using compositing layers. SeesetUseCompositingLayer(boolean, Paint)
.- Returns:
- true if a compositing layer is forced, false otherwise
-
getUseTransientLayer
public boolean getUseTransientLayer()Gets whether a compositing layer should be used. This pushes the RenderNode into a cached color buffer stack and avoids creating a new layer.- Returns:
- true if a compositing layer should be used, false otherwise
-
getLayerAlpha
public int getLayerAlpha()Returns the alpha value if a compositing layer is used. This alpha is multiplied withgetAlpha()
to resolve the final alpha of the RenderNode.- Returns:
- the layer's alpha
-
getLayerBlendMode
Returns the blend mode if a compositing layer is used.- Returns:
- the layer's blend mode
-
setClipBounds
Sets an additional clip on the RenderNode. If null, the extra clip is removed from the RenderNode. If non-null, the RenderNode will be clipped to this rect. In addition, ifsetClipToBounds(boolean)
is true, then the RenderNode will be clipped to the intersection of this rectangle and the bounds of the RenderNode, which is set withsetPosition(Rect)
.- Parameters:
clipBounds
- the bounds to clip to. If null, the additional clip is removed.- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
setClipToBounds
public boolean setClipToBounds(boolean clipToBounds) Set whether the RenderNode should clip itself to its bounds. This defaults to true, and is useful to the RenderNode in enable quick-rejection of chunks of the tree as well as better partial invalidation support. Clipping can be further restricted or controlled through the combination of this property as well assetClipBounds(Rect)
, which allows for a different clipping rectangle to be used in addition to or instead of thesetPosition(int, int, int, int)
or the RenderNode.- Parameters:
clipToBounds
- true if the RenderNode should clip to its bounds, false otherwise.- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
getClipToBounds
public boolean getClipToBounds()Returns whether the RenderNode is clipping to its bounds. SeesetClipToBounds(boolean)
andsetPosition(int, int, int, int)
- Returns:
- true if the render node clips to its bounds, false otherwise.
-
setAnimationMatrix
Set the animation matrix on the RenderNode. This matrix exists if an animation is currently playing on a View, and is set on the RenderNode during at draw time. When the animation finishes, the matrix should be cleared by sendingnull
for the matrix parameter.- Parameters:
matrix
- The matrix, null indicates that the matrix should be cleared.- See Also:
-
getAnimationMatrix
Returns the previously set animation matrix. This matrix exists if an animation is currently playing on a View, and is set on the RenderNode during at draw time. Returnsnull
when there is no transformation provided bysetAnimationMatrix(Matrix)
.- Returns:
- the current Animation matrix.
- See Also:
-
setAlpha
public boolean setAlpha(float alpha) Sets the translucency level for the RenderNode.- Parameters:
alpha
- The translucency of the RenderNode, must be a value between 0.0f and 1.0f- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getAlpha
public float getAlpha()Returns the translucency level of this RenderNode.- Returns:
- A value between 0.0f and 1.0f
- See Also:
-
setHasOverlappingRendering
public boolean setHasOverlappingRendering(boolean hasOverlappingRendering) Sets whether the RenderNode renders content which overlaps. Non-overlapping rendering can use a fast path for alpha that avoids rendering to an offscreen buffer. By default, RenderNodes consider they do not have overlapping content.- Parameters:
hasOverlappingRendering
- False if the content is guaranteed to be non-overlapping, true otherwise.- See Also:
-
getHasOverlappingRendering
public boolean getHasOverlappingRendering()Indicates whether the content of this RenderNode overlaps.- Returns:
- True if this RenderNode renders content which overlaps, false otherwise.
- See Also:
-
setElevation
public boolean setElevation(float lift) Sets the base elevation of this RenderNode in pixels- Parameters:
lift
- the elevation in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
getElevation
public float getElevation()- Returns:
- The RenderNode's current elevation
-
setTranslationX
public boolean setTranslationX(float translationX) Sets the translation value for the RenderNode on the X axis.- Parameters:
translationX
- The X axis translation value of the RenderNode, in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getTranslationX
public float getTranslationX()Returns the translation value for this RenderNode on the X axis, in pixels.- See Also:
-
setTranslationY
public boolean setTranslationY(float translationY) Sets the translation value for the RenderNode on the Y axis.- Parameters:
translationY
- The Y axis translation value of the RenderNode, in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getTranslationY
public float getTranslationY()Returns the translation value for this RenderNode on the Y axis, in pixels.- See Also:
-
setTranslationZ
public boolean setTranslationZ(float translationZ) Sets the translation value for the RenderNode on the Z axis.- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getTranslationZ
public float getTranslationZ()Returns the translation value for this RenderNode on the Z axis.- See Also:
-
setX
public boolean setX(float x) Sets the visual x position of this view, in pixels. This is equivalent to setting thetranslationX
property to be the difference between the x value passed in and the currentleft
property.- Parameters:
x
- The visual x position of this view, in pixels.
-
getX
public float getX()The visual x position of this view, in pixels. This is equivalent to thetranslationX
property plus the currentleft
property.- Returns:
- The visual x position of this view, in pixels.
-
setY
public boolean setY(float y) Sets the visual y position of this view, in pixels. This is equivalent to setting thetranslationY
property to be the difference between the y value passed in and the currenttop
property.- Parameters:
y
- The visual y position of this view, in pixels.
-
getY
public float getY()The visual y position of this view, in pixels. This is equivalent to thetranslationY
property plus the currenttop
property.- Returns:
- The visual y position of this view, in pixels.
-
setZ
public boolean setZ(float z) Sets the visual z position of this view, in pixels. This is equivalent to setting thetranslationZ
property to be the difference between the z value passed in and the currentelevation
property.- Parameters:
z
- The visual z position of this view, in pixels.
-
getZ
public float getZ()The visual z position of this view, in pixels. This is equivalent to thetranslationZ
property plus the currentelevation
property.- Returns:
- The visual z position of this view, in pixels.
-
setRotationX
public boolean setRotationX(float rotationX) Sets the rotation value for the RenderNode around the X axis.- Parameters:
rotationX
- The rotation value of the RenderNode, in degrees- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getRotationX
public float getRotationX()Returns the rotation value for this RenderNode around the X axis, in degrees.- See Also:
-
setRotationY
public boolean setRotationY(float rotationY) Sets the rotation value for the RenderNode around the Y axis.- Parameters:
rotationY
- The rotation value of the RenderNode, in degrees- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getRotationY
public float getRotationY()Returns the rotation value for this RenderNode around the Y axis, in degrees.- See Also:
-
setRotationZ
public boolean setRotationZ(float rotationZ) Sets the rotation value for the RenderNode around the Z axis.- Parameters:
rotationZ
- The rotation value of the RenderNode, in degrees- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getRotationZ
public float getRotationZ()Returns the rotation value for this RenderNode around the Z axis, in degrees.- See Also:
-
setScaleX
public boolean setScaleX(float scaleX) Sets the scale value for the RenderNode on the X axis.- Parameters:
scaleX
- The scale value of the RenderNode- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getScaleX
public float getScaleX()Returns the scale value for this RenderNode on the X axis.- See Also:
-
setScaleY
public boolean setScaleY(float scaleY) Sets the scale value for the RenderNode on the Y axis.- Parameters:
scaleY
- The scale value of the RenderNode- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getScaleY
public float getScaleY()Returns the scale value for this RenderNode on the Y axis.- See Also:
-
setPivotX
public boolean setPivotX(float pivotX) Sets the pivot value for the RenderNode on the X axis- Parameters:
pivotX
- The pivot value of the RenderNode on the X axis, in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getPivotX
public float getPivotX()Returns the pivot value for this RenderNode on the X axis, in pixels.- See Also:
-
setPivotY
public boolean setPivotY(float pivotY) Sets the pivot value for the RenderNode on the Y axis- Parameters:
pivotY
- The pivot value of the RenderNode on the Y axis, in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getPivotY
public float getPivotY()Returns the pivot value for this RenderNode on the Y axis, in pixels.- See Also:
-
isPivotExplicitlySet
public boolean isPivotExplicitlySet()- Returns:
- Whether a pivot was explicitly set with
setPivotX(float)
orsetPivotY(float)
. If no pivot has been set then the pivot will be the center of the RenderNode.
-
resetPivot
public boolean resetPivot()Clears any pivot previously set by a call tosetPivotX(float)
orsetPivotY(float)
. After calling thisisPivotExplicitlySet()
will be false and the pivot used for rotation will return to default of being centered on the view.- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
setCameraDistance
Sets the distance along the Z axis (orthogonal to the X/Y plane on which RenderNodes are drawn) from the camera to this RenderNode. The camera's distance affects 3D transformations, for instance rotations around the X and Y axis. If the rotationX or rotationY properties are changed and this view is large (more than half the size of the screen), it is recommended to always use a camera distance that's greater than the height (X axis rotation) or the width (Y axis rotation) of this view.
The distance of the camera from the drawing plane can have an affect on the perspective distortion of the RenderNode when it is rotated around the x or y axis. For example, a large distance will result in a large viewing angle, and there will not be much perspective distortion of the view as it rotates. A short distance may cause much more perspective distortion upon rotation, and can also result in some drawing artifacts if the rotated view ends up partially behind the camera (which is why the recommendation is to use a distance at least as far as the size of the view, if the view is to be rotated.)
The distance is expressed in pixels and must always be positive
- Parameters:
distance
- The distance in pixels, must always be positive- Returns:
- True if the value changed, false if the new value was the same as the previous value.
- See Also:
-
getCameraDistance
Returns the distance in Z of the camera for this RenderNode- Returns:
- the distance along the Z axis in pixels.
- See Also:
-
isCameraDistanceExplicitlySet
public boolean isCameraDistanceExplicitlySet()- Returns:
- Whether a camera distance was explicitly set with
setCameraDistance(float)
. If no camera distance has been set then the camera distance will be the max(width,height) of the RenderNode.
-
resetCameraDistance
public boolean resetCameraDistance()Clears any camera distance previously set by a call tosetCameraDistance(float)
. After calling thisisCameraDistanceExplicitlySet()
will be false and the camera distance used for rotation will return to default to the max(width,height) of the view.- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
setLeft
public boolean setLeft(int left) Sets the left position for the RenderNode.- Parameters:
left
- The left position, in pixels, of the RenderNode- Returns:
- true if the value changed, false otherwise
-
getLeft
public int getLeft()Gets the left position for the RenderNode.- Returns:
- the left position in pixels
-
setTop
public boolean setTop(int top) Sets the top position for the RenderNode.- Parameters:
top
- The top position, in pixels, of the RenderNode- Returns:
- true if the value changed, false otherwise.
-
getTop
public int getTop()Gets the top position for the RenderNode.- Returns:
- the top position in pixels
-
setRight
public boolean setRight(int right) Sets the right position for the RenderNode.- Parameters:
right
- The right position, in pixels, of the RenderNode- Returns:
- true if the value changed, false otherwise.
-
getRight
public int getRight()Gets the right position for the RenderNode.- Returns:
- the right position in pixels
-
setBottom
public boolean setBottom(int bottom) Sets the bottom position for the RenderNode.- Parameters:
bottom
- The bottom position, in pixels, of the RenderNode- Returns:
- true if the value changed, false otherwise.
-
getBottom
public int getBottom()Gets the bottom position for the RenderNode.- Returns:
- the bottom position in pixels
-
setPosition
public boolean setPosition(int left, int top, int right, int bottom) Sets the position of the RenderNode.- Parameters:
left
- The left position of the RenderNode, in pixelstop
- The top position of the RenderNode, in pixelsright
- The right position of the RenderNode, in pixelsbottom
- The bottom position of the RenderNode, in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
setPosition
Sets the position of the RenderNode.- Parameters:
position
- The position rectangle in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
offsetLeftAndRight
public boolean offsetLeftAndRight(int offset) Offsets the left and right positions for the RenderNode- Parameters:
offset
- The amount that the left and right positions are offset in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
offsetTopAndBottom
public boolean offsetTopAndBottom(int offset) Offsets the top and bottom values for the RenderNode- Parameters:
offset
- The amount that the left and right positions are offset in pixels- Returns:
- True if the value changed, false if the new value was the same as the previous value.
-
getWidth
public int getWidth()Gets the width of the RenderNode, which is the right - left.- Returns:
- the width of the RenderNode
-
getHeight
public int getHeight()Gets the height of the RenderNode, which is the bottom - top.- Returns:
- the height of the RenderNode
-