pub struct GraphicsLayer {Show 21 fields
pub alpha: f32,
pub scale: f32,
pub scale_x: f32,
pub scale_y: f32,
pub rotation_x: f32,
pub rotation_y: f32,
pub rotation_z: f32,
pub camera_distance: f32,
pub transform_origin: TransformOrigin,
pub translation_x: f32,
pub translation_y: f32,
pub shadow_elevation: f32,
pub ambient_shadow_color: Color,
pub spot_shadow_color: Color,
pub shape: LayerShape,
pub clip: bool,
pub compositing_strategy: CompositingStrategy,
pub blend_mode: BlendMode,
pub color_filter: Option<ColorFilter>,
pub render_effect: Option<RenderEffect>,
pub backdrop_effect: Option<RenderEffect>,
}Fields§
§alpha: f32§scale: f32§scale_x: f32§scale_y: f32§rotation_x: f32§rotation_y: f32§rotation_z: f32§camera_distance: f32§transform_origin: TransformOrigin§translation_x: f32§translation_y: f32§shadow_elevation: f32§ambient_shadow_color: Color§spot_shadow_color: Color§shape: LayerShape§clip: bool§compositing_strategy: CompositingStrategy§blend_mode: BlendMode§color_filter: Option<ColorFilter>§render_effect: Option<RenderEffect>§backdrop_effect: Option<RenderEffect>Filters the pixels behind this layer. The result shares the layer’s
group opacity and blend mode with its content; ModulateAlpha applies
opacity independently to the backdrop and each content draw.
Implementations§
Source§impl GraphicsLayer
impl GraphicsLayer
Sourcepub const DEFAULT: GraphicsLayer
pub const DEFAULT: GraphicsLayer
Default properties for an untransformed, opaque layer without effects.
Sourcepub fn composite_alpha_8bit(alpha: f32) -> f32
pub fn composite_alpha_8bit(alpha: f32) -> f32
The alpha an isolated layer is composited at: an eight-bit one, truncated.
The platform never composites a layer at a float alpha. HWUI hands an
isolated RenderNode to the rasterizer as
canvas->saveLayerAlpha(&bounds, (int)(properties.getAlpha() * 255))
(frameworks/base/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp,
setViewProperties), and (int) truncates — 0.5 composites at 127/255,
not at 128/255. The fraction below that byte is gone before a single pixel
is blended, so anything that keeps it lands a level out wherever the byte
and the float fall on opposite sides of a half.
The sibling branch is a float on purpose: where getHasOverlappingRendering()
is false HWUI takes *alphaMultiplier = properties.getAlpha() and folds it
into each draw without ever making a byte of it. That is what
CompositingStrategy::ModulateAlpha names.
Truncating here and rounding in Color::srgb_8bit is not an
inconsistency: they are different call sites in the platform. A colour’s own
alpha is snapped by Color’s constructor, which adds the half; a layer’s
alpha is snapped by HWUI’s cast, which does not. Anything modelling a faded
layer without allocating one — a canvas drawing a list row’s fade by hand,
say — wants this rule and not the other.
Trait Implementations§
Source§impl Clone for GraphicsLayer
impl Clone for GraphicsLayer
Source§fn clone(&self) -> GraphicsLayer
fn clone(&self) -> GraphicsLayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphicsLayer
impl Debug for GraphicsLayer
Source§impl Default for GraphicsLayer
impl Default for GraphicsLayer
Source§fn default() -> GraphicsLayer
fn default() -> GraphicsLayer
Source§impl PartialEq for GraphicsLayer
impl PartialEq for GraphicsLayer
impl StructuralPartialEq for GraphicsLayer
Auto Trait Implementations§
impl Freeze for GraphicsLayer
impl RefUnwindSafe for GraphicsLayer
impl Send for GraphicsLayer
impl Sync for GraphicsLayer
impl Unpin for GraphicsLayer
impl UnsafeUnpin for GraphicsLayer
impl UnwindSafe for GraphicsLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more