1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef DEVICE_VR_ANDROID_ARCORE_ARCORE_SESSION_UTILS_H_ 6 #define DEVICE_VR_ANDROID_ARCORE_ARCORE_SESSION_UTILS_H_ 7 8 #include "base/android/scoped_java_ref.h" 9 #include "base/memory/weak_ptr.h" 10 #include "ui/display/display.h" 11 #include "ui/gfx/geometry/point_f.h" 12 #include "ui/gfx/geometry/size.h" 13 #include "ui/gfx/native_widget_types.h" 14 15 namespace vr { 16 17 // Immersive AR sessions use callbacks in the following sequence: 18 // 19 // RequestArSession 20 // SurfaceReadyCallback 21 // SurfaceTouchCallback (repeated for each touch) 22 // [exit session via "back" button, or via JS session exit] 23 // DestroyedCallback 24 // 25 using SurfaceReadyCallback = 26 base::RepeatingCallback<void(gfx::AcceleratedWidget window, 27 display::Display::Rotation rotation, 28 const gfx::Size& size)>; 29 using SurfaceTouchCallback = 30 base::RepeatingCallback<void(bool is_primary, 31 bool touching, 32 int32_t pointer_id, 33 const gfx::PointF& location)>; 34 using SurfaceDestroyedCallback = base::OnceClosure; 35 36 class ArCoreSessionUtils { 37 public: 38 virtual ~ArCoreSessionUtils() = default; 39 virtual bool EnsureLoaded() = 0; 40 virtual base::android::ScopedJavaLocalRef<jobject> 41 GetApplicationContext() = 0; 42 virtual void RequestArSession( 43 int render_process_id, 44 int render_frame_id, 45 bool use_overlay, 46 SurfaceReadyCallback ready_callback, 47 SurfaceTouchCallback touch_callback, 48 SurfaceDestroyedCallback destroyed_callback) = 0; 49 virtual void EndSession() = 0; 50 }; 51 52 } // namespace vr 53 54 #endif // DEVICE_VR_ANDROID_ARCORE_ARCORE_SESSION_UTILS_H_ 55