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-wl-render-surface.h"
22 #include <dali/integration-api/gl-abstraction.h>
23 #include <dali/integration-api/debug.h>
26 #include <ecore-wl-types.h>
27 #include <trigger-event.h>
28 #include <gl/egl-implementation.h>
33 #if defined(DEBUG_ENABLED)
34 Debug::Filter* gRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_ECORE_X_RENDER_SURFACE");
40 EcoreWlRenderSurface::EcoreWlRenderSurface(Dali::PositionSize positionSize,
42 const std::string& name,
44 : mPosition(positionSize),
46 mRenderNotification(NULL),
47 mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24),
52 void EcoreWlRenderSurface::Init( Any surface )
54 // see if there is a surface in Any surface
55 unsigned int surfaceId = GetSurfaceId( surface );
57 // if the surface is empty, create a new one.
60 // we own the surface about to created
66 // XLib should already be initialized so no point in calling XInitThreads
67 UseExistingRenderable( surfaceId );
71 // prints out 'INFO: DALI: new EcoreWlRenderSurface, created display xx, used existing surface xx
72 // we can not use LOG_INFO because the surface can be created before Dali Core is created.
73 printf( "INFO: DALI: new EcoreWlRenderSurface, %s %s surface %X \n",
74 mOwnSurface?"created":"used existing",
75 Dali::RenderSurface::PIXMAP==mType?" pixmap" :"window",
80 EcoreWlRenderSurface::~EcoreWlRenderSurface()
84 void EcoreWlRenderSurface::SetRenderNotification(TriggerEventInterface* renderNotification)
86 mRenderNotification = renderNotification;
89 Ecore_Wl_Window* EcoreWlRenderSurface::GetWlWindow()
94 Ecore_Wl_Window* EcoreWlRenderSurface::GetDrawable()
99 PositionSize EcoreWlRenderSurface::GetPositionSize() const
104 void EcoreWlRenderSurface::MoveResize( Dali::PositionSize positionSize )
106 // nothing to do in base class
109 void EcoreWlRenderSurface::SetViewMode( ViewMode viewMode )
113 unsigned int EcoreWlRenderSurface::GetSurfaceId( Any surface ) const
115 unsigned int surfaceId = 0;
117 if ( surface.Empty() == false )
119 // check we have a valid type
120 DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (Ecore_Wl_Window *) ) )
121 && "Surface type is invalid" );
123 surfaceId = AnyCast<unsigned int>( surface );