mPlatformAbstraction,
mGlAbstraction,
mGlSyncAbstraction,
+ mGlContextHelperAbstraction,
mDataRetentionPolicy,
Integration::RenderToFrameBuffer::FALSE,
Integration::DepthBufferAvailable::TRUE,
return mGlSyncAbstraction;
}
+TestGlContextHelperAbstraction& TestApplication::GetGlContextHelperAbstraction()
+{
+ return mGlContextHelperAbstraction;
+}
+
void TestApplication::ProcessEvent(const Integration::Event& event)
{
mCore->QueueEvent(event);
#include <test-platform-abstraction.h>
#include "test-gl-sync-abstraction.h"
#include "test-gl-abstraction.h"
+#include "test-gl-context-helper-abstraction.h"
#include "test-render-controller.h"
#include "test-render-surface.h"
#include <dali/public-api/common/dali-common.h>
TestRenderController& GetRenderController();
TestGlAbstraction& GetGlAbstraction();
TestGlSyncAbstraction& GetGlSyncAbstraction();
+ TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
void ProcessEvent(const Integration::Event& event);
void SendNotification();
bool Render( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL );
TestRenderController mRenderController;
TestGlAbstraction mGlAbstraction;
TestGlSyncAbstraction mGlSyncAbstraction;
+ TestGlContextHelperAbstraction mGlContextHelperAbstraction;
TestRenderSurface* mRenderSurface;
Integration::UpdateStatus mStatus;
--- /dev/null
+#ifndef TEST_GL_CONTEXT_HELPER_ABSTRACTION_H
+#define TEST_GL_CONTEXT_HELPER_ABSTRACTION_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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/gl-context-helper-abstraction.h>
+
+namespace Dali
+{
+
+/**
+ * Class to emulate the GL context helper
+ */
+class DALI_CORE_API TestGlContextHelperAbstraction: public Integration::GlContextHelperAbstraction
+{
+public:
+ /**
+ * Constructor
+ */
+ TestGlContextHelperAbstraction() {};
+
+ /**
+ * Destructor
+ */
+ ~TestGlContextHelperAbstraction() {};
+
+ /**
+ * @brief Switch to the surfaceless GL context
+ */
+ virtual void MakeSurfacelessContextCurrent() {};
+
+ /**
+ * @brief Switch to the GL context of the specific render surface
+ * @param[in] surface The render surface
+ */
+ virtual void MakeContextCurrent( Integration::RenderSurface* surface ) {};
+
+ /**
+ * @brief Clear the GL context
+ */
+ virtual void MakeContextNull() {};
+
+ /**
+ * @brief Wait until all GL rendering calls for the current GL context are executed
+ */
+ virtual void WaitClient() {};
+private:
+
+ TestGlContextHelperAbstraction( const TestGlContextHelperAbstraction& ); ///< Undefined
+ TestGlContextHelperAbstraction& operator=( const TestGlContextHelperAbstraction& ); ///< Undefined
+};
+
+} // Dali
+
+#endif // TEST_GL_CONTEXT_HELPER_ABSTRACTION_H
GlImplementation& mGLES = eglGraphics->GetGlesInterface();
EglSyncImplementation& eglSyncImpl = eglGraphics->GetSyncImplementation();
+ EglContextHelperImplementation& eglContextHelperImpl = eglGraphics->GetContextHelperImplementation();
mCore = Integration::Core::New( *this,
*mPlatformAbstraction,
mGLES,
eglSyncImpl,
+ eglContextHelperImpl,
dataRetentionPolicy ,
( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
mGraphics->GetDepthBufferRequired(),
${adaptor_graphics_dir}/gles/egl-debug.cpp \
${adaptor_graphics_dir}/gles/egl-implementation.cpp \
${adaptor_graphics_dir}/gles/egl-sync-implementation.cpp \
+ ${adaptor_graphics_dir}/gles/egl-context-helper-implementation.cpp \
${adaptor_graphics_dir}/gles/gl-extensions.cpp \
${adaptor_graphics_dir}/gles/gl-proxy-implementation.cpp \
${adaptor_graphics_dir}/gles/egl-graphics-factory.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/gles/egl-context-helper-implementation.h>
+
+// EXTERNAL INCLUDES
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-implementation.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+EglContextHelperImplementation::EglContextHelperImplementation()
+: mEglImplementation( NULL )
+{
+}
+
+void EglContextHelperImplementation::Initialize( EglImplementation* eglImpl )
+{
+ mEglImplementation = eglImpl;
+}
+
+void EglContextHelperImplementation::MakeSurfacelessContextCurrent()
+{
+ if ( mEglImplementation && mEglImplementation->IsSurfacelessContextSupported() )
+ {
+ mEglImplementation->MakeContextCurrent( EGL_NO_SURFACE, mEglImplementation->GetContext() );
+ }
+}
+
+void EglContextHelperImplementation::MakeContextCurrent( Integration::RenderSurface* surface )
+{
+ if ( mEglImplementation && surface )
+ {
+ surface->MakeContextCurrent();
+ }
+}
+
+void EglContextHelperImplementation::MakeContextNull()
+{
+ if ( mEglImplementation )
+ {
+ mEglImplementation->MakeContextNull();
+ }
+}
+
+void EglContextHelperImplementation::WaitClient()
+{
+ if ( mEglImplementation )
+ {
+ mEglImplementation->WaitClient();
+ }
+}
+
+} // namespace Dali
+} // namespace Internal
+} // namespace Adaptor
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_EGL_CONTEXT_HELPER_IMPLEMENTATION_H
+#define DALI_INTERNAL_ADAPTOR_EGL_CONTEXT_HELPER_IMPLEMENTATION_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 <EGL/egl.h>
+#include <dali/integration-api/gl-context-helper-abstraction.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+class RenderSurface;
+}
+
+namespace Internal
+{
+namespace Adaptor
+{
+
+class EglImplementation;
+
+/**
+ * EglContextHelperImplementation is a concrete implementation for GlContextHelperAbstraction.
+ * It provides helper functions to access EGL context APIs
+ */
+class EglContextHelperImplementation : public Integration::GlContextHelperAbstraction
+{
+public:
+ /**
+ * Constructor
+ */
+ EglContextHelperImplementation();
+
+ /**
+ * Destructor
+ */
+ virtual ~EglContextHelperImplementation() = default;
+
+ /**
+ * Initialize with the Egl implementation.
+ * @param[in] impl The EGL implementation (to access the EGL context)
+ */
+ void Initialize( EglImplementation* impl );
+
+ /**
+ * @copydoc Dali::Integration::GlContextHelperAbstraction::MakeSurfacelessContextCurrent()
+ */
+ virtual void MakeSurfacelessContextCurrent() override;
+
+ /**
+ * @copydoc Dali::Integration::GlContextHelperAbstraction::MakeContextCurrent()
+ */
+ virtual void MakeContextCurrent( Integration::RenderSurface* surface ) override;
+
+ /**
+ * @copydoc Dali::Integration::GlContextHelperAbstraction::MakeContextNull()
+ */
+ virtual void MakeContextNull() override;
+
+ /**
+ * @copydoc Dali::Integration::GlContextHelperAbstraction::WaitClient()
+ */
+ virtual void WaitClient() override;
+
+private:
+
+ EglImplementation* mEglImplementation; ///< Egl implementation (to access the EGL context)
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_EGL_CONTEXT_HELPER_IMPLEMENTATION_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * 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.
mMultiSamplingLevel = environmentOptions->GetMultiSamplingLevel();
mEglSync = Utils::MakeUnique< EglSyncImplementation >();
+
+ mEglContextHelper = Utils::MakeUnique< EglContextHelperImplementation >();
}
EglInterface* EglGraphics::Create()
mEglSync->Initialize( mEglImplementation.get() ); // The sync impl needs the EglDisplay
+ mEglContextHelper->Initialize( mEglImplementation.get() ); // The context helper impl needs the EglContext
+
return mEglImplementation.get();
}
return *mEglSync;
}
+EglContextHelperImplementation& EglGraphics::GetContextHelperImplementation()
+{
+ DALI_ASSERT_DEBUG( mEglContextHelper && "EglContextHelperImplementation not created" );
+ return *mEglContextHelper;
+}
+
EglImageExtensions* EglGraphics::GetImageExtensions()
{
DALI_ASSERT_DEBUG( mEglImageExtensions && "EglImageExtensions not created" );
#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-sync-implementation.h>
-
+#include <dali/internal/graphics/gles/egl-context-helper-implementation.h>
namespace Dali
{
EglSyncImplementation& GetSyncImplementation();
/**
+ * Gets the implementation of GlContextHelperAbstraction for EGL.
+ * @return The implementation of GlContextHelperAbstraction for EGL.
+ */
+ EglContextHelperImplementation& GetContextHelperImplementation();
+
+ /**
* @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetDepthBufferRequired()
*/
Integration::DepthBufferAvailable& GetDepthBufferRequired();
std::unique_ptr< EglImplementation > mEglImplementation; ///< EGL implementation
std::unique_ptr< EglImageExtensions > mEglImageExtensions; ///< EGL image extension
std::unique_ptr< EglSyncImplementation > mEglSync; ///< GlSyncAbstraction implementation for EGL
+ std::unique_ptr< EglContextHelperImplementation > mEglContextHelper; ///< GlContextHelperAbstraction implementation for EGL
int mMultiSamplingLevel; ///< The multiple sampling level
};
if(mIsOwnSurface)
{
- if( mCurrentEglContext != EGL_NO_CONTEXT )
- {
- glFinish();
- }
-
eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, eglContext );
mCurrentEglContext = eglContext;
if(mIsOwnSurface)
{
- if( mCurrentEglContext != EGL_NO_CONTEXT )
- {
- glFinish();
- }
-
eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, mEglContext );
mCurrentEglContext = mEglContext;
return mIsSurfacelessContextSupported;
}
+void EglImplementation::WaitClient()
+{
+ // Wait for EGL to finish executing all rendering calls for the current context
+ if ( eglWaitClient() != EGL_TRUE )
+ {
+ TEST_EGL_ERROR("eglWaitClient");
+ }
+}
+
} // namespace Adaptor
} // namespace Internal
*/
bool IsSurfacelessContextSupported() const;
+ /**
+ * @brief Wait until all rendering calls for the currently context are executed
+ */
+ void WaitClient();
+
private:
Vector<EGLint> mContextAttribs;
{
mRenderNotification->Trigger();
}
-
- if ( eglImpl.IsSurfacelessContextSupported() )
- {
- // Switch to the shared context after rendering this surface
- eglImpl.MakeContextCurrent( EGL_NO_SURFACE, eglImpl.GetContext() );
- }
}
}