1 /* 2 * Copyright 2018 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkArCamera_DEFINED 9 #define SkArCamera_DEFINED 10 11 #include <memory> 12 #include "SkArTrackingState.h" 13 14 class ArCamera; 15 class SkArFrame; 16 class SkArSession; 17 18 /** 19 * Provides information about the camera that is used to capture images. Such information 20 * includes projection matrices, pose of camera... 21 */ 22 23 class SkArCamera { 24 25 public: 26 /** 27 * Factory method used to construct an SkArCamera from the current frame, using the current 28 * session 29 * @param session raw pointer to the current SkArSession 30 * @param frame raw pointer to the current SkArFrame 31 * @return unique pointer to an SkArCamera. Never nullptr 32 */ 33 static std::unique_ptr<SkArCamera> Make(SkArSession* session, SkArFrame* frame); 34 35 ~SkArCamera(); 36 37 /** 38 * Fills outColMajor with the values of the camera's current View matrix in column-major order 39 * @param session current SkArSession 40 * @param outColMajor 16-float array that will contain the View matrix content 41 */ 42 void getViewMatrix(const SkArSession* session, float outColMajor[16]); 43 44 /** 45 * Fills outColMajor with the values of the camera's current Projection matrix in 46 * column-major order 47 * @param session current SkArSession 48 * @param nearClip wanted near clip value for the camera 49 * @param farClip wanted far clip value for the camera 50 * @param outColMajor 16-float array that will contain the Projection matrix content 51 */ 52 void getProjectionMatrix(const SkArSession* session, float nearClip, float farClip, 53 float outColMajor[16]); 54 55 /** 56 * Used to check the current SkArTrackingState of the camera 57 * @param session current SkArSession 58 * @return tracking state of the SkArCamera described by the SkArTrackingState enum 59 */ 60 SkArTrackingState getTrackingState(const SkArSession* session); 61 62 private: 63 SkArCamera(SkArSession* session, SkArFrame* frame); 64 65 // This is a raw pointer. Its lifetime matches that of this class (SkArCamera) 66 ArCamera* fArCamera; 67 }; 68 #endif // SkArCamera_DEFINED 69