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 "pixmap-render-surface.h"
22 #include <dali/integration-api/gl-abstraction.h>
23 #include <dali/integration-api/debug.h>
27 #include <trigger-event.h>
28 #include <gl/egl-implementation.h>
29 #include <base/display-connection.h>
34 #if defined(DEBUG_ENABLED)
35 extern Debug::Filter* gRenderSurfaceLogFilter;
41 PixmapRenderSurface::PixmapRenderSurface(Dali::PositionSize positionSize,
43 const std::string& name,
45 : EcoreWlRenderSurface( positionSize, surface, name, isTransparent )
50 PixmapRenderSurface::~PixmapRenderSurface()
52 // release the surface if we own one
55 // if we did create the pixmap, delete the pixmap
56 DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", mX11Pixmap );
60 Ecore_Wl_Window* PixmapRenderSurface::GetDrawable()
65 Any PixmapRenderSurface::GetSurface()
70 void PixmapRenderSurface::InitializeEgl( EglInterface& egl )
72 DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
74 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
76 eglImpl.ChooseConfig(false, mColorDepth);
79 void PixmapRenderSurface::CreateEglSurface( EglInterface& egl )
81 DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
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
88 void PixmapRenderSurface::DestroyEglSurface( EglInterface& egl )
90 DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
92 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
93 eglImpl.DestroySurface();
96 bool PixmapRenderSurface::ReplaceEGLSurface( EglInterface& egl )
98 DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
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
106 void PixmapRenderSurface::StartRender()
111 bool PixmapRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
113 // nothing to do for pixmaps
117 void PixmapRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface )
119 // flush gl instruction queue
120 glAbstraction.Flush();
122 // create damage for client applications which wish to know the update timing
123 if( mRenderNotification )
125 // use notification trigger
126 // Tell the event-thread to render the pixmap
127 mRenderNotification->Trigger();
134 // Do render synchronisation
135 // AcquireLock( replacingSurface ? SYNC_MODE_NONE : SYNC_MODE_WAIT );
138 void PixmapRenderSurface::StopRender()
143 void PixmapRenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
148 void PixmapRenderSurface::CreateWlRenderable()
150 // check we're creating one with a valid size
151 DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "Pixmap size is invalid" );
156 void PixmapRenderSurface::UseExistingRenderable( unsigned int surfaceId )
161 void PixmapRenderSurface::SetSyncMode( SyncMode syncMode )
166 void PixmapRenderSurface::AcquireLock()
171 void PixmapRenderSurface::ReleaseLock()