cc76c24f685058991752e186ba05f36d762630fb
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / pixmap-render-surface-ecore-wl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "pixmap-render-surface.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/gl-abstraction.h>
23 #include <dali/integration-api/debug.h>
24
25 // INTERNAL INCLUDES
26 #include <ecore-wl-types.h>
27 #include <trigger-event.h>
28 #include <gl/egl-implementation.h>
29 #include <base/display-connection.h>
30
31 namespace Dali
32 {
33
34 #if defined(DEBUG_ENABLED)
35 extern Debug::Filter* gRenderSurfaceLogFilter;
36 #endif
37
38 namespace ECore
39 {
40
41 PixmapRenderSurface::PixmapRenderSurface(Dali::PositionSize positionSize,
42                                          Any surface,
43                                          const std::string& name,
44                                          bool isTransparent)
45 : EcoreWlRenderSurface( positionSize, surface, name, isTransparent )
46 {
47   Init( surface );
48 }
49
50 PixmapRenderSurface::~PixmapRenderSurface()
51 {
52   // release the surface if we own one
53   if( mOwnSurface )
54   {
55     // if we did create the pixmap, delete the pixmap
56     DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", mX11Pixmap );
57   }
58 }
59
60 Ecore_Wl_Window* PixmapRenderSurface::GetDrawable()
61 {
62   return NULL;
63 }
64
65 Any PixmapRenderSurface::GetSurface()
66 {
67   return Any( NULL );
68 }
69
70 void PixmapRenderSurface::InitializeEgl( EglInterface& egl )
71 {
72   DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
73
74   Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
75
76   eglImpl.ChooseConfig(false, mColorDepth);
77 }
78
79 void PixmapRenderSurface::CreateEglSurface( EglInterface& egl )
80 {
81   DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
82
83   // create the EGL surface
84   // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
85   // FIXME
86 }
87
88 void PixmapRenderSurface::DestroyEglSurface( EglInterface& egl )
89 {
90   DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
91
92   Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
93   eglImpl.DestroySurface();
94 }
95
96 bool PixmapRenderSurface::ReplaceEGLSurface( EglInterface& egl )
97 {
98   DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
99
100   // a new surface for the new pixmap
101   // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
102   // FIXME
103   return false;
104 }
105
106 void PixmapRenderSurface::StartRender()
107 {
108   // FIXME
109 }
110
111 bool PixmapRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
112 {
113   // nothing to do for pixmaps
114   return true;
115 }
116
117 void PixmapRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface )
118 {
119   // flush gl instruction queue
120   glAbstraction.Flush();
121
122  // create damage for client applications which wish to know the update timing
123   if( mRenderNotification )
124   {
125     // use notification trigger
126     // Tell the event-thread to render the pixmap
127     mRenderNotification->Trigger();
128   }
129   else
130   {
131     // FIXME
132   }
133
134   // Do render synchronisation
135   // AcquireLock( replacingSurface ? SYNC_MODE_NONE : SYNC_MODE_WAIT );
136 }
137
138 void PixmapRenderSurface::StopRender()
139 {
140   // FIXME
141 }
142
143 void PixmapRenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
144 {
145   // Nothing to do
146 }
147
148 void PixmapRenderSurface::CreateWlRenderable()
149 {
150   // check we're creating one with a valid size
151   DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "Pixmap size is invalid" );
152
153   // FIXME
154 }
155
156 void PixmapRenderSurface::UseExistingRenderable( unsigned int surfaceId )
157 {
158   // FIXME
159 }
160
161 void PixmapRenderSurface::SetSyncMode( SyncMode syncMode )
162 {
163   // FIXME
164 }
165
166 void PixmapRenderSurface::AcquireLock()
167 {
168   // FIXME
169 }
170
171 void PixmapRenderSurface::ReleaseLock()
172 {
173   // FIXME
174 }
175
176 } // namespace ECore
177
178 } // namespace Dali