Skip to content

Commit

Permalink
Bug 1734280 - Remove pipeline_id from hit-test API r=gfx-reviewers,jr…
Browse files Browse the repository at this point in the history
…muizel

The ability to restrict hit-tests by pipeline_id isn't used by
Gecko or wrench. Remove it to simplify landing some of the upcoming
spatial tree work.

Differential Revision: https://phabricator.services.mozilla.com/D127608
  • Loading branch information
Glenn Watson committed Oct 6, 2021
1 parent 72e3c52 commit 41785a2
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 23 deletions.
2 changes: 1 addition & 1 deletion gfx/webrender_bindings/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3819,7 +3819,7 @@ pub struct HitResult {
pub extern "C" fn wr_api_hit_test(dh: &mut DocumentHandle, point: WorldPoint, out_results: &mut ThinVec<HitResult>) {
dh.ensure_hit_tester();

let result = dh.hit_tester.as_ref().unwrap().hit_test(None, point);
let result = dh.hit_tester.as_ref().unwrap().hit_test(point);

for item in &result.items {
out_results.push(HitResult {
Expand Down
1 change: 0 additions & 1 deletion gfx/wr/examples/scrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ impl Example for App {
winit::WindowEvent::MouseInput { .. } => {
let results = api.hit_test(
document_id,
None,
self.cursor_position,
);

Expand Down
10 changes: 1 addition & 9 deletions gfx/wr/webrender/src/hit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ impl SharedHitTester {

impl ApiHitTester for SharedHitTester {
fn hit_test(&self,
pipeline_id: Option<PipelineId>,
point: WorldPoint,
) -> HitTestResult {
self.get_ref().hit_test(HitTest::new(pipeline_id, point))
self.get_ref().hit_test(HitTest::new(point))
}
}

Expand Down Expand Up @@ -389,10 +388,6 @@ impl HitTester {
for item in self.scene.items.iter().rev() {
let scroll_node = &self.spatial_nodes[&item.spatial_node_index];
let pipeline_id = scroll_node.pipeline_id;
match (test.pipeline_id, pipeline_id) {
(Some(id), node_id) if node_id != id => continue,
_ => {},
}

// Update the cached point in layer space, if the spatial node
// changed since last primitive.
Expand Down Expand Up @@ -479,17 +474,14 @@ impl HitTester {

#[derive(MallocSizeOf)]
pub struct HitTest {
pipeline_id: Option<PipelineId>,
point: WorldPoint,
}

impl HitTest {
pub fn new(
pipeline_id: Option<PipelineId>,
point: WorldPoint,
) -> HitTest {
HitTest {
pipeline_id,
point,
}
}
Expand Down
5 changes: 2 additions & 3 deletions gfx/wr/webrender/src/render_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ pub enum FrameMsg {
///
UpdateEpoch(PipelineId, Epoch),
///
HitTest(Option<PipelineId>, WorldPoint, Sender<HitTestResult>),
HitTest(WorldPoint, Sender<HitTestResult>),
///
RequestHitTester(Sender<Arc<dyn ApiHitTester>>),
///
Expand Down Expand Up @@ -1273,14 +1273,13 @@ impl RenderApi {
/// front to back.
pub fn hit_test(&self,
document_id: DocumentId,
pipeline_id: Option<PipelineId>,
point: WorldPoint,
) -> HitTestResult {
let (tx, rx) = single_msg_channel();

self.send_frame_msg(
document_id,
FrameMsg::HitTest(pipeline_id, point, tx)
FrameMsg::HitTest(point, tx)
);
rx.recv().unwrap()
}
Expand Down
4 changes: 2 additions & 2 deletions gfx/wr/webrender/src/render_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,14 @@ impl Document {
FrameMsg::UpdateEpoch(pipeline_id, epoch) => {
self.scene.pipeline_epochs.insert(pipeline_id, epoch);
}
FrameMsg::HitTest(pipeline_id, point, tx) => {
FrameMsg::HitTest(point, tx) => {
if !self.hit_tester_is_valid {
self.rebuild_hit_tester();
}

let result = match self.hit_tester {
Some(ref hit_tester) => {
hit_tester.hit_test(HitTest::new(pipeline_id, point))
hit_tester.hit_test(HitTest::new(point))
}
None => HitTestResult { items: Vec::new() },
};
Expand Down
8 changes: 3 additions & 5 deletions gfx/wr/webrender_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,9 @@ impl NotificationRequest {
/// the RenderBackendThread.
pub trait ApiHitTester: Send + Sync {
/// Does a hit test on display items in the specified document, at the given
/// point. If a pipeline_id is specified, it is used to further restrict the
/// hit results so that only items inside that pipeline are matched. The vector
/// of hit results will contain all display items that match, ordered from
/// front to back.
fn hit_test(&self, pipeline_id: Option<PipelineId>, point: WorldPoint) -> HitTestResult;
/// point. The vector of hit results will contain all display items that match,
/// ordered from front to back.
fn hit_test(&self, point: WorldPoint) -> HitTestResult;
}

/// A hit tester requested to the render backend thread but not necessarily ready yet.
Expand Down
1 change: 0 additions & 1 deletion gfx/wr/wrench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,6 @@ fn render<'a>(
VirtualKeyCode::X => {
let results = wrench.api.hit_test(
wrench.document_id,
None,
cursor_position,
);

Expand Down
1 change: 0 additions & 1 deletion gfx/wr/wrench/src/rawtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,6 @@ impl<'a> RawtestHarness<'a> {
let hit_test = |point: WorldPoint| -> HitTestResult {
self.wrench.api.hit_test(
self.wrench.document_id,
None,
point,
)
};
Expand Down

0 comments on commit 41785a2

Please sign in to comment.