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>
26 #include <ecore-wl-types.h>
27 #include <trigger-event.h>
38 #if defined(DEBUG_ENABLED)
39 extern Debug::Filter* gRenderSurfaceLogFilter;
45 PixmapRenderSurface::PixmapRenderSurface( Dali::PositionSize positionSize,
48 const std::string& name,
50 : RenderSurface( Dali::RenderSurface::PIXMAP, positionSize, surface, display, name, isTransparent )
55 PixmapRenderSurface::~PixmapRenderSurface()
57 // release the surface if we own one
60 // if we did create the pixmap, delete the pixmap
61 DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", mX11Pixmap );
65 Dali::RenderSurface::SurfaceType PixmapRenderSurface::GetType()
67 return Dali::RenderSurface::PIXMAP;
70 Any PixmapRenderSurface::GetSurface()
75 void PixmapRenderSurface::InitializeEgl( EglInterface& eglIf )
77 DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
79 EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
80 eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
82 eglImpl.ChooseConfig(false, mColorDepth);
85 void PixmapRenderSurface::CreateEglSurface( EglInterface& eglIf )
87 DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
89 //EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
91 // create the EGL surface
92 // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
96 void PixmapRenderSurface::DestroyEglSurface( EglInterface& eglIf )
98 DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
100 EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
101 eglImpl.DestroySurface();
104 bool PixmapRenderSurface::ReplaceEGLSurface( EglInterface& eglIf )
106 DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
108 EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
109 eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
111 // a new surface for the new pixmap
112 // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
117 bool PixmapRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
119 // nothing to do for pixmaps
123 void PixmapRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode )
125 // flush gl instruction queue
126 glAbstraction.Flush();
128 // create damage for client applications which wish to know the update timing
129 if( mRenderNotification )
131 // use notification trigger
132 // Tell the event-thread to render the pixmap
133 mRenderNotification->Trigger();
137 // as a fallback, send damage event. This is needed until livebox is fixed to
138 // stop using damage events for render
142 // Do render synchronisation
143 DoRenderSync( timeDelta, syncMode );
146 void PixmapRenderSurface::CreateWlRenderable()
148 // check we're creating one with a valid size
149 DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "Pixmap size is invalid" );
154 void PixmapRenderSurface::UseExistingRenderable( unsigned int surfaceId )
158 void PixmapRenderSurface::RenderSync()
161 boost::unique_lock< boost::mutex > lock( mSyncMutex );
162 mSyncReceived = true;
165 // wake render thread if it was waiting for the notify
166 mSyncNotify.notify_all();
171 } // namespace Adaptor
173 } // namespace Internal