Skip to content
Permalink
Browse files

Update WR (transaction API change)

  • Loading branch information
gw3583 committed Jun 19, 2018
1 parent c2d3f2a commit 823f3e2eb16d8cff0879e05d8db16df1fba20b39

Some generated files are not rendered by default. Learn more.

@@ -416,8 +416,7 @@ impl<'a> CanvasData<'a> {
let size = self.drawtarget.get_size();

let descriptor = webrender_api::ImageDescriptor {
width: size.width as u32,
height: size.height as u32,
size: webrender_api::DeviceUintSize::new(size.width as u32, size.height as u32),
stride: None,
format: webrender_api::ImageFormat::BGRA8,
offset: 0,
@@ -426,31 +425,25 @@ impl<'a> CanvasData<'a> {
};
let data = webrender_api::ImageData::Raw(Arc::new(element.into()));

let mut updates = webrender_api::ResourceUpdates::new();
let mut txn = webrender_api::Transaction::new();

match self.image_key {
Some(image_key) => {
debug!("Updating image {:?}.", image_key);
updates.update_image(image_key,
descriptor,
data,
None);
txn.update_image(image_key, descriptor, data, None);
}
None => {
self.image_key = Some(self.webrender_api.generate_image_key());
debug!("New image {:?}.", self.image_key);
updates.add_image(self.image_key.unwrap(),
descriptor,
data,
None);
txn.add_image(self.image_key.unwrap(), descriptor, data, None);
}
}

if let Some(image_key) = mem::replace(&mut self.very_old_image_key, self.old_image_key.take()) {
updates.delete_image(image_key);
txn.delete_image(image_key);
}

self.webrender_api.update_resources(updates);
self.webrender_api.update_resources(txn.resource_updates);

let data = CanvasImageData {
image_key: self.image_key.unwrap(),
@@ -647,16 +640,16 @@ impl<'a> CanvasData<'a> {

impl<'a> Drop for CanvasData<'a> {
fn drop(&mut self) {
let mut updates = webrender_api::ResourceUpdates::new();
let mut txn = webrender_api::Transaction::new();

if let Some(image_key) = self.old_image_key.take() {
updates.delete_image(image_key);
txn.delete_image(image_key);
}
if let Some(image_key) = self.very_old_image_key.take() {
updates.delete_image(image_key);
txn.delete_image(image_key);
}

self.webrender_api.update_resources(updates);
self.webrender_api.update_resources(txn.resource_updates);
}
}

@@ -268,13 +268,13 @@ impl<VR: WebVRRenderHandler + 'static, OB: WebGLThreadObserver> WebGLThread<VR,
fn remove_webgl_context(&mut self, context_id: WebGLContextId) {
// Release webrender image keys.
if let Some(info) = self.cached_context_info.remove(&context_id) {
let mut updates = webrender_api::ResourceUpdates::new();
let mut txn = webrender_api::Transaction::new();

if let Some(image_key) = info.image_key {
updates.delete_image(image_key);
txn.delete_image(image_key);
}

self.webrender_api.update_resources(updates)
self.webrender_api.update_resources(txn.resource_updates)
}

// Release GL context.
@@ -423,12 +423,9 @@ impl<VR: WebVRRenderHandler + 'static, OB: WebGLThreadObserver> WebGLThread<VR,
let data = Self::external_image_data(context_id);

let image_key = webrender_api.generate_image_key();
let mut updates = webrender_api::ResourceUpdates::new();
updates.add_image(image_key,
descriptor,
data,
None);
webrender_api.update_resources(updates);
let mut txn = webrender_api::Transaction::new();
txn.add_image(image_key, descriptor, data, None);
webrender_api.update_resources(txn.resource_updates);

image_key
}
@@ -442,12 +439,9 @@ impl<VR: WebVRRenderHandler + 'static, OB: WebGLThreadObserver> WebGLThread<VR,
let descriptor = Self::image_descriptor(size, alpha);
let data = Self::external_image_data(context_id);

let mut updates = webrender_api::ResourceUpdates::new();
updates.update_image(image_key,
descriptor,
data,
None);
webrender_api.update_resources(updates);
let mut txn = webrender_api::Transaction::new();
txn.update_image(image_key, descriptor, data, None);
webrender_api.update_resources(txn.resource_updates);
}

/// Creates a `webrender_api::ImageKey` that uses raw pixels.
@@ -459,12 +453,9 @@ impl<VR: WebVRRenderHandler + 'static, OB: WebGLThreadObserver> WebGLThread<VR,
let data = webrender_api::ImageData::new(data);

let image_key = webrender_api.generate_image_key();
let mut updates = webrender_api::ResourceUpdates::new();
updates.add_image(image_key,
descriptor,
data,
None);
webrender_api.update_resources(updates);
let mut txn = webrender_api::Transaction::new();
txn.add_image(image_key, descriptor, data, None);
webrender_api.update_resources(txn.resource_updates);

image_key
}
@@ -478,19 +469,15 @@ impl<VR: WebVRRenderHandler + 'static, OB: WebGLThreadObserver> WebGLThread<VR,
let descriptor = Self::image_descriptor(size, alpha);
let data = webrender_api::ImageData::new(data);

let mut updates = webrender_api::ResourceUpdates::new();
updates.update_image(image_key,
descriptor,
data,
None);
webrender_api.update_resources(updates);
let mut txn = webrender_api::Transaction::new();
txn.update_image(image_key, descriptor, data, None);
webrender_api.update_resources(txn.resource_updates);
}

/// Helper function to create a `webrender_api::ImageDescriptor`.
fn image_descriptor(size: Size2D<i32>, alpha: bool) -> webrender_api::ImageDescriptor {
webrender_api::ImageDescriptor {
width: size.width as u32,
height: size.height as u32,
size: webrender_api::DeviceUintSize::new(size.width as u32, size.height as u32),
stride: None,
format: webrender_api::ImageFormat::BGRA8,
offset: 0,
@@ -177,14 +177,14 @@ impl FontCache {
.entry((font_key, size))
.or_insert_with(|| {
let key = webrender_api.generate_font_instance_key();
let mut updates = webrender_api::ResourceUpdates::new();
updates.add_font_instance(key,
let mut txn = webrender_api::Transaction::new();
txn.add_font_instance(key,
font_key,
size,
None,
None,
Vec::new());
webrender_api.update_resources(updates);
webrender_api.update_resources(txn.resource_updates);
key
});

@@ -373,13 +373,13 @@ impl FontCache {

let font_key = *webrender_fonts.entry(template.identifier.clone()).or_insert_with(|| {
let font_key = webrender_api.generate_font_key();
let mut updates = webrender_api::ResourceUpdates::new();
let mut txn = webrender_api::Transaction::new();
match (template.bytes_if_in_memory(), template.native_font()) {
(Some(bytes), _) => updates.add_raw_font(font_key, bytes, 0),
(None, Some(native_font)) => updates.add_native_font(font_key, native_font),
(None, None) => updates.add_raw_font(font_key, template.bytes().clone(), 0),
(Some(bytes), _) => txn.add_raw_font(font_key, bytes, 0),
(None, Some(native_font)) => txn.add_native_font(font_key, native_font),
(None, None) => txn.add_raw_font(font_key, template.bytes().clone(), 0),
}
webrender_api.update_resources(updates);
webrender_api.update_resources(txn.resource_updates);
font_key
});

@@ -73,8 +73,8 @@ use style_traits::cursor::CursorKind;
use table_cell::CollapsedBordersForCell;
use webrender_api::{self, BorderRadius, BorderSide, BoxShadowClipMode, ColorF, ExternalScrollId};
use webrender_api::{FilterOp, GlyphInstance, ImageRendering, LayoutRect, LayoutSize};
use webrender_api::{LayoutTransform, LayoutVector2D, LineStyle, NormalBorder, ScrollPolicy};
use webrender_api::{ScrollSensitivity, StickyOffsetBounds};
use webrender_api::{LayoutTransform, LayoutVector2D, LineStyle, NormalBorder, ScrollSensitivity};
use webrender_api::StickyOffsetBounds;

fn establishes_containing_block_for_absolute(
flags: StackingContextCollectionFlags,
@@ -760,7 +760,6 @@ pub trait FragmentDisplayListBuilding {
&self,
id: StackingContextId,
base_flow: &BaseFlow,
scroll_policy: ScrollPolicy,
context_type: StackingContextType,
established_reference_frame: Option<ClipScrollNodeIndex>,
parent_clipping_and_scrolling: ClippingAndScrolling,
@@ -1887,7 +1886,6 @@ impl FragmentDisplayListBuilding for Fragment {
&self,
id: StackingContextId,
base_flow: &BaseFlow,
scroll_policy: ScrollPolicy,
context_type: StackingContextType,
established_reference_frame: Option<ClipScrollNodeIndex>,
parent_clipping_and_scrolling: ClippingAndScrolling,
@@ -1931,7 +1929,6 @@ impl FragmentDisplayListBuilding for Fragment {
self.transform_matrix(&border_box),
self.style().get_used_transform_style().to_layout(),
self.perspective_matrix(&border_box),
scroll_policy,
parent_clipping_and_scrolling,
established_reference_frame,
)
@@ -2713,7 +2710,6 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let new_context = self.fragment.create_stacking_context(
self.base.stacking_context_id,
&self.base,
ScrollPolicy::Scrollable,
stacking_context_type,
None,
parent_clipping_and_scrolling,
@@ -2747,7 +2743,6 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let stacking_context = self.fragment.create_stacking_context(
self.base.stacking_context_id,
&self.base,
ScrollPolicy::Scrollable,
StackingContextType::Real,
established_reference_frame,
parent_clipping_and_scrolling,
@@ -2885,7 +2880,6 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
let stacking_context = fragment.create_stacking_context(
fragment.stacking_context_id,
&self.base,
ScrollPolicy::Scrollable,
StackingContextType::Real,
None,
state.current_clipping_and_scrolling,
@@ -26,8 +26,8 @@ use webrender_api::{BorderRadius, BorderWidths, BoxShadowClipMode, ClipMode, Col
use webrender_api::{ComplexClipRegion, ExtendMode, ExternalScrollId, FilterOp, FontInstanceKey};
use webrender_api::{GlyphInstance, GradientStop, ImageKey, ImageRendering, LayoutPoint};
use webrender_api::{LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D, LineStyle};
use webrender_api::{MixBlendMode, NinePatchBorder, NormalBorder, ScrollPolicy, ScrollSensitivity};
use webrender_api::{Shadow, StickyOffsetBounds, TransformStyle};
use webrender_api::{MixBlendMode, NinePatchBorder, NormalBorder, ScrollSensitivity, Shadow};
use webrender_api::{StickyOffsetBounds, TransformStyle};

pub use style::dom::OpaqueNode;

@@ -203,9 +203,6 @@ pub struct StackingContext {
/// The perspective matrix to be applied to children.
pub perspective: Option<LayoutTransform>,

/// The scroll policy of this layer.
pub scroll_policy: ScrollPolicy,

/// The clip and scroll info for this StackingContext.
pub parent_clipping_and_scrolling: ClippingAndScrolling,

@@ -227,7 +224,6 @@ impl StackingContext {
transform: Option<LayoutTransform>,
transform_style: TransformStyle,
perspective: Option<LayoutTransform>,
scroll_policy: ScrollPolicy,
parent_clipping_and_scrolling: ClippingAndScrolling,
established_reference_frame: Option<ClipScrollNodeIndex>,
) -> StackingContext {
@@ -242,7 +238,6 @@ impl StackingContext {
transform,
transform_style,
perspective,
scroll_policy,
parent_clipping_and_scrolling,
established_reference_frame,
}
@@ -261,7 +256,6 @@ impl StackingContext {
None,
TransformStyle::Flat,
None,
ScrollPolicy::Scrollable,
ClippingAndScrolling::simple(ClipScrollNodeIndex::root_scroll_node()),
None,
)
@@ -7,9 +7,8 @@
// This might be achieved by sharing types between WR and Servo display lists, or
// completely converting layout to directly generate WebRender display lists, for example.

use display_list::items::{BorderDetails, ClipScrollNode};
use display_list::items::{ClipScrollNodeIndex, ClipScrollNodeType, DisplayItem};
use display_list::items::{DisplayList, StackingContextType};
use display_list::items::{BorderDetails, ClipScrollNode, ClipScrollNodeIndex, ClipScrollNodeType};
use display_list::items::{DisplayItem, DisplayList, StackingContextType};
use msg::constellation_msg::PipelineId;
use webrender_api::{self, ClipAndScrollInfo, ClipId, DisplayListBuilder, GlyphRasterSpace};

@@ -213,7 +212,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
builder.pop_all_shadows();
},
DisplayItem::Iframe(ref item) => {
builder.push_iframe(&self.prim_info(), item.iframe.to_webrender());
builder.push_iframe(&self.prim_info(), item.iframe.to_webrender(), true);
},
DisplayItem::PushStackingContext(ref item) => {
let stacking_context = &item.stacking_context;
@@ -222,7 +221,6 @@ impl WebRenderDisplayItemConverter for DisplayItem {
let reference_frame_clip_id = builder.push_stacking_context(
&webrender_api::LayoutPrimitiveInfo::new(stacking_context.bounds),
None,
stacking_context.scroll_policy,
stacking_context.transform.map(Into::into),
stacking_context.transform_style,
stacking_context.perspective,
@@ -807,8 +807,6 @@ malloc_size_of_is_0!(webrender_api::NormalBorder);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::RepeatMode);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ScrollPolicy);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::ScrollSensitivity);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::StickyOffsetBounds);

0 comments on commit 823f3e2

Please sign in to comment.
You can’t perform that action at this time.