[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / camera-view / camera-view-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_CAMERA_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_CAMERA_VIEW_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/camera-player.h>
23 #include <dali/public-api/object/property-notification.h>
24 #include <dali/public-api/rendering/renderer.h>
25 #include <dali/public-api/rendering/texture.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/public-api/controls/camera-view/camera-view.h>
29 #include <dali-toolkit/public-api/controls/control-impl.h>
30
31 namespace Dali
32 {
33 namespace Toolkit
34 {
35 class CameraView;
36
37 namespace Internal
38 {
39 class CameraView : public Control
40 {
41 protected:
42   /**
43    * @brief Constructor.
44    * @param[in] type Where it is an overlay type or a native image type
45    */
46   CameraView(Dali::Toolkit::CameraView::DisplayType type);
47
48   /**
49    * @brief Destructor
50    */
51   virtual ~CameraView();
52
53 public:
54   /**
55    * @brief Creates an initialized CameraView.
56    * @param[in] handle Multimedia camera player handle
57    * @param[in] type Where it is an overlay type or a native image type
58    */
59   static Toolkit::CameraView New(Any handle, Dali::Toolkit::CameraView::DisplayType type);
60
61   /**
62    * @brief Update camera player.
63    */
64   void Update();
65
66 private: // From Control
67   /**
68    * @copydoc Toolkit::Control::OnSceneConnection()
69    */
70   void OnSceneConnection(int depth) override;
71
72   /**
73    * @copydoc Toolkit::Control::OnSceneDisconnection()
74    */
75   void OnSceneDisconnection() override;
76
77 private:
78   /**
79    * @brief Construct a new CameraView.
80    */
81   CameraView(const CameraView& cameraView);
82
83   // Undefined assignment operator.
84   CameraView& operator=(const CameraView& cameraView);
85
86   /**
87    * @brief Updates camera display area for window rendering target
88    * @param[in] source PropertyNotification
89    */
90   void UpdateDisplayArea(Dali::PropertyNotification& source);
91
92   /**
93    * @brief SetWindowSurfaceTarget for underlay camera preview.
94    */
95   void SetWindowSurfaceTarget();
96
97   /**
98    * @brief SetNativeImageTarget for native image camera preview.
99    */
100   void SetNativeImageTarget();
101
102   /**
103    * @brief CreateShader for native image target
104    * @param[in] nativeImageSourcePtr to apply custom fragment prefix
105    * @return Returns the shader for NativeImage.
106    */
107   Dali::Shader CreateShader(Dali::NativeImageSourcePtr nativeImageSourcePtr);
108
109 private:
110   Dali::CameraPlayer mCameraPlayer;
111   Dali::Texture      mNativeTexture;
112
113   Dali::DisplayArea mDisplayArea;
114   Dali::Renderer    mOverlayRenderer;
115   Dali::Renderer    mTextureRenderer;
116
117   Dali::PropertyNotification mPositionUpdateNotification;
118   Dali::PropertyNotification mSizeUpdateNotification;
119   Dali::PropertyNotification mScaleUpdateNotification;
120
121   Dali::Toolkit::CameraView::DisplayType mDisplayType;
122 };
123
124 } // namespace Internal
125
126 inline Toolkit::Internal::CameraView& GetImpl(Toolkit::CameraView& handle)
127 {
128   DALI_ASSERT_ALWAYS(handle);
129   Dali::RefObject& impl = handle.GetImplementation();
130   return static_cast<Toolkit::Internal::CameraView&>(impl);
131 }
132
133 inline const Toolkit::Internal::CameraView& GetImpl(const Toolkit::CameraView& handle)
134 {
135   DALI_ASSERT_ALWAYS(handle);
136   const Dali::RefObject& impl = handle.GetImplementation();
137   return static_cast<const Toolkit::Internal::CameraView&>(impl);
138 }
139
140 } // namespace Toolkit
141
142 } // namespace Dali
143
144 #endif // DALI_TOOLKIT_INTERNAL_CAMERA_VIEW_H