зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1888400, bug 1887837, bug 1885571) for causing reftest failures on radial-size-1a.html. CLOSED TREE
Backed out changeset b8e93a704beb (bug 1888400) Backed out changeset b15f6d439444 (bug 1887837) Backed out changeset 09548e11b44f (bug 1885571) Backed out changeset 0fd0f35dc653 (bug 1888400) Backed out changeset d9e0b8db1532 (bug 1888400)
This commit is contained in:
Родитель
0fa9577fc3
Коммит
8934b4bd6e
|
@ -1,74 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
/// This shader renders radial graidents in a color or alpha target.
|
||||
|
||||
#include ps_quad,gradient
|
||||
|
||||
#define PI 3.141592653589793
|
||||
|
||||
// x: start offset, y: offset scale, z: angle
|
||||
// Packed in to a vector to work around bug 1630356.
|
||||
flat varying highp vec3 v_start_offset_offset_scale_angle_vec;
|
||||
#define v_start_offset v_start_offset_offset_scale_angle_vec.x
|
||||
#define v_offset_scale v_start_offset_offset_scale_angle_vec.y
|
||||
#define v_angle v_start_offset_offset_scale_angle_vec.z
|
||||
|
||||
varying highp vec2 v_dir;
|
||||
|
||||
#ifdef WR_VERTEX_SHADER
|
||||
struct ConicGradient {
|
||||
vec2 center;
|
||||
vec2 scale;
|
||||
float start_offset;
|
||||
float end_offset;
|
||||
float angle;
|
||||
// 1.0 if the gradient should be repeated, 0.0 otherwise.
|
||||
float repeat;
|
||||
};
|
||||
|
||||
ConicGradient fetch_conic_gradient(int address) {
|
||||
vec4[2] data = fetch_from_gpu_buffer_2f(address);
|
||||
|
||||
return ConicGradient(
|
||||
data[0].xy,
|
||||
data[0].zw,
|
||||
data[1].x,
|
||||
data[1].y,
|
||||
data[1].z,
|
||||
data[1].w
|
||||
);
|
||||
}
|
||||
|
||||
void pattern_vertex(PrimitiveInfo info) {
|
||||
ConicGradient gradient = fetch_conic_gradient(info.pattern_input.x);
|
||||
v_gradient_address.x = info.pattern_input.y;
|
||||
v_gradient_repeat.x = gradient.repeat;
|
||||
|
||||
// Store 1/d where d = end_offset - start_offset
|
||||
// If d = 0, we can't get its reciprocal. Instead, just use a zero scale.
|
||||
float d = gradient.end_offset - gradient.start_offset;
|
||||
v_offset_scale = d != 0.0 ? 1.0 / d : 0.0;
|
||||
|
||||
v_angle = PI / 2.0 - gradient.angle;
|
||||
v_start_offset = gradient.start_offset * v_offset_scale;
|
||||
v_dir = ((info.local_pos - info.local_prim_rect.p0) * gradient.scale - gradient.center);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
|
||||
vec4 pattern_fragment(vec4 color) {
|
||||
// Use inverse trig to find the angle offset from the relative position.
|
||||
vec2 current_dir = v_dir;
|
||||
float current_angle = atan(current_dir.y, current_dir.x) + v_angle;
|
||||
float offset = fract(current_angle / (2.0 * PI)) * v_offset_scale - v_start_offset;
|
||||
|
||||
color *= sample_gradient(offset);
|
||||
return color;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,81 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
/// This shader renders radial graidents in a color or alpha target.
|
||||
|
||||
#include ps_quad,gradient
|
||||
|
||||
// Start radius. Packed in to a vector to work around bug 1630356.
|
||||
flat varying highp vec2 v_start_radius;
|
||||
varying highp vec2 v_pos;
|
||||
|
||||
struct RadialGradient {
|
||||
vec2 center;
|
||||
vec2 scale;
|
||||
float start_radius;
|
||||
float end_radius;
|
||||
float xy_ratio;
|
||||
// 1.0 if the gradient should be repeated, 0.0 otherwise.
|
||||
float repeat;
|
||||
};
|
||||
|
||||
RadialGradient fetch_radial_gradient(int address) {
|
||||
vec4[2] data = fetch_from_gpu_buffer_2f(address);
|
||||
|
||||
return RadialGradient(
|
||||
data[0].xy,
|
||||
data[0].zw,
|
||||
data[1].x,
|
||||
data[1].y,
|
||||
data[1].z,
|
||||
data[1].w
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef WR_VERTEX_SHADER
|
||||
void pattern_vertex(PrimitiveInfo info) {
|
||||
RadialGradient gradient = fetch_radial_gradient(info.pattern_input.x);
|
||||
v_gradient_address.x = info.pattern_input.y;
|
||||
|
||||
// Store 1/rd where rd = end_radius - start_radius
|
||||
// If rd = 0, we can't get its reciprocal. Instead, just use a zero scale.
|
||||
float rd = gradient.end_radius - gradient.start_radius;
|
||||
float radius_scale = rd != 0.0 ? 1.0 / rd : 0.0;
|
||||
|
||||
v_start_radius.x = gradient.start_radius * radius_scale;
|
||||
|
||||
// Transform all coordinates by the y scale so the
|
||||
// fragment shader can work with circles
|
||||
|
||||
// v_pos is in a coordinate space relative to the task rect
|
||||
// (so it is independent of the task origin).
|
||||
v_pos = ((info.local_pos - info.local_prim_rect.p0) * gradient.scale - gradient.center) * radius_scale;
|
||||
v_pos.y *= gradient.xy_ratio;
|
||||
|
||||
v_gradient_repeat.x = gradient.repeat;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
vec4 pattern_fragment(vec4 color) {
|
||||
// Solve for t in length(pd) = v_start_radius + t * rd
|
||||
float offset = length(v_pos) - v_start_radius.x;
|
||||
color *= sample_gradient(offset);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#if defined(SWGL_DRAW_SPAN)
|
||||
void swgl_drawSpanRGBA8() {
|
||||
int address = swgl_validateGradient(sGpuBufferF, get_gpu_buffer_uv(v_gradient_address.x),
|
||||
int(GRADIENT_ENTRIES + 2.0));
|
||||
if (address < 0) {
|
||||
return;
|
||||
}
|
||||
swgl_commitRadialGradientRGBA8(sGpuBufferF, address, GRADIENT_ENTRIES, v_gradient_repeat.x != 0.0,
|
||||
v_pos, v_start_radius.x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -571,7 +571,6 @@ impl From<QuadInstance> for PrimitiveInstanceData {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
pub struct QuadSegment {
|
||||
pub rect: LayoutRect,
|
||||
|
|
|
@ -10,14 +10,12 @@ use api::{ColorF, PremultipliedColorF};
|
|||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum PatternKind {
|
||||
ColorOrTexture = 0,
|
||||
RadialGradient = 1,
|
||||
ConicGradient = 2,
|
||||
|
||||
Mask = 3,
|
||||
Mask = 1,
|
||||
// When adding patterns, don't forget to update the NUM_PATTERNS constant.
|
||||
}
|
||||
|
||||
pub const NUM_PATTERNS: u32 = 4;
|
||||
pub const NUM_PATTERNS: u32 = 2;
|
||||
|
||||
impl PatternKind {
|
||||
pub fn from_u32(val: u32) -> Self {
|
||||
|
|
|
@ -28,7 +28,7 @@ use crate::prim_store::line_dec::MAX_LINE_DECORATION_RESOLUTION;
|
|||
use crate::prim_store::*;
|
||||
use crate::quad;
|
||||
use crate::pattern::Pattern;
|
||||
use crate::prim_store::gradient::{radial_gradient_pattern, conic_gradient_pattern, GradientGpuBlockBuilder};
|
||||
use crate::prim_store::gradient::GradientGpuBlockBuilder;
|
||||
use crate::render_backend::DataStores;
|
||||
use crate::render_task_graph::RenderTaskId;
|
||||
use crate::render_task_cache::RenderTaskCacheKeyKind;
|
||||
|
@ -209,32 +209,6 @@ fn prepare_prim_for_render(
|
|||
let prim_instance = &mut prim_instances[prim_instance_index];
|
||||
|
||||
if !is_passthrough {
|
||||
fn may_need_repetition(stretch_size: LayoutSize, prim_rect: LayoutRect) -> bool {
|
||||
stretch_size.width < prim_rect.width() ||
|
||||
stretch_size.height < prim_rect.height()
|
||||
}
|
||||
// Bug 1887841: At the moment the quad shader does not support repetitions.
|
||||
// Bug 1888349: Some primitives have brush segments that aren't handled by
|
||||
// the quad infrastructure yet.
|
||||
let disable_quad_path = match &prim_instance.kind {
|
||||
PrimitiveInstanceKind::Rectangle { .. } => false,
|
||||
PrimitiveInstanceKind::LinearGradient { data_handle, .. } => {
|
||||
let prim_data = &data_stores.linear_grad[*data_handle];
|
||||
!prim_data.brush_segments.is_empty() ||
|
||||
may_need_repetition(prim_data.stretch_size, prim_data.common.prim_rect)
|
||||
}
|
||||
PrimitiveInstanceKind::RadialGradient { data_handle, .. } => {
|
||||
let prim_data = &data_stores.radial_grad[*data_handle];
|
||||
!prim_data.brush_segments.is_empty() ||
|
||||
may_need_repetition(prim_data.stretch_size, prim_data.common.prim_rect)
|
||||
}
|
||||
PrimitiveInstanceKind::ConicGradient { data_handle, .. } => {
|
||||
let prim_data = &data_stores.conic_grad[*data_handle];
|
||||
!prim_data.brush_segments.is_empty() ||
|
||||
may_need_repetition(prim_data.stretch_size, prim_data.common.prim_rect)
|
||||
}
|
||||
_ => true,
|
||||
};
|
||||
|
||||
// In this initial patch, we only support non-masked primitives through the new
|
||||
// quad rendering path. Follow up patches will extend this to support masks, and
|
||||
|
@ -242,19 +216,18 @@ fn prepare_prim_for_render(
|
|||
// to skip the entry point to `update_clip_task` as that does old-style segmenting
|
||||
// and mask generation.
|
||||
let should_update_clip_task = match prim_instance.kind {
|
||||
PrimitiveInstanceKind::Rectangle { use_legacy_path: ref mut no_quads, .. }
|
||||
| PrimitiveInstanceKind::RadialGradient { cached: ref mut no_quads, .. }
|
||||
| PrimitiveInstanceKind::ConicGradient { cached: ref mut no_quads, .. }
|
||||
=> {
|
||||
*no_quads = disable_quad_path || !can_use_clip_chain_for_quad_path(
|
||||
PrimitiveInstanceKind::Rectangle { ref mut use_legacy_path, .. } => {
|
||||
*use_legacy_path = !can_use_clip_chain_for_quad_path(
|
||||
&prim_instance.vis.clip_chain,
|
||||
frame_state.clip_store,
|
||||
data_stores,
|
||||
);
|
||||
|
||||
*no_quads
|
||||
*use_legacy_path
|
||||
}
|
||||
PrimitiveInstanceKind::Picture { .. } => {
|
||||
false
|
||||
}
|
||||
PrimitiveInstanceKind::Picture { .. } => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
|
@ -805,45 +778,12 @@ fn prepare_interned_prim_for_render(
|
|||
}
|
||||
}
|
||||
}
|
||||
PrimitiveInstanceKind::RadialGradient { data_handle, ref mut visible_tiles_range, cached, .. } => {
|
||||
PrimitiveInstanceKind::RadialGradient { data_handle, ref mut visible_tiles_range, .. } => {
|
||||
profile_scope!("RadialGradient");
|
||||
let prim_data = &mut data_stores.radial_grad[*data_handle];
|
||||
|
||||
if !*cached {
|
||||
// The scaling parameter is used to compensate for when we reduce the size
|
||||
// of the render task for cached gradients. Here we aren't applying any.
|
||||
let no_scale = DeviceVector2D::one();
|
||||
|
||||
let pattern = radial_gradient_pattern(
|
||||
prim_data.center,
|
||||
no_scale,
|
||||
&prim_data.params,
|
||||
prim_data.extend_mode,
|
||||
&prim_data.stops,
|
||||
&mut frame_state.frame_gpu_data,
|
||||
);
|
||||
|
||||
quad::push_quad(
|
||||
&pattern,
|
||||
&prim_data.common.prim_rect,
|
||||
prim_instance_index,
|
||||
prim_spatial_node_index,
|
||||
&prim_instance.vis.clip_chain,
|
||||
device_pixel_scale,
|
||||
frame_context,
|
||||
pic_context,
|
||||
targets,
|
||||
&data_stores.clip,
|
||||
frame_state,
|
||||
pic_state,
|
||||
scratch,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
prim_data.common.may_need_repetition = prim_data.stretch_size.width < prim_data.common.prim_rect.width()
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.height();
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.height();
|
||||
|
||||
// Update the template this instane references, which may refresh the GPU
|
||||
// cache with any shared template data.
|
||||
|
@ -868,44 +808,14 @@ fn prepare_interned_prim_for_render(
|
|||
prim_instance.clear_visibility();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(gw): Consider whether it's worth doing segment building
|
||||
// for gradient primitives.
|
||||
}
|
||||
PrimitiveInstanceKind::ConicGradient { data_handle, ref mut visible_tiles_range, cached, .. } => {
|
||||
PrimitiveInstanceKind::ConicGradient { data_handle, ref mut visible_tiles_range, .. } => {
|
||||
profile_scope!("ConicGradient");
|
||||
let prim_data = &mut data_stores.conic_grad[*data_handle];
|
||||
|
||||
if !*cached {
|
||||
// The scaling parameter is used to compensate for when we reduce the size
|
||||
// of the render task for cached gradients. Here we aren't applying any.
|
||||
let no_scale = DeviceVector2D::one();
|
||||
|
||||
let pattern = conic_gradient_pattern(
|
||||
prim_data.center,
|
||||
no_scale,
|
||||
&prim_data.params,
|
||||
prim_data.extend_mode,
|
||||
&prim_data.stops,
|
||||
&mut frame_state.frame_gpu_data,
|
||||
);
|
||||
|
||||
quad::push_quad(
|
||||
&pattern,
|
||||
&prim_data.common.prim_rect,
|
||||
prim_instance_index,
|
||||
prim_spatial_node_index,
|
||||
&prim_instance.vis.clip_chain,
|
||||
device_pixel_scale,
|
||||
frame_context,
|
||||
pic_context,
|
||||
targets,
|
||||
&data_stores.clip,
|
||||
frame_state,
|
||||
pic_state,
|
||||
scratch,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
prim_data.common.may_need_repetition = prim_data.stretch_size.width < prim_data.common.prim_rect.width()
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.height();
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
use euclid::vec2;
|
||||
use api::{ExtendMode, GradientStop, PremultipliedColorF};
|
||||
use api::units::*;
|
||||
use crate::pattern::{Pattern, PatternKind, PatternShaderInput};
|
||||
use crate::scene_building::IsVisible;
|
||||
use crate::frame_builder::FrameBuildingState;
|
||||
use crate::intern::{Internable, InternDebug, Handle as InternHandle};
|
||||
|
@ -23,8 +22,8 @@ use crate::prim_store::{NinePatchDescriptor, PointKey, SizeKey, InternablePrimit
|
|||
use crate::render_task::{RenderTask, RenderTaskKind};
|
||||
use crate::render_task_graph::RenderTaskId;
|
||||
use crate::render_task_cache::{RenderTaskCacheKeyKind, RenderTaskCacheKey, RenderTaskParent};
|
||||
use crate::renderer::{GpuBufferAddress, GpuBufferBuilder};
|
||||
use crate::picture::SurfaceIndex;
|
||||
use crate::renderer::GpuBufferAddress;
|
||||
use crate::picture::{SurfaceIndex};
|
||||
|
||||
use std::{hash, ops::{Deref, DerefMut}};
|
||||
use super::{stops_and_min_alpha, GradientStopKey, GradientGpuBlockBuilder};
|
||||
|
@ -330,7 +329,6 @@ impl InternablePrimitive for ConicGradient {
|
|||
PrimitiveInstanceKind::ConicGradient {
|
||||
data_handle,
|
||||
visible_tiles_range: GradientTileRange::empty(),
|
||||
cached: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -399,44 +397,3 @@ pub struct ConicGradientCacheKey {
|
|||
pub stops: Vec<GradientStopKey>,
|
||||
}
|
||||
|
||||
pub fn conic_gradient_pattern(
|
||||
center: DevicePoint,
|
||||
scale: DeviceVector2D,
|
||||
params: &ConicGradientParams,
|
||||
extend_mode: ExtendMode,
|
||||
stops: &[GradientStop],
|
||||
gpu_buffer_builder: &mut GpuBufferBuilder
|
||||
) -> Pattern {
|
||||
let mut writer = gpu_buffer_builder.f32.write_blocks(2);
|
||||
writer.push_one([
|
||||
center.x,
|
||||
center.y,
|
||||
scale.x,
|
||||
scale.y,
|
||||
]);
|
||||
writer.push_one([
|
||||
params.start_offset,
|
||||
params.end_offset,
|
||||
params.angle,
|
||||
if extend_mode == ExtendMode::Repeat { 1.0 } else { 0.0 }
|
||||
]);
|
||||
let gradient_address = writer.finish();
|
||||
|
||||
let stops_address = GradientGpuBlockBuilder::build(
|
||||
false,
|
||||
&mut gpu_buffer_builder.f32,
|
||||
&stops,
|
||||
);
|
||||
|
||||
let is_opaque = stops.iter().all(|stop| stop.color.a >= 1.0);
|
||||
|
||||
Pattern {
|
||||
kind: PatternKind::ConicGradient,
|
||||
shader_input: PatternShaderInput(
|
||||
gradient_address.as_int(),
|
||||
stops_address.as_int(),
|
||||
),
|
||||
base_color: PremultipliedColorF::WHITE,
|
||||
is_opaque,
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
use euclid::{vec2, size2};
|
||||
use api::{ExtendMode, GradientStop, PremultipliedColorF, ColorU};
|
||||
use api::units::*;
|
||||
use crate::pattern::{Pattern, PatternKind, PatternShaderInput};
|
||||
use crate::scene_building::IsVisible;
|
||||
use crate::frame_builder::FrameBuildingState;
|
||||
use crate::intern::{Internable, InternDebug, Handle as InternHandle};
|
||||
|
@ -23,8 +22,8 @@ use crate::prim_store::{NinePatchDescriptor, PointKey, SizeKey, FloatKey};
|
|||
use crate::render_task::{RenderTask, RenderTaskKind};
|
||||
use crate::render_task_graph::RenderTaskId;
|
||||
use crate::render_task_cache::{RenderTaskCacheKeyKind, RenderTaskCacheKey, RenderTaskParent};
|
||||
use crate::renderer::{GpuBufferAddress, GpuBufferBuilder};
|
||||
use crate::picture::SurfaceIndex;
|
||||
use crate::renderer::GpuBufferAddress;
|
||||
use crate::picture::{SurfaceIndex};
|
||||
|
||||
use std::{hash, ops::{Deref, DerefMut}};
|
||||
use super::{
|
||||
|
@ -296,7 +295,6 @@ impl InternablePrimitive for RadialGradient {
|
|||
PrimitiveInstanceKind::RadialGradient {
|
||||
data_handle,
|
||||
visible_tiles_range: GradientTileRange::empty(),
|
||||
cached: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -531,45 +529,3 @@ pub fn optimize_radial_gradient(
|
|||
tile_spacing.width += l + r;
|
||||
tile_spacing.height += t + b;
|
||||
}
|
||||
|
||||
pub fn radial_gradient_pattern(
|
||||
center: DevicePoint,
|
||||
scale: DeviceVector2D,
|
||||
params: &RadialGradientParams,
|
||||
extend_mode: ExtendMode,
|
||||
stops: &[GradientStop],
|
||||
gpu_buffer_builder: &mut GpuBufferBuilder
|
||||
) -> Pattern {
|
||||
let mut writer = gpu_buffer_builder.f32.write_blocks(2);
|
||||
writer.push_one([
|
||||
center.x,
|
||||
center.y,
|
||||
scale.x,
|
||||
scale.y,
|
||||
]);
|
||||
writer.push_one([
|
||||
params.start_radius,
|
||||
params.end_radius,
|
||||
params.ratio_xy,
|
||||
if extend_mode == ExtendMode::Repeat { 1.0 } else { 0.0 }
|
||||
]);
|
||||
let gradient_address = writer.finish();
|
||||
|
||||
let stops_address = GradientGpuBlockBuilder::build(
|
||||
false,
|
||||
&mut gpu_buffer_builder.f32,
|
||||
&stops,
|
||||
);
|
||||
|
||||
let is_opaque = stops.iter().all(|stop| stop.color.a >= 1.0);
|
||||
|
||||
Pattern {
|
||||
kind: PatternKind::RadialGradient,
|
||||
shader_input: PatternShaderInput(
|
||||
gradient_address.as_int(),
|
||||
stops_address.as_int(),
|
||||
),
|
||||
base_color: PremultipliedColorF::WHITE,
|
||||
is_opaque,
|
||||
}
|
||||
}
|
|
@ -1029,13 +1029,11 @@ pub enum PrimitiveInstanceKind {
|
|||
/// Handle to the common interned data for this primitive.
|
||||
data_handle: RadialGradientDataHandle,
|
||||
visible_tiles_range: GradientTileRange,
|
||||
cached: bool,
|
||||
},
|
||||
ConicGradient {
|
||||
/// Handle to the common interned data for this primitive.
|
||||
data_handle: ConicGradientDataHandle,
|
||||
visible_tiles_range: GradientTileRange,
|
||||
cached: bool,
|
||||
},
|
||||
/// Clear out a rect, used for special effects.
|
||||
Clear {
|
||||
|
|
|
@ -162,10 +162,10 @@ pub fn push_quad(
|
|||
match strategy {
|
||||
QuadRenderStrategy::Direct => {}
|
||||
QuadRenderStrategy::Indirect => {
|
||||
let task_id = add_render_task_with_mask(
|
||||
let segment = add_segment(
|
||||
pattern,
|
||||
clipped_surface_rect.size(),
|
||||
clipped_surface_rect.min.to_f32(),
|
||||
&clipped_surface_rect,
|
||||
true,
|
||||
clip_chain,
|
||||
prim_spatial_node_index,
|
||||
pic_context.raster_spatial_node_index,
|
||||
|
@ -178,15 +178,14 @@ pub fn push_quad(
|
|||
frame_state,
|
||||
);
|
||||
|
||||
let rect = clipped_surface_rect.to_f32().cast_unit();
|
||||
add_composite_prim(
|
||||
pattern,
|
||||
prim_instance_index,
|
||||
rect,
|
||||
segment.rect,
|
||||
quad_flags,
|
||||
frame_state,
|
||||
targets,
|
||||
&[QuadSegment { rect, task_id }],
|
||||
&[segment],
|
||||
);
|
||||
}
|
||||
QuadRenderStrategy::Tiled { x_tiles, y_tiles } => {
|
||||
|
@ -227,17 +226,16 @@ pub fn push_quad(
|
|||
continue;
|
||||
}
|
||||
|
||||
let int_rect = DeviceIntRect {
|
||||
let create_task = true;
|
||||
let rect = DeviceIntRect {
|
||||
min: point2(x0, y0),
|
||||
max: point2(x1, y1),
|
||||
};
|
||||
|
||||
let rect = int_rect.to_f32();
|
||||
|
||||
let task_id = add_render_task_with_mask(
|
||||
let segment = add_segment(
|
||||
pattern,
|
||||
int_rect.size(),
|
||||
rect.min,
|
||||
&rect,
|
||||
create_task,
|
||||
clip_chain,
|
||||
prim_spatial_node_index,
|
||||
pic_context.raster_spatial_node_index,
|
||||
|
@ -249,8 +247,7 @@ pub fn push_quad(
|
|||
needs_scissor,
|
||||
frame_state,
|
||||
);
|
||||
|
||||
scratch.quad_segments.push(QuadSegment { rect: rect.cast_unit(), task_id });
|
||||
scratch.quad_segments.push(segment);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,16 +318,6 @@ pub fn push_quad(
|
|||
|
||||
scratch.quad_segments.clear();
|
||||
|
||||
fn should_create_task(mode: ClipMode, x: usize, y: usize) -> bool {
|
||||
match mode {
|
||||
// Only create render tasks for the corners.
|
||||
ClipMode::Clip => x != 1 && y != 1,
|
||||
// Create render tasks for all segments (the
|
||||
// center will be skipped).
|
||||
ClipMode::ClipOut => true,
|
||||
}
|
||||
}
|
||||
|
||||
for y in 0 .. y_coords.len()-1 {
|
||||
let y0 = y_coords[y];
|
||||
let y1 = y_coords[y+1];
|
||||
|
@ -340,16 +327,6 @@ pub fn push_quad(
|
|||
}
|
||||
|
||||
for x in 0 .. x_coords.len()-1 {
|
||||
// We'll create render tasks and segments for the corners in a
|
||||
// separate loop.
|
||||
if should_create_task(mode, x, y) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if mode == ClipMode::ClipOut && x == 1 && y == 1 {
|
||||
continue;
|
||||
}
|
||||
|
||||
let x0 = x_coords[x];
|
||||
let x1 = x_coords[x+1];
|
||||
|
||||
|
@ -357,73 +334,33 @@ pub fn push_quad(
|
|||
continue;
|
||||
}
|
||||
|
||||
let create_task = match mode {
|
||||
ClipMode::Clip => {
|
||||
// Only create render tasks for the corners.
|
||||
x != 1 && y != 1
|
||||
}
|
||||
ClipMode::ClipOut => {
|
||||
if x == 1 && y == 1 {
|
||||
continue;
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
};
|
||||
|
||||
let rect = DeviceIntRect::new(point2(x0, y0), point2(x1, y1));
|
||||
|
||||
let device_rect = match rect.intersection(&clipped_surface_rect) {
|
||||
let rect = match rect.intersection(&clipped_surface_rect) {
|
||||
Some(rect) => rect,
|
||||
None => {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
scratch.quad_segments.push(QuadSegment {
|
||||
rect: device_rect.to_f32().cast_unit(),
|
||||
task_id: RenderTaskId::INVALID,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if !scratch.quad_segments.is_empty() {
|
||||
add_pattern_prim(
|
||||
pattern,
|
||||
prim_instance_index,
|
||||
unclipped_surface_rect.cast_unit(),
|
||||
quad_flags,
|
||||
frame_state,
|
||||
targets,
|
||||
&scratch.quad_segments,
|
||||
);
|
||||
}
|
||||
|
||||
scratch.quad_segments.clear();
|
||||
// Only create render tasks for the corners.
|
||||
for y in 0 .. y_coords.len()-1 {
|
||||
let y0 = y_coords[y];
|
||||
let y1 = y_coords[y+1];
|
||||
|
||||
if y1 <= y0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
for x in 0 .. x_coords.len()-1 {
|
||||
if !should_create_task(mode, x, y) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if mode == ClipMode::ClipOut && x == 1 && y == 1 {
|
||||
continue;
|
||||
}
|
||||
|
||||
let x0 = x_coords[x];
|
||||
let x1 = x_coords[x+1];
|
||||
|
||||
if x1 <= x0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
let rect = DeviceIntRect::new(point2(x0, y0), point2(x1, y1));
|
||||
|
||||
let device_rect = match rect.intersection(&clipped_surface_rect) {
|
||||
Some(rect) => rect,
|
||||
None => {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
let task_id = add_render_task_with_mask(
|
||||
let segment = add_segment(
|
||||
pattern,
|
||||
device_rect.size(),
|
||||
device_rect.min.to_f32(),
|
||||
&rect,
|
||||
create_task,
|
||||
clip_chain,
|
||||
prim_spatial_node_index,
|
||||
pic_context.raster_spatial_node_index,
|
||||
|
@ -435,9 +372,7 @@ pub fn push_quad(
|
|||
false,
|
||||
frame_state,
|
||||
);
|
||||
|
||||
let rect = device_rect.to_f32().cast_unit();
|
||||
scratch.quad_segments.push(QuadSegment { rect, task_id });
|
||||
scratch.quad_segments.push(segment);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,10 +462,10 @@ fn get_prim_render_strategy(
|
|||
}
|
||||
}
|
||||
|
||||
fn add_render_task_with_mask(
|
||||
fn add_segment(
|
||||
pattern: &Pattern,
|
||||
task_size: DeviceIntSize,
|
||||
content_origin: DevicePoint,
|
||||
rect: &DeviceIntRect,
|
||||
create_task: bool,
|
||||
clip_chain: &ClipChainInstance,
|
||||
prim_spatial_node_index: SpatialNodeIndex,
|
||||
raster_spatial_node_index: SpatialNodeIndex,
|
||||
|
@ -541,73 +476,49 @@ fn add_render_task_with_mask(
|
|||
device_pixel_scale: DevicePixelScale,
|
||||
needs_scissor_rect: bool,
|
||||
frame_state: &mut FrameBuildingState,
|
||||
) -> RenderTaskId {
|
||||
let task_id = frame_state.rg_builder.add().init(RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_prim(
|
||||
pattern.kind,
|
||||
pattern.shader_input,
|
||||
prim_spatial_node_index,
|
||||
raster_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
content_origin,
|
||||
prim_address_f,
|
||||
transform_id,
|
||||
aa_flags,
|
||||
quad_flags,
|
||||
clip_chain.clips_range,
|
||||
needs_scissor_rect,
|
||||
),
|
||||
));
|
||||
) -> QuadSegment {
|
||||
let task_size = rect.size();
|
||||
let rect = rect.to_f32();
|
||||
let content_origin = rect.min;
|
||||
|
||||
let masks = MaskSubPass {
|
||||
clip_node_range: clip_chain.clips_range,
|
||||
prim_spatial_node_index,
|
||||
prim_address_f,
|
||||
let task_id = if create_task {
|
||||
let task_id = frame_state.rg_builder.add().init(RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_prim(
|
||||
pattern.kind,
|
||||
pattern.shader_input,
|
||||
prim_spatial_node_index,
|
||||
raster_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
content_origin,
|
||||
prim_address_f,
|
||||
transform_id,
|
||||
aa_flags,
|
||||
quad_flags,
|
||||
clip_chain.clips_range,
|
||||
needs_scissor_rect,
|
||||
),
|
||||
));
|
||||
|
||||
let masks = MaskSubPass {
|
||||
clip_node_range: clip_chain.clips_range,
|
||||
prim_spatial_node_index,
|
||||
prim_address_f,
|
||||
};
|
||||
|
||||
let task = frame_state.rg_builder.get_task_mut(task_id);
|
||||
task.add_sub_pass(SubPass::Masks { masks });
|
||||
|
||||
frame_state
|
||||
.surface_builder
|
||||
.add_child_render_task(task_id, frame_state.rg_builder);
|
||||
|
||||
task_id
|
||||
} else {
|
||||
RenderTaskId::INVALID
|
||||
};
|
||||
|
||||
let task = frame_state.rg_builder.get_task_mut(task_id);
|
||||
task.add_sub_pass(SubPass::Masks { masks });
|
||||
|
||||
frame_state
|
||||
.surface_builder
|
||||
.add_child_render_task(task_id, frame_state.rg_builder);
|
||||
|
||||
task_id
|
||||
}
|
||||
|
||||
fn add_pattern_prim(
|
||||
pattern: &Pattern,
|
||||
prim_instance_index: PrimitiveInstanceIndex,
|
||||
rect: LayoutRect,
|
||||
quad_flags: QuadFlags,
|
||||
frame_state: &mut FrameBuildingState,
|
||||
targets: &[CommandBufferIndex],
|
||||
segments: &[QuadSegment],
|
||||
) {
|
||||
let prim_address = write_prim_blocks(
|
||||
&mut frame_state.frame_gpu_data.f32,
|
||||
rect,
|
||||
rect,
|
||||
pattern.base_color,
|
||||
segments,
|
||||
);
|
||||
|
||||
frame_state.set_segments(segments, targets);
|
||||
|
||||
frame_state.push_cmd(
|
||||
&PrimitiveCommand::quad(
|
||||
pattern.kind,
|
||||
pattern.shader_input,
|
||||
prim_instance_index,
|
||||
prim_address,
|
||||
TransformPaletteId::IDENTITY,
|
||||
quad_flags,
|
||||
// TODO(gw): No AA on composite, unless we use it to apply 2d clips
|
||||
EdgeAaSegmentMask::empty(),
|
||||
),
|
||||
targets,
|
||||
);
|
||||
QuadSegment { rect: rect.cast_unit(), task_id }
|
||||
}
|
||||
|
||||
fn add_composite_prim(
|
||||
|
|
|
@ -263,7 +263,7 @@ impl RenderTarget for ColorRenderTarget {
|
|||
used_rect,
|
||||
resolve_ops: Vec::new(),
|
||||
clear_color: Some(ColorF::TRANSPARENT),
|
||||
prim_instances: [Vec::new(), Vec::new(), Vec::new(), Vec::new()],
|
||||
prim_instances: [Vec::new(), Vec::new()],
|
||||
prim_instances_with_scissor: FastHashMap::default(),
|
||||
clip_masks: ClipMaskInstanceList::new(),
|
||||
}
|
||||
|
|
|
@ -193,11 +193,11 @@ const GPU_TAG_CACHE_LINEAR_GRADIENT: GpuProfileTag = GpuProfileTag {
|
|||
label: "C_LinearGradient",
|
||||
color: debug_colors::BROWN,
|
||||
};
|
||||
const GPU_TAG_RADIAL_GRADIENT: GpuProfileTag = GpuProfileTag {
|
||||
const GPU_TAG_CACHE_RADIAL_GRADIENT: GpuProfileTag = GpuProfileTag {
|
||||
label: "C_RadialGradient",
|
||||
color: debug_colors::BROWN,
|
||||
};
|
||||
const GPU_TAG_CONIC_GRADIENT: GpuProfileTag = GpuProfileTag {
|
||||
const GPU_TAG_CACHE_CONIC_GRADIENT: GpuProfileTag = GpuProfileTag {
|
||||
label: "C_ConicGradient",
|
||||
color: debug_colors::BROWN,
|
||||
};
|
||||
|
@ -288,8 +288,6 @@ impl BatchKind {
|
|||
}
|
||||
BatchKind::TextRun(_) => GPU_TAG_PRIM_TEXT_RUN,
|
||||
BatchKind::Quad(PatternKind::ColorOrTexture) => GPU_TAG_PRIMITIVE,
|
||||
BatchKind::Quad(PatternKind::RadialGradient) => GPU_TAG_RADIAL_GRADIENT,
|
||||
BatchKind::Quad(PatternKind::ConicGradient) => GPU_TAG_CONIC_GRADIENT,
|
||||
BatchKind::Quad(PatternKind::Mask) => GPU_TAG_INDIRECT_MASK,
|
||||
}
|
||||
}
|
||||
|
@ -4071,7 +4069,7 @@ impl Renderer {
|
|||
|
||||
// Draw any radial gradients for this target.
|
||||
if !target.radial_gradients.is_empty() {
|
||||
let _timer = self.gpu_profiler.start_timer(GPU_TAG_RADIAL_GRADIENT);
|
||||
let _timer = self.gpu_profiler.start_timer(GPU_TAG_CACHE_RADIAL_GRADIENT);
|
||||
|
||||
self.set_blend(false, FramebufferKind::Other);
|
||||
|
||||
|
@ -4097,7 +4095,7 @@ impl Renderer {
|
|||
|
||||
// Draw any conic gradients for this target.
|
||||
if !target.conic_gradients.is_empty() {
|
||||
let _timer = self.gpu_profiler.start_timer(GPU_TAG_CONIC_GRADIENT);
|
||||
let _timer = self.gpu_profiler.start_timer(GPU_TAG_CACHE_CONIC_GRADIENT);
|
||||
|
||||
self.set_blend(false, FramebufferKind::Other);
|
||||
|
||||
|
|
|
@ -632,8 +632,6 @@ pub struct Shaders {
|
|||
|
||||
ps_split_composite: LazilyCompiledShader,
|
||||
pub ps_quad_textured: LazilyCompiledShader,
|
||||
pub ps_quad_radial_gradient: LazilyCompiledShader,
|
||||
pub ps_quad_conic_gradient: LazilyCompiledShader,
|
||||
pub ps_mask: LazilyCompiledShader,
|
||||
pub ps_mask_fast: LazilyCompiledShader,
|
||||
pub ps_clear: LazilyCompiledShader,
|
||||
|
@ -890,26 +888,6 @@ impl Shaders {
|
|||
profile,
|
||||
)?;
|
||||
|
||||
let ps_quad_radial_gradient = LazilyCompiledShader::new(
|
||||
ShaderKind::Primitive,
|
||||
"ps_quad_radial_gradient",
|
||||
&[],
|
||||
device,
|
||||
options.precache_flags,
|
||||
&shader_list,
|
||||
profile,
|
||||
)?;
|
||||
|
||||
let ps_quad_conic_gradient = LazilyCompiledShader::new(
|
||||
ShaderKind::Primitive,
|
||||
"ps_quad_conic_gradient",
|
||||
&[],
|
||||
device,
|
||||
options.precache_flags,
|
||||
&shader_list,
|
||||
profile,
|
||||
)?;
|
||||
|
||||
let ps_split_composite = LazilyCompiledShader::new(
|
||||
ShaderKind::Primitive,
|
||||
"ps_split_composite",
|
||||
|
@ -1144,8 +1122,6 @@ impl Shaders {
|
|||
ps_text_run,
|
||||
ps_text_run_dual_source,
|
||||
ps_quad_textured,
|
||||
ps_quad_radial_gradient,
|
||||
ps_quad_conic_gradient,
|
||||
ps_mask,
|
||||
ps_mask_fast,
|
||||
ps_split_composite,
|
||||
|
@ -1184,8 +1160,6 @@ impl Shaders {
|
|||
) -> &mut LazilyCompiledShader {
|
||||
match pattern {
|
||||
PatternKind::ColorOrTexture => &mut self.ps_quad_textured,
|
||||
PatternKind::RadialGradient => &mut self.ps_quad_radial_gradient,
|
||||
PatternKind::ConicGradient => &mut self.ps_quad_conic_gradient,
|
||||
PatternKind::Mask => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
@ -1201,12 +1175,6 @@ impl Shaders {
|
|||
BatchKind::Quad(PatternKind::ColorOrTexture) => {
|
||||
&mut self.ps_quad_textured
|
||||
}
|
||||
BatchKind::Quad(PatternKind::RadialGradient) => {
|
||||
&mut self.ps_quad_radial_gradient
|
||||
}
|
||||
BatchKind::Quad(PatternKind::ConicGradient) => {
|
||||
&mut self.ps_quad_conic_gradient
|
||||
}
|
||||
BatchKind::Quad(PatternKind::Mask) => {
|
||||
unreachable!();
|
||||
}
|
||||
|
@ -1337,8 +1305,6 @@ impl Shaders {
|
|||
self.cs_border_segment.deinit(device);
|
||||
self.ps_split_composite.deinit(device);
|
||||
self.ps_quad_textured.deinit(device);
|
||||
self.ps_quad_radial_gradient.deinit(device);
|
||||
self.ps_quad_conic_gradient.deinit(device);
|
||||
self.ps_mask.deinit(device);
|
||||
self.ps_mask_fast.deinit(device);
|
||||
self.ps_clear.deinit(device);
|
||||
|
|
|
@ -228,10 +228,6 @@ pub fn get_shader_features(flags: ShaderFeatureFlags) -> ShaderFeatures {
|
|||
|
||||
shaders.insert("ps_quad_textured", vec![base_prim_features.finish()]);
|
||||
|
||||
shaders.insert("ps_quad_radial_gradient", vec![base_prim_features.finish()]);
|
||||
|
||||
shaders.insert("ps_quad_conic_gradient", vec![base_prim_features.finish()]);
|
||||
|
||||
shaders.insert("ps_clear", vec![base_prim_features.finish()]);
|
||||
|
||||
shaders.insert("ps_copy", vec![base_prim_features.finish()]);
|
||||
|
|
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 17 KiB |
|
@ -1,21 +0,0 @@
|
|||
# This test contains a radial gradient with rounded corners.
|
||||
# The primitive is large enough to exercise the quad nine-patch
|
||||
# code path.
|
||||
# In addition the primitive contains a large solid color portion
|
||||
# causing the gradient optimization to split it into two primitives.
|
||||
---
|
||||
root:
|
||||
items:
|
||||
- type: clip
|
||||
id: 5
|
||||
complex:
|
||||
- rect: [10, 10, 750, 500]
|
||||
radius: 32
|
||||
- type: radial-gradient
|
||||
bounds: 10 10 750 500
|
||||
center: 0 0
|
||||
radius: 400 350
|
||||
stops: [0.0, red, 1.0, blue]
|
||||
clip-chain: [5]
|
||||
|
||||
|
|
@ -82,7 +82,6 @@ fuzzy(1,7) == tiling-conic-3.yaml tiling-conic-3-ref.yaml
|
|||
platform(linux,mac) == linear-aligned-border-radius.yaml linear-aligned-border-radius.png
|
||||
# interpolation fuzz from sampling texture-baked gradient ramps
|
||||
platform(linux,mac) fuzzy-range(<=1,*1404) == repeat-border-radius.yaml repeat-border-radius.png
|
||||
fuzzy(1,6000) == radial-border-radius-large.yaml radial-border-radius-large-ref.png
|
||||
|
||||
== conic.yaml conic-ref.yaml
|
||||
fuzzy(1,57) == conic-simple.yaml conic-simple.png
|
||||
|
@ -120,7 +119,7 @@ fuzzy-range(<=1,1) == gradient_cache_hardstop_clip.yaml gradient_cache_hardstop_
|
|||
fuzzy(2,23000) == linear-large.yaml linear-large-ref.yaml
|
||||
== conic-large.yaml conic-large-ref.yaml
|
||||
fuzzy-if(env(android,device),254,1) == conic-large-hard-stop.yaml conic-large-hard-stop-ref.yaml # Android device is Samsung Galaxy A51
|
||||
fuzzy(1,80000) == radial-large.yaml radial-large-ref.png
|
||||
fuzzy(1,7000) == radial-large.yaml radial-large-ref.png
|
||||
|
||||
# crash tests
|
||||
== linear-far-endpoints.yaml linear-far-endpoints.yaml
|
||||
|
|
Загрузка…
Ссылка в новой задаче