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>Implementations§
Source§impl GraphicsLayer
impl GraphicsLayer
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 more