Add pepper-dali
[platform/core/uifw/pepper-dali.git] / pepper-dali / internal / output-impl.h
1 #ifndef __DALI_PEPPER_INTERNAL_OUTPUT_H__
2 #define __DALI_PEPPER_INTERNAL_OUTPUT_H__
3
4 /*
5  * Copyright (c) 2016 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 // INTERNAL INCLUDES
22 #include <pepper-dali/internal/output.h>
23 #include <pepper-dali/internal/object.h>
24
25 // EXTERNAL INCLUDES
26 #include <dali/public-api/common/intrusive-ptr.h>
27 #include <dali/public-api/common/vector-wrapper.h>
28 #include <dali/public-api/object/base-object.h>
29 #include <dali/public-api/signals/connection-tracker.h>
30 #include <pepper-output-backend.h>
31
32 namespace Dali
33 {
34
35 namespace Pepper
36 {
37
38 namespace Internal
39 {
40
41 class Output;
42 typedef IntrusivePtr<Output> OutputPtr;
43
44 class Output : public BaseObject, public ConnectionTracker
45 {
46 public:
47
48   static OutputPtr New( Pepper::Compositor compositor, Application application, Pepper::Input input );
49
50   static void OnDestroy( void* data );
51   static int32_t OnGetSubpixelOrder( void* data );
52   static const char* OnGetMakerName( void* data );
53   static const char* OnGetModelName( void* data );
54   static int OnGetModeCount( void* data );
55   static void OnGetMode( void* data, int index, pepper_output_mode_t* mode );
56   static pepper_bool_t OnSetMode( void* data, const pepper_output_mode_t* mode );
57   static void OnAssignPlanes( void* data, const pepper_list_t* viewList );
58   static void OnStartRepaintLoop( void* data );
59   static void OnRepaint( void* data, const pepper_list_t* planeList );
60   static void OnAttachSurface( void* data, pepper_surface_t* surface, int* width, int* height );
61   static void OnFlushSurface( void* data, pepper_surface_t* surface, pepper_bool_t* keepBuffer );
62
63 public: //Signals
64
65   Pepper::Output::OutputSignalType& ObjectViewAddedSignal();
66   Pepper::Output::OutputSignalType& ObjectViewDeletedSignal();
67
68 private:
69
70   /**
71    * Construct a new Output.
72    */
73   Output();
74
75   /**
76    * A reference counted object may only be deleted by calling Unreference()
77    */
78   virtual ~Output();
79
80   /**
81    * Second-phase constructor. Must be called immediately after creating a new Output;
82    */
83   void Initialize( Pepper::Compositor& compositor, Application application, Pepper::Input input );
84
85   void OnResize( Application& application );
86
87   void OnObjectViewAdded( Pepper::Object object, Pepper::ObjectView objectView );
88   void OnObjectViewDeleted( Pepper::Object object, Pepper::ObjectView objectView );
89
90 private:
91
92   // Undefined
93   Output( const Output& );
94
95   // Undefined
96   Output& operator=( const Output& rhs );
97
98 private: // Data
99
100   Pepper::Compositor mCompositor;
101
102   Vector2 mSize;
103
104   Pepper::Input mInput;
105   std::vector<Pepper::Object> mObjectList;
106
107   pepper_output_t* mOutput;
108   pepper_plane_t* mPrimaryPlane;
109
110   // Signals
111   Pepper::Output::OutputSignalType mObjectViewAddedSignal;
112   Pepper::Output::OutputSignalType mObjectViewDeletedSignal;
113 };
114
115 } // namespace Internal
116
117 // Helpers for public-api forwarding methods
118
119 inline Pepper::Internal::Output& GetImplementation( Pepper::Output& output )
120 {
121   DALI_ASSERT_ALWAYS( output && "Output handle is empty" );
122
123   BaseObject& handle = output.GetBaseObject();
124
125   return static_cast< Internal::Output& >( handle );
126 }
127
128 inline const Pepper::Internal::Output& GetImplementation( const Pepper::Output& output )
129 {
130   DALI_ASSERT_ALWAYS( output && "Output handle is empty" );
131
132   const BaseObject& handle = output.GetBaseObject();
133
134   return static_cast< const Internal::Output& >( handle );
135 }
136
137 } // namespace Pepper
138
139 } // namespace Dali
140
141 #endif // __DALI_PEPPER_INTERNAL_OUTPUT_H__