DALI_TEST_EQUALS( argc, 1, TEST_LOCATION );
// Check values
- DALI_TEST_EQUALS( options.noVSyncOnRender, 0, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageWidth, 0, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageHeight, 0, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageDPI, "", TEST_LOCATION );
DALI_TEST_EQUALS( argc, 1, TEST_LOCATION );
// Check values
- DALI_TEST_EQUALS( options.noVSyncOnRender, 0, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageWidth, 800, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageHeight, 1000, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageDPI, "4x5", TEST_LOCATION );
"--width=800",
"--height=1000",
"--dpi=3x4",
- "--no-vsync",
"--help"
};
int argc( sizeof( argList ) / sizeof( argList[0] ) );
DALI_TEST_EQUALS( argc, 1, TEST_LOCATION );
// Check values
- DALI_TEST_EQUALS( options.noVSyncOnRender, 1, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageWidth, 800, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageHeight, 1000, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageDPI, "3x4", TEST_LOCATION );
"--width", "800",
"--height", "1000",
"--dpi", "3x4",
- "--no-vsync",
"--help"
};
int argc( sizeof( argList ) / sizeof( argList[0] ) );
DALI_TEST_EQUALS( argc, 1, TEST_LOCATION );
// Check values
- DALI_TEST_EQUALS( options.noVSyncOnRender, 1, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageWidth, 800, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageHeight, 1000, TEST_LOCATION );
DALI_TEST_EQUALS( options.stageDPI, "3x4", TEST_LOCATION );
*/
void SetPreRenderCallback( CallbackBase* callback );
- /**
- * @brief Set whether the frame count per render is managed using the hardware VSync or
- * manually timed.
- *
- * @param[in] useHardware True if the hardware VSync should be used
- */
- void SetUseHardwareVSync(bool useHardware);
-
/**
* @brief Returns a reference to the instance of the adaptor used by the current thread.
*
#include <dali/internal/graphics/gles/egl-sync-implementation.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/clipboard/common/clipboard-impl.h>
-#include <dali/internal/graphics/common/vsync-monitor.h>
#include <dali/internal/system/common/object-profiler.h>
#include <dali/internal/window-system/common/display-connection.h>
#include <dali/internal/window-system/common/window-impl.h>
mNotificationTrigger = mTriggerEventFactory.CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
- mVSyncMonitor = new VSyncMonitor;
-
mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow->GetSurface()->GetSurfaceType() );
mThreadController = new ThreadController( *this, *mEnvironmentOptions );
mWindows.clear();
delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
- delete mVSyncMonitor;
delete mObjectProfiler;
delete mCore;
mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender );
}
-void Adaptor::SetUseHardwareVSync( bool useHardware )
-{
- mVSyncMonitor->SetUseHardwareVSync( useHardware );
-}
-
Dali::DisplayConnection& Adaptor::GetDisplayConnectionInterface()
{
DALI_ASSERT_DEBUG( mDisplayConnection && "Display connection not created" );
return nullptr;
}
-VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
-{
- return mVSyncMonitor;
-}
-
TraceInterface& Adaptor::GetKernelTraceInterface()
{
return mKernelTracer;
mState( READY ),
mCore( nullptr ),
mThreadController( nullptr ),
- mVSyncMonitor( nullptr ),
mGraphics( nullptr ),
mDisplayConnection( nullptr ),
mWindows(),
*/
void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender );
- /**
- * @copydoc Dali::Adaptor::SetUseHardwareVSync()
- */
- void SetUseHardwareVSync(bool useHardware);
-
/**
* Return the PlatformAbstraction.
* @return The PlatformAbstraction.
*/
virtual Dali::RenderSurfaceInterface* GetRenderSurfaceInterface();
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetVSyncMonitorInterface()
- */
- virtual VSyncMonitorInterface* GetVSyncMonitorInterface();
-
/**
* @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPerformanceInterface()
*/
State mState; ///< Current state of the adaptor
Dali::Integration::Core* mCore; ///< Dali Core
ThreadController* mThreadController; ///< Controls the threads
- VSyncMonitor* mVSyncMonitor; ///< Monitors VSync events
GraphicsInterface* mGraphics; ///< Graphics interface
Dali::DisplayConnection* mDisplayConnection; ///< Display connection
#include <dali/internal/graphics/gles/egl-factory-interface.h>
#include <dali/internal/network/common/socket-factory-interface.h>
#include <dali/internal/system/common/performance-interface.h>
-#include <dali/internal/graphics/common/vsync-monitor-interface.h>
#include <dali/internal/network/common/trace-interface.h>
#include <dali/integration-api/render-surface.h>
*/
virtual Dali::RenderSurfaceInterface* GetRenderSurfaceInterface() = 0;
- /**
- * @return vsync monitor interface
- */
- virtual VSyncMonitorInterface* GetVSyncMonitorInterface() = 0;
-
/**
* @return performance interface
*/
mImpl->SetPreRenderCallback( callback );
}
-void Adaptor::SetUseHardwareVSync(bool useHardware)
-{
- mImpl->SetUseHardwareVSync( useHardware );
-}
-
Adaptor& Adaptor::Get()
{
return Internal::Adaptor::Adaptor::Get();
// Run the adaptor
mAdaptor->Start();
- // Check if user requires no vsyncing and set Adaptor
- if (mCommandLineOptions->noVSyncOnRender)
- {
- mAdaptor->SetUseHardwareVSync(false);
- }
-
if( ! mStylesheet.empty() )
{
Dali::StyleMonitor::Get().SetTheme( mStylesheet );
+++ /dev/null
-#ifndef DALI_INTERNAL_BASE_VSYNC_MONITOR_INTERFACE_H
-#define DALI_INTERNAL_BASE_VSYNC_MONITOR_INTERFACE_H
-
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Interface for monitoring VSync
- * Implementations must provide a DoSync method
- */
-class VSyncMonitorInterface
-{
-public:
-
- /**
- * Initialize the vsync monitor.
- */
- virtual void Initialize() = 0;
-
- /**
- * Terminate the vsync monitor
- */
- virtual void Terminate() = 0;
-
- /**
- * Checks if hardware sync is available and enabled
- * @return true if hardware sync is available and enabled
- */
- virtual bool UseHardware() = 0;
-
- /**
- * Wait for vertical blank sync.
- * @param[out] frameNumber The current sequence number for this vsync (increments by one for each vsync)
- * @param[out] seconds The timestamp (seconds) when the vsync occured
- * @param[out] microseconds The timestamp (microseconds) when the vsync occured
- * @return true if a valid sync was detected, false on error
- */
- virtual bool DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds ) = 0;
-
-protected:
-
- /**
- * Virtual protected destructor - no deletion through this interface
- */
- virtual ~VSyncMonitorInterface() {}
-
-}; // class VSyncMonitorInterface
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_BASE_VSYNC_MONITOR_INTERFACE_H
+++ /dev/null
-#ifndef DALI_INTERNAL_VSYNC_MONITOR_IMPL_H
-#define DALI_INTERNAL_VSYNC_MONITOR_IMPL_H
-
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <xf86drm.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/graphics/common/vsync-monitor-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Tizen interface for monitoring VSync
- */
-class VSyncMonitor : public VSyncMonitorInterface
-{
-public:
- /**
- * Default constructor
- */
- VSyncMonitor();
-
- /**
- * Destructor
- */
- virtual ~VSyncMonitor();
-
-public:
-
- /**
- * Set the use hardware flag
- * @param[in] useHardware The new state for the use hardware flag.
- */
- void SetUseHardwareVSync( bool useHardware );
-
- /**
- * Set whether the vsync hardware is available.
- * (This is public to allow callback method to work...)
- */
- void SetHardwareVSyncAvailable(bool available);
-
-private: // From Dali::Internal::Adaptor::VSyncMonitorInterface
-
- /**
- * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::Initialize
- */
- virtual void Initialize();
-
- /**
- * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::Terminate
- */
- virtual void Terminate();
-
- /**
- * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::UseHardware
- */
- virtual bool UseHardware();
-
- /**
- * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::DoSync
- */
- virtual bool DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds );
-
-private:
-
- int mFileDescriptor; ///< DRM dev node file descriptor
- drmVBlank mVBlankInfo;
- // NOTE cannot use booleans as these are used from multiple threads, must use variable with machine word size for atomic read/write
- unsigned int mUseHardwareVSync; ///< Whether to use hardware vsync
- unsigned int mHardwareVSyncAvailable; ///< Whether hardware vsync is available
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_VSYNC_MONITOR_IMPL_H
# module: graphics, backend: tizen
adaptor_graphics_tizen_src_files=\
- ${adaptor_graphics_dir}/tizen/egl-image-extensions-tizen.cpp \
- ${adaptor_graphics_dir}/tizen/vsync-monitor-tizen.cpp
+ ${adaptor_graphics_dir}/tizen/egl-image-extensions-tizen.cpp
-# module: graphics, backend: ubuntu
+# module: graphics, backend: generic
adaptor_graphics_ubuntu_src_files=\
- ${adaptor_graphics_dir}/ubuntu/egl-image-extensions-ubuntu.cpp \
- ${adaptor_graphics_dir}/ubuntu/vsync-monitor-ubuntu.cpp
+ ${adaptor_graphics_dir}/generic/egl-image-extensions-generic.cpp
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include <dali/internal/graphics/common/egl-image-extensions.h>
+
+// EXTERNAL INCLUDES
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <GLES3/gl3.h>
+
+#include <EGL/eglext.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-implementation.h>
+
+
+namespace
+{
+// function pointers assigned in InitializeEglImageKHR
+PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0;
+PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0;
+PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOESProc = 0;
+} // unnamed namespace
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
+: mEglImplementation(eglImpl),
+ mImageKHRInitialized(false),
+ mImageKHRInitializeFailed(false)
+{
+ DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
+}
+
+EglImageExtensions::~EglImageExtensions()
+{
+}
+
+void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
+{
+ if (mImageKHRInitialized == false)
+ {
+ InitializeEglImageKHR();
+ }
+
+ if (mImageKHRInitialized == false)
+ {
+ return NULL;
+ }
+
+ // Use the EGL image extension
+ const EGLint attribs[] =
+ {
+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
+ EGL_NONE
+ };
+
+ EGLImageKHR eglImage = eglCreateImageKHRProc( mEglImplementation->GetDisplay(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ clientBuffer,
+ attribs );
+
+ DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "X11Image::GlExtensionCreate eglCreateImageKHR failed!\n");
+ if( EGL_NO_IMAGE_KHR == eglImage )
+ {
+ switch( eglGetError() )
+ {
+ case EGL_SUCCESS :
+ {
+ break;
+ }
+ case EGL_BAD_DISPLAY:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
+ break;
+ }
+ case EGL_BAD_CONTEXT:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_CONTEXT: Invalid EGLContext object\n" );
+ break;
+ }
+ case EGL_BAD_PARAMETER:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n" );
+ break;
+ }
+ case EGL_BAD_MATCH:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_MATCH: attrib_list does not match target\n" );
+ break;
+ }
+ case EGL_BAD_ACCESS:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n" );
+ break;
+ }
+ case EGL_BAD_ALLOC:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available\n" );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+
+ return eglImage;
+}
+
+void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
+{
+ DALI_ASSERT_DEBUG( mImageKHRInitialized );
+
+ if( ! mImageKHRInitialized )
+ {
+ return;
+ }
+
+ if( eglImageKHR == NULL )
+ {
+ return;
+ }
+
+ EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
+
+ EGLBoolean result = eglDestroyImageKHRProc(mEglImplementation->GetDisplay(), eglImage);
+
+ if( EGL_FALSE == result )
+ {
+ switch( eglGetError() )
+ {
+ case EGL_BAD_DISPLAY:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
+ break;
+ }
+ case EGL_BAD_PARAMETER:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n" );
+ break;
+ }
+ case EGL_BAD_ACCESS:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_ACCESS: EGLImage sibling error\n" );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+}
+
+void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
+{
+ DALI_ASSERT_DEBUG( mImageKHRInitialized );
+
+ if( eglImageKHR != NULL )
+ {
+ EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
+
+#ifdef EGL_ERROR_CHECKING
+ GLint glError = glGetError();
+#endif
+
+ glEGLImageTargetTexture2DOESProc(GL_TEXTURE_2D, reinterpret_cast< GLeglImageOES >( eglImage ) );
+
+#ifdef EGL_ERROR_CHECKING
+ glError = glGetError();
+ if( GL_NO_ERROR != glError )
+ {
+ DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError );
+ }
+#endif
+ }
+}
+
+void EglImageExtensions::InitializeEglImageKHR()
+{
+ // avoid trying to reload extended KHR functions, if it fails the first time
+ if( ! mImageKHRInitializeFailed )
+ {
+ eglCreateImageKHRProc = reinterpret_cast< PFNEGLCREATEIMAGEKHRPROC >( eglGetProcAddress("eglCreateImageKHR") );
+ eglDestroyImageKHRProc = reinterpret_cast< PFNEGLDESTROYIMAGEKHRPROC >( eglGetProcAddress("eglDestroyImageKHR") );
+ glEGLImageTargetTexture2DOESProc = reinterpret_cast< PFNGLEGLIMAGETARGETTEXTURE2DOESPROC >( eglGetProcAddress("glEGLImageTargetTexture2DOES") );
+ }
+
+ if (eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc)
+ {
+ mImageKHRInitialized = true;
+ }
+ else
+ {
+ mImageKHRInitializeFailed = true;
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/graphics/common/vsync-monitor.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-// constants to keep code readability with unsigned int has to be used as boolean (due to multithreading)
-const unsigned int TRUE = 1u;
-const unsigned int FALSE = 0u;
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VSYNC_MONITOR");
-#endif
-
-const char * const DRM_DEVICE( "/dev/dri/card0" );
-const int FD_NONE( -1 );
-
-void ScreenStatusChanged(keynode_t* node, void* data)
-{
- VSyncMonitor* vsyncMonitor( static_cast< VSyncMonitor* >( data ) );
-
- int status = 0;
- vconf_get_int( VCONFKEY_PM_STATE, &status );
-
- // status values
- // - VCONFKEY_PM_STATE_NORMAL : turn vsync on
- // - VCONFKEY_PM_STATE_LCDDIM : turn vsync off
- // - VCONFKEY_PM_STATE_LCDOFF : turn vsync off
- // - VCONFKEY_PM_STATE_SLEEP : turn vsync off
- const unsigned int screenOn( VCONFKEY_PM_STATE_NORMAL == status );
-
- vsyncMonitor->SetHardwareVSyncAvailable( screenOn );
-
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "%s, Screen %s.\n", __PRETTY_FUNCTION__, screenOn ? "On" : "Off" );
-}
-
-} // unnamed namespace
-
-VSyncMonitor::VSyncMonitor()
-: mFileDescriptor( FD_NONE ),
- mUseHardwareVSync( TRUE ),
- mHardwareVSyncAvailable( FALSE )
-{
- vconf_notify_key_changed( VCONFKEY_PM_STATE, ScreenStatusChanged, this );
-}
-
-VSyncMonitor::~VSyncMonitor()
-{
- Terminate();
-
- vconf_ignore_key_changed( VCONFKEY_PM_STATE, ScreenStatusChanged );
-}
-
-void VSyncMonitor::SetUseHardwareVSync( bool useHardware )
-{
- mUseHardwareVSync = useHardware;
-}
-
-void VSyncMonitor::SetHardwareVSyncAvailable( bool hardwareVSyncAvailable )
-{
- mHardwareVSyncAvailable = hardwareVSyncAvailable;
-}
-
-void VSyncMonitor::Initialize()
-{
- DALI_ASSERT_DEBUG( mFileDescriptor == FD_NONE && "VSyncMonitor::Initialize() called twice" );
-
- // Read initial 'use hardware' status
- ScreenStatusChanged( NULL, this );
-
- // open /dev node
- mFileDescriptor = open( DRM_DEVICE, O_RDWR );
-
- // setup vblank request - block and wait for next vblank
- mVBlankInfo.request.type = DRM_VBLANK_NEXTONMISS;
- mVBlankInfo.request.sequence = 0;
- mVBlankInfo.request.signal = 0;
-
- // setup vblank reply - block and wait for next vblank
- mVBlankInfo.reply.type = DRM_VBLANK_NEXTONMISS;
- mVBlankInfo.reply.sequence = 0;
- mVBlankInfo.reply.tval_sec = 0;
- mVBlankInfo.reply.tval_usec = 0;
-}
-
-void VSyncMonitor::Terminate()
-{
- if( mFileDescriptor != FD_NONE )
- {
- close( mFileDescriptor );
- mFileDescriptor = FD_NONE;
- }
-}
-
-bool VSyncMonitor::UseHardware()
-{
- return mUseHardwareVSync && mHardwareVSyncAvailable && (FD_NONE != mFileDescriptor );
-}
-
-bool VSyncMonitor::DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds )
-{
- DALI_ASSERT_DEBUG( mFileDescriptor != FD_NONE && "ECoreX::VSyncMonitor is not initialized" );
-
- if( 0 == drmWaitVBlank( mFileDescriptor, &mVBlankInfo ) )
- {
- frameNumber = mVBlankInfo.reply.sequence;
- seconds = mVBlankInfo.reply.tval_sec;
- microseconds = mVBlankInfo.reply.tval_usec;
-
- return true;
- }
-
- return false;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-// CLASS HEADER
-#include <dali/internal/graphics/common/egl-image-extensions.h>
-
-// EXTERNAL INCLUDES
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <GLES3/gl3.h>
-
-#include <EGL/eglext.h>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/graphics/gles/egl-implementation.h>
-
-
-namespace
-{
-// function pointers assigned in InitializeEglImageKHR
-PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0;
-PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0;
-PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOESProc = 0;
-} // unnamed namespace
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
-: mEglImplementation(eglImpl),
- mImageKHRInitialized(false),
- mImageKHRInitializeFailed(false)
-{
- DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
-}
-
-EglImageExtensions::~EglImageExtensions()
-{
-}
-
-void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
-{
- if (mImageKHRInitialized == false)
- {
- InitializeEglImageKHR();
- }
-
- if (mImageKHRInitialized == false)
- {
- return NULL;
- }
-
- // Use the EGL image extension
- const EGLint attribs[] =
- {
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE
- };
-
-// EGL constants use C casts
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wold-style-cast"
- EGLImageKHR eglImage = eglCreateImageKHRProc( mEglImplementation->GetDisplay(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- clientBuffer,
- attribs );
-
- DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "X11Image::GlExtensionCreate eglCreateImageKHR failed!\n");
- if( EGL_NO_IMAGE_KHR == eglImage )
- {
- switch( eglGetError() )
- {
- case EGL_SUCCESS :
- {
- break;
- }
- case EGL_BAD_DISPLAY:
- {
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
- break;
- }
- case EGL_BAD_CONTEXT:
- {
- DALI_LOG_ERROR( "EGL_BAD_CONTEXT: Invalid EGLContext object\n" );
- break;
- }
- case EGL_BAD_PARAMETER:
- {
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n" );
- break;
- }
- case EGL_BAD_MATCH:
- {
- DALI_LOG_ERROR( "EGL_BAD_MATCH: attrib_list does not match target\n" );
- break;
- }
- case EGL_BAD_ACCESS:
- {
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n" );
- break;
- }
- case EGL_BAD_ALLOC:
- {
- DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available\n" );
- break;
- }
- default:
- {
- break;
- }
- }
- }
-#pragma GCC diagnostic pop
-
- return eglImage;
-}
-
-void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
-{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
-
- if( ! mImageKHRInitialized )
- {
- return;
- }
-
- if( eglImageKHR == NULL )
- {
- return;
- }
-
- EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
-
- EGLBoolean result = eglDestroyImageKHRProc(mEglImplementation->GetDisplay(), eglImage);
-
- if( EGL_FALSE == result )
- {
- switch( eglGetError() )
- {
- case EGL_BAD_DISPLAY:
- {
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
- break;
- }
- case EGL_BAD_PARAMETER:
- {
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n" );
- break;
- }
- case EGL_BAD_ACCESS:
- {
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: EGLImage sibling error\n" );
- break;
- }
- default:
- {
- break;
- }
- }
- }
-}
-
-void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
-{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
-
- if( eglImageKHR != NULL )
- {
- EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
-
-#ifdef EGL_ERROR_CHECKING
- GLint glError = glGetError();
-#endif
-
- glEGLImageTargetTexture2DOESProc(GL_TEXTURE_2D, reinterpret_cast< GLeglImageOES >( eglImage ) );
-
-#ifdef EGL_ERROR_CHECKING
- glError = glGetError();
- if( GL_NO_ERROR != glError )
- {
- DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError );
- }
-#endif
- }
-}
-
-void EglImageExtensions::InitializeEglImageKHR()
-{
- // avoid trying to reload extended KHR functions, if it fails the first time
- if( ! mImageKHRInitializeFailed )
- {
- eglCreateImageKHRProc = reinterpret_cast< PFNEGLCREATEIMAGEKHRPROC >( eglGetProcAddress("eglCreateImageKHR") );
- eglDestroyImageKHRProc = reinterpret_cast< PFNEGLDESTROYIMAGEKHRPROC >( eglGetProcAddress("eglDestroyImageKHR") );
- glEGLImageTargetTexture2DOESProc = reinterpret_cast< PFNGLEGLIMAGETARGETTEXTURE2DOESPROC >( eglGetProcAddress("glEGLImageTargetTexture2DOES") );
- }
-
- if (eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc)
- {
- mImageKHRInitialized = true;
- }
- else
- {
- mImageKHRInitializeFailed = true;
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/graphics/common/vsync-monitor.h>
-
-// EXTERNAL INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-// constants to keep code readability with unsigned int has to be used as boolean (due to multithreading)
-const unsigned int TRUE = 1u;
-const unsigned int FALSE = 0u;
-
-const int FD_NONE( -1 );
-
-} // unnamed namespace
-
-VSyncMonitor::VSyncMonitor()
-: mFileDescriptor( FD_NONE ),
- mUseHardwareVSync( FALSE ),
- mHardwareVSyncAvailable( FALSE )
-{
-}
-
-VSyncMonitor::~VSyncMonitor()
-{
- Terminate();
-}
-
-void VSyncMonitor::SetUseHardwareVSync( bool useHardware )
-{
- mUseHardwareVSync = useHardware;
-}
-
-void VSyncMonitor::SetHardwareVSyncAvailable( bool hardwareVSyncAvailable )
-{
- mHardwareVSyncAvailable = hardwareVSyncAvailable;
-}
-
-void VSyncMonitor::Initialize()
-{
- DALI_ASSERT_DEBUG( mFileDescriptor == FD_NONE && "VSyncMonitor::Initialize() called twice" );
-
- // setup vblank request - block and wait for next vblank
- mVBlankInfo.request.type = DRM_VBLANK_NEXTONMISS;
- mVBlankInfo.request.sequence = 0;
- mVBlankInfo.request.signal = 0;
-
- // setup vblank reply - block and wait for next vblank
- mVBlankInfo.reply.type = DRM_VBLANK_NEXTONMISS;
- mVBlankInfo.reply.sequence = 0;
- mVBlankInfo.reply.tval_sec = 0;
- mVBlankInfo.reply.tval_usec = 0;
-}
-
-void VSyncMonitor::Terminate()
-{
-}
-
-bool VSyncMonitor::UseHardware()
-{
- return mUseHardwareVSync && mHardwareVSyncAvailable && (FD_NONE != mFileDescriptor );
-}
-
-
-bool VSyncMonitor::DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds )
-{
- DALI_ASSERT_DEBUG( mFileDescriptor != FD_NONE && "ECoreX::VSyncMonitor is not initialized" );
-
- if( 0 == drmWaitVBlank( mFileDescriptor, &mVBlankInfo ) )
- {
- frameNumber = mVBlankInfo.reply.sequence;
- seconds = mVBlankInfo.reply.tval_sec;
- microseconds = mVBlankInfo.reply.tval_usec;
-
- return true;
- }
-
- return false;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/graphics/common/vsync-monitor.h>
-
-// EXTERNAL INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-// constants to keep code readability with unsigned int has to be used as boolean (due to multithreading)
-const unsigned int TRUE = 1u;
-const unsigned int FALSE = 0u;
-
-const int FD_NONE( -1 );
-
-} // unnamed namespace
-
-VSyncMonitor::VSyncMonitor()
-: mFileDescriptor( FD_NONE ),
- mUseHardwareVSync( FALSE ),
- mHardwareVSyncAvailable( FALSE )
-{
-}
-
-VSyncMonitor::~VSyncMonitor()
-{
- Terminate();
-}
-
-void VSyncMonitor::SetUseHardwareVSync( bool useHardware )
-{
- mUseHardwareVSync = useHardware;
-}
-
-void VSyncMonitor::SetHardwareVSyncAvailable( bool hardwareVSyncAvailable )
-{
- mHardwareVSyncAvailable = hardwareVSyncAvailable;
-}
-
-void VSyncMonitor::Initialize()
-{
- DALI_ASSERT_DEBUG( mFileDescriptor == FD_NONE && "VSyncMonitor::Initialize() called twice" );
-
- // setup vblank request - block and wait for next vblank
- mVBlankInfo.request.type = DRM_VBLANK_NEXTONMISS;
- mVBlankInfo.request.sequence = 0;
- mVBlankInfo.request.signal = 0;
-
- // setup vblank reply - block and wait for next vblank
- mVBlankInfo.reply.type = DRM_VBLANK_NEXTONMISS;
- mVBlankInfo.reply.sequence = 0;
- mVBlankInfo.reply.tval_sec = 0;
- mVBlankInfo.reply.tval_usec = 0;
-}
-
-void VSyncMonitor::Terminate()
-{
-}
-
-bool VSyncMonitor::UseHardware()
-{
- return mUseHardwareVSync && mHardwareVSyncAvailable && (FD_NONE != mFileDescriptor );
-}
-
-
-bool VSyncMonitor::DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds )
-{
- DALI_ASSERT_DEBUG( mFileDescriptor != FD_NONE && "Windows::VSyncMonitor is not initialized" );
- return false;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
Argument EXPECTED_ARGS[] =
{
- { "no-vsync", "Disable VSync on Render" },
{ "width", "Stage Width" },
{ "height", "Stage Height" },
{ "dpi", "Emulated DPI" },
enum Option
{
- OPTION_NO_VSYNC = 0,
- OPTION_STAGE_WIDTH,
+ OPTION_STAGE_WIDTH = 0,
OPTION_STAGE_HEIGHT,
OPTION_DPI,
OPTION_HELP
} // unnamed namespace
CommandLineOptions::CommandLineOptions(int32_t *argc, char **argv[])
-: noVSyncOnRender(0),
- stageWidth(0), stageHeight(0)
+: stageWidth(0),
+ stageHeight(0)
{
// Exit gracefully if no arguments provided
if ( !argc || !argv )
const struct option options[]=
{
- { EXPECTED_ARGS[OPTION_NO_VSYNC].opt, no_argument, &noVSyncOnRender, 1 }, // "--no-vsync"
{ EXPECTED_ARGS[OPTION_STAGE_WIDTH].opt, required_argument, NULL, 'w' }, // "--width"
{ EXPECTED_ARGS[OPTION_STAGE_HEIGHT].opt, required_argument, NULL, 'h' }, // "--height"
{ EXPECTED_ARGS[OPTION_DPI].opt, required_argument, NULL, 'd' }, // "--dpi"
* The following options are supported:
*
* @code
- * --no-vsync Disable VSync on Render
* -w|--width Stage Width
* -h|--height Stage Height
* -d|--dpi Emulated DPI
public: // Command line parsed values
- int32_t noVSyncOnRender; ///< If 1, then the user does not want VSync on Render
int32_t stageWidth; ///< The width of the stage required. 0 if not set.
int32_t stageHeight; ///< The height of the stage required. 0 if not set.
std::string stageDPI; ///< DPI stored as hxv, where h is horizontal DPI and v is vertical DPI
* This class accepts command line arguments as well. The following options are supported:
*
* @code
- * --no-vsync Disable VSync on Render
* -w|--width Stage Width
* -h|--height Stage Height
* -d|--dpi Emulated DPI