author | Emilio Cobos Álvarez <emilio@crisal.io> |
Tue, 19 Nov 2019 13:03:52 +0000 | |
changeset 502583 | 82e4062e839a57c0dbcb08df9965883c162eb8d1 |
parent 502582 | ff37a98047d63550c77052e7dfecbda14b188e0d |
child 502584 | 72c162fff80c7a8a053b1b4a584f7c1fc7228c0f |
push id | 100923 |
push user | ealvarez@mozilla.com |
push date | Tue, 19 Nov 2019 13:34:43 +0000 |
treeherder | autoland@82e4062e839a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nical |
bugs | 1564873 |
milestone | 72.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
gfx/wr/webrender/src/platform/unix/font.rs | file | annotate | diff | comparison | revisions | |
gfx/wr/webrender/src/prim_store/gradient.rs | file | annotate | diff | comparison | revisions |
--- a/gfx/wr/webrender/src/platform/unix/font.rs +++ b/gfx/wr/webrender/src/platform/unix/font.rs @@ -530,26 +530,26 @@ impl FontContext { // Get the bounding box for a glyph, accounting for sub-pixel positioning. fn get_bounding_box( &self, slot: FT_GlyphSlot, font: &FontInstance, glyph: &GlyphKey, scale: f32, ) -> FT_BBox { - let mut cbox: FT_BBox = unsafe { mem::uninitialized() }; + // Get the estimated bounding box from FT (control points). + let mut cbox = FT_BBox { xMin: 0, yMin: 0, xMax: 0, yMax: 0 }; - // Get the estimated bounding box from FT (control points). unsafe { FT_Outline_Get_CBox(&(*slot).outline, &mut cbox); + } - // For spaces and other non-printable characters, early out. - if (*slot).outline.n_contours == 0 { - return cbox; - } + // For spaces and other non-printable characters, early out. + if unsafe { (*slot).outline.n_contours } == 0 { + return cbox; } self.pad_bounding_box(font, &mut cbox); // Offset the bounding box by subpixel positioning. // Convert to 26.6 fixed point format for FT. let (dx, dy) = font.get_subpx_offset(glyph); let (dx, dy) = ( @@ -713,17 +713,17 @@ impl FontContext { (dx / scale as f64 * 64.0 + 0.5) as FT_Pos, -(dy / scale as f64 * 64.0 + 0.5) as FT_Pos, ); // Move the outline curves to be at the origin, taking // into account the subpixel positioning. unsafe { let outline = &(*slot).outline; - let mut cbox: FT_BBox = mem::uninitialized(); + let mut cbox = FT_BBox { xMin: 0, yMin: 0, xMax: 0, yMax: 0 }; FT_Outline_Get_CBox(outline, &mut cbox); self.pad_bounding_box(font, &mut cbox); FT_Outline_Translate( outline, dx - ((cbox.xMin + dx) & !63), dy - ((cbox.yMin + dy) & !63), ); }
--- a/gfx/wr/webrender/src/prim_store/gradient.rs +++ b/gfx/wr/webrender/src/prim_store/gradient.rs @@ -13,17 +13,17 @@ use crate::frame_builder::FrameBuildingS use crate::gpu_cache::{GpuCacheHandle, GpuDataRequest}; use crate::intern::{Internable, InternDebug, Handle as InternHandle}; use crate::internal_types::LayoutPrimitiveInfo; use crate::prim_store::{BrushSegment, GradientTileRange, VectorKey}; use crate::prim_store::{PrimitiveInstanceKind, PrimitiveOpacity, PrimitiveSceneData}; use crate::prim_store::{PrimKeyCommonData, PrimTemplateCommonData, PrimitiveStore}; use crate::prim_store::{NinePatchDescriptor, PointKey, SizeKey, InternablePrimitive}; use crate::render_task_cache::RenderTaskCacheEntryHandle; -use std::{hash, ops::{Deref, DerefMut}, mem}; +use std::{hash, ops::{Deref, DerefMut}}; use crate::util::pack_as_float; /// The maximum number of stops a gradient may have to use the fast path. pub const GRADIENT_FP_STOPS: usize = 4; /// A hashable gradient stop that can be used in primitive keys. #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] @@ -575,22 +575,32 @@ pub const GRADIENT_DATA_TABLE_BEGIN: usi // The exclusive bound of the gradient data table pub const GRADIENT_DATA_TABLE_END: usize = GRADIENT_DATA_LAST_STOP; // The number of entries in the gradient data table. pub const GRADIENT_DATA_TABLE_SIZE: usize = 128; // The number of entries in a gradient data: GRADIENT_DATA_TABLE_SIZE + first stop entry + last stop entry pub const GRADIENT_DATA_SIZE: usize = GRADIENT_DATA_TABLE_SIZE + 2; -#[derive(Debug)] +/// An entry in a gradient data table representing a segment of the gradient +/// color space. +#[derive(Debug, Copy, Clone)] #[repr(C)] -// An entry in a gradient data table representing a segment of the gradient color space. -pub struct GradientDataEntry { - pub start_color: PremultipliedColorF, - pub end_color: PremultipliedColorF, +struct GradientDataEntry { + start_color: PremultipliedColorF, + end_color: PremultipliedColorF, +} + +impl GradientDataEntry { + fn white() -> Self { + Self { + start_color: PremultipliedColorF::WHITE, + end_color: PremultipliedColorF::WHITE, + } + } } // TODO(gw): Tidy this up to be a free function / module? struct GradientGpuBlockBuilder {} impl GradientGpuBlockBuilder { /// Generate a color ramp filling the indices in [start_idx, end_idx) and interpolating /// from start_color to end_color. @@ -657,17 +667,17 @@ impl GradientGpuBlockBuilder { // within the segment of the gradient space represented by that entry. To lookup a gradient result, // first the entry index is calculated to determine which two colors to interpolate between, then // the offset within that entry bucket is used to interpolate between the two colors in that entry. // This layout preserves hard stops, as the end color for a given entry can differ from the start // color for the following entry, despite them being adjacent. Colors are stored within in BGRA8 // format for texture upload. This table requires the gradient color stops to be normalized to the // range [0, 1]. The first and last entries hold the first and last color stop colors respectively, // while the entries in between hold the interpolated color stop values for the range [0, 1]. - let mut entries: [GradientDataEntry; GRADIENT_DATA_SIZE] = unsafe { mem::uninitialized() }; + let mut entries = [GradientDataEntry::white(); GRADIENT_DATA_SIZE]; if reverse_stops { // Fill in the first entry (for reversed stops) with the first color stop GradientGpuBlockBuilder::fill_colors( GRADIENT_DATA_LAST_STOP, GRADIENT_DATA_LAST_STOP + 1, &cur_color, &cur_color, @@ -692,23 +702,16 @@ impl GradientGpuBlockBuilder { ); cur_idx = next_idx; } cur_color = next_color; } if cur_idx != GRADIENT_DATA_TABLE_BEGIN { error!("Gradient stops abruptly at {}, auto-completing to white", cur_idx); - GradientGpuBlockBuilder::fill_colors( - GRADIENT_DATA_TABLE_BEGIN, - cur_idx, - &PremultipliedColorF::WHITE, - &cur_color, - &mut entries, - ); } // Fill in the last entry (for reversed stops) with the last color stop GradientGpuBlockBuilder::fill_colors( GRADIENT_DATA_FIRST_STOP, GRADIENT_DATA_FIRST_STOP + 1, &cur_color, &cur_color, @@ -742,23 +745,16 @@ impl GradientGpuBlockBuilder { ); cur_idx = next_idx; } cur_color = next_color; } if cur_idx != GRADIENT_DATA_TABLE_END { error!("Gradient stops abruptly at {}, auto-completing to white", cur_idx); - GradientGpuBlockBuilder::fill_colors( - cur_idx, - GRADIENT_DATA_TABLE_END, - &PremultipliedColorF::WHITE, - &cur_color, - &mut entries, - ); } // Fill in the last entry with the last color stop GradientGpuBlockBuilder::fill_colors( GRADIENT_DATA_LAST_STOP, GRADIENT_DATA_LAST_STOP + 1, &cur_color, &cur_color,