Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce PicturePrimitive::Image. #2031

Merged
merged 3 commits into from Nov 15, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -90,11 +90,6 @@ void main(void) {
* 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/. */

vec4 Blur(float radius, vec2 direction) {
// TODO(gw): Support blur in WR2!
return vec4(1.0);
}

vec4 Contrast(vec4 Cs, float amount) {
return vec4(Cs.rgb * amount - 0.5 * amount + 0.5, 1.0);
}
@@ -135,8 +130,7 @@ void main(void) {

switch (vOp) {
case 0:
// Gaussian blur is specially handled:
oFragColor = Cs;// Blur(vAmount, vec2(0,0));
oFragColor = Cs;
break;
case 1:
oFragColor = Contrast(Cs, vAmount);
@@ -4,7 +4,8 @@

use api::{BorderRadiusKind, ColorF, LayerPoint, LayerRect, LayerSize, LayerVector2D};
use api::{BorderRadius, BoxShadowClipMode, LayoutSize, LayerPrimitiveInfo};
use api::{ClipMode, ComplexClipRegion, EdgeAaSegmentMask, LocalClip, ClipAndScrollInfo};
use api::{ClipMode, ClipAndScrollInfo, ComplexClipRegion, EdgeAaSegmentMask, LocalClip};
use api::{PipelineId};
use clip::ClipSource;
use frame_builder::FrameBuilder;
use prim_store::{PrimitiveContainer, RectangleContent, RectanglePrimitive};
@@ -24,6 +25,7 @@ pub const MASK_CORNER_PADDING: f32 = 4.0;
impl FrameBuilder {
pub fn add_box_shadow(
&mut self,
pipeline_id: PipelineId,
clip_and_scroll: ClipAndScrollInfo,
prim_info: &LayerPrimitiveInfo,
box_offset: &LayerVector2D,
@@ -51,8 +53,8 @@ impl FrameBuilder {
spread_amount,
);
let shadow_rect = prim_info.rect
.translate(box_offset)
.inflate(spread_amount, spread_amount);
.translate(box_offset)
.inflate(spread_amount, spread_amount);

if blur_radius == 0.0 {
let mut clips = Vec::new();
@@ -185,13 +187,12 @@ impl FrameBuilder {
Vec::new(),
clip_mode,
radii_kind,
pipeline_id,
);
pic_prim.add_primitive(
brush_prim_index,
&brush_rect,
clip_and_scroll
);
pic_prim.build();

// TODO(gw): Right now, we always use a clip out
// mask for outset shadows. We can make this
@@ -264,13 +265,12 @@ impl FrameBuilder {
BoxShadowClipMode::Inset,
// TODO(gw): Make use of optimization for inset.
BorderRadiusKind::NonUniform,
pipeline_id,
);
pic_prim.add_primitive(
brush_prim_index,
&brush_rect,
clip_and_scroll
);
pic_prim.build();

// Draw the picture one pixel outside the original
// rect to account for the inflate above. This
@@ -13,7 +13,7 @@ use prim_store::{ClipData, ImageMaskData};
use resource_cache::ResourceCache;
use util::{extract_inner_rect_safe, TransformedRect};

const MAX_CLIP: f32 = 1000000.0;
pub const MAX_CLIP: f32 = 1000000.0;

pub type ClipStore = FreeList<ClipSources>;
pub type ClipSourcesHandle = FreeListHandle<ClipSources>;
@@ -309,6 +309,7 @@ impl ClipScrollNode {
}
None => {
state.combined_outer_clip_bounds = DeviceIntRect::zero();
self.combined_clip_outer_bounds = DeviceIntRect::zero();
ClipScrollNodeData::invalid()
}
};
@@ -48,6 +48,7 @@ struct FlattenContext<'a> {
opaque_parts: Vec<LayoutRect>,
/// Same for the transparent rectangles.
transparent_parts: Vec<LayoutRect>,
output_pipelines: &'a FastHashSet<PipelineId>,
}

impl<'a> FlattenContext<'a> {
@@ -88,21 +89,18 @@ impl<'a> FlattenContext<'a> {
root_reference_frame_id: ClipId,
root_scroll_frame_id: ClipId,
) {
let clip_id = ClipId::root_scroll_node(pipeline_id);

self.builder.push_stacking_context(
&LayerVector2D::zero(),
pipeline_id,
CompositeOps::default(),
TransformStyle::Flat,
true,
true,
ClipAndScrollInfo::simple(clip_id),
self.output_pipelines,
);

// We do this here, rather than above because we want any of the top-level
// stacking contexts in the display list to be treated like root stacking contexts.
// FIXME(mrobinson): Currently only the first one will, which for the moment is
// sufficient for all our use cases.
self.builder.notify_waiting_for_root_stacking_context();

// For the root pipeline, there's no need to add a full screen rectangle
// here, as it's handled by the framebuffer clear.
if self.scene.root_pipeline_id != Some(pipeline_id) {
@@ -121,7 +119,11 @@ impl<'a> FlattenContext<'a> {
}


self.flatten_items(traversal, pipeline_id, LayerVector2D::zero());
self.flatten_items(
traversal,
pipeline_id,
LayerVector2D::zero(),
);

if self.builder.config.enable_scrollbars {
let scrollbar_rect = LayerRect::new(LayerPoint::zero(), LayerSize::new(10.0, 70.0));
@@ -154,7 +156,11 @@ impl<'a> FlattenContext<'a> {
return;
}

self.flatten_item(item, pipeline_id, reference_frame_relative_offset)
self.flatten_item(
item,
pipeline_id,
reference_frame_relative_offset,
)
};

// If flatten_item created a sub-traversal, we need `traversal` to have the
@@ -286,15 +292,18 @@ impl<'a> FlattenContext<'a> {
reference_frame_relative_offset.x + bounds.origin.x,
reference_frame_relative_offset.y + bounds.origin.y,
);
}
};

let sc_scroll_node_id = self.apply_scroll_frame_id_replacement(context_scroll_node_id);

self.builder.push_stacking_context(
&reference_frame_relative_offset,
pipeline_id,
composition_operations,
stacking_context.transform_style,
is_backface_visible,
false,
ClipAndScrollInfo::simple(sc_scroll_node_id),
self.output_pipelines,
);

self.flatten_items(
@@ -518,6 +527,7 @@ impl<'a> FlattenContext<'a> {
let mut prim_info = prim_info.clone();
prim_info.rect = bounds;
self.builder.add_box_shadow(
pipeline_id,
clip_and_scroll,
&prim_info,
&box_shadow_info.offset,
@@ -1088,6 +1098,7 @@ impl FrameContext {
window_size: DeviceUintSize,
inner_rect: DeviceUintRect,
device_pixel_ratio: f32,
output_pipelines: &FastHashSet<PipelineId>,
) -> Option<FrameBuilder> {
let root_pipeline_id = match scene.root_pipeline_id {
Some(root_pipeline_id) => root_pipeline_id,
@@ -1128,6 +1139,7 @@ impl FrameContext {
replacements: Vec::new(),
opaque_parts: Vec::new(),
transparent_parts: Vec::new(),
output_pipelines,
};

roller.builder.push_root(
@@ -1154,6 +1166,8 @@ impl FrameContext {
scroll_frame_id,
);

debug_assert!(roller.builder.picture_stack.is_empty());

self.pipeline_epoch_map.extend(roller.pipeline_epochs.drain(..));
roller.builder
};
@@ -1180,7 +1194,6 @@ impl FrameContext {
pipelines: &FastHashMap<PipelineId, ScenePipeline>,
device_pixel_ratio: f32,
pan: LayerPoint,
output_pipelines: &FastHashSet<PipelineId>,
texture_cache_profile: &mut TextureCacheProfileCounters,
gpu_cache_profile: &mut GpuCacheProfileCounters,
) -> RendererFrame {
@@ -1192,7 +1205,6 @@ impl FrameContext {
pipelines,
device_pixel_ratio,
pan,
output_pipelines,
texture_cache_profile,
gpu_cache_profile,
);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.