Merge mozilla-central to autoland a=merge

This commit is contained in:
Coroiu Cristina 2018-09-20 09:52:11 +03:00
commit b287d5ad06
11 changed files with 13 additions and 141 deletions

View File

@ -91,7 +91,6 @@ void main(void) {
#ifdef WR_FEATURE_ALPHA_PASS
write_clip(
vi.world_pos,
vi.snap_offset,
clip_area
);
#endif

View File

@ -27,7 +27,6 @@ vec2 clamp_rect(vec2 pt, RectWithSize rect) {
// TODO: convert back to RectWithEndPoint if driver issues are resolved, if ever.
flat varying vec4 vClipMaskUvBounds;
flat varying vec4 vClipMaskUvSampleBounds;
// XY and W are homogeneous coordinates, Z is the layer index
varying vec4 vClipMaskUv;
@ -223,21 +222,14 @@ VertexInfo write_transform_vertex(RectWithSize local_segment_rect,
return vi;
}
void write_clip(vec4 world_pos, vec2 snap_offset, ClipArea area) {
void write_clip(vec4 world_pos, ClipArea area) {
vec2 uv = world_pos.xy * uDevicePixelRatio +
world_pos.w * (snap_offset + area.common_data.task_rect.p0 - area.screen_origin);
world_pos.w * (area.common_data.task_rect.p0 - area.screen_origin);
vClipMaskUvBounds = vec4(
area.common_data.task_rect.p0,
area.common_data.task_rect.p0 + area.common_data.task_rect.size
);
vClipMaskUvSampleBounds.xy = vClipMaskUvBounds.xy + vec2(0.5);
vClipMaskUvSampleBounds.zw = vClipMaskUvBounds.zw - vec2(0.5);
vClipMaskUv = vec4(uv, area.common_data.texture_layer_index, world_pos.w);
vec2 texture_size = vec2(textureSize(sCacheA8, 0).xy);
vClipMaskUv.xy /= texture_size;
vClipMaskUvBounds /= texture_size.xyxy;
vClipMaskUvSampleBounds /= texture_size.xyxy;
}
#endif //WR_VERTEX_SHADER
@ -258,14 +250,9 @@ float do_clip() {
if (!all(inside)) {
return 0.0;
}
// finally, the slow path - fetch the mask value from an image
// TODO(gw): texelFetch here fails on some nVidia hardware in
// some cases. For now, just use texture()
// unconditionally.
mask_uv = clamp(mask_uv, vClipMaskUvSampleBounds.xy, vClipMaskUvSampleBounds.zw);
return texture(sCacheA8, vec3(mask_uv, vClipMaskUv.z)).r;
ivec3 tc = ivec3(mask_uv, vClipMaskUv.z);
return texelFetch(sCacheA8, tc, 0).r;
}
#ifdef WR_FEATURE_DITHERING

View File

@ -80,7 +80,6 @@ void main(void) {
write_clip(
world_pos,
vec2(0.0),
clip_area
);

View File

@ -229,7 +229,7 @@ void main(void) {
vec2 f = (vi.local_pos - glyph_rect.p0) / glyph_rect.size;
#endif
write_clip(vi.world_pos, vi.snap_offset, clip_area);
write_clip(vi.world_pos, clip_area);
switch (color_mode) {
case COLOR_MODE_ALPHA:

View File

@ -106,7 +106,6 @@ enum ClipResult {
// positioning information and implementation details
// that control where the GPU data for this clip source
// can be found.
#[derive(Debug)]
pub struct ClipNode {
pub item: ClipItem,
pub gpu_cache_handle: GpuCacheHandle,
@ -766,14 +765,11 @@ impl ClipItem {
pub fn new_box_shadow(
shadow_rect: LayoutRect,
mut shadow_radius: BorderRadius,
shadow_radius: BorderRadius,
prim_shadow_rect: LayoutRect,
blur_radius: f32,
clip_mode: BoxShadowClipMode,
) -> Self {
// Make sure corners don't overlap.
ensure_no_corner_overlap(&mut shadow_radius, &shadow_rect);
// Get the fractional offsets required to match the
// source rect with a minimal rect.
let fract_offset = LayoutPoint::new(

View File

@ -740,7 +740,7 @@ impl RenderTask {
// so the shader doesn't need to shift by the origin.
if let RenderTaskLocation::Fixed(_) = self.location {
target_rect.origin = DeviceIntPoint::origin();
}
};
RenderTaskData {
data: [

View File

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(missing_docs)]
extern crate serde_bytes;
use font::{FontInstanceKey, FontInstanceData, FontKey, FontTemplate};
@ -12,18 +10,13 @@ use {DevicePoint, DeviceUintPoint, DeviceUintRect, DeviceUintSize};
use {IdNamespace, TileOffset, TileSize};
use euclid::size2;
/// An opaque identifier describing an image registered with WebRender.
/// This is used as a handle to reference images, and is used as the
/// hash map key for the actual image storage in the `ResourceCache`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ImageKey(pub IdNamespace, pub u32);
impl ImageKey {
/// Placeholder Image key, used to represent None.
pub const DUMMY: Self = ImageKey(IdNamespace(0), 0);
/// Mints a new ImageKey. The given ID must be unique.
pub fn new(namespace: IdNamespace, key: u32) -> Self {
ImageKey(namespace, key)
}
@ -36,73 +29,40 @@ impl ImageKey {
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct ExternalImageId(pub u64);
/// Specifies the type of texture target in driver terms.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub enum TextureTarget {
/// Standard texture. This maps to GL_TEXTURE_2D in OpenGL.
Default = 0,
/// Array texture. This maps to GL_TEXTURE_2D_ARRAY in OpenGL. See
/// https://www.khronos.org/opengl/wiki/Array_Texture for background
/// on Array textures.
Array = 1,
/// Rectange texture. This maps to GL_TEXTURE_RECTANGLE in OpenGL. This
/// is similar to a standard texture, with a few subtle differences
/// (no mipmaps, non-power-of-two dimensions, different coordinate space)
/// that make it useful for representing the kinds of textures we use
/// in WebRender. See https://www.khronos.org/opengl/wiki/Rectangle_Texture
/// for background on Rectangle textures.
Rect = 2,
/// External texture. This maps to GL_TEXTURE_EXTERNAL_OES in OpenGL, which
/// is an extension. This is used for image formats that OpenGL doesn't
/// understand, particularly YUV. See
/// https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt
External = 3,
}
/// Storage format identifier for externally-managed images.
#[repr(u32)]
#[derive(Debug, Copy, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub enum ExternalImageType {
/// The image is texture-backed.
TextureHandle(TextureTarget),
/// The image is heap-allocated by the embedding.
Buffer,
}
/// Descriptor for external image resources. See `ImageData`.
#[repr(C)]
#[derive(Debug, Copy, Clone, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct ExternalImageData {
/// The identifier of this external image, provided by the embedding.
pub id: ExternalImageId,
/// For multi-plane images (i.e. YUV), indicates the plane of the
/// original image that this struct represents. 0 for single-plane images.
pub channel_index: u8,
/// Storage format identifier.
pub image_type: ExternalImageType,
}
/// Specifies the format of a series of pixels, in driver terms.
#[repr(u32)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum ImageFormat {
/// One-channel, byte storage. The "red" doesn't map to the color
/// red per se, and is just the way that OpenGL has historically referred
/// to single-channel buffers.
R8 = 1,
/// Four channels, byte storage.
BGRA8 = 3,
/// Four channels, float storage.
RGBAF32 = 4,
/// Two-channels, byte storage. Similar to `R8`, this just means
/// "two channels" rather than "red and green".
RG8 = 5,
/// Four channels, signed integer storage.
RGBAI32 = 6,
}
impl ImageFormat {
/// Returns the number of bytes per pixel for the given format.
pub fn bytes_per_pixel(self) -> u32 {
match self {
ImageFormat::R8 => 1,
@ -114,37 +74,17 @@ impl ImageFormat {
}
}
/// Metadata (but not storage) describing an image In WebRender.
#[derive(Copy, Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ImageDescriptor {
/// Format of the image data.
pub format: ImageFormat,
/// Width and length of the image data, in pixels.
pub size: DeviceUintSize,
/// The number of bytes from the start of one row to the next. If non-None,
/// `compute_stride` will return this value, otherwise it returns
/// `width * bpp`. Different source of images have different alignment
/// constraints for rows, so the stride isn't always equal to width * bpp.
pub stride: Option<u32>,
/// Offset in bytes of the first pixel of this image in its backing buffer.
/// This is used for tiling, wherein WebRender extracts chunks of input images
/// in order to cache, manipulate, and render them individually. This offset
/// tells the texture upload machinery where to find the bytes to upload for
/// this tile. Non-tiled images generally set this to zero.
pub offset: u32,
/// Whether this image is opaque, or has an alpha channel. Avoiding blending
/// for opaque surfaces is an important optimization.
pub is_opaque: bool,
/// Whether to allow the driver to automatically generate mipmaps. If images
/// are already downscaled appropriately, mipmap generation can be wasted
/// work, and cause performance problems on some cards/drivers.
///
/// See https://github.com/servo/webrender/pull/2555/
pub allow_mipmaps: bool,
}
impl ImageDescriptor {
/// Mints a new ImageDescriptor.
pub fn new(
width: u32,
height: u32,
@ -162,18 +102,14 @@ impl ImageDescriptor {
}
}
/// Returns the stride, either via an explicit stride stashed on the object
/// or by the default computation.
pub fn compute_stride(&self) -> u32 {
self.stride.unwrap_or(self.size.width * self.format.bytes_per_pixel())
}
/// Computes the total size of the image, in bytes.
pub fn compute_total_size(&self) -> u32 {
self.compute_stride() * self.size.height
}
/// Computes the bounding rectangle for the image, rooted at (0, 0).
pub fn full_rect(&self) -> DeviceUintRect {
DeviceUintRect::new(
DeviceUintPoint::zero(),
@ -182,18 +118,10 @@ impl ImageDescriptor {
}
}
/// Represents the backing store of an arbitrary series of pixels for display by
/// WebRender. This storage can take several forms.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum ImageData {
/// A simple series of bytes, provided by the embedding and owned by WebRender.
/// The format is stored out-of-band, currently in ImageDescriptor.
Raw(#[serde(with = "serde_image_data_raw")] Arc<Vec<u8>>),
/// An series of commands that can be rasterized into an image via an
/// embedding-provided callback.
Blob(#[serde(with = "serde_image_data_raw")] Arc<BlobImageData>),
/// An image owned by the embedding, and referenced by WebRender. This may
/// take the form of a texture or a heap-allocated buffer.
External(ExternalImageData),
}
@ -213,22 +141,18 @@ mod serde_image_data_raw {
}
impl ImageData {
/// Mints a new raw ImageData, taking ownership of the bytes.
pub fn new(bytes: Vec<u8>) -> Self {
ImageData::Raw(Arc::new(bytes))
}
/// Mints a new raw ImageData from Arc-ed bytes.
pub fn new_shared(bytes: Arc<Vec<u8>>) -> Self {
ImageData::Raw(bytes)
}
/// Mints a new Blob ImageData.
pub fn new_blob_image(commands: BlobImageData) -> Self {
ImageData::Blob(Arc::new(commands))
}
/// Returns true if this ImageData represents a blob.
#[inline]
pub fn is_blob(&self) -> bool {
match *self {
@ -237,8 +161,6 @@ impl ImageData {
}
}
/// Returns true if this variant of ImageData should go through the texture
/// cache.
#[inline]
pub fn uses_texture_cache(&self) -> bool {
match *self {
@ -254,11 +176,8 @@ impl ImageData {
/// The resources exposed by the resource cache available for use by the blob rasterizer.
pub trait BlobImageResources {
/// Returns the `FontTemplate` for the given key.
fn get_font_data(&self, key: FontKey) -> &FontTemplate;
/// Returns the `FontInstanceData` for the given key, if found.
fn get_font_instance_data(&self, key: FontInstanceKey) -> Option<FontInstanceData>;
/// Returns the image metadata and backing store for the given key, if found.
fn get_image(&self, key: ImageKey) -> Option<(&ImageData, &ImageDescriptor)>;
}
@ -303,72 +222,44 @@ pub trait BlobImageHandler: Send {
/// A group of rasterization requests to execute synchronously on the scene builder thread.
pub trait AsyncBlobImageRasterizer : Send {
/// Rasterize the requests.
fn rasterize(&mut self, requests: &[BlobImageParams]) -> Vec<(BlobImageRequest, BlobImageResult)>;
}
/// Input parameters for the BlobImageRasterizer.
#[derive(Copy, Clone, Debug)]
pub struct BlobImageParams {
/// A key that identifies the blob image rasterization request.
pub request: BlobImageRequest,
/// Description of the format of the blob's output image.
pub descriptor: BlobImageDescriptor,
/// An optional sub-rectangle of the image to avoid re-rasterizing
/// the entire image when only a portion is updated.
///
/// If set to None the entire image is rasterized.
pub dirty_rect: Option<DeviceUintRect>,
}
/// Backing store for blob image command streams.
pub type BlobImageData = Vec<u8>;
/// Result type for blob raserization.
pub type BlobImageResult = Result<RasterizedBlobImage, BlobImageError>;
/// Metadata (but not storage) for a blob image.
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct BlobImageDescriptor {
/// Size in device pixels of the blob's output image.
pub size: DeviceUintSize,
/// When tiling, offset point in device pixels of this tile in the full
/// image. Generally (0, 0) outside of tiling.
pub offset: DevicePoint,
/// Format for the data in the backing store.
pub format: ImageFormat,
}
/// Representation of a rasterized blob image. This is obtained by passing
/// `BlobImageData` to the embedding via the rasterization callback.
pub struct RasterizedBlobImage {
/// The bounding rectangle for this bob image.
pub rasterized_rect: DeviceUintRect,
/// Backing store. The format is stored out of band in `BlobImageDescriptor`.
pub data: Arc<Vec<u8>>,
}
/// Error code for when blob rasterization failed.
#[derive(Clone, Debug)]
pub enum BlobImageError {
/// Out of memory.
Oom,
/// Other failure, embedding-specified.
InvalidKey,
InvalidData,
Other(String),
}
/// A key identifying blob image rasterization work requested from the blob
/// image rasterizer.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct BlobImageRequest {
/// Unique handle to the image.
pub key: ImageKey,
/// Tiling offset in number of tiles, if applicable.
///
/// `None` if the image will not be tiled.
pub tile: Option<TileOffset>,
}

View File

@ -1 +1 @@
3104734e8927d25b7ef81c6be021bb9337718720
5b5b4145ecef117acb02fd1f9b72bf02e85c650b

View File

@ -1545,7 +1545,7 @@ impl YamlFrameReader {
let reference_frame_id = dl.push_reference_frame(info, transform.into(), perspective);
let numeric_id = yaml["id"].as_i64();
let numeric_id = yaml["reference-frame-id"].as_i64();
if let Some(numeric_id) = numeric_id {
self.add_clip_id_mapping(numeric_id as u64, reference_frame_id);
}

View File

@ -22,7 +22,7 @@ fuzzy-if(skiaContent,0-1,0-50) == boxshadow-dynamic.xul boxshadow-dynamic-ref.xu
random-if(d2d) fuzzy-if(skiaContent,0-1,0-14) == boxshadow-onecorner.html boxshadow-onecorner-ref.html
random-if(d2d) fuzzy-if(skiaContent,0-1,0-22) == boxshadow-twocorners.html boxshadow-twocorners-ref.html
random-if(d2d) fuzzy-if(skiaContent,0-1,0-36) == boxshadow-threecorners.html boxshadow-threecorners-ref.html
fuzzy(0-2,0-440) fails-if(webrender&&gtkWidget) == boxshadow-skiprect.html boxshadow-skiprect-ref.html
fuzzy(0-2,0-440) fails-if(webrender) == boxshadow-skiprect.html boxshadow-skiprect-ref.html
== boxshadow-opacity.html boxshadow-opacity-ref.html
== boxshadow-color-rounding.html boxshadow-color-rounding-ref.html
== boxshadow-color-rounding-middle.html boxshadow-color-rounding-middle-ref.html

View File

@ -62,7 +62,7 @@ fails-if(webrender) == transform-style-flat-1a.html transform-style-flat-1-ref.h
!= willchange-containing-block.html?willchange willchange-containing-block.html?noblock
fuzzy-if(winWidget&&!layersGPUAccelerated,0-1,0-606) == scroll-perspective-1.html scroll-perspective-1-ref.html
# Bugs
fails-if(!layersGPUAccelerated) fuzzy-if(winWidget&&webrender,5-5,71-71) == 1035611-1.html 1035611-1-ref.html # Bug 1072898 for !layersGPUAccelerated failures
fails-if(!layersGPUAccelerated) == 1035611-1.html 1035611-1-ref.html # Bug 1072898 for !layersGPUAccelerated failures
!= 1157984-1.html about:blank # Bug 1157984
fuzzy(0-3,0-99) == animate-cube-radians.html animate-cube-radians-ref.html # subpixel AA
fuzzy(0-3,0-99) fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated,0-16,0-6) == animate-cube-radians-zoom.html animate-cube-radians-zoom-ref.html