Skip to content

Commit 9f1255e

Browse files
committed
Early mask-based culling, plus rebasing onto master
1 parent 5fd9457 commit 9f1255e

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

webrender/src/internal_types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,12 @@ impl TextureSampler {
223223
#[derive(Copy, Clone, Debug)]
224224
pub struct BatchTextures {
225225
pub colors: [SourceTexture; 3],
226-
pub mask: SourceTexture,
227226
}
228227

229228
impl BatchTextures {
230229
pub fn no_texture() -> Self {
231230
BatchTextures {
232231
colors: [SourceTexture::Invalid; 3],
233-
mask: SourceTexture::Invalid,
234232
}
235233
}
236234
}

webrender/src/prim_store.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
use app_units::Au;
6-
use device::TextureId;
76
use euclid::{Point2D, Matrix4D, Rect, Size2D};
87
use gpu_store::{GpuStore, GpuStoreAddress};
98
use internal_types::{device_pixel, DeviceRect, DeviceSize, SourceTexture};

webrender/src/renderer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,9 @@ impl Renderer {
11311131
&projection);
11321132
}
11331133
// draw image masks
1134-
for (&mask_texture_id, items) in target.clip_batcher.images.iter() {
1135-
self.device.bind_texture(TextureSampler::Mask, mask_texture_id);
1134+
for (mask_texture_id, items) in target.clip_batcher.images.iter() {
1135+
let texture_id = self.resolve_source_texture(mask_texture_id);
1136+
self.device.bind_texture(TextureSampler::Mask, texture_id);
11361137
let shader = self.cs_clip_image.get(&mut self.device);
11371138
self.draw_ubo_batch(items,
11381139
shader,

webrender/src/tiling.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use app_units::Au;
66
use batch_builder::BorderSideHelpers;
7-
use device::{TextureId};
87
use euclid::{Point2D, Point4D, Rect, Matrix4D, Size2D};
98
use fnv::FnvHasher;
109
use frame::FrameId;
@@ -152,18 +151,19 @@ impl AlphaBatchHelpers for PrimitiveStore {
152151
device_pixel_ratio: f32) -> bool {
153152
let metadata = self.get_metadata(prim_index);
154153

154+
// bail out if the clip rectangle is outside of the tile
155+
if let Some(ref clip_info) = metadata.clip_cache_info {
156+
if !clip_info.device_rect.intersects(tile_rect) {
157+
return false;
158+
}
159+
}
160+
155161
match metadata.prim_kind {
156162
PrimitiveKind::Rectangle |
157163
PrimitiveKind::TextRun |
158164
PrimitiveKind::Image |
159165
PrimitiveKind::Gradient |
160-
PrimitiveKind::BoxShadow => {
161-
if let Some(ref clip_info) = metadata.clip_cache_info {
162-
clip_info.device_rect.intersects(tile_rect)
163-
} else {
164-
true
165-
}
166-
}
166+
PrimitiveKind::BoxShadow => true,
167167
PrimitiveKind::Border => {
168168
let border = &self.cpu_borders[metadata.cpu_prim_index.0];
169169
let inner_rect = TransformedRect::new(&border.inner_rect,
@@ -589,7 +589,7 @@ impl AlphaBatcher {
589589
pub struct ClipBatcher {
590590
pub clears: Vec<CacheClipInstance>,
591591
pub rectangles: Vec<CacheClipInstance>,
592-
pub images: HashMap<TextureId, Vec<CacheClipInstance>>,
592+
pub images: HashMap<SourceTexture, Vec<CacheClipInstance>>,
593593
}
594594

595595
impl ClipBatcher {
@@ -1729,13 +1729,9 @@ impl ScreenTile {
17291729

17301730
// Add a task to render the updated image mask
17311731
if let Some(ref clip_info) = prim_metadata.clip_cache_info {
1732-
if let Some(mask_task) = RenderTask::new_mask(self.rect, clip_info) {
1733-
current_task.children.push(mask_task);
1734-
} else {
1735-
// The primitive has clip items but their intersection is empty
1736-
// meaning, no pixels will be visible, we can skip it entirely
1737-
continue;
1738-
}
1732+
let mask_task = RenderTask::new_mask(self.rect, clip_info)
1733+
.expect("Primitive should have been culled by `prim_affects_tile` alread");
1734+
current_task.children.push(mask_task);
17391735
}
17401736

17411737
// Add any dynamic render tasks needed to render this primitive

0 commit comments

Comments
 (0)