Revert "[Tizen] Added 'make clean' on each profile build."
[platform/core/uifw/dali-adaptor.git] / adaptors / x11 / ecore-x-render-surface.cpp
1 /*
2  * Copyright (c) 2017 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 "ecore-x-render-surface.h"
20
21 // EXTERNAL INCLUDES
22 #include <X11/Xatom.h>
23 #include <X11/Xlib.h>
24 #include <X11/Xutil.h>
25
26 #include <X11/extensions/Xfixes.h> // for damage notify
27 #include <X11/extensions/Xdamage.h> // for damage notify
28
29 #include <dali/integration-api/gl-abstraction.h>
30 #include <dali/integration-api/debug.h>
31
32 // INTERNAL INCLUDES
33 #include <ecore-x-types.h>
34 #include <trigger-event.h>
35 #include <gl/egl-implementation.h>
36
37 namespace Dali
38 {
39
40 #if defined(DEBUG_ENABLED)
41 Debug::Filter* gRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_ECORE_X_RENDER_SURFACE");
42 #endif
43
44 namespace ECore
45 {
46
47 EcoreXRenderSurface::EcoreXRenderSurface(Dali::PositionSize positionSize,
48                                          Any surface,
49                                          const std::string& name,
50                                          bool isTransparent)
51 : mPosition(positionSize),
52   mTitle(name),
53   mRenderNotification(NULL),
54   mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24),
55   mOwnSurface(false)
56 {
57 }
58
59 void EcoreXRenderSurface::Init( Any surface )
60 {
61   // see if there is a surface in Any surface
62   unsigned int surfaceId  = GetSurfaceId( surface );
63
64   // if the surface is empty, create a new one.
65   if ( surfaceId == 0 )
66   {
67     // we own the surface about to created
68     mOwnSurface = true;
69     CreateXRenderable();
70   }
71   else
72   {
73     // XLib should already be initialized so no point in calling XInitThreads
74     UseExistingRenderable( surfaceId );
75   }
76 }
77
78 EcoreXRenderSurface::~EcoreXRenderSurface()
79 {
80 }
81
82 void EcoreXRenderSurface::SetRenderNotification(TriggerEventInterface* renderNotification)
83 {
84   mRenderNotification = renderNotification;
85 }
86
87 Ecore_X_Window EcoreXRenderSurface::GetXWindow()
88 {
89   return 0;
90 }
91
92 Ecore_X_Drawable EcoreXRenderSurface::GetDrawable()
93 {
94   return 0;
95 }
96
97 PositionSize EcoreXRenderSurface::GetPositionSize() const
98 {
99   return mPosition;
100 }
101
102 void EcoreXRenderSurface::MoveResize( Dali::PositionSize positionSize )
103 {
104   // nothing to do in base class
105 }
106
107 void EcoreXRenderSurface::SetViewMode( ViewMode viewMode )
108 {
109 }
110
111 unsigned int EcoreXRenderSurface::GetSurfaceId( Any surface ) const
112 {
113   unsigned int surfaceId = 0;
114
115   if ( surface.Empty() == false )
116   {
117     // check we have a valid type
118     DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) ||
119                           (surface.GetType() == typeid (Ecore_X_Window) ) )
120                         && "Surface type is invalid" );
121
122     if ( surface.GetType() == typeid (Ecore_X_Window) )
123     {
124       surfaceId = AnyCast<Ecore_X_Window>( surface );
125     }
126     else
127     {
128       surfaceId = AnyCast<XWindow>( surface );
129     }
130   }
131   return surfaceId;
132 }
133
134 RenderSurface::Type EcoreXRenderSurface::GetSurfaceType()
135 {
136   return RenderSurface::ECORE_RENDER_SURFACE;
137 }
138
139 } // namespace ECore
140
141 } // namespace Dali