2 * Copyright (c) 2017 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 EcoreXRenderSurface::~EcoreXRenderSurface()
82 void EcoreXRenderSurface::SetRenderNotification(TriggerEventInterface* renderNotification)
84 mRenderNotification = renderNotification;
87 Ecore_X_Window EcoreXRenderSurface::GetXWindow()
92 Ecore_X_Drawable EcoreXRenderSurface::GetDrawable()
97 PositionSize EcoreXRenderSurface::GetPositionSize() const
102 void EcoreXRenderSurface::MoveResize( Dali::PositionSize positionSize )
104 // nothing to do in base class
107 void EcoreXRenderSurface::SetViewMode( ViewMode viewMode )
111 unsigned int EcoreXRenderSurface::GetSurfaceId( Any surface ) const
113 unsigned int surfaceId = 0;
115 if ( surface.Empty() == false )
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" );
122 if ( surface.GetType() == typeid (Ecore_X_Window) )
124 surfaceId = AnyCast<Ecore_X_Window>( surface );
128 surfaceId = AnyCast<XWindow>( surface );
134 RenderSurface::Type EcoreXRenderSurface::GetSurfaceType()
136 return RenderSurface::ECORE_RENDER_SURFACE;