/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/integration-api/debug.h>
#include <dali/internal/system/common/configuration-manager.h>
#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/window-system/common/display-utils.h> // For Utils::MakeUnique
{
}
-void EglGraphics::SetGlesVersion(const int32_t glesVersion)
-{
- if(mEglImplementation)
- {
- mEglImplementation->SetGlesVersion(glesVersion);
- }
-
- mGLES->SetGlesVersion(glesVersion);
-}
-
void EglGraphics::SetIsSurfacelessContextSupported(const bool isSupported)
{
mGLES->SetIsSurfacelessContextSupported(isSupported);
// Make the shared surfaceless context as current before rendering
mEglImplementation->MakeContextCurrent(EGL_NO_SURFACE, mEglImplementation->GetContext());
}
+
+ mGraphicsController.ActivateResourceContext();
+}
+
+void EglGraphics::ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface)
+{
+ if(surface)
+ {
+ surface->InitializeGraphics();
+ surface->MakeContextCurrent();
+ }
+
+ mGraphicsController.ActivateSurfaceContext(surface);
+}
+
+void EglGraphics::PostRender()
+{
+ ActivateResourceContext();
+
+ if(mGraphicsController.GetCurrentContext())
+ {
+ mGraphicsController.GetCurrentContext()->InvalidateDepthStencilBuffers();
+ }
+
+ mGraphicsController.PostRender();
}
void EglGraphics::SetFirstFrameAfterResume()
EglInitialize();
// Sync and context helper require EGL to be initialized first (can't execute in the constructor)
- mGraphicsController.Initialize(*mEglSync.get(), *mEglContextHelper.get());
+ mGraphicsController.Initialize(*mEglSync.get(), *this);
}
void EglGraphics::Initialize(bool depth, bool stencil, bool partialRendering, int msaa)
void EglGraphics::EglInitialize()
{
mEglSync = Utils::MakeUnique<EglSyncImplementation>();
- mEglContextHelper = Utils::MakeUnique<EglContextHelperImplementation>();
mEglImplementation = Utils::MakeUnique<EglImplementation>(mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired, mPartialUpdateRequired);
mEglImageExtensions = Utils::MakeUnique<EglImageExtensions>(mEglImplementation.get());
- mEglSync->Initialize(mEglImplementation.get()); // The sync impl needs the EglDisplay
- mEglContextHelper->Initialize(mEglImplementation.get()); // The context helper impl needs the EglContext
+ mEglSync->Initialize(mEglImplementation.get()); // The sync impl needs the EglDisplay
}
void EglGraphics::ConfigureSurface(Dali::RenderSurfaceInterface* surface)
if(!mEglImplementation->ChooseConfig(true, COLOR_DEPTH_32))
{
// Retry to use OpenGL es 2.0
- SetGlesVersion(20);
+ mEglImplementation->SetGlesVersion(20);
+
+ // Mark gles that we will use gles 2.0 version.
+ // After this call, we will not change mGLES version anymore.
+ mGLES->SetGlesVersion(20);
+
mEglImplementation->ChooseConfig(true, COLOR_DEPTH_32);
}
{
// Create a surfaceless OpenGL context for shared resources
mEglImplementation->CreateContext();
- mEglImplementation->MakeContextCurrent(EGL_NO_SURFACE, mEglImplementation->GetContext());
+ ActivateResourceContext();
}
else
{
currentSurface = surface;
if(currentSurface)
{
- currentSurface->InitializeGraphics();
- currentSurface->MakeContextCurrent();
+ ActivateSurfaceContext(currentSurface);
}
}
- mGLES->ContextCreated();
- SetGlesVersion(mGLES->GetGlesVersion());
+ mGLES->ContextCreated(); // After this call, we can know exact gles version.
+ auto glesVersion = mGLES->GetGlesVersion();
+
+ // Set more detail GLES version to egl and graphics controller.
+ // Note. usually we don't need EGL client's minor version. So don't need to choose config one more time.
+ mEglImplementation->SetGlesVersion(glesVersion);
+ mGraphicsController.SetGLESVersion(static_cast<Graphics::GLES::GLESVersion>(glesVersion));
}
void EglGraphics::Shutdown()
{
if(mEglImplementation)
{
+ // Shutdown controller
+ mGraphicsController.Shutdown();
+
+ // Terminate GLES
mEglImplementation->TerminateGles();
}
}
void EglGraphics::Destroy()
{
+ mGraphicsController.Destroy();
}
GlImplementation& EglGraphics::GetGlesInterface()
return *mEglSync;
}
-EglContextHelperImplementation& EglGraphics::GetContextHelperImplementation()
-{
- DALI_ASSERT_DEBUG(mEglContextHelper && "EglContextHelperImplementation not created");
- return *mEglContextHelper;
-}
-
EglImageExtensions* EglGraphics::GetImageExtensions()
{
DALI_ASSERT_DEBUG(mEglImageExtensions && "EglImageExtensions not created");
void EglGraphics::CacheConfigurations(ConfigurationManager& configurationManager)
{
mGLES->SetIsAdvancedBlendEquationSupported(configurationManager.IsAdvancedBlendEquationSupported());
+ mGLES->SetIsMultisampledRenderToTextureSupported(configurationManager.IsMultisampledRenderToTextureSupported());
mGLES->SetShadingLanguageVersion(configurationManager.GetShadingLanguageVersion());
}
+void EglGraphics::FrameStart()
+{
+ mGraphicsController.FrameStart();
+}
+
+void EglGraphics::LogMemoryPools()
+{
+ std::size_t graphicsCapacity = mGraphicsController.GetCapacity();
+ DALI_LOG_RELEASE_INFO(
+ "EglGraphics:\n"
+ " GraphicsController Capacity: %lu\n",
+ graphicsCapacity);
+}
+
} // namespace Adaptor
} // namespace Internal
} // namespace Dali