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

Decompose gradients during scene building. #2752

Merged
merged 2 commits into from May 11, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Remove unused PrimitiveInfoTiler.

  • Loading branch information
nical committed May 11, 2018
commit c77fe02167b60c7c8de5f9bf46bef26a102a19ea
@@ -2107,72 +2107,6 @@ pub fn build_scene(config: &FrameBuilderConfig, request: SceneRequest) -> BuiltS
}
}

trait PrimitiveInfoTiler {
fn decompose(
&self,
tile_size: LayoutSize,
tile_spacing: LayoutSize,
max_prims: usize,
) -> Vec<LayoutPrimitiveInfo>;
}

impl PrimitiveInfoTiler for LayoutPrimitiveInfo {
fn decompose(
&self,
tile_size: LayoutSize,
tile_spacing: LayoutSize,
max_prims: usize,
) -> Vec<LayoutPrimitiveInfo> {
let mut prims = Vec::new();
let tile_repeat = tile_size + tile_spacing;

if tile_repeat.width <= 0.0 ||
tile_repeat.height <= 0.0 {
return prims;
}

if tile_repeat.width < self.rect.size.width ||
tile_repeat.height < self.rect.size.height {
let clip_rect = self.clip_rect
.intersection(&self.rect)
.unwrap_or_else(LayoutRect::zero);
let rect_p0 = self.rect.origin;
let rect_p1 = self.rect.bottom_right();

let mut y0 = rect_p0.y;
while y0 < rect_p1.y {
let mut x0 = rect_p0.x;

while x0 < rect_p1.x {
prims.push(LayoutPrimitiveInfo {
rect: LayoutRect::new(
LayoutPoint::new(x0, y0),
tile_size,
),
clip_rect,
is_backface_visible: self.is_backface_visible,
tag: self.tag,
});

// Mostly a safety against a crazy number of primitives
// being generated. If we exceed that amount, just bail
// out and only draw the maximum amount.
if prims.len() > max_prims {
warn!("too many prims found due to repeat/tile. dropping extra prims!");
return prims;
}

x0 += tile_repeat.width;
}

y0 += tile_repeat.height;
}
}

prims
}
}

/// Properties of a stacking context that are maintained
/// during creation of the scene. These structures are
/// not persisted after the initial scene build.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.