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

Remove the scroll bar APIs. #3134

Merged
merged 1 commit into from Sep 28, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Remove the scroll bar APIs.

It's much better if applications draw scrollbars by adding normal
primitives to the display list. This means:

* Better control of how they look visually.
* Can make them clickable / draggable.
* Less code complexity in WR.
* Better control of scrollbar behavior (where enabled etc).
  • Loading branch information
gw3583 committed Sep 27, 2018
commit 6d3338d5a55aee2012f94fb306bef585c386af40
@@ -33,16 +33,9 @@ use resource_cache::{FontInstanceMap, ImageRequest};
use scene::{Scene, ScenePipeline, StackingContextHelpers};
use spatial_node::{SpatialNodeType, StickyFrameInfo};
use std::{f32, mem};
use tiling::{CompositeOps, ScrollbarPrimitive};
use tiling::{CompositeOps};
use util::{MaxRect, RectHelpers};

static DEFAULT_SCROLLBAR_COLOR: ColorF = ColorF {
r: 0.3,
g: 0.3,
b: 0.3,
a: 0.6,
};

#[derive(Debug, Copy, Clone)]
struct ClipNode {
id: ClipChainId,
@@ -144,9 +137,6 @@ pub struct DisplayListFlattener<'a> {
/// The stack keeping track of the root clip chains associated with pipelines.
pipeline_clip_chain_stack: Vec<ClipChainId>,

/// A list of scrollbar primitives.
pub scrollbar_prims: Vec<ScrollbarPrimitive>,

/// The store of primitives.
pub prim_store: PrimitiveStore,

@@ -196,7 +186,6 @@ impl<'a> DisplayListFlattener<'a> {
output_pipelines,
id_to_index_mapper: ClipIdToIndexMapper::default(),
hit_testing_runs: Vec::new(),
scrollbar_prims: Vec::new(),
shadow_stack: Vec::new(),
sc_stack: Vec::new(),
pipeline_clip_chain_stack: vec![ClipChainId::NONE],
@@ -259,7 +248,6 @@ impl<'a> DisplayListFlattener<'a> {
);

let root_scroll_node = ClipId::root_scroll_node(pipeline_id);
let scroll_frame_info = self.simple_scroll_and_clip_chain(&root_scroll_node);

self.push_stacking_context(
pipeline_id,
@@ -295,17 +283,6 @@ impl<'a> DisplayListFlattener<'a> {

self.flatten_items(&mut pipeline.display_list.iter(), pipeline_id, LayoutVector2D::zero());

if self.config.enable_scrollbars {
let scrollbar_rect = LayoutRect::new(LayoutPoint::zero(), LayoutSize::new(10.0, 70.0));
let container_rect = LayoutRect::new(LayoutPoint::zero(), *frame_size);
self.add_scroll_bar(
reference_frame_info.spatial_node_index,
&LayoutPrimitiveInfo::new(scrollbar_rect),
DEFAULT_SCROLLBAR_COLOR,
ScrollbarInfo(scroll_frame_info.spatial_node_index, container_rect),
);
}

self.pop_stacking_context();
}

@@ -1528,40 +1505,6 @@ impl<'a> DisplayListFlattener<'a> {
);
}

pub fn add_scroll_bar(
&mut self,
spatial_node_index: SpatialNodeIndex,
info: &LayoutPrimitiveInfo,
color: ColorF,
scrollbar_info: ScrollbarInfo,
) {
if color.a == 0.0 {
return;
}

let prim = BrushPrimitive::new(
BrushKind::new_solid(color),
None,
);

let prim_index = self.create_primitive(
info,
ClipChainId::NONE,
spatial_node_index,
PrimitiveContainer::Brush(prim),
);

self.add_primitive_to_draw_list(
prim_index,
);

self.scrollbar_prims.push(ScrollbarPrimitive {
prim_index,
scroll_frame_index: scrollbar_info.0,
frame_rect: scrollbar_info.1,
});
}

pub fn add_line(
&mut self,
clip_and_scroll: ScrollNodeAndClipChain,
@@ -2117,6 +2060,3 @@ struct FlattenedStackingContext {
participating_in_3d_context: bool,
has_mix_blend_mode: bool,
}

#[derive(Debug)]
pub struct ScrollbarInfo(pub SpatialNodeIndex, pub LayoutRect);
@@ -24,8 +24,7 @@ use spatial_node::SpatialNode;
use std::f32;
use std::sync::Arc;
use tiling::{Frame, RenderPass, RenderPassKind, RenderTargetContext};
use tiling::{ScrollbarPrimitive, SpecialRenderPasses};
use util;
use tiling::{SpecialRenderPasses};


#[derive(Clone, Copy, Debug, PartialEq)]
@@ -47,7 +46,6 @@ impl Default for ChasePrimitive {
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct FrameBuilderConfig {
pub enable_scrollbars: bool,
pub default_font_render_mode: FontRenderMode,
pub dual_source_blending_is_supported: bool,
pub dual_source_blending_is_enabled: bool,
@@ -64,7 +62,6 @@ pub struct FrameBuilder {
pub clip_store: ClipStore,
pub hit_testing_runs: Vec<HitTestingRun>,
pub config: FrameBuilderConfig,
pub scrollbar_prims: Vec<ScrollbarPrimitive>,
}

pub struct FrameBuildingContext<'a> {
@@ -135,15 +132,13 @@ impl FrameBuilder {
pub fn empty() -> Self {
FrameBuilder {
hit_testing_runs: Vec::new(),
scrollbar_prims: Vec::new(),
prim_store: PrimitiveStore::new(),
clip_store: ClipStore::new(),
screen_rect: DeviceUintRect::zero(),
window_size: DeviceUintSize::zero(),
background_color: None,
scene_id: 0,
config: FrameBuilderConfig {
enable_scrollbars: false,
default_font_render_mode: FontRenderMode::Mono,
dual_source_blending_is_enabled: true,
dual_source_blending_is_supported: false,
@@ -161,7 +156,6 @@ impl FrameBuilder {
) -> Self {
FrameBuilder {
hit_testing_runs: flattener.hit_testing_runs,
scrollbar_prims: flattener.scrollbar_prims,
prim_store: flattener.prim_store,
clip_store: flattener.clip_store,
screen_rect,
@@ -290,35 +284,6 @@ impl FrameBuilder {
Some(render_task_id)
}

fn update_scroll_bars(&mut self, clip_scroll_tree: &ClipScrollTree, gpu_cache: &mut GpuCache) {
static SCROLLBAR_PADDING: f32 = 8.0;

for scrollbar_prim in &self.scrollbar_prims {
let metadata = &mut self.prim_store.primitives[scrollbar_prim.prim_index.0].metadata;
let scroll_frame = &clip_scroll_tree.spatial_nodes[scrollbar_prim.scroll_frame_index.0];

// Invalidate what's in the cache so it will get rebuilt.
gpu_cache.invalidate(&metadata.gpu_location);

let scrollable_distance = scroll_frame.scrollable_size().height;
if scrollable_distance <= 0.0 {
metadata.local_clip_rect.size = LayoutSize::zero();
continue;
}
let amount_scrolled = -scroll_frame.scroll_offset().y / scrollable_distance;

let frame_rect = scrollbar_prim.frame_rect;
let min_y = frame_rect.origin.y + SCROLLBAR_PADDING;
let max_y = frame_rect.origin.y + frame_rect.size.height -
(SCROLLBAR_PADDING + metadata.local_rect.size.height);

metadata.local_rect.origin.x = frame_rect.origin.x + frame_rect.size.width -
(metadata.local_rect.size.width + SCROLLBAR_PADDING);
metadata.local_rect.origin.y = util::lerp(min_y, max_y, amount_scrolled);
metadata.local_clip_rect = metadata.local_rect;
}
}

pub fn build(
&mut self,
resource_cache: &mut ResourceCache,
@@ -355,8 +320,6 @@ impl FrameBuilder {
Some(&mut transform_palette),
);

self.update_scroll_bars(clip_scroll_tree, gpu_cache);

let mut render_tasks = RenderTaskTree::new(frame_id);

let screen_size = self.screen_rect.size.to_i32();
@@ -1721,7 +1721,6 @@ impl Renderer {
};

let config = FrameBuilderConfig {
enable_scrollbars: options.enable_scrollbars,
default_font_render_mode,
dual_source_blending_is_enabled: true,
dual_source_blending_is_supported: ext_dual_source_blending,
@@ -4400,7 +4399,6 @@ pub struct RendererOptions {
pub enable_aa: bool,
pub enable_dithering: bool,
pub max_recorded_profiles: usize,
pub enable_scrollbars: bool,
pub precache_shaders: bool,
pub renderer_kind: RendererKind,
pub enable_subpixel_aa: bool,
@@ -4433,7 +4431,6 @@ impl Default for RendererOptions {
enable_dithering: true,
debug_flags: DebugFlags::empty(),
max_recorded_profiles: 0,
enable_scrollbars: false,
precache_shaders: false,
renderer_kind: RendererKind::Native,
enable_subpixel_aa: false,
@@ -4,10 +4,10 @@

use api::{ColorF, BorderStyle, DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixelScale};
use api::{DeviceUintPoint, DeviceUintRect, DeviceUintSize, DocumentLayer, FilterOp, ImageFormat};
use api::{LayoutRect, MixBlendMode, PipelineId};
use api::{MixBlendMode, PipelineId};
use batch::{AlphaBatchBuilder, AlphaBatchContainer, ClipBatcher, resolve_image};
use clip::{ClipDataStore, ClipStore};
use clip_scroll_tree::{ClipScrollTree, SpatialNodeIndex};
use clip_scroll_tree::{ClipScrollTree};
use device::{FrameId, Texture};
#[cfg(feature = "pathfinder")]
use euclid::{TypedPoint2D, TypedVector2D};
@@ -17,7 +17,7 @@ use gpu_types::{TransformData, TransformPalette};
use internal_types::{FastHashMap, SavedTargetIndex, SourceTexture};
#[cfg(feature = "pathfinder")]
use pathfinder_partitioner::mesh::Mesh;
use prim_store::{PrimitiveIndex, PrimitiveStore, DeferredResolve};
use prim_store::{PrimitiveStore, DeferredResolve};
use profiler::FrameProfileCounters;
use render_task::{BlitSource, RenderTaskAddress, RenderTaskId, RenderTaskKind};
use render_task::{BlurTask, ClearMode, GlyphTask, RenderTaskLocation, RenderTaskTree, ScalingTask};
@@ -31,13 +31,6 @@ const MIN_TARGET_SIZE: u32 = 2048;
const STYLE_SOLID: i32 = ((BorderStyle::Solid as i32) << 8) | ((BorderStyle::Solid as i32) << 16);
const STYLE_MASK: i32 = 0x00FF_FF00;

#[derive(Debug)]
pub struct ScrollbarPrimitive {
pub scroll_frame_index: SpatialNodeIndex,
pub prim_index: PrimitiveIndex,
pub frame_rect: LayoutRect,
}

#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.