2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "ecore-x-render-surface.h"
22 #include <X11/Xatom.h>
24 #include <X11/Xutil.h>
26 #include <X11/extensions/Xfixes.h> // for damage notify
27 #include <X11/extensions/Xdamage.h> // for damage notify
29 #include <dali/integration-api/gl-abstraction.h>
30 #include <dali/integration-api/debug.h>
33 #include <ecore-x-types.h>
34 #include <trigger-event.h>
35 #include <gl/egl-implementation.h>
40 #if defined(DEBUG_ENABLED)
41 Debug::Filter* gRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_ECORE_X_RENDER_SURFACE");
47 EcoreXRenderSurface::EcoreXRenderSurface(Dali::PositionSize positionSize,
49 const std::string& name,
51 : mPosition(positionSize),
53 mRenderNotification(NULL),
54 mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24),
59 void EcoreXRenderSurface::Init( Any surface )
61 // see if there is a surface in Any surface
62 unsigned int surfaceId = GetSurfaceId( surface );
64 // if the surface is empty, create a new one.
67 // we own the surface about to created
73 // XLib should already be initialized so no point in calling XInitThreads
74 UseExistingRenderable( surfaceId );
78 // prints out 'INFO: DALI: new EcoreXRenderSurface, used existing surface xx
79 // we can not use LOG_INFO because the surface can be created before Dali Core is created.
80 printf( "INFO: DALI: new EcoreXRenderSurface, %s surface %X \n",
81 mOwnSurface?"created":"used existing",
82 AnyCast<Ecore_X_Drawable>( GetSurface() ) );
86 EcoreXRenderSurface::~EcoreXRenderSurface()
90 void EcoreXRenderSurface::SetRenderNotification(TriggerEventInterface* renderNotification)
92 mRenderNotification = renderNotification;
95 Ecore_X_Window EcoreXRenderSurface::GetXWindow()
100 Ecore_X_Drawable EcoreXRenderSurface::GetDrawable()
105 PositionSize EcoreXRenderSurface::GetPositionSize() const
110 void EcoreXRenderSurface::MoveResize( Dali::PositionSize positionSize )
112 // nothing to do in base class
115 void EcoreXRenderSurface::SetViewMode( ViewMode viewMode )
119 unsigned int EcoreXRenderSurface::GetSurfaceId( Any surface ) const
121 unsigned int surfaceId = 0;
123 if ( surface.Empty() == false )
125 // check we have a valid type
126 DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) ||
127 (surface.GetType() == typeid (Ecore_X_Window) ) )
128 && "Surface type is invalid" );
130 if ( surface.GetType() == typeid (Ecore_X_Window) )
132 surfaceId = AnyCast<Ecore_X_Window>( surface );
136 surfaceId = AnyCast<XWindow>( surface );
142 RenderSurface::Type EcoreXRenderSurface::GetSurfaceType()
144 return RenderSurface::ECORE_RENDER_SURFACE;