aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools
diff options
context:
space:
mode:
authorGravatar ziadb <ziadb@google.com>2018-07-11 10:16:49 -0400
committerGravatar Ziad Ben Hadj-Alouane <ziadb@google.com>2018-07-12 17:32:54 +0000
commit4cb6520bd0f0b65b29b02d8fa95afea689ae592b (patch)
tree040a4c0e21eecc056d8f91fd65ff17b5d3e6fe78 /platform_tools
parente346b1eea442065261c14f92b304031e1330e491 (diff)
SkArCamera* files
Bug: skia: Change-Id: I711143c53bf66ebc8130b2401738da3cde644fbe Reviewed-on: https://skia-review.googlesource.com/140560 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'platform_tools')
-rw-r--r--platform_tools/android/apps/arcore/CMakeLists.txt4
-rw-r--r--platform_tools/android/apps/arcore/src/main/cpp/SkArCamera.cpp38
-rw-r--r--platform_tools/android/apps/arcore/src/main/cpp/SkArCamera.h68
3 files changed, 109 insertions, 1 deletions
diff --git a/platform_tools/android/apps/arcore/CMakeLists.txt b/platform_tools/android/apps/arcore/CMakeLists.txt
index 92c5968c95..6bfe1b7bef 100644
--- a/platform_tools/android/apps/arcore/CMakeLists.txt
+++ b/platform_tools/android/apps/arcore/CMakeLists.txt
@@ -33,7 +33,9 @@ add_library(hello_ar_native SHARED
"src/main/cpp/point_cloud_renderer.cc"
"src/main/cpp/util.cc"
"src/main/cpp/pending_anchor.cc"
- "src/main/cpp/anchor_wrapper.cc")
+ "src/main/cpp/anchor_wrapper.cc"
+
+ "src/main/cpp/SkArCamera.cpp")
target_include_directories(hello_ar_native PRIVATE
#BASIC AR NATIVE CODE
diff --git a/platform_tools/android/apps/arcore/src/main/cpp/SkArCamera.cpp b/platform_tools/android/apps/arcore/src/main/cpp/SkArCamera.cpp
new file mode 100644
index 0000000000..f27aebbffa
--- /dev/null
+++ b/platform_tools/android/apps/arcore/src/main/cpp/SkArCamera.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <arcore_c_api.h>
+#include "SkArCamera.h"
+#include "SkArUtil.h"
+
+std::unique_ptr<SkArCamera> SkArCamera::Make(SkArSession* session, SkArFrame* frame) {
+ return std::unique_ptr<SkArCamera>(new SkArCamera(session, frame));
+}
+
+SkArCamera::~SkArCamera() {
+ ArCamera_release(fArCamera);
+}
+
+SkArCamera::SkArCamera(SkArSession* session, SkArFrame* frame) : fArCamera(nullptr) {
+ ArFrame_acquireCamera(session->getArSession(), frame->getArFrame(), &fArCamera);
+}
+
+void SkArCamera::getViewMatrix(const SkArSession* session, float outColMajor[16]) {
+ ArCamera_getViewMatrix(session->getArSession(), fArCamera, outColMajor);
+}
+
+void SkArCamera::getProjectionMatrix(const SkArSession* session, float nearClip,
+ float farClip, float outColMajor[16]) {
+ ArCamera_getProjectionMatrix(session->getArSession(), fArCamera, nearClip, farClip,
+ outColMajor);
+}
+
+SkArTrackingState SkArCamera::getTrackingState(const SkArSession* session) {
+ ArTrackingState arTrackingState;
+ ArCamera_getTrackingState(session->getArSession(), fArCamera, &arTrackingState);
+ return SkArUtil::MakeSkArTrackingState(arTrackingState);
+}
diff --git a/platform_tools/android/apps/arcore/src/main/cpp/SkArCamera.h b/platform_tools/android/apps/arcore/src/main/cpp/SkArCamera.h
new file mode 100644
index 0000000000..0cf8f3c449
--- /dev/null
+++ b/platform_tools/android/apps/arcore/src/main/cpp/SkArCamera.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2018 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkArCamera_DEFINED
+#define SkArCamera_DEFINED
+
+#include <memory>
+#include "SkArTrackingState.h"
+
+class ArCamera;
+class SkArFrame;
+class SkArSession;
+
+/**
+ * Provides information about the camera that is used to capture images. Such information
+ * includes projection matrices, pose of camera...
+ */
+
+class SkArCamera {
+
+public:
+ /**
+ * Factory method used to construct an SkArCamera from the current frame, using the current
+ * session
+ * @param session raw pointer to the current SkArSession
+ * @param frame raw pointer to the current SkArFrame
+ * @return unique pointer to an SkArCamera. Never nullptr
+ */
+ static std::unique_ptr<SkArCamera> Make(SkArSession* session, SkArFrame* frame);
+
+ ~SkArCamera();
+
+ /**
+ * Fills outColMajor with the values of the camera's current View matrix in column-major order
+ * @param session current SkArSession
+ * @param outColMajor 16-float array that will contain the View matrix content
+ */
+ void getViewMatrix(const SkArSession* session, float outColMajor[16]);
+
+ /**
+ * Fills outColMajor with the values of the camera's current Projection matrix in
+ * column-major order
+ * @param session current SkArSession
+ * @param nearClip wanted near clip value for the camera
+ * @param farClip wanted far clip value for the camera
+ * @param outColMajor 16-float array that will contain the Projection matrix content
+ */
+ void getProjectionMatrix(const SkArSession* session, float nearClip, float farClip,
+ float outColMajor[16]);
+
+ /**
+ * Used to check the current SkArTrackingState of the camera
+ * @param session current SkArSession
+ * @return tracking state of the SkArCamera described by the SkArTrackingState enum
+ */
+ SkArTrackingState getTrackingState(const SkArSession* session);
+
+private:
+ SkArCamera(SkArSession* session, SkArFrame* frame);
+
+ // This is a raw pointer. Its lifetime matches that of this class (SkArCamera)
+ ArCamera* fArCamera;
+};
+#endif // SkArCamera_DEFINED