diff --git a/garnet/lib/ui/gfx/engine/session.cc b/garnet/lib/ui/gfx/engine/session.cc index 2d36d4d79209c10378e773ca0bd38db07f3720d6..525631594f18368037838797d798aba59e74e9f2 100644 --- a/garnet/lib/ui/gfx/engine/session.cc +++ b/garnet/lib/ui/gfx/engine/session.cc @@ -35,23 +35,6 @@ namespace { #define SESSION_TRACE_ID(session_id, count) \ (((uint64_t)(session_id) << 32) | (count)) -// Converts the provided vector of Hits into a fidl array of HitPtrs. -fidl::VectorPtr<::fuchsia::ui::gfx::Hit> WrapHits( - const std::vector<Hit>& hits) { - fidl::VectorPtr<::fuchsia::ui::gfx::Hit> wrapped_hits; - wrapped_hits.resize(hits.size()); - for (size_t i = 0; i < hits.size(); ++i) { - const Hit& hit = hits[i]; - fuchsia::ui::gfx::Hit wrapped_hit; - wrapped_hit.tag_value = hit.tag_value; - wrapped_hit.ray_origin = Wrap(hit.ray.origin); - wrapped_hit.ray_direction = Wrap(hit.ray.direction); - wrapped_hit.inverse_transform = Wrap(hit.inverse_transform); - wrapped_hit.distance = hit.distance; - wrapped_hits->at(i) = std::move(wrapped_hit); - } - return wrapped_hits; -} } // anonymous namespace Session::Session(SessionId id, SessionContext session_context, @@ -331,42 +314,5 @@ bool Session::ApplyUpdate(CommandContext* command_context, // consumed by the FrameScheduler. } -void Session::HitTest(uint32_t node_id, fuchsia::ui::gfx::vec3 ray_origin, - fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback) { - if (auto node = resources_.FindResource<Node>(node_id)) { - SessionHitTester hit_tester(node->session()); - std::vector<Hit> hits = hit_tester.HitTest( - node.get(), escher::ray4{escher::vec4(Unwrap(ray_origin), 1.f), - escher::vec4(Unwrap(ray_direction), 0.f)}); - callback(WrapHits(hits)); - } else { - // TODO(SCN-162): Currently the test fails if the node isn't presented yet. - // Perhaps we should given clients more control over which state of - // the scene graph will be consulted for hit testing purposes. - error_reporter_->WARN() - << "Cannot perform hit test because node " << node_id - << " does not exist in the currently presented content."; - callback(nullptr); - } -} - -void Session::HitTestDeviceRay( - fuchsia::ui::gfx::vec3 ray_origin, fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback) { - escher::ray4 ray = - escher::ray4{{Unwrap(ray_origin), 1.f}, {Unwrap(ray_direction), 0.f}}; - - // The layer stack expects the input to the hit test to be in unscaled device - // coordinates. - SessionHitTester hit_tester(this); - // TODO(SCN-1170): get rid of SceneGraph::first_compositor(). - std::vector<Hit> layer_stack_hits = - session_context_.scene_graph->first_compositor()->layer_stack()->HitTest( - ray, &hit_tester); - - callback(WrapHits(layer_stack_hits)); -} - } // namespace gfx } // namespace scenic_impl diff --git a/garnet/lib/ui/gfx/engine/session.h b/garnet/lib/ui/gfx/engine/session.h index b726fdba8e1973bb1664115ea50035011daedd9e..b480dd2d85ad166b1a379cce7d6f3a8d495578cf 100644 --- a/garnet/lib/ui/gfx/engine/session.h +++ b/garnet/lib/ui/gfx/engine/session.h @@ -120,16 +120,6 @@ class Session { void EnqueueEvent(::fuchsia::ui::gfx::Event event); void EnqueueEvent(::fuchsia::ui::input::InputEvent event); - // Called by SessionHandler::HitTest(). - void HitTest(uint32_t node_id, fuchsia::ui::gfx::vec3 ray_origin, - fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback); - - // Called by SessionHandler::HitTestDeviceRay(). - void HitTestDeviceRay(::fuchsia::ui::gfx::vec3 ray_origin, - fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback); - void SetDebugName(const std::string& debug_name) { debug_name_ = debug_name; } private: diff --git a/garnet/lib/ui/gfx/engine/session_handler.cc b/garnet/lib/ui/gfx/engine/session_handler.cc index 4661dbf8aaa2db3fd4c8b7271db7a7fb7250fb6d..37234e09d14a95d4427503733fbb2d4c2c02f901 100644 --- a/garnet/lib/ui/gfx/engine/session_handler.cc +++ b/garnet/lib/ui/gfx/engine/session_handler.cc @@ -38,21 +38,6 @@ void SessionHandler::Present( } } -void SessionHandler::HitTest( - uint32_t node_id, fuchsia::ui::gfx::vec3 ray_origin, - fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback) { - session_->HitTest(node_id, std::move(ray_origin), std::move(ray_direction), - std::move(callback)); -} - -void SessionHandler::HitTestDeviceRay( - fuchsia::ui::gfx::vec3 ray_origin, fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestDeviceRayCallback callback) { - session_->HitTestDeviceRay(std::move(ray_origin), std::move(ray_direction), - std::move(callback)); -} - void SessionHandler::DispatchCommand(fuchsia::ui::scenic::Command command) { FXL_DCHECK(command.Which() == fuchsia::ui::scenic::Command::Tag::kGfx); buffered_commands_.emplace_back(std::move(command.gfx())); diff --git a/garnet/lib/ui/gfx/engine/session_handler.h b/garnet/lib/ui/gfx/engine/session_handler.h index 560a7ab7f73767e39b1202d4ab57864b55f75e07..47bc5dc3899c0914d82678cd02c139bc6aceff99 100644 --- a/garnet/lib/ui/gfx/engine/session_handler.h +++ b/garnet/lib/ui/gfx/engine/session_handler.h @@ -47,17 +47,6 @@ class SessionHandler : public TempSessionDelegate { ::std::vector<zx::event> release_fences, fuchsia::ui::scenic::Session::PresentCallback callback) override; - // |fuchsia::ui::scenic::Session / scenic::TempSessionDelegate| - void HitTest(uint32_t node_id, ::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback) override; - - // |fuchsia::ui::scenic::Session / scenic::TempSessionDelegate| - void HitTestDeviceRay( - ::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback) override; - // |fuchsia::ui::scenic::Session / scenic::TempSessionDelegate| void SetDebugName(const std::string& debug_name) override { session_->SetDebugName(debug_name); diff --git a/garnet/lib/ui/gfx/tests/BUILD.gn b/garnet/lib/ui/gfx/tests/BUILD.gn index 8a756985cf41cbc78952255618516f3c59512dda..e4138d3d561f5bcf230d6ebe14897152b9186388 100644 --- a/garnet/lib/ui/gfx/tests/BUILD.gn +++ b/garnet/lib/ui/gfx/tests/BUILD.gn @@ -82,7 +82,6 @@ executable("unittests") { "gfx_command_applier_unittest.cc", "hardware_layer_assignment_unittest.cc", "hittest_global_unittest.cc", - "hittest_unittest.cc", "image_pipe_unittest.cc", "import_unittest.cc", "memory_unittest.cc", diff --git a/garnet/lib/ui/gfx/tests/hittest_unittest.cc b/garnet/lib/ui/gfx/tests/hittest_unittest.cc deleted file mode 100644 index e886e8a8402984b590146a3a493dd04a461d2f7f..0000000000000000000000000000000000000000 --- a/garnet/lib/ui/gfx/tests/hittest_unittest.cc +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2017 The Fuchsia Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <math.h> - -#include "garnet/lib/ui/gfx/tests/session_test.h" -#include "garnet/lib/ui/gfx/util/unwrap.h" -#include "lib/ui/scenic/cpp/commands.h" - -#include "gtest/gtest.h" - -namespace scenic_impl { -namespace gfx { -namespace test { -namespace { -using vec3 = escher::vec3; - -constexpr vec3 kDownVector{0.f, 0.f, 1.f}; -constexpr vec3 kUpVector{0.f, 0.f, -1.f}; -} // namespace - -/* - * We assume that the various ray-intersection tests for each shape - * have been covered by other unit tests. So for ease of testing, - * we only use rectangles and most use simple downward pointing rays. - * - * To make things even easier, the rectangles are all 8x8. - * The number indicated is the tag id. - * - * +------+ +------+ - * | | | | #10 corners: (0, 0, 2) .. (8, 8, 2) - * | 10 +--+ 30 | #20 corners: (5, 5, 1) .. (13, 13, 1) - * | | | | #30 corners: (10, 0, 1) .. (18, 8, 1) - * +----+-+20+-+----+ - * | | - * +------+ - * - * These rectangles are arranged such that their front-to-back drawing - * order is #30, #20, #10 which forces a tie-break for distance sorting - * at the intersections of #20 and #30. - * - * The node tree looks like this: - * @1: entity node - * + @2: entity node, tag #100 - * + @3: entity node, tag #25, translate x+4, y+4 - * + @4: shape node, tag #10, translate z+2 - * + @5: entity node, tag #20, translate x+5, y+5, z+1 - * + @6: shape node - * + @7: entity node, tag #35, translate x+10, z+1 - * + @8: shape node, tag #30, translate x+4, y+4 - * + @9: entity node, tag #1 - * - * The 8x8 square used for testing has shape id 20. - */ - -class HitTestTest : public SessionTest { - public: - void SetUp() override { - SessionTest::SetUp(); - - Apply(scenic::NewCreateRectangleCmd(20, 8.f, 8.f)); - - Apply(scenic::NewCreateEntityNodeCmd(1)); - - Apply(scenic::NewCreateEntityNodeCmd(2)); - Apply(scenic::NewSetTagCmd(2, 100)); - Apply(scenic::NewAddChildCmd(1, 2)); - - Apply(scenic::NewCreateEntityNodeCmd(3)); - Apply(scenic::NewSetTagCmd(3, 25)); - Apply(scenic::NewSetTranslationCmd(3, (float[3]){4.f, 4.f, 0.f})); - Apply(scenic::NewAddChildCmd(2, 3)); - - Apply(scenic::NewCreateShapeNodeCmd(4)); - Apply(scenic::NewSetTagCmd(4, 10)); - Apply(scenic::NewSetShapeCmd(4, 20)); - Apply(scenic::NewSetTranslationCmd(4, (float[3]){0.f, 0.f, -2.f})); - Apply(scenic::NewAddChildCmd(3, 4)); - - Apply(scenic::NewCreateEntityNodeCmd(5)); - Apply(scenic::NewSetTagCmd(5, 20)); - Apply(scenic::NewSetTranslationCmd(5, (float[3]){5.f, 5.f, -1.f})); - Apply(scenic::NewAddChildCmd(3, 5)); - - Apply(scenic::NewCreateShapeNodeCmd(6)); - Apply(scenic::NewSetShapeCmd(6, 20)); - Apply(scenic::NewAddChildCmd(5, 6)); - - Apply(scenic::NewCreateEntityNodeCmd(7)); - Apply(scenic::NewSetTagCmd(7, 35)); - Apply(scenic::NewSetTranslationCmd(7, (float[3]){10.f, 0.f, -1.f})); - Apply(scenic::NewAddChildCmd(2, 7)); - - Apply(scenic::NewCreateShapeNodeCmd(8)); - Apply(scenic::NewSetTagCmd(8, 30)); - Apply(scenic::NewSetShapeCmd(8, 20)); - Apply(scenic::NewSetTranslationCmd(8, (float[3]){4.f, 4.f, 0.f})); - Apply(scenic::NewAddChildCmd(7, 8)); - - Apply(scenic::NewCreateEntityNodeCmd(9)); - Apply(scenic::NewSetTagCmd(9, 1)); - Apply(scenic::NewAddChildCmd(1, 9)); - } - - protected: - struct ExpectedHit { - uint32_t tag; - float tx; // inverse transform translation components - float ty; - float tz; - float d; // distance - }; - - void ExpectHits(uint32_t node_id, const vec3& ray_origin, - const vec3& ray_direction, - std::vector<ExpectedHit> expected_hits, - bool expected_null = false) { - ::fuchsia::ui::gfx::vec3 wrapped_ray_origin; - wrapped_ray_origin.x = ray_origin.x; - wrapped_ray_origin.y = ray_origin.y; - wrapped_ray_origin.z = ray_origin.z; - - ::fuchsia::ui::gfx::vec3 wrapped_ray_direction; - wrapped_ray_direction.x = ray_direction.x; - wrapped_ray_direction.y = ray_direction.y; - wrapped_ray_direction.z = ray_direction.z; - - fidl::VectorPtr<::fuchsia::ui::gfx::Hit> actual_hits; - session_->HitTest( - node_id, wrapped_ray_origin, wrapped_ray_direction, - [&actual_hits](fidl::VectorPtr<::fuchsia::ui::gfx::Hit> hits) { - actual_hits = std::move(hits); - }); - - EXPECT_EQ(expected_null, actual_hits.is_null()); - EXPECT_EQ(expected_hits.size(), actual_hits->size()); - for (uint32_t i = 0; - i < std::min(expected_hits.size(), actual_hits->size()); i++) { - EXPECT_EQ(expected_hits[i].tag, actual_hits->at(i).tag_value) - << "i=" << i; - const auto& m = actual_hits->at(i).inverse_transform.matrix; - EXPECT_EQ(1.f, m[0]) << "i=" << i; - EXPECT_EQ(0.f, m[1]) << "i=" << i; - EXPECT_EQ(0.f, m[2]) << "i=" << i; - EXPECT_EQ(0.f, m[3]) << "i=" << i; - EXPECT_EQ(0.f, m[4]) << "i=" << i; - EXPECT_EQ(1.f, m[5]) << "i=" << i; - EXPECT_EQ(0.f, m[6]) << "i=" << i; - EXPECT_EQ(0.f, m[7]) << "i=" << i; - EXPECT_EQ(0.f, m[8]) << "i=" << i; - EXPECT_EQ(0.f, m[9]) << "i=" << i; - EXPECT_EQ(1.f, m[10]) << "i=" << i; - EXPECT_EQ(0.f, m[11]) << "i=" << i; - EXPECT_EQ(expected_hits[i].tx, m[12]) << "i=" << i; - EXPECT_EQ(expected_hits[i].ty, m[13]) << "i=" << i; - EXPECT_EQ(expected_hits[i].tz, m[14]) << "i=" << i; - EXPECT_EQ(1.f, m[15]) << "i=" << i; - EXPECT_EQ(expected_hits[i].d, actual_hits->at(i).distance) << "i=" << i; - } - } -}; - -TEST_F(HitTestTest, InvalidNodeId) { - ExpectHits(0, vec3(0.f, 0.f, 0.f), kDownVector, {}, true); -} - -TEST_F(HitTestTest, RayBelowScenePointingDown) { - ExpectHits(1, vec3(0.f, 0.f, 10.f), kDownVector, {}); -} - -TEST_F(HitTestTest, RayBelowScenePointingUp) { - ExpectHits(1, vec3(0.f, 0.f, 10.f), kUpVector, {}); -} - -TEST_F(HitTestTest, RayAboveScenePointingUp) { - ExpectHits(1, vec3(0.f, 0.f, -10.f), kUpVector, {}); -} - -TEST_F(HitTestTest, Hit10InTopLeftCornerFromNode1) { - ExpectHits(1, vec3(0.f, 0.f, -10.f), kDownVector, - {{.tag = 10, .tx = -4.f, .ty = -4.f, .tz = 2.f, .d = 8.f}, - {.tag = 25, .tx = -4.f, .ty = -4.f, .tz = 0.f, .d = 8.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 8.f}}); -} - -TEST_F(HitTestTest, Hit10InTopLeftCornerFromNode2) { - ExpectHits(2, vec3(0.f, 0.f, -10.f), kDownVector, - {{.tag = 10, .tx = -4.f, .ty = -4.f, .tz = 2.f, .d = 8.f}, - {.tag = 25, .tx = -4.f, .ty = -4.f, .tz = 0.f, .d = 8.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 8.f}}); -} - -TEST_F(HitTestTest, Hit10InTopLeftCornerFromNode3) { - ExpectHits(3, vec3(-4.f, -4.f, -10.f), kDownVector, - {{.tag = 10, .tx = 0.f, .ty = 0.f, .tz = 2.f, .d = 8.f}, - {.tag = 25, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 8.f}}); -} - -TEST_F(HitTestTest, Hit10InTopLeftCornerFromNode4) { - ExpectHits(4, vec3(-4.f, -4.f, -10.f), kDownVector, - {{.tag = 10, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 10.f}}); -} - -TEST_F(HitTestTest, Hit20InMiddleFromNode1) { - ExpectHits(1, vec3(9.f, 9.f, -10.f), kDownVector, - {{.tag = 20, .tx = -9.f, .ty = -9.f, .tz = 1.f, .d = 9.f}, - {.tag = 25, .tx = -4.f, .ty = -4.f, .tz = 0.f, .d = 9.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 9.f}}); -} - -TEST_F(HitTestTest, Hit20InMiddleFromNode2) { - ExpectHits(2, vec3(9.f, 9.f, -10.f), kDownVector, - {{.tag = 20, .tx = -9.f, .ty = -9.f, .tz = 1.f, .d = 9.f}, - {.tag = 25, .tx = -4.f, .ty = -4.f, .tz = 0.f, .d = 9.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 9.f}}); -} - -TEST_F(HitTestTest, Hit20InMiddleFromNode3) { - ExpectHits(3, vec3(5.f, 5.f, -10.f), kDownVector, - {{.tag = 20, .tx = -5.f, .ty = -5.f, .tz = 1.f, .d = 9.f}, - {.tag = 25, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 9.f}}); -} - -TEST_F(HitTestTest, Hit20InMiddleFromNode5) { - ExpectHits(5, vec3(0.f, 0.f, -10.f), kDownVector, - {{.tag = 20, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 10.f}}); -} - -TEST_F(HitTestTest, Hit20InMiddleFromNode6) { - ExpectHits(6, vec3(0.f, 0.f, -10.f), kDownVector, {}); -} - -TEST_F(HitTestTest, HitBoth10And20FromNode1) { - // 10 is nearer so it comes before 20 - ExpectHits(1, vec3(6.f, 6.f, -10.f), kDownVector, - {{.tag = 10, .tx = -4.f, .ty = -4.f, .tz = 2.f, .d = 8.f}, - {.tag = 25, .tx = -4.f, .ty = -4.f, .tz = 0.f, .d = 8.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 8.f}, - {.tag = 20, .tx = -9.f, .ty = -9.f, .tz = 1.f, .d = 9.f}}); -} - -TEST_F(HitTestTest, HitBoth20And30FromNode1) { - // 20 and 30 are same distance but 30 is closer in draw order so it - // comes before 20 - ExpectHits(1, vec3(12.f, 6.f, -10.f), kDownVector, - {{.tag = 30, .tx = -14.f, .ty = -4.f, .tz = 1.f, .d = 9.f}, - {.tag = 35, .tx = -10.f, .ty = 0.f, .tz = 1.f, .d = 9.f}, - {.tag = 20, .tx = -9.f, .ty = -9.f, .tz = 1.f, .d = 9.f}, - {.tag = 25, .tx = -4.f, .ty = -4.f, .tz = 0.f, .d = 9.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 9.f}}); -} - -TEST_F(HitTestTest, SuppressNode25FromNode1) { - Apply(scenic::NewSetHitTestBehaviorCmd( - 3, ::fuchsia::ui::gfx::HitTestBehavior::kSuppress)); - - // While we would have hit 20 and 25, we suppressed node 3 so neither appears. - ExpectHits(1, vec3(12.f, 6.f, -10.f), kDownVector, - {{.tag = 30, .tx = -14.f, .ty = -4.f, .tz = 1.f, .d = 9.f}, - {.tag = 35, .tx = -10.f, .ty = 0.f, .tz = 1.f, .d = 9.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 9.f}}); -} - -TEST_F(HitTestTest, Clipping) { - // Try to hit 10 from the top left corner, with clipping applied - // to a rectangle added as a part in 25, which contains 10. - // We move this part around and turn clipping on and off to see what happens - // when the clip is intersected or not. - Apply(scenic::NewCreateEntityNodeCmd(11)); - Apply(scenic::NewAddPartCmd(3, 11)); - Apply(scenic::NewCreateShapeNodeCmd(12)); - Apply(scenic::NewSetShapeCmd(12, 20)); - Apply(scenic::NewAddChildCmd(11, 12)); - - // Initially, position the clip shape someplace far away from the content. - // This causes 10 to be outside of its containing clip region. - Apply(scenic::NewSetTranslationCmd(11, (float[3]){20.f, 20.f, 0.f})); - Apply(scenic::NewSetClipCmd(3, 0, true)); - ExpectHits(1, vec3(0.f, 0.f, 10.f), kDownVector, {}); - - // Now disable clipping and try again. - Apply(scenic::NewSetClipCmd(3, 0, false)); - ExpectHits(1, vec3(0.f, 0.f, -10.f), kDownVector, - {{.tag = 10, .tx = -4.f, .ty = -4.f, .tz = 2.f, .d = 8.f}, - {.tag = 25, .tx = -4.f, .ty = -4.f, .tz = 0.f, .d = 8.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 8.f}}); - - // Move the clip shape so it covers the part of 10 that we're hitting - // and reenable clipping. - Apply(scenic::NewSetTranslationCmd(11, (float[3]){-4.f, -4.f, 0.f})); - Apply(scenic::NewSetClipCmd(3, 0, true)); - ExpectHits(1, vec3(0.f, 0.f, -10.f), kDownVector, - {{.tag = 10, .tx = -4.f, .ty = -4.f, .tz = 2.f, .d = 8.f}, - {.tag = 25, .tx = -4.f, .ty = -4.f, .tz = 0.f, .d = 8.f}, - {.tag = 100, .tx = 0.f, .ty = 0.f, .tz = 0.f, .d = 8.f}}); -} - -} // namespace test -} // namespace gfx -} // namespace scenic_impl diff --git a/garnet/lib/ui/scenic/command_dispatcher.h b/garnet/lib/ui/scenic/command_dispatcher.h index 55c71f18e7168c7c33a86dd76d4173543d6934dd..f612c7f37bbd4221115159a92886706ea64f6df6 100644 --- a/garnet/lib/ui/scenic/command_dispatcher.h +++ b/garnet/lib/ui/scenic/command_dispatcher.h @@ -69,16 +69,6 @@ class TempSessionDelegate : public CommandDispatcher { ::std::vector<zx::event> release_fences, fuchsia::ui::scenic::Session::PresentCallback callback) = 0; - virtual void HitTest( - uint32_t node_id, ::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback) = 0; - - virtual void HitTestDeviceRay( - ::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - fuchsia::ui::scenic::Session::HitTestCallback callback) = 0; - virtual void SetDebugName(const std::string& debug_name) = 0; private: diff --git a/garnet/lib/ui/scenic/session.cc b/garnet/lib/ui/scenic/session.cc index 9ad826348777308dea558ef6ca70dd55da2a129b..47c60e05af9d72f3ebedb05b066a1b7630cb4b09 100644 --- a/garnet/lib/ui/scenic/session.cc +++ b/garnet/lib/ui/scenic/session.cc @@ -63,21 +63,6 @@ void Session::SetCommandDispatchers( } } -void Session::HitTest(uint32_t node_id, ::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - HitTestCallback callback) { - // TODO(SCN-1265): Come up with a better solution to avoid children - // calling into us during destruction. - if (!valid_) - return; - auto& dispatcher = dispatchers_[System::TypeId::kGfx]; - FXL_DCHECK(dispatcher); - TempSessionDelegate* delegate = - static_cast<TempSessionDelegate*>(dispatcher.get()); - delegate->HitTest(node_id, std::move(ray_origin), std::move(ray_direction), - std::move(callback)); -} - void Session::SetDebugName(std::string debug_name) { // TODO(SCN-1265): Come up with a better solution to avoid children // calling into us during destruction. @@ -90,17 +75,6 @@ void Session::SetDebugName(std::string debug_name) { delegate->SetDebugName(debug_name); } -void Session::HitTestDeviceRay(::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - HitTestCallback callback) { - auto& dispatcher = dispatchers_[System::TypeId::kGfx]; - FXL_DCHECK(dispatcher); - TempSessionDelegate* delegate = - reinterpret_cast<TempSessionDelegate*>(dispatcher.get()); - delegate->HitTestDeviceRay(std::move(ray_origin), std::move(ray_direction), - std::move(callback)); -} - void Session::PostFlushTask() { // If this is the first EnqueueEvent() since the last FlushEvent(), post a // task to ensure that FlushEvents() is called. diff --git a/garnet/lib/ui/scenic/session.h b/garnet/lib/ui/scenic/session.h index b7c47ecacf17988f585340f8913f677253101d16..e9b377cb4928ed136410d68cc26eb772acc1a74c 100644 --- a/garnet/lib/ui/scenic/session.h +++ b/garnet/lib/ui/scenic/session.h @@ -49,18 +49,6 @@ class Session final : public fuchsia::ui::scenic::Session, ::std::vector<zx::event> release_fences, PresentCallback callback) override; - // |fuchsia::ui::scenic::Session| - // TODO(SCN-422): Remove this after it's removed from session.fidl. - void HitTest(uint32_t node_id, ::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - HitTestCallback callback) override; - - // |fuchsia::ui::scenic::Session| - // TODO(SCN-422): Remove this after it's removed from session.fidl. - void HitTestDeviceRay(::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - HitTestCallback callback) override; - // |fuchsia::ui::scenic::Session| void SetDebugName(std::string debug_name) override; diff --git a/sdk/fidl/fuchsia.ui.scenic/fuchsia.ui.scenic.api b/sdk/fidl/fuchsia.ui.scenic/fuchsia.ui.scenic.api index edfb01e71535bc5740e125f2fba9f68bb4a8c375..d49a88603fbdb2dda8533dcb434a9f266a55aef5 100644 --- a/sdk/fidl/fuchsia.ui.scenic/fuchsia.ui.scenic.api +++ b/sdk/fidl/fuchsia.ui.scenic/fuchsia.ui.scenic.api @@ -2,5 +2,5 @@ "fidl/fuchsia.ui.scenic/commands.fidl": "6710eee1f3c859bdeb5fd4279bbdd48f", "fidl/fuchsia.ui.scenic/events.fidl": "0b2de80e3dfc14c02961196c6827f0d2", "fidl/fuchsia.ui.scenic/scenic.fidl": "a02fbcb8be1b00d385c9bebb1c3c43ee", - "fidl/fuchsia.ui.scenic/session.fidl": "e51c510b1327b1504063a8d98a08f832" + "fidl/fuchsia.ui.scenic/session.fidl": "8b639668afb95f72ea20abc0c2f8bf41" } \ No newline at end of file diff --git a/sdk/fidl/fuchsia.ui.scenic/session.fidl b/sdk/fidl/fuchsia.ui.scenic/session.fidl index b20e4ad12f5f2d854c410e75663c40104987f5a4..34494f677ecea327cd52e810f3222b4e602065cf 100644 --- a/sdk/fidl/fuchsia.ui.scenic/session.fidl +++ b/sdk/fidl/fuchsia.ui.scenic/session.fidl @@ -127,13 +127,6 @@ protocol Session { vector<handle<event>> acquire_fences, vector<handle<event>> release_fences) -> (fuchsia.images.PresentationInfo presentation_info); - // TODO(SCN-422) Remove these methods from the FIDL; they should just be - // exposed to View Manager directly using a C++ interface. - HitTest(uint32 node_id, fuchsia.ui.gfx.vec3 ray_origin, fuchsia.ui.gfx.vec3 ray_direction) - -> (vector<fuchsia.ui.gfx.Hit>? hits); - HitTestDeviceRay(fuchsia.ui.gfx.vec3 ray_origin, fuchsia.ui.gfx.vec3 ray_direction) - -> (vector<fuchsia.ui.gfx.Hit>? hits); - // Set an optional debug name for the session. The debug name will be // output in things such as logging and trace events. SetDebugName(string debug_name); diff --git a/sdk/lib/ui/scenic/cpp/scenic_cpp.api b/sdk/lib/ui/scenic/cpp/scenic_cpp.api index 13777052c922083ff25bb1d28f499eec875905e0..9da59da02481788cf3e721b9307013f923e696de 100644 --- a/sdk/lib/ui/scenic/cpp/scenic_cpp.api +++ b/sdk/lib/ui/scenic/cpp/scenic_cpp.api @@ -3,7 +3,7 @@ "pkg/scenic_cpp/include/lib/ui/scenic/cpp/host_memory.h": "d9c14240ee79c58d60260a9d4c680681", "pkg/scenic_cpp/include/lib/ui/scenic/cpp/id.h": "4442d6e024bba018b7a8038d0a069713", "pkg/scenic_cpp/include/lib/ui/scenic/cpp/resources.h": "c34d6a22311f5f81e6d7c571f178049f", - "pkg/scenic_cpp/include/lib/ui/scenic/cpp/session.h": "3055e2a58ffb264559fe73e14774cf85", + "pkg/scenic_cpp/include/lib/ui/scenic/cpp/session.h": "379efdac3f9e986cd4da7b87fc944f41", "pkg/scenic_cpp/include/lib/ui/scenic/cpp/util/mesh_utils.h": "41dd823e1bd4cf48c560873547a689ea", "pkg/scenic_cpp/include/lib/ui/scenic/cpp/view_token_pair.h": "1d32d345d5e1746ada8a36d45b1ebf56" } \ No newline at end of file diff --git a/sdk/lib/ui/scenic/cpp/session.cc b/sdk/lib/ui/scenic/cpp/session.cc index 8e656f44a41962101d8967d42cdddcbd714a2804..efb3a794ebe65b5a2de529cecf75e67f1882a265 100644 --- a/sdk/lib/ui/scenic/cpp/session.cc +++ b/sdk/lib/ui/scenic/cpp/session.cc @@ -109,41 +109,6 @@ void Session::Present(uint64_t presentation_time, PresentCallback callback) { std::move(release_fences_), std::move(callback)); } -void Session::HitTest(uint32_t node_id, const float ray_origin[3], - const float ray_direction[3], HitTestCallback callback) { - ZX_DEBUG_ASSERT(session_); - fuchsia::ui::gfx::vec3 ray_origin_vec; - ray_origin_vec.x = ray_origin[0]; - ray_origin_vec.y = ray_origin[1]; - ray_origin_vec.z = ray_origin[2]; - - fuchsia::ui::gfx::vec3 ray_direction_vec; - ray_direction_vec.x = ray_direction[0]; - ray_direction_vec.y = ray_direction[1]; - ray_direction_vec.z = ray_direction[2]; - - session_->HitTest(node_id, std::move(ray_origin_vec), - std::move(ray_direction_vec), std::move(callback)); -} - -void Session::HitTestDeviceRay( - const float ray_origin[3], const float ray_direction[3], - fuchsia::ui::scenic::Session::HitTestDeviceRayCallback callback) { - ZX_DEBUG_ASSERT(session_); - fuchsia::ui::gfx::vec3 ray_origin_vec; - ray_origin_vec.x = ray_origin[0]; - ray_origin_vec.y = ray_origin[1]; - ray_origin_vec.z = ray_origin[2]; - - fuchsia::ui::gfx::vec3 ray_direction_vec; - ray_direction_vec.x = ray_direction[0]; - ray_direction_vec.y = ray_direction[1]; - ray_direction_vec.z = ray_direction[2]; - - session_->HitTestDeviceRay(std::move(ray_origin_vec), - std::move(ray_direction_vec), std::move(callback)); -} - void Session::Unbind() { ZX_DEBUG_ASSERT(session_); ZX_DEBUG_ASSERT(!session_handle_); diff --git a/sdk/lib/ui/scenic/cpp/session.h b/sdk/lib/ui/scenic/cpp/session.h index 480a3c415d07e3f9ecab99f96c80589f47cea5eb..aa9c5a766ca3c4a7d5e759c66f0b788f32a1f7b2 100644 --- a/sdk/lib/ui/scenic/cpp/session.h +++ b/sdk/lib/ui/scenic/cpp/session.h @@ -34,10 +34,6 @@ class Session : private fuchsia::ui::scenic::SessionListener { using PresentCallback = fit::function<void(fuchsia::images::PresentationInfo info)>; - // Provide information about hits. - using HitTestCallback = - fit::function<void(fidl::VectorPtr<fuchsia::ui::gfx::Hit> hits)>; - // Called when session events are received. using EventHandler = fit::function<void(std::vector<fuchsia::ui::scenic::Event>)>; @@ -106,16 +102,6 @@ class Session : private fuchsia::ui::scenic::SessionListener { // Invokes the callback when the scene manager applies the presentation. void Present(uint64_t presentation_time, PresentCallback callback); - // Performs a hit test along the specified ray. - void HitTest(uint32_t node_id, const float ray_origin[3], - const float ray_direction[3], HitTestCallback callback); - - // Performs a hit test along the specified ray into the engine's first - // compositor. - void HitTestDeviceRay( - const float ray_origin[3], const float ray_direction[3], - fuchsia::ui::scenic::Session::HitTestDeviceRayCallback callback); - // Unbinds the internal SessionPtr; this allows moving this across threads. void Unbind(); diff --git a/src/media/playback/mediaplayer/test/fakes/fake_session.cc b/src/media/playback/mediaplayer/test/fakes/fake_session.cc index 3bea449e9620cbb462d4d53b943edcd70025d0c3..2a2528393c685544882c5edca26176a07d2b7bf9 100644 --- a/src/media/playback/mediaplayer/test/fakes/fake_session.cc +++ b/src/media/playback/mediaplayer/test/fakes/fake_session.cc @@ -137,20 +137,6 @@ void FakeSession::Present(uint64_t presentation_time, }); } -void FakeSession::HitTest(uint32_t node_id, ::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - HitTestCallback callback) { - FXL_LOG(INFO) << "HitTest (not implemented)"; - // fit::function<void(fidl::VectorPtr<::fuchsia::ui::gfx::Hit>)> -} - -void FakeSession::HitTestDeviceRay(::fuchsia::ui::gfx::vec3 ray_origin, - ::fuchsia::ui::gfx::vec3 ray_direction, - HitTestDeviceRayCallback callback) { - FXL_LOG(INFO) << "HitTestDeviceRay (not implemented)"; - // fit::function<void(fidl::VectorPtr<::fuchsia::ui::gfx::Hit>)> -} - FakeSession::Resource* FakeSession::FindResource(uint32_t id) { auto iter = resources_by_id_.find(id); return (iter == resources_by_id_.end()) ? nullptr : &iter->second; diff --git a/src/media/playback/mediaplayer/test/fakes/fake_session.h b/src/media/playback/mediaplayer/test/fakes/fake_session.h index 4ddcc6497bc0217d106d6d581278d200f91624f5..90d20f6bd31580e527d84a442155358af91715b3 100644 --- a/src/media/playback/mediaplayer/test/fakes/fake_session.h +++ b/src/media/playback/mediaplayer/test/fakes/fake_session.h @@ -57,14 +57,6 @@ class FakeSession : public fuchsia::ui::scenic::Session { std::vector<::zx::event> release_fences, PresentCallback callback) override; - void HitTest(uint32_t node_id, fuchsia::ui::gfx::vec3 ray_origin, - fuchsia::ui::gfx::vec3 ray_direction, - HitTestCallback callback) override; - - void HitTestDeviceRay(fuchsia::ui::gfx::vec3 ray_origin, - fuchsia::ui::gfx::vec3 ray_direction, - HitTestDeviceRayCallback callback) override; - void SetDebugName(std::string debug_name) override {} private: