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

[DO NOT MERGE] WIP implementation of line decorations. #1494

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

add LineDisplayItem

Contains a dummy backend implementation for basic tests
  • Loading branch information
Gankra authored and gw3583 committed Jul 18, 2017
commit 965fd99fe1c3fc45e0e34b5b249f6cfc7a13b47e
@@ -621,6 +621,17 @@ impl Frame {

}
}
SpecificDisplayItem::Line(ref info) => {
context.builder.add_line(clip_and_scroll,
item.local_clip(),
info.baseline,
info.start,
info.end,
info.orientation,
info.width,
&info.color,
info.style);
}
SpecificDisplayItem::Gradient(ref info) => {
context.builder.add_gradient(clip_and_scroll,
item.rect(),
@@ -6,8 +6,9 @@ use api::{BorderDetails, BorderDisplayItem, BoxShadowClipMode, ClipAndScrollInfo
use api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DeviceUintRect, DeviceUintSize};
use api::{ExtendMode, FontKey, FontRenderMode, GlyphInstance, GlyphOptions, GradientStop};
use api::{ImageKey, ImageRendering, ItemRange, LayerPoint, LayerRect, LayerSize};
use api::{LayerToScrollTransform, LayerVector2D, LocalClip, PipelineId, RepeatMode, TextShadow};
use api::{TileOffset, TransformStyle, WebGLContextId, WorldPixel, YuvColorSpace, YuvData};
use api::{LayerToScrollTransform, LayerVector2D, LineOrientation, LineStyle, LocalClip};
use api::{PipelineId, RepeatMode, TextShadow, TileOffset, TransformStyle};
use api::{WebGLContextId, WorldPixel, YuvColorSpace, YuvData};
use app_units::Au;
use frame::FrameId;
use gpu_cache::GpuCache;
@@ -704,6 +705,42 @@ impl FrameBuilder {
}
}

pub fn add_line(&mut self,
clip_and_scroll: ClipAndScrollInfo,
local_clip: &LocalClip,
baseline: f32,
start: f32,
end: f32,
orientation: LineOrientation,
width: f32,
color: &ColorF,
style: LineStyle) {

// Dummy impl for testing (replace this)
match style {
LineStyle::Solid => {
let new_rect = match orientation {
LineOrientation::Horizontal => {
LayerRect::new(LayerPoint::new(start, baseline),
LayerSize::new(end - start, width))
}
LineOrientation::Vertical => {
LayerRect::new(LayerPoint::new(baseline, start),
LayerSize::new(width, end - start))
}
};

self.add_solid_rectangle(clip_and_scroll,
&new_rect,
local_clip,
color,
PrimitiveFlags::None);
}
_ => unimplemented!(),
}

}

pub fn add_border(&mut self,
clip_and_scroll: ClipAndScrollInfo,
rect: LayerRect,
@@ -51,6 +51,7 @@ pub enum SpecificDisplayItem {
Clip(ClipDisplayItem),
ScrollFrame(ClipDisplayItem),
Rectangle(RectangleDisplayItem),
Line(LineDisplayItem),
Text(TextDisplayItem),
Image(ImageDisplayItem),
YuvImage(YuvImageDisplayItem),
@@ -81,6 +82,33 @@ pub struct RectangleDisplayItem {
pub color: ColorF,
}

#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct LineDisplayItem {
pub baseline: f32, // LayerPixel
pub start: f32,
pub end: f32,
pub orientation: LineOrientation, // toggles whether above values are interpreted as x/y values
pub width: f32,
pub color: ColorF,
pub style: LineStyle,
}

#[repr(u8)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum LineOrientation {
Vertical,
Horizontal,
}

#[repr(u8)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum LineStyle {
Solid,
Dotted,
Dashed,
Wavy,
}

#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct TextDisplayItem {
pub font_key: FontKey,
@@ -11,11 +11,12 @@ use {BorderDetails, BorderDisplayItem, BorderWidths, BoxShadowClipMode, BoxShado
use {ClipAndScrollInfo, ClipDisplayItem, ClipId, ColorF, ComplexClipRegion, DisplayItem};
use {ExtendMode, FilterOp, FontKey, GlyphInstance, GlyphOptions, Gradient, GradientDisplayItem};
use {GradientStop, IframeDisplayItem, ImageDisplayItem, ImageKey, ImageMask, ImageRendering};
use {LayoutPoint, LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D, LocalClip};
use {MixBlendMode, PipelineId, PropertyBinding, PushStackingContextDisplayItem, RadialGradient};
use {RadialGradientDisplayItem, RectangleDisplayItem, ScrollPolicy, SpecificDisplayItem};
use {StackingContext, TextDisplayItem, TextShadow, TransformStyle, WebGLContextId, WebGLDisplayItem};
use {YuvColorSpace, YuvData, YuvImageDisplayItem};
use {LayoutPoint, LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D, LineDisplayItem};
use {LineOrientation, LineStyle, LocalClip, MixBlendMode, PipelineId};
use {PropertyBinding, PushStackingContextDisplayItem, RadialGradient};
use {RadialGradientDisplayItem, RectangleDisplayItem, ScrollPolicy};
use {SpecificDisplayItem, StackingContext, TextDisplayItem, TextShadow, TransformStyle};
use {WebGLContextId, WebGLDisplayItem, YuvColorSpace, YuvData, YuvImageDisplayItem};
use std::marker::PhantomData;

#[repr(C)]
@@ -494,6 +495,23 @@ impl DisplayListBuilder {
self.push_item(item, rect, local_clip);
}

pub fn push_line(&mut self,
local_clip: Option<LocalClip>,
baseline: f32,
start: f32,
end: f32,
orientation: LineOrientation,
width: f32,
color: ColorF,
style: LineStyle) {
let item = SpecificDisplayItem::Line(LineDisplayItem {
baseline, start, end, orientation,
width, color, style,
});

self.push_item(item, LayoutRect::zero(), local_clip);
}

pub fn push_image(&mut self,
rect: LayoutRect,
local_clip: Option<LocalClip>,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.