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>
This commit is contained in:
ziadb 2018-07-11 10:16:49 -04:00 committed by Ziad Ben Hadj-Alouane
parent e346b1eea4
commit 4cb6520bd0
3 changed files with 109 additions and 1 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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