/build/tizen/.cov
/build/tizen/.ninja_deps
/build/tizen/.ninja_log
-/build/tizen/clion/
/build/tizen/build.ninja
/build/tizen/rules.ninja
/build/desktop
END_TEST;
}
-namespace
-{
/**
* @brief Build a square bitmap, downscale it and assert the resulting bitmap has the right dimensions.
*/
DALI_TEST_EQUALS(downScaled.GetPixelFormat(), format, location);
}
-/**
- * @brief Test that resizing RGBA8888 images as raw pixel arrays produces a result of the correct dimensions.
- */
-void TestDownscaleOutputsExpectedDimensionsRGBA8888(uint32_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
-{
- unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
- Dali::Internal::Platform::DownscaleInPlacePow2RGBA8888(
- reinterpret_cast<unsigned char*>(pixels),
- inputWidth,
- inputHeight,
- inputWidth,
- desiredWidth,
- desiredHeight,
- BoxDimensionTestBoth,
- resultingWidth,
- resultingHeight,
- resultingStride);
-
- DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
- DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
- DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
-}
-
-/**
- * @brief Test that resizing RGB565 images as raw pixel arrays produces a result of the correct dimensions.
- */
-void TestDownscaleOutputsExpectedDimensionsRGB565(uint16_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
-{
- unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
- Dali::Internal::Platform::DownscaleInPlacePow2RGB565(
- reinterpret_cast<unsigned char*>(pixels),
- inputWidth,
- inputHeight,
- inputWidth,
- desiredWidth,
- desiredHeight,
- BoxDimensionTestBoth,
- resultingWidth,
- resultingHeight,
- resultingStride);
-
- DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
- DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
- DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
-}
-
-/**
- * @brief Test that resizing 2-byte-per-pixel images as raw pixel arrays produces a result of the correct dimensions.
- */
-void TestDownscaleOutputsExpectedDimensions2ComponentPair(uint8_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
-{
- unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
- Dali::Internal::Platform::DownscaleInPlacePow2ComponentPair(
- pixels,
- inputWidth,
- inputHeight,
- inputWidth,
- desiredWidth,
- desiredHeight,
- BoxDimensionTestBoth,
- resultingWidth,
- resultingHeight,
- resultingStride);
-
- DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
- DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
- DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
-}
-
-/**
- * @brief Test that resizing single-byte-per-pixel images as raw pixel arrays produces a result of the correct dimensions.
- */
-void TestDownscaleOutputsExpectedDimensionsSingleComponent(uint8_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
-{
- unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
- Dali::Internal::Platform::DownscaleInPlacePow2SingleBytePerPixel(
- pixels,
- inputWidth,
- inputHeight,
- inputWidth,
- desiredWidth,
- desiredHeight,
- BoxDimensionTestBoth,
- resultingWidth,
- resultingHeight,
- resultingStride);
-
- DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
- DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
- DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
-}
-} // namespace
-
/**
* @brief Test the top-level function for reducing the dimension of a bitmap,
* feeding it each of the five pixel formats that are output by image loaders.
END_TEST;
}
+/**
+ * @brief Test that resizing RGBA8888 images as raw pixel arrays produces a result of the correct dimensions.
+ */
+void TestDownscaleOutputsExpectedDimensionsRGBA8888(uint32_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
+{
+ unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
+ Dali::Internal::Platform::DownscaleInPlacePow2RGBA8888(
+ reinterpret_cast<unsigned char*>(pixels),
+ inputWidth,
+ inputHeight,
+ inputWidth,
+ desiredWidth,
+ desiredHeight,
+ BoxDimensionTestBoth,
+ resultingWidth,
+ resultingHeight,
+ resultingStride);
+
+ DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
+ DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
+ DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
+}
+
+/**
+ * @brief Test that resizing RGB565 images as raw pixel arrays produces a result of the correct dimensions.
+ */
+void TestDownscaleOutputsExpectedDimensionsRGB565(uint16_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
+{
+ unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
+ Dali::Internal::Platform::DownscaleInPlacePow2RGB565(
+ reinterpret_cast<unsigned char*>(pixels),
+ inputWidth,
+ inputHeight,
+ inputWidth,
+ desiredWidth,
+ desiredHeight,
+ BoxDimensionTestBoth,
+ resultingWidth,
+ resultingHeight,
+ resultingStride);
+
+ DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
+ DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
+ DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
+}
+
+/**
+ * @brief Test that resizing 2-byte-per-pixel images as raw pixel arrays produces a result of the correct dimensions.
+ */
+void TestDownscaleOutputsExpectedDimensions2ComponentPair(uint8_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
+{
+ unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
+ Dali::Internal::Platform::DownscaleInPlacePow2ComponentPair(
+ pixels,
+ inputWidth,
+ inputHeight,
+ inputWidth,
+ desiredWidth,
+ desiredHeight,
+ BoxDimensionTestBoth,
+ resultingWidth,
+ resultingHeight,
+ resultingStride);
+
+ DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
+ DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
+ DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
+}
+
+/**
+ * @brief Test that resizing single-byte-per-pixel images as raw pixel arrays produces a result of the correct dimensions.
+ */
+void TestDownscaleOutputsExpectedDimensionsSingleComponent(uint8_t pixels[], unsigned inputWidth, unsigned inputHeight, unsigned int desiredWidth, unsigned int desiredHeight, unsigned int expectedWidth, unsigned int expectedHeight, const char* const location)
+{
+ unsigned int resultingWidth = -1, resultingHeight = -1, resultingStride = -1;
+ Dali::Internal::Platform::DownscaleInPlacePow2SingleBytePerPixel(
+ pixels,
+ inputWidth,
+ inputHeight,
+ inputWidth,
+ desiredWidth,
+ desiredHeight,
+ BoxDimensionTestBoth,
+ resultingWidth,
+ resultingHeight,
+ resultingStride);
+
+ DALI_TEST_EQUALS(resultingWidth, expectedWidth, location);
+ DALI_TEST_EQUALS(resultingHeight, expectedHeight, location);
+ DALI_TEST_EQUALS(resultingStride, expectedWidth, location);
+}
+
/**
* @brief Test downscaling of RGBA8888 images in raw image arrays.
*/
return texture;
}
-bool TestGraphicsController::HasClipMatrix() const
-{
- return true;
-}
-
-const Matrix& TestGraphicsController::GetClipMatrix() const
-{
- // This matrix transforms from GL -> Vulkan clip space
- constexpr float VULKAN_CLIP_MATRIX_DATA[] = {
- 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f};
- static const Matrix VULKAN_CLIP_MATRIX(VULKAN_CLIP_MATRIX_DATA);
- static const Matrix IDENTITY = Matrix::IDENTITY;
-
- // For now, return IDENTITY to stay in GL clip space.
- // @todo Add test toggle
- return IDENTITY;
-}
-
} // namespace Dali
*/
Graphics::UniquePtr<Graphics::Texture> ReleaseTextureFromResourceId(uint32_t resourceId) override;
- bool HasClipMatrix() const override;
- const Matrix& GetClipMatrix() const override;
-
public: // Test Functions
void SetAutoAttrCreation(bool v)
{
uint32_t elementStrideInBytes)
{
TestGraphicsReflection::TestUniformInfo info;
- info.name = std::move(name);
- info.type = type;
- info.uniformClass = Graphics::UniformClass::UNIFORM;
- info.numElements = elementCount;
- info.locations = {0};
- info.bufferIndex = 0; // this will update when AddCustomUniformBlock called
-
- auto retval = GetUniformBufferArrayStrideAndTypeSize(info, elementStrideInBytes);
+ info.name = std::move(name);
+ info.type = type;
+ info.uniformClass = Graphics::UniformClass::UNIFORM;
+ info.numElements = elementCount;
+ info.locations = {0};
+ info.bufferIndex = 0; // this will update when AddCustomUniformBlock called
+
+ auto retval= GetUniformBufferArrayStrideAndTypeSize(info, elementStrideInBytes);
info.elementStride = std::max(retval.first, retval.second);
info.offsets = {blockInfo.size};
blockInfo.size += (elementCount == 0 ? 1 : elementCount) * std::max(retval.first, retval.second);
} // namespace Dali
-#endif // TEST_GRAPHICS_CONTROLLER_H
+#endif //TEST_GRAPHICS_CONTROLLER_H
CHECK_MODULE_AND_SET( ELDBUS eldbus>=${ELDBUS_REQUIRED} eldbus_available )
CHECK_MODULE_AND_SET( TPKP_CURL tpkp-curl tpkp_curl_available )
CHECK_MODULE_AND_SET( UTILX utilX utilx_available )
+CHECK_MODULE_AND_SET( OPENGLES20 glesv2 [] )
+CHECK_MODULE_AND_SET( EGL egl [] )
CHECK_MODULE_AND_SET( DLOG dlog [] )
CHECK_MODULE_AND_SET( TTS tts [] )
CHECK_MODULE_AND_SET( VCONF vconf [] )
CHECK_MODULE_AND_SET( LIBUV libuv [] )
CHECK_MODULE_AND_SET( GLIB glib-2.0 [] )
+CHECK_MODULE_AND_SET( VULKAN vulkan [] )
+CHECK_MODULE_AND_SET( GLSLANG glslang [] )
+CHECK_MODULE_AND_SET( SPIRVTOOLS SPIRV-Tools [] )
CHECK_MODULE_AND_SET( X11 x11 [] )
CHECK_MODULE_AND_SET( XCB x11-xcb [] )
CHECK_MODULE_AND_SET( XDAMAGE xdamage [] )
CHECK_MODULE_AND_SET( THORVG thorvg thorvg_support )
-IF( ENABLE_VULKAN )
- CHECK_MODULE_AND_SET( VULKAN vulkan [] )
- CHECK_MODULE_AND_SET( GLSLANG glslang [] )
- CHECK_MODULE_AND_SET( SPIRVTOOLS SPIRV-Tools [] )
-ELSE()
- CHECK_MODULE_AND_SET( OPENGLES20 glesv2 [] )
- CHECK_MODULE_AND_SET( EGL egl [] )
-ENDIF()
-
IF( thorvg_support )
ADD_DEFINITIONS( -DTHORVG_SUPPORT )
ENDIF()
SET(DALI_LDFLAGS ${DALI_LDFLAGS} ${GLSLANG_LDFLAGS} -lSPIRV ${SPIRVTOOLS_LDFLAGS} -lglslang-default-resource-limits)
ENDIF()
- SET(DALI_CFLAGS ${DALI_CFLAGS} ${GLSLANG_CFLAGS} )
ENDIF()
IF(LIBUV_X11_PROFILE)
-DFONT_CONFIGURATION_FILE="${fontConfigurationFile}"
-DTIZEN_PLATFORM_CONFIG_SUPPORTED=${tizenPlatformConfigSupported}
)
-
-
-MESSAGE(STATUS "DALI_CFLAGS: ${DALI_CFLAGS}")
{
}
- ~AdaptorAccessible() override
- {
- if(mRoot)
- {
- if(auto bridge = Accessibility::Bridge::GetCurrentBridge())
- {
- bridge->RemoveTopLevelWindow(this);
- }
- }
- }
-
bool GrabFocus() override
{
return false;
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
}
}
+int Dali::AtspiAccessibility::SetForcefully(bool turnOn)
+{
+ if(turnOn)
+ {
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
+ {
+ bridge->Initialize();
+ auto ret = bridge->ForceUp();
+ return (int)ret;
+ }
+ }
+ else
+ {
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
+ {
+ bridge->ForceDown();
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int Dali::AtspiAccessibility::GetStatus()
+{
+ //0(ATSPI OFF, ScreenReader OFF), 1(ATSPI ON, ScreenReader OFF), 2 (ATSPI OFF, ScreenReader ON), 3(ATSPI ON, ScreenReader ON)
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
+ {
+ if(bridge->GetScreenReaderEnabled())
+ {
+ if(bridge->IsEnabled())
+ {
+ return 3;
+ }
+ else
+ {
+ return 2;
+ }
+ }
+ else
+ {
+ if(bridge->IsEnabled())
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+ return -1;
+}
+
bool Dali::AtspiAccessibility::IsEnabled()
{
return Dali::Accessibility::IsUp();
#ifndef DALI_DEVEL_ATSPI_ACCESSIBILITY_H
#define DALI_DEVEL_ATSPI_ACCESSIBILITY_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
DALI_ADAPTOR_API bool SuppressScreenReader(bool suppress);
+/**
+ * @brief Sets ATSPI to be turned On or Off forcibly.
+ *
+ * @param[in] turnOn true to turn on, false to turn off.
+ * @return The status of ATSPI : 0(ATSPI OFF, ScreenReader OFF), 1(ATSPI ON, ScreenReader OFF),
+ * 2 (ATSPI OFF, ScreenReader ON), 3(ATSPI ON, ScreenReader ON)
+ */
+DALI_ADAPTOR_API int SetForcefully(bool turnOn);
+
+/**
+ * @brief Gets ATSPI status.
+ * @return Status of ATSPI : 0(ATSPI OFF, ScreenReader OFF), 1(ATSPI ON, ScreenReader OFF),
+ * 2 (ATSPI OFF, ScreenReader ON), 3(ATSPI ON, ScreenReader ON)
+ */
+DALI_ADAPTOR_API int GetStatus();
+
/**
* @brief Returns whether the state of Accessibility is enabled or not.
*
DALI_KEY_CONTROL_RIGHT = 105,
/**
- * @brief Return key.
+ * @brief Control Return key.
*/
- DALI_KEY_RETURN = 36,
+ DALI_KEY_RETURN = 36
- /**
- * @brief Keypad Enter key.
- */
- DALI_KEY_KP_ENTER = 104
};
/**
class WebEngineSettings;
class HoverEvent;
class WheelEvent;
-class WebEngineUserMediaPermissionRequest;
/**
* @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
*/
using PlainTextReceivedCallback = std::function<void(const std::string&)>;
- /**
- * @brief WebView callback informs browser app to display QB code popup for passkey scenario.
- */
- using WebEngineWebAuthDisplayQRCallback = std::function<void(const std::string&)>;
-
- /**
- * @brief WebView callback informs browser app that the passkey registration and authentication has been successful and app can close QR popup.
- */
- using WebEngineWebAuthResponseCallback = std::function<void(void)>;
-
- /**
- * @brief The callback to be called when the web engine received a user media permission reqeust from user application.
- */
- using WebEngineUserMediaPermissionRequestCallback = std::function<void(std::unique_ptr<Dali::WebEngineUserMediaPermissionRequest>, const std::string&)>;
-
/**
* @brief Enumeration for the scroll edge.
*/
* @param[in] callback The callback function called asynchronously.
*/
virtual void GetPlainTextAsynchronously(PlainTextReceivedCallback callback) = 0;
-
- /**
- * @brief Cancel WebAuthentication(cancel in progress passkey operation).
- */
- virtual void WebAuthenticationCancel() = 0;
-
- /**
- * @brief Register WebAuthDisplayQR callback.
- *
- * @param[in] callback The callback informs browser app to display QR code popup for passkey scenario.
- */
- virtual void RegisterWebAuthDisplayQRCallback(WebEngineWebAuthDisplayQRCallback callback) = 0;
-
- /**
- * @brief Register WebAuthResponse callback.
- *
- * @param[in] callback The callback informs browser app that the passkey registration and authentication has been successful and app can close QR popup.
- */
- virtual void RegisterWebAuthResponseCallback(WebEngineWebAuthResponseCallback callback) = 0;
-
- /**
- * @brief Register UserMediaPermissionRequest callback.
- *
- * @param[in] callback The callback to be called for handling user media permission.
- */
- virtual void RegisterUserMediaPermissionRequestCallback(WebEngineUserMediaPermissionRequestCallback callback) = 0;
-
};
// specialization has to be done in the same namespace
+++ /dev/null
-#ifndef DALI_WEB_ENGINE_USER_MEDIA_PERMISSION_REQUEST_H
-#define DALI_WEB_ENGINE_USER_MEDIA_PERMISSION_REQUEST_H
-
-/*
- * 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.
- * 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
-
-namespace Dali
-{
-/**
- * @brief A class WebEngineUserMediaPermissionRequest for handling user's media permission of web engine.
- */
-class WebEngineUserMediaPermissionRequest
-{
-public:
- /**
- * @brief Constructor.
- */
- WebEngineUserMediaPermissionRequest() = default;
-
- /**
- * @brief Destructor.
- */
- virtual ~WebEngineUserMediaPermissionRequest() = default;
-
- /**
- * @brief Request to set user media permission of web engine.
- *
- * @param[in] allowed if true, allow to set, false, not allow to set.
- */
- virtual void Set(bool allowed) const = 0;
-
- /**
- * @brief Suspend user media permission request process of web engine.
- * @return true if the suspension was successful, false otherwise.
- */
- virtual bool Suspend() const = 0;
-};
-} // namespace Dali
-
-#endif // DALI_WEB_ENGINE_USER_MEDIA_PERMISSION_REQUEST_H
WebEngine WebEngine::New()
{
- Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New(-1);
-
- return WebEngine(engine.Get());
-}
-
-WebEngine WebEngine::New(int32_t type)
-{
- Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New(type);
+ Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
return WebEngine(engine.Get());
}
GetImplementation(*this).GetPlainTextAsynchronously(callback);
}
-void WebEngine::WebAuthenticationCancel()
-{
- GetImplementation(*this).WebAuthenticationCancel();
-}
-
-void WebEngine::RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback)
-{
- GetImplementation(*this).RegisterWebAuthDisplayQRCallback(callback);
-}
-
-void WebEngine::RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback)
-{
- GetImplementation(*this).RegisterWebAuthResponseCallback(callback);
-}
-
-void WebEngine::RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback)
-{
- GetImplementation(*this).RegisterUserMediaPermissionRequestCallback(callback);
-}
-
} // namespace Dali
*/
static WebEngine New();
- /**
- * @brief Create a new instance of a WebEngine with type (0: Chromium, 1: LWE, otherwise: depend on system environment).
- * @param[in] type The WebEngine type (0: Chromium, 1: LWE, otherwise: depend on system environment).
- */
- static WebEngine New(int type);
-
/**
* @brief Get context of WebEngine.
*/
*/
void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);
- /**
- * @brief Cancel WebAuthentication(cancel in progress passkey operation).
- */
- void WebAuthenticationCancel();
-
- /**
- * @brief Get a plain text of current web page asynchronously.
- *
- * @param[in] callback The callback function called asynchronously.
-
- */
- void RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback);
-
- /**
- * @brief Get a plain text of current web page asynchronously.
- *
- * @param[in] callback The callback function called asynchronously.
-
- */
- void RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback);
-
- /**
- * @brief Register UserMediaPermissionRequest callback.
- *
- * @param[in] callback The callback to be called for handling user media permission.
- */
- void RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback);
-
-
private: // Not intended for application developers
/**
* @brief Internal constructor
{
return false;
}
- if(backgroundCornerRadius != blurInfo.backgroundCornerRadius)
+ if(backgroundBlurRadius != blurInfo.backgroundBlurRadius)
{
return false;
}
void WindowBlurInfo::SetCornerRadiusForBackground(int cornerRadius)
{
- backgroundCornerRadius = cornerRadius;
+ backgroundBlurRadius = cornerRadius;
}
int WindowBlurInfo::GetCornerRadiusForBackground() const
{
- return backgroundCornerRadius;
+ return backgroundBlurRadius;
}
} // namespace Dali
WindowBlurInfo()
: windowBlurType(WindowBlurType::NONE),
windowBlurRadius(0),
- backgroundCornerRadius(0)
+ backgroundBlurRadius(0)
{
}
explicit constexpr WindowBlurInfo(WindowBlurType type, int blurRadius, int cornerRadius)
: windowBlurType(type),
windowBlurRadius(blurRadius),
- backgroundCornerRadius(cornerRadius)
+ backgroundBlurRadius(cornerRadius)
{
}
explicit constexpr WindowBlurInfo(WindowBlurType type, int blurRadius)
: windowBlurType(type),
windowBlurRadius(blurRadius),
- backgroundCornerRadius(0)
+ backgroundBlurRadius(0)
{
}
public:
WindowBlurType windowBlurType;
int windowBlurRadius;
- int backgroundCornerRadius;
+ int backgroundBlurRadius;
};
} // namespace Dali
return GetImplementation(window).IsAlwaysOnTop();
}
-void SetBottom(Window window, bool enable)
-{
- GetImplementation(window).SetBottom(enable);
-}
-
-bool IsBottom(Window window)
-{
- return GetImplementation(window).IsBottom();
-}
-
Any GetNativeBuffer(Window window)
{
return GetImplementation(window).GetNativeBuffer();
/**
* @brief Enables or disables the window always is on top.
*
- * This is valid between windows that have no notification level or a notification level of 'none'.
- * If it has a notification level, this will not do anything.
- *
* @param[in] window The window instance.
* @param[in] alwaysOnTop true to enable the window always is on top, false to disable.
*/
*/
DALI_ADAPTOR_API bool IsAlwaysOnTop(Window window);
-/**
- * @brief Enables or disables the window's layer is changed to bottom.
- *
- * If the enable flag is true, this window will be placed below other windows.
- * Otherwise, if it's called with a false value, it will be located above other windows.
- *
- * @param[in] window The window instance.
- * @param[in] enable true to change the window layer to the bottom.
- */
-DALI_ADAPTOR_API void SetBottom(Window window, bool enable);
-
-/**
- * @brief Returns whether the window layer is the bottom or not.
- *
- * @param[in] window The window instance.
- * @return True if the window layer is the bottom, false otherwise.
- */
-DALI_ADAPTOR_API bool IsBottom(Window window);
-
/**
* @brief Gets the native buffer of the window.
*
#define DALI_ADAPTOR_ATSPI_COLLECTION_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
class DALI_ADAPTOR_API Collection : public virtual Accessible
{
-public:
- /**
- * MatchRule type is a tuple that only carries data of de-serialized parameter from BridgeCollection::GetMatches dbus method.
- */
- using MatchRule = std::tuple<
- std::array<int32_t, 2>,
- int32_t,
- std::unordered_map<std::string, std::string>,
- int32_t,
- std::array<int32_t, 4>,
- int32_t,
- std::vector<std::string>,
- int32_t,
- bool>;
-
/**
* @brief Downcasts an Accessible to a Collection.
*
* @see Dali::Accessibility::Accessible::DownCast()
*/
static inline Collection* DownCast(Accessible* obj);
-
- /**
- * @brief Gets the matching Accessible objects with MatchRule.
- *
- * @param[in] rule Collection::MatchRule
- * @param[in] sortBy SortOrder::CANONICAL or SortOrder::REVERSE_CANONICAL
- * @param[in] maxCount The maximum number of objects; returns all matches if 0
- * @return The matching Accessible objects
- */
- std::vector<Accessible*> GetMatches(MatchRule rule, uint32_t sortBy, size_t maxCount);
-
- /**
- * @brief Gets the matching Accessible objects with two MatchRules.
- *
- * @param[in] firstRule The initial Collection::MatchRule.
- * @param[in] secondRule An secondary Collection::MatchRule.
- * @param[in] sortBy SortOrder::CANONICAL or SortOrder::REVERSE_CANONICAL
- * @param[in] firstCount The maximum number of objects to return for the initial match.; returns all matches if 0
- * @param[in] secondCount The maximum number of objects to return for the secondary match.; returns all matches if 0
- * @return The matching Accessible objects
- */
- std::vector<Accessible*> GetMatchesInMatches(MatchRule firstRule, MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount);
};
namespace Internal
${adaptor_devel_api_dir}/adaptor-framework/web-engine/web-engine-request-interceptor.h
${adaptor_devel_api_dir}/adaptor-framework/web-engine/web-engine-security-origin.h
${adaptor_devel_api_dir}/adaptor-framework/web-engine/web-engine-settings.h
- ${adaptor_devel_api_dir}/adaptor-framework/web-engine/web-engine-user-media-permission-request.h
)
ShaderPreCompiler::ShaderPreCompiler()
: mRawShaderList(),
- mEnabled(false),
- mNeedsSleep(true)
+ mPrecompiled(false),
+ mEnabled(false)
{
}
return *(mInstance.get());
}
-void ShaderPreCompiler::AddPreCompiledProgram(ShaderPreCompiler::CompiledProgram program)
+void ShaderPreCompiler::AddPreCompiledProgram(Graphics::UniquePtr<Dali::Graphics::Program> program)
{
mProgram.push_back(move(program));
}
-void ShaderPreCompiler::GetPreCompileShaderList(ShaderPreCompiler::RawShaderDataList& shaderList)
+void ShaderPreCompiler::GetPreCompileShaderList(std::vector<RawShaderData>& shaderList)
{
// move shader list
- shaderList = std::move(mRawShaderList);
-
- // Call clear, to avoid SVACE false alarm.
- mRawShaderList.clear();
+ shaderList = mRawShaderList;
}
-void ShaderPreCompiler::SavePreCompileShaderList(ShaderPreCompiler::RawShaderDataList&& shaderList)
+void ShaderPreCompiler::SavePreCompileShaderList(std::vector<RawShaderData>& shaderList)
{
- mRawShaderList = std::move(shaderList);
+ mRawShaderList = shaderList;
+ mPrecompiled = true;
DALI_LOG_RELEASE_INFO("Precompile shader list is saved! Precompile available now\n");
Awake();
}
-void ShaderPreCompiler::Enable(bool enable)
+bool ShaderPreCompiler::IsReady() const
+{
+ return mPrecompiled;
+}
+
+void ShaderPreCompiler::Enable()
{
- mEnabled = enable;
+ mEnabled = true;
}
-bool ShaderPreCompiler::IsEnable() const
+bool ShaderPreCompiler::IsEnable()
{
return mEnabled;
}
mNeedsSleep = false;
mConditionalWait.Notify(lock);
}
-
-void ShaderPreCompiler::ClearPreCompiledPrograms()
-{
- mProgram.clear();
-}
-
} // namespace Dali
namespace Dali
{
+struct RawShaderData
+{
+ int shaderCount;
+ std::vector<std::string_view> vertexPrefix;
+ std::vector<std::string_view> fragmentPrefix;
+ std::vector<std::string_view> shaderName;
+ std::string_view vertexShader;
+ std::string_view fragmentShader;
+ bool custom;
+};
+
/**
* ShaderPreCompiler is used to precompile shaders.
* The precompiled shaders are stored in a file.
*/
class DALI_CORE_API ShaderPreCompiler : public BaseHandle
{
-public:
- struct RawShaderData
- {
- uint32_t shaderCount;
- std::vector<std::string> vertexPrefix;
- std::vector<std::string> fragmentPrefix;
- std::vector<std::string> shaderName;
- std::string_view vertexShader;
- std::string_view fragmentShader;
- bool custom;
- };
-
- using RawShaderDataList = std::vector<RawShaderData>;
- using CompiledProgram = Dali::Graphics::UniquePtr<Dali::Graphics::Program>;
-
public:
/**
* @brief Gets the singleton of ShaderPreCompiler object.
*
* @param[in] program precompiled program
*/
- void AddPreCompiledProgram(CompiledProgram program);
+ void AddPreCompiledProgram(Graphics::UniquePtr<Dali::Graphics::Program> program);
/**
- * @brief Gets the shader list to be precompiled.
- * @note Stored shader list will be cleared after calling this function.
+ * @brief Gets the shader list to be precompiled
*
- * @param[out] shaders shader data for precompile
+ * @param[in] shaders shader data for precompile
*/
- void GetPreCompileShaderList(RawShaderDataList& shaders);
+ void GetPreCompileShaderList(std::vector<RawShaderData>& shaders);
/**
* @brief Save the shader list to be precompiled
*
* @param[in] shaders shader data for precompile
*/
- void SavePreCompileShaderList(RawShaderDataList&& shaders);
+ void SavePreCompileShaderList(std::vector<RawShaderData>& shaders);
+
+ /**
+ * @brief Checks whether the precompiled list is ready or not
+ *
+ * @return true if precompile list is ready
+ */
+ bool IsReady() const;
/**
* @brief Enable the feature of precompile
*
- * @param[in] enable True if we need to enable precompile. False if we need to disable precompile.
*/
- void Enable(bool enable);
+ void Enable();
/**
* @brief Check the feature of precompile is enabled or not
*
* @return true if the feature of precompile is enabled
*/
- bool IsEnable() const;
+ bool IsEnable();
/**
* @brief Waiting for a list of shaders to be precompiled
*/
void Awake();
- /**
- * @brief Remove all pre-compiled programs from cache.
- * @note It must be called before graphics shutdown.
- */
- void ClearPreCompiledPrograms();
-
private:
/**
* Construct a new ShaderPreCompiler.
ShaderPreCompiler& operator=(const ShaderPreCompiler& rhs) = delete;
private:
- static std::unique_ptr<ShaderPreCompiler> mInstance;
- static std::once_flag mOnceFlag;
-
-private:
- std::vector<CompiledProgram> mProgram; ///< Keep compiled programs so we can use cached program.
-
- RawShaderDataList mRawShaderList;
- ConditionalWait mConditionalWait;
- Dali::Mutex mMutex;
-
- bool mEnabled : 1;
- bool mNeedsSleep : 1;
+ std::vector<Graphics::UniquePtr<Dali::Graphics::Program>> mProgram;
+ static std::unique_ptr<ShaderPreCompiler> mInstance;
+ static std::once_flag mOnceFlag;
+ std::vector<RawShaderData> mRawShaderList;
+ ConditionalWait mConditionalWait;
+ Dali::Mutex mMutex;
+ bool mPrecompiled;
+ bool mEnabled;
+ bool mNeedsSleep{true};
};
} // namespace Dali
BridgeBase::~BridgeBase()
{
+ mApplication.mChildren.clear();
}
void BridgeBase::AddCoalescableMessage(CoalescableMessages kind, Dali::Accessibility::Accessible* obj, float delay, std::function<void()> functor)
if(mApplication.mChildren[i] == windowAccessible)
{
mApplication.mChildren.erase(mApplication.mChildren.begin() + i);
- Emit(windowAccessible, WindowEvent::DESTROY);
break;
}
}
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
using namespace Dali::Accessibility;
+namespace
+{
+/**
+ * @brief Enumeration used for quering Accessibility objects.
+ *
+ * Refer to MatchType enumeration.
+ */
+enum class AtspiCollection
+{
+ MATCH_INVALID,
+ MATCH_ALL,
+ MATCH_ANY,
+ MATCH_NONE,
+ MATCH_EMPTY,
+ MATCH_LAST_DEFINED,
+};
+} // anonymous namespace
+
void BridgeCollection::RegisterInterfaces()
{
DBus::DBusInterfaceDescription desc{Accessible::GetInterfaceName(AtspiInterface::COLLECTION)};
return FindCurrentObjectWithInterface<Dali::Accessibility::AtspiInterface::COLLECTION>();
}
-DBus::ValueOrError<std::vector<Accessible*> > BridgeCollection::GetMatches(Collection::MatchRule rule, uint32_t sortBy, int32_t count, bool traverse)
+/**
+ * @brief The BridgeCollection::Comparer structure.
+ *
+ * Once the data is de-serialized by DBusWrapper, the data of match rule is passed
+ * to Comparer type which do the comparison against a single accessible object.
+ */
+struct BridgeCollection::Comparer
{
- if(auto collection = FindSelf())
+ using Mode = MatchType;
+
+ /**
+ * @brief Enumeration to check the object is found first.
+ */
+ enum class CompareFuncExit
{
- return collection->GetMatches(std::move(rule), sortBy, count);
+ FIRST_FOUND,
+ FIRST_NOT_FOUND
+ };
+
+ static Mode ConvertToMatchType(int32_t mode)
+ {
+ switch(mode)
+ {
+ case static_cast<int32_t>(AtspiCollection::MATCH_INVALID):
+ {
+ return Mode::INVALID;
+ }
+ case static_cast<int32_t>(AtspiCollection::MATCH_ALL):
+ {
+ return Mode::ALL;
+ }
+ case static_cast<int32_t>(AtspiCollection::MATCH_ANY):
+ {
+ return Mode::ANY;
+ }
+ case static_cast<int32_t>(AtspiCollection::MATCH_NONE):
+ {
+ return Mode::NONE;
+ }
+ case static_cast<int32_t>(AtspiCollection::MATCH_EMPTY):
+ {
+ return Mode::EMPTY;
+ }
+ }
+ return Mode::INVALID;
}
- return {};
+ /**
+ * @brief The ComparerInterfaces structure
+ */
+ struct ComparerInterfaces
+ {
+ std::unordered_set<std::string> mObject;
+ std::vector<std::string> mRequested;
+ Mode mMode = Mode::INVALID;
+
+ ComparerInterfaces(MatchRule* rule)
+ : mMode(ConvertToMatchType(std::get<static_cast<std::size_t>(Index::INTERFACES_MATCH_TYPE)>(*rule)))
+ {
+ mRequested = {std::get<static_cast<std::size_t>(Index::INTERFACES)>(*rule).begin(), std::get<static_cast<std::size_t>(Index::INTERFACES)>(*rule).end()};
+ }
+
+ void Update(Accessible* obj)
+ {
+ mObject.clear();
+ for(auto& interface : obj->GetInterfacesAsStrings())
+ {
+ mObject.insert(std::move(interface));
+ }
+ }
+
+ bool IsRequestEmpty() const
+ {
+ return mRequested.empty();
+ }
+
+ bool IsObjectEmpty() const
+ {
+ return mObject.empty();
+ }
+
+ bool Compare(CompareFuncExit exit)
+ {
+ bool foundAny = false;
+ for(auto& iname : mRequested)
+ {
+ bool found = (mObject.find(iname) != mObject.end());
+ if(found)
+ {
+ foundAny = true;
+ }
+
+ if(found == (exit == CompareFuncExit::FIRST_FOUND))
+ {
+ return found;
+ }
+ }
+ return foundAny;
+ }
+ }; // ComparerInterfaces struct
+
+ /**
+ * @brief The ComparerAttributes structure
+ */
+ struct ComparerAttributes
+ {
+ std::unordered_map<std::string, std::string> mRequested;
+ std::unordered_map<std::string, std::string> mObject;
+ Mode mMode = Mode::INVALID;
+
+ ComparerAttributes(MatchRule* rule)
+ : mMode(ConvertToMatchType(std::get<static_cast<std::size_t>(Index::ATTRIBUTES_MATCH_TYPE)>(*rule)))
+ {
+ mRequested = std::get<static_cast<std::size_t>(Index::ATTRIBUTES)>(*rule);
+ }
+
+ void Update(Accessible* obj)
+ {
+ mObject = obj->GetAttributes();
+ }
+
+ bool IsRequestEmpty() const
+ {
+ return mRequested.empty();
+ }
+
+ bool IsObjectEmpty() const
+ {
+ return mObject.empty();
+ }
+
+ bool Compare(CompareFuncExit exit)
+ {
+ bool foundAny = false;
+ for(auto& iname : mRequested)
+ {
+ auto it = mObject.find(iname.first);
+ bool found = it != mObject.end() && iname.second == it->second;
+ if(found)
+ {
+ foundAny = true;
+ }
+
+ if(found == (exit == CompareFuncExit::FIRST_FOUND))
+ {
+ return found;
+ }
+ }
+ return foundAny;
+ }
+ }; // ComparerAttributes struct
+
+ /**
+ * @brief The ComparerRoles structure
+ */
+ struct ComparerRoles
+ {
+ using Roles = EnumBitSet<Role, Role::MAX_COUNT>;
+
+ Roles mRequested;
+ Roles mObject;
+ Mode mMode = Mode::INVALID;
+
+ ComparerRoles(MatchRule* rule)
+ : mMode(ConvertToMatchType(std::get<static_cast<std::size_t>(Index::ROLES_MATCH_TYPE)>(*rule)))
+ {
+ mRequested = Roles{std::get<static_cast<std::size_t>(Index::ROLES)>(*rule)};
+ }
+
+ void Update(Accessible* obj)
+ {
+ mObject = {};
+ mObject[obj->GetRole()] = true;
+ assert(mObject);
+ }
+
+ bool IsRequestEmpty() const
+ {
+ return !mRequested;
+ }
+
+ bool IsObjectEmpty() const
+ {
+ return !mObject;
+ }
+
+ bool Compare(CompareFuncExit exit)
+ {
+ switch(mMode)
+ {
+ case Mode::INVALID:
+ {
+ return true;
+ }
+ case Mode::EMPTY:
+ case Mode::ALL:
+ {
+ return mRequested == (mObject & mRequested);
+ }
+ case Mode::ANY:
+ {
+ return bool(mObject & mRequested);
+ }
+ case Mode::NONE:
+ {
+ return bool(mObject & mRequested);
+ }
+ }
+ return false;
+ }
+ }; // ComparerRoles struct
+
+ /**
+ * @brief The ComparerStates structure
+ */
+ struct ComparerStates
+ {
+ States mRequested;
+ States mObject;
+ Mode mMode = Mode::INVALID;
+
+ ComparerStates(MatchRule* rule)
+ : mMode(ConvertToMatchType(std::get<static_cast<std::size_t>(Index::STATES_MATCH_TYPE)>(*rule)))
+ {
+ mRequested = States{std::get<static_cast<std::size_t>(Index::STATES)>(*rule)};
+ }
+
+ void Update(Accessible* obj)
+ {
+ mObject = obj->GetStates();
+ }
+
+ bool IsRequestEmpty() const
+ {
+ return !mRequested;
+ }
+
+ bool IsObjectEmpty() const
+ {
+ return !mObject;
+ }
+
+ bool Compare(CompareFuncExit exit)
+ {
+ switch(mMode)
+ {
+ case Mode::INVALID:
+ {
+ return true;
+ }
+ case Mode::EMPTY:
+ case Mode::ALL:
+ {
+ return mRequested == (mObject & mRequested);
+ }
+ case Mode::ANY:
+ {
+ return bool(mObject & mRequested);
+ }
+ case Mode::NONE:
+ {
+ return bool(mObject & mRequested);
+ }
+ }
+ return false;
+ }
+ }; // ComparerStates struct
+
+ template<typename T>
+ bool CompareFunc(T& cmp, Accessible* obj)
+ {
+ if(cmp.mMode == Mode::INVALID)
+ {
+ return true;
+ }
+
+ cmp.Update(obj);
+ switch(cmp.mMode)
+ {
+ case Mode::ANY:
+ {
+ if(cmp.IsRequestEmpty() || cmp.IsObjectEmpty())
+ {
+ return false;
+ }
+ break;
+ }
+ case Mode::ALL:
+ {
+ if(cmp.IsRequestEmpty())
+ {
+ return true;
+ }
+ if(cmp.IsObjectEmpty())
+ {
+ return false;
+ }
+ break;
+ }
+ case Mode::NONE:
+ {
+ if(cmp.IsRequestEmpty() || cmp.IsObjectEmpty())
+ {
+ return true;
+ }
+ break;
+ }
+ case Mode::EMPTY:
+ {
+ if(cmp.IsRequestEmpty() && cmp.IsObjectEmpty())
+ {
+ return true;
+ }
+ if(cmp.IsRequestEmpty() || cmp.IsObjectEmpty())
+ {
+ return false;
+ }
+ break;
+ }
+ case Mode::INVALID:
+ {
+ return true;
+ }
+ }
+
+ switch(cmp.mMode)
+ {
+ case Mode::EMPTY:
+ case Mode::ALL:
+ {
+ if(!cmp.Compare(CompareFuncExit::FIRST_NOT_FOUND))
+ {
+ return false;
+ }
+ break;
+ }
+ case Mode::ANY:
+ {
+ if(cmp.Compare(CompareFuncExit::FIRST_FOUND))
+ {
+ return true;
+ }
+ break;
+ }
+ case Mode::NONE:
+ {
+ if(cmp.Compare(CompareFuncExit::FIRST_FOUND))
+ {
+ return false;
+ }
+ break;
+ }
+ case Mode::INVALID:
+ {
+ return true;
+ }
+ }
+
+ switch(cmp.mMode)
+ {
+ case Mode::EMPTY:
+ case Mode::ALL:
+ case Mode::NONE:
+ {
+ return true;
+ }
+ case Mode::ANY:
+ {
+ return false;
+ }
+ case Mode::INVALID:
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ Comparer(MatchRule* rule)
+ : mInterface(rule),
+ mAttribute(rule),
+ mRole(rule),
+ mState(rule)
+ {
+ }
+
+ bool operator()(Accessible* obj)
+ {
+ return CompareFunc(mInterface, obj) &&
+ CompareFunc(mAttribute, obj) &&
+ CompareFunc(mRole, obj) &&
+ CompareFunc(mState, obj);
+ }
+
+ bool IsShowing(Accessible* obj)
+ {
+ if (mState.mMode == Mode::NONE) return true;
+ mState.Update(obj);
+ if (mState.IsRequestEmpty() || mState.IsObjectEmpty()) return true;
+ if (!mState.mRequested[State::SHOWING] ) return true;
+ if (mState.mObject[State::SHOWING]) return true;
+
+ return false;
+ }
+
+ ComparerInterfaces mInterface;
+ ComparerAttributes mAttribute;
+ ComparerRoles mRole;
+ ComparerStates mState;
+}; // BridgeCollection::Comparer struct
+
+
+void BridgeCollection::VisitNodes(Accessible* obj, std::vector<Accessible*>& result, Comparer& comparer, size_t maxCount)
+{
+ if(maxCount > 0 && result.size() >= maxCount)
+ {
+ return;
+ }
+
+ if(comparer(obj))
+ {
+ result.emplace_back(obj);
+ // the code below will never return for maxCount equal 0
+ if(result.size() == maxCount)
+ {
+ return;
+ }
+ }
+
+ if (!comparer.IsShowing(obj))
+ {
+ return;
+ }
+
+ for(auto i = 0u; i < obj->GetChildCount(); ++i)
+ {
+ VisitNodes(obj->GetChildAtIndex(i), result, comparer, maxCount);
+ }
}
-DBus::ValueOrError<std::vector<Accessible*> > BridgeCollection::GetMatchesInMatches(Collection::MatchRule firstRule, Collection::MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount, bool traverse)
+DBus::ValueOrError<std::vector<Accessible*> > BridgeCollection::GetMatches(MatchRule rule, uint32_t sortBy, int32_t count, bool traverse)
{
- if(auto collection = FindSelf())
+ std::vector<Accessible*> res;
+ auto self = BridgeBase::FindCurrentObject();
+ auto matcher = Comparer{&rule};
+ VisitNodes(self, res, matcher, count);
+
+ switch(static_cast<SortOrder>(sortBy))
{
- return collection->GetMatchesInMatches(std::move(firstRule), std::move(secondRule), sortBy, firstCount, secondCount);
+ case SortOrder::CANONICAL:
+ {
+ break;
+ }
+
+ case SortOrder::REVERSE_CANONICAL:
+ {
+ std::reverse(res.begin(), res.end());
+ break;
+ }
+
+ default:
+ {
+ throw std::domain_error{"unsupported sorting order"};
+ }
+ //TODO: other cases
+ }
+
+ return res;
+}
+
+DBus::ValueOrError<std::vector<Accessible*> > BridgeCollection::GetMatchesInMatches(MatchRule firstRule, MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount, bool traverse)
+{
+ std::vector<Accessible*> res;
+ std::vector<Accessible*> firstRes;
+ std::vector<Accessible*> secondRes;
+ auto self = BridgeBase::FindCurrentObject();
+ auto firstMatcher = Comparer{&firstRule};
+ auto secondMatcher = Comparer{&secondRule};
+ VisitNodes(self, firstRes, firstMatcher, firstCount);
+
+ for (auto &obj : firstRes)
+ {
+ VisitNodes(obj, secondRes, secondMatcher, secondCount);
+
+ res.insert(res.end(), secondRes.begin(), secondRes.end());
+ secondRes.clear();
+ }
+
+ switch(static_cast<SortOrder>(sortBy))
+ {
+ case SortOrder::CANONICAL:
+ {
+ break;
+ }
+
+ case SortOrder::REVERSE_CANONICAL:
+ {
+ std::reverse(res.begin(), res.end());
+ break;
+ }
+
+ default:
+ {
+ throw std::domain_error{"unsupported sorting order"};
+ }
+ //TODO: other cases
}
- return {};
+ return res;
}
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
class BridgeCollection : public virtual BridgeBase
{
+private:
+ struct Comparer;
+
+ /**
+ * @brief Visits all nodes of Accessible object and pushes the object to 'result' container.
+ *
+ * To query the entire tree, the BridgeCollection::Comparer is used inside this method,
+ * which traverse the tree using GetChildAtIndex().
+ * @param[in] obj The Accessible object to search
+ * @param[out] result The vector container for result
+ * @param[in] comparer BridgeCollection::Comparer which do the comparison against a single accessible object
+ * @param[in] maxCount The maximum count of containing Accessible object
+ */
+ static void VisitNodes(Dali::Accessibility::Accessible* obj, std::vector<Dali::Accessibility::Accessible*>& result, Comparer& comparer, size_t maxCount);
+
protected:
BridgeCollection() = default;
public:
/**
- * @copydoc Dali::Accessibility::Collection::GetMatches()
+ * MatchRule type is a tuple that only carries data of de-serialized parameter from BridgeCollection::GetMatches dbus method.
*/
- DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*> > GetMatches(Dali::Accessibility::Collection::MatchRule rule, uint32_t sortBy, int32_t count, bool traverse);
+ using MatchRule = std::tuple<
+ std::array<int32_t, 2>,
+ int32_t,
+ std::unordered_map<std::string, std::string>,
+ int32_t,
+ std::array<int32_t, 4>,
+ int32_t,
+ std::vector<std::string>,
+ int32_t,
+ bool>;
/**
- * @copydoc Dali::Accessibility::Collection::GetMatchesInMatches()
+ * @brief Enumeration for Collection Index.
+ */
+ enum class Index
+ {
+ STATES,
+ STATES_MATCH_TYPE,
+ ATTRIBUTES,
+ ATTRIBUTES_MATCH_TYPE,
+ ROLES,
+ ROLES_MATCH_TYPE,
+ INTERFACES,
+ INTERFACES_MATCH_TYPE,
+ };
+
+ /**
+ * @brief Gets the matching Accessible objects with MatchRule.
+ *
+ * @param[in] rule BridgeCollection::MatchRule
+ * @param[in] sortBy SortOrder::CANONICAL or SortOrder::REVERSE_CANONICAL
+ * @param[in] count The maximum number of objects
+ * @param[in] traverse True if it is traverse, otherwise false.
+ * @return The matching Accessible objects
+ */
+ DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*> > GetMatches(MatchRule rule, uint32_t sortBy, int32_t count, bool traverse);
+
+ /**
+ * @brief Gets the matching Accessible objects with two MatchRules.
+ *
+ * @param[in] firstRule The initial BridgeCollection::MatchRule.
+ * @param[in] secondRule An secondary BridgeCollection::MatchRule.
+ * @param[in] sortBy SortOrder::CANONICAL or SortOrder::REVERSE_CANONICAL
+ * @param[in] firstCount The maximum number of objects to return for the initial match.
+ * @param[in] secondCount The maximum number of objects to return for the secondary match.
+ * @param[in] traverse True if it is traverse, otherwise false.
+ * @return The matching Accessible objects
*/
- DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*> > GetMatchesInMatches(Dali::Accessibility::Collection::MatchRule firstRule, Dali::Accessibility::Collection::MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount, bool traverse);
+ DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*> > GetMatchesInMatches(MatchRule firstRule, MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount, bool traverse);
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H
+++ /dev/null
-/*
- * 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.
- * 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
-
-// EXTERNAL INCLUDES
-#include <iostream>
-#include <set>
-
-// INTERNAL INCLUDES
-#include <dali/devel-api/atspi-interfaces/collection.h>
-#include <dali/internal/accessibility/bridge/accessibility-common.h>
-
-using namespace Dali::Accessibility;
-
-namespace
-{
-using MatchRule = Collection::MatchRule;
-
-/**
- * @brief Enumeration for Collection Index.
- */
-enum class Index
-{
- STATES,
- STATES_MATCH_TYPE,
- ATTRIBUTES,
- ATTRIBUTES_MATCH_TYPE,
- ROLES,
- ROLES_MATCH_TYPE,
- INTERFACES,
- INTERFACES_MATCH_TYPE,
-};
-
-/**
- * @brief Enumeration used for quering Accessibility objects.
- *
- * Refer to MatchType enumeration.
- */
-enum class AtspiCollection
-{
- MATCH_INVALID,
- MATCH_ALL,
- MATCH_ANY,
- MATCH_NONE,
- MATCH_EMPTY,
- MATCH_LAST_DEFINED,
-};
-
-/**
- * @brief The Comparer structure.
- *
- * Once the data is de-serialized by DBusWrapper, the data of match rule is passed
- * to Comparer type which do the comparison against a single accessible object.
- */
-struct Comparer
-{
- using Mode = MatchType;
-
- /**
- * @brief Enumeration to check the object is found first.
- */
- enum class CompareFuncExit
- {
- FIRST_FOUND,
- FIRST_NOT_FOUND
- };
-
- static Mode ConvertToMatchType(int32_t mode)
- {
- switch(mode)
- {
- case static_cast<int32_t>(AtspiCollection::MATCH_INVALID):
- {
- return Mode::INVALID;
- }
- case static_cast<int32_t>(AtspiCollection::MATCH_ALL):
- {
- return Mode::ALL;
- }
- case static_cast<int32_t>(AtspiCollection::MATCH_ANY):
- {
- return Mode::ANY;
- }
- case static_cast<int32_t>(AtspiCollection::MATCH_NONE):
- {
- return Mode::NONE;
- }
- case static_cast<int32_t>(AtspiCollection::MATCH_EMPTY):
- {
- return Mode::EMPTY;
- }
- }
- return Mode::INVALID;
- }
-
- /**
- * @brief The ComparerInterfaces structure
- */
- struct ComparerInterfaces
- {
- std::unordered_set<std::string> mObject;
- std::vector<std::string> mRequested;
- Mode mMode = Mode::INVALID;
-
- ComparerInterfaces(MatchRule* rule)
- : mMode(ConvertToMatchType(std::get<static_cast<std::size_t>(Index::INTERFACES_MATCH_TYPE)>(*rule)))
- {
- mRequested = {std::get<static_cast<std::size_t>(Index::INTERFACES)>(*rule).begin(), std::get<static_cast<std::size_t>(Index::INTERFACES)>(*rule).end()};
- }
-
- void Update(Accessible* obj)
- {
- mObject.clear();
- for(auto& interface : obj->GetInterfacesAsStrings())
- {
- mObject.insert(std::move(interface));
- }
- }
-
- bool IsRequestEmpty() const
- {
- return mRequested.empty();
- }
-
- bool IsObjectEmpty() const
- {
- return mObject.empty();
- }
-
- bool Compare(CompareFuncExit exit)
- {
- bool foundAny = false;
- for(auto& iname : mRequested)
- {
- bool found = (mObject.find(iname) != mObject.end());
- if(found)
- {
- foundAny = true;
- }
-
- if(found == (exit == CompareFuncExit::FIRST_FOUND))
- {
- return found;
- }
- }
- return foundAny;
- }
- }; // ComparerInterfaces struct
-
- /**
- * @brief The ComparerAttributes structure
- */
- struct ComparerAttributes
- {
- std::unordered_map<std::string, std::string> mRequested;
- std::unordered_map<std::string, std::string> mObject;
- Mode mMode = Mode::INVALID;
-
- ComparerAttributes(MatchRule* rule)
- : mMode(ConvertToMatchType(std::get<static_cast<std::size_t>(Index::ATTRIBUTES_MATCH_TYPE)>(*rule)))
- {
- mRequested = std::get<static_cast<std::size_t>(Index::ATTRIBUTES)>(*rule);
- }
-
- void Update(Accessible* obj)
- {
- mObject = obj->GetAttributes();
- }
-
- bool IsRequestEmpty() const
- {
- return mRequested.empty();
- }
-
- bool IsObjectEmpty() const
- {
- return mObject.empty();
- }
-
- bool Compare(CompareFuncExit exit)
- {
- bool foundAny = false;
- for(auto& iname : mRequested)
- {
- auto it = mObject.find(iname.first);
- bool found = it != mObject.end() && iname.second == it->second;
- if(found)
- {
- foundAny = true;
- }
-
- if(found == (exit == CompareFuncExit::FIRST_FOUND))
- {
- return found;
- }
- }
- return foundAny;
- }
- }; // ComparerAttributes struct
-
- /**
- * @brief The ComparerRoles structure
- */
- struct ComparerRoles
- {
- using Roles = EnumBitSet<Role, Role::MAX_COUNT>;
-
- Roles mRequested;
- Roles mObject;
- Mode mMode = Mode::INVALID;
-
- ComparerRoles(MatchRule* rule)
- : mMode(ConvertToMatchType(std::get<static_cast<std::size_t>(Index::ROLES_MATCH_TYPE)>(*rule)))
- {
- mRequested = Roles{std::get<static_cast<std::size_t>(Index::ROLES)>(*rule)};
- }
-
- void Update(Accessible* obj)
- {
- mObject = {};
- mObject[obj->GetRole()] = true;
- assert(mObject);
- }
-
- bool IsRequestEmpty() const
- {
- return !mRequested;
- }
-
- bool IsObjectEmpty() const
- {
- return !mObject;
- }
-
- bool Compare(CompareFuncExit exit)
- {
- switch(mMode)
- {
- case Mode::INVALID:
- {
- return true;
- }
- case Mode::EMPTY:
- case Mode::ALL:
- {
- return mRequested == (mObject & mRequested);
- }
- case Mode::ANY:
- {
- return bool(mObject & mRequested);
- }
- case Mode::NONE:
- {
- return bool(mObject & mRequested);
- }
- }
- return false;
- }
- }; // ComparerRoles struct
-
- /**
- * @brief The ComparerStates structure
- */
- struct ComparerStates
- {
- States mRequested;
- States mObject;
- Mode mMode = Mode::INVALID;
-
- ComparerStates(MatchRule* rule)
- : mMode(ConvertToMatchType(std::get<static_cast<std::size_t>(Index::STATES_MATCH_TYPE)>(*rule)))
- {
- mRequested = States{std::get<static_cast<std::size_t>(Index::STATES)>(*rule)};
- }
-
- void Update(Accessible* obj)
- {
- mObject = obj->GetStates();
- }
-
- bool IsRequestEmpty() const
- {
- return !mRequested;
- }
-
- bool IsObjectEmpty() const
- {
- return !mObject;
- }
-
- bool Compare(CompareFuncExit exit)
- {
- switch(mMode)
- {
- case Mode::INVALID:
- {
- return true;
- }
- case Mode::EMPTY:
- case Mode::ALL:
- {
- return mRequested == (mObject & mRequested);
- }
- case Mode::ANY:
- {
- return bool(mObject & mRequested);
- }
- case Mode::NONE:
- {
- return bool(mObject & mRequested);
- }
- }
- return false;
- }
- }; // ComparerStates struct
-
- template<typename T>
- bool CompareFunc(T& cmp, Accessible* obj)
- {
- if(cmp.mMode == Mode::INVALID)
- {
- return true;
- }
-
- cmp.Update(obj);
- switch(cmp.mMode)
- {
- case Mode::ANY:
- {
- if(cmp.IsRequestEmpty() || cmp.IsObjectEmpty())
- {
- return false;
- }
- break;
- }
- case Mode::ALL:
- {
- if(cmp.IsRequestEmpty())
- {
- return true;
- }
- if(cmp.IsObjectEmpty())
- {
- return false;
- }
- break;
- }
- case Mode::NONE:
- {
- if(cmp.IsRequestEmpty() || cmp.IsObjectEmpty())
- {
- return true;
- }
- break;
- }
- case Mode::EMPTY:
- {
- if(cmp.IsRequestEmpty() && cmp.IsObjectEmpty())
- {
- return true;
- }
- if(cmp.IsRequestEmpty() || cmp.IsObjectEmpty())
- {
- return false;
- }
- break;
- }
- case Mode::INVALID:
- {
- return true;
- }
- }
-
- switch(cmp.mMode)
- {
- case Mode::EMPTY:
- case Mode::ALL:
- {
- if(!cmp.Compare(CompareFuncExit::FIRST_NOT_FOUND))
- {
- return false;
- }
- break;
- }
- case Mode::ANY:
- {
- if(cmp.Compare(CompareFuncExit::FIRST_FOUND))
- {
- return true;
- }
- break;
- }
- case Mode::NONE:
- {
- if(cmp.Compare(CompareFuncExit::FIRST_FOUND))
- {
- return false;
- }
- break;
- }
- case Mode::INVALID:
- {
- return true;
- }
- }
-
- switch(cmp.mMode)
- {
- case Mode::EMPTY:
- case Mode::ALL:
- case Mode::NONE:
- {
- return true;
- }
- case Mode::ANY:
- {
- return false;
- }
- case Mode::INVALID:
- {
- return true;
- }
- }
- return false;
- }
-
- Comparer(MatchRule* rule)
- : mInterface(rule),
- mAttribute(rule),
- mRole(rule),
- mState(rule)
- {
- }
-
- bool operator()(Accessible* obj)
- {
- return CompareFunc(mInterface, obj) &&
- CompareFunc(mAttribute, obj) &&
- CompareFunc(mRole, obj) &&
- CompareFunc(mState, obj);
- }
-
- bool IsShowing(Accessible* obj)
- {
- if(mState.mMode == Mode::NONE) return true;
- mState.Update(obj);
- if(mState.IsRequestEmpty() || mState.IsObjectEmpty()) return true;
- if(!mState.mRequested[State::SHOWING]) return true;
- if(mState.mObject[State::SHOWING]) return true;
-
- return false;
- }
-
- ComparerInterfaces mInterface;
- ComparerAttributes mAttribute;
- ComparerRoles mRole;
- ComparerStates mState;
-}; // BridgeCollection::Comparer struct
-
-/**
- * @brief Visits all nodes of Accessible object and pushes the object to 'result' container.
- *
- * To query the entire tree, the BridgeCollection::Comparer is used inside this method,
- * which traverse the tree using GetChildAtIndex().
- * @param[in] obj The Accessible object to search
- * @param[out] result The vector container for result
- * @param[in] comparer BridgeCollection::Comparer which do the comparison against a single accessible object
- * @param[in] maxCount The maximum count of containing Accessible object
- */
-void VisitNodes(Accessible* obj, std::vector<Accessible*>& result, Comparer& comparer, size_t maxCount, std::set<Accessible*>& visitedNodes)
-{
- if(visitedNodes.count(obj) > 0)
- {
- return;
- }
-
- visitedNodes.insert(obj);
-
- if(maxCount > 0 && result.size() >= maxCount)
- {
- return;
- }
-
- if(comparer(obj))
- {
- result.emplace_back(obj);
- // the code below will never return for maxCount equal 0
- if(result.size() == maxCount)
- {
- return;
- }
- }
-
- if(!comparer.IsShowing(obj))
- {
- return;
- }
-
- for(auto i = 0u; i < obj->GetChildCount(); ++i)
- {
- VisitNodes(obj->GetChildAtIndex(i), result, comparer, maxCount, visitedNodes);
- }
-}
-
-void SortMatchedResult(std::vector<Accessible*>& result, SortOrder sortBy)
-{
- switch(sortBy)
- {
- case SortOrder::CANONICAL:
- {
- break;
- }
-
- case SortOrder::REVERSE_CANONICAL:
- {
- std::reverse(result.begin(), result.end());
- break;
- }
-
- default:
- {
- throw std::domain_error{"unsupported sorting order"};
- }
- //TODO: other cases
- }
-}
-
-} // namespace
-
-std::vector<Accessible*> Collection::GetMatches(MatchRule rule, uint32_t sortBy, size_t maxCount)
-{
- std::vector<Accessible*> res;
- auto matcher = Comparer{&rule};
- std::set<Accessible*> visitedNodes;
- VisitNodes(this, res, matcher, maxCount, visitedNodes);
- SortMatchedResult(res, static_cast<SortOrder>(sortBy));
- return res;
-}
-
-std::vector<Accessible*> Collection::GetMatchesInMatches(MatchRule firstRule, MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount)
-{
- std::vector<Accessible*> res;
- std::vector<Accessible*> firstRes;
- auto firstMatcher = Comparer{&firstRule};
- std::set<Accessible*> visitedNodes;
- VisitNodes(this, firstRes, firstMatcher, firstCount, visitedNodes);
-
- if(!firstRes.empty())
- {
- visitedNodes.clear();
- auto secondMatcher = Comparer{&secondRule};
- for(auto* obj : firstRes)
- {
- std::vector<Accessible*> secondRes;
- VisitNodes(obj, secondRes, secondMatcher, secondCount, visitedNodes);
-
- if(!secondRes.empty())
- {
- res.insert(res.end(), secondRes.begin(), secondRes.end());
- }
- }
-
- SortMatchedResult(res, static_cast<SortOrder>(sortBy));
- }
-
- return res;
-}
${adaptor_accessibility_dir}/bridge/bridge-table-cell.cpp
${adaptor_accessibility_dir}/bridge/bridge-text.cpp
${adaptor_accessibility_dir}/bridge/bridge-value.cpp
- ${adaptor_accessibility_dir}/bridge/collection.cpp
${adaptor_accessibility_dir}/bridge/component.cpp
${adaptor_accessibility_dir}/bridge/dbus/dbus-tizen.cpp
)
// EXTERNAL INCLUDES
#include <dali/integration-api/platform-abstraction.h>
-#include <dali/integration-api/shader-integ.h>
-#include <dali/public-api/common/dali-common.h>
#include <errno.h>
#include <unistd.h>
+#include "dali/public-api/common/dali-common.h"
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/shader-precompiler.h>
if(ShaderPreCompiler::Get().IsEnable())
{
TRACE_UPDATE_RENDER_BEGIN("DALI_PRECOMPILE_SHADER");
- ShaderPreCompiler::RawShaderDataList precompiledShaderList;
+ std::vector<RawShaderData> precompiledShaderList;
ShaderPreCompiler::Get().GetPreCompileShaderList(precompiledShaderList);
-
- while(!precompiledShaderList.empty())
+ DALI_LOG_RELEASE_INFO("ShaderPreCompiler[ENABLE], list size:%d \n", precompiledShaderList.size());
+ for(auto precompiledShader = precompiledShaderList.begin(); precompiledShader != precompiledShaderList.end(); ++precompiledShader)
{
if(mIsPreCompileCancelled == TRUE)
{
break;
}
- DALI_LOG_RELEASE_INFO("ShaderPreCompiler[ENABLE], Remained shader list : %zu \n", precompiledShaderList.size());
-
- // We can assume that last element exist.
- const auto& shaderRawData = precompiledShaderList.back();
-
- auto numberOfPrecompiledShader = shaderRawData.shaderCount;
- DALI_LOG_RELEASE_INFO("ShaderPreCompiler[ENABLE], shader count : %u \n", numberOfPrecompiledShader);
- for(auto i = 0u; i < numberOfPrecompiledShader; ++i)
+ auto numberOfPrecompiledShader = precompiledShader->shaderCount;
+ DALI_LOG_RELEASE_INFO("ShaderPreCompiler[ENABLE], shader count :%d \n", numberOfPrecompiledShader);
+ for(int i = 0; i < numberOfPrecompiledShader; ++i)
{
std::string vertexShader;
std::string fragmentShader;
- if(shaderRawData.custom)
+ if(precompiledShader->custom)
{
- vertexShader = shaderRawData.vertexPrefix[i];
- fragmentShader = shaderRawData.fragmentPrefix[i];
+ vertexShader = precompiledShader->vertexPrefix[i].data();
+ fragmentShader = precompiledShader->fragmentPrefix[i].data();
}
else
{
- vertexShader = Dali::Integration::GenerateTaggedShaderPrefix(graphics.GetController().GetGraphicsConfig().GetVertexShaderPrefix()) + shaderRawData.vertexPrefix[i] + std::string(shaderRawData.vertexShader);
- fragmentShader = Dali::Integration::GenerateTaggedShaderPrefix(graphics.GetController().GetGraphicsConfig().GetFragmentShaderPrefix()) + shaderRawData.fragmentPrefix[i] + std::string(shaderRawData.fragmentShader);
+ vertexShader = graphics.GetController().GetGraphicsConfig().GetVertexShaderPrefix() + std::string(precompiledShader->vertexPrefix[i].data()) + std::string(precompiledShader->vertexShader.data());
+ fragmentShader = graphics.GetController().GetGraphicsConfig().GetFragmentShaderPrefix() + std::string(precompiledShader->fragmentPrefix[i].data()) + std::string(precompiledShader->fragmentShader.data());
}
- PreCompileShader(std::move(vertexShader), std::move(fragmentShader), static_cast<uint32_t>(i) < shaderRawData.shaderName.size() ? shaderRawData.shaderName[i] : "");
- DALI_LOG_RELEASE_INFO("ShaderPreCompiler[ENABLE], precompile shader [%u/%u] >> %s \n", i + 1u, numberOfPrecompiledShader, shaderRawData.shaderName.size() ? shaderRawData.shaderName[i].c_str() : "");
+ PreCompileShader(std::move(vertexShader), std::move(fragmentShader), static_cast<uint32_t>(i) < precompiledShader->shaderName.size() ? std::string(precompiledShader->shaderName[i]) : "");
+ DALI_LOG_RELEASE_INFO("ShaderPreCompiler[ENABLE], precompile shader >> %s \n", precompiledShader->shaderName.size() ? std::string(precompiledShader->shaderName[i]).c_str() : "");
}
-
- // Pop last one.
- precompiledShaderList.pop_back();
}
TRACE_UPDATE_RENDER_END("DALI_PRECOMPILE_SHADER");
}
}
TRACE_UPDATE_RENDER_BEGIN("DALI_RENDER_THREAD_FINISH");
- // Remove pre-compiled program before context destroyed
- ShaderPreCompiler::Get().ClearPreCompiledPrograms();
- ShaderPreCompiler::Get().Enable(false);
-
// Inform core of context destruction
mCore.ContextDestroyed();
bool currentInside = IsIntersection(cursor.x + position.GetX(), cursor.y + position.GetY(), position.GetX(), position.GetY(), size.GetWidth(), size.GetHeight());
// Calculate Drag Enter, Leave, Move Event
- if(currentInside && !mDropWindowTargets[targetIndex].inside)
+ if(currentInside && !mDropTargets[targetIndex].inside)
{
- mDropWindowTargets[targetIndex].inside = true;
+ mDropTargets[targetIndex].inside = true;
// Call Enter Event
dragEvent.SetAction(Dali::DragAndDrop::DragType::ENTER);
dragEvent.SetPosition(cursor);
- mDropWindowTargets[targetIndex].callback(dragEvent);
+ mDropTargets[targetIndex].callback(dragEvent);
// Accept Offer
ecore_wl2_offer_mimes_set(event->offer, mimes);
}
- else if(!currentInside && mDropWindowTargets[targetIndex].inside)
+ else if(!currentInside && mDropTargets[targetIndex].inside)
{
- mDropWindowTargets[targetIndex].inside = false;
+ mDropTargets[targetIndex].inside = false;
// Call Leave Event
dragEvent.SetAction(Dali::DragAndDrop::DragType::LEAVE);
dragEvent.SetPosition(cursor);
- mDropWindowTargets[targetIndex].callback(dragEvent);
+ mDropTargets[targetIndex].callback(dragEvent);
// Reject Offer
ecore_wl2_offer_accept(event->offer, nullptr);
}
- else if(currentInside && mDropWindowTargets[targetIndex].inside)
+ else if(currentInside && mDropTargets[targetIndex].inside)
{
// Call Move Event
dragEvent.SetAction(Dali::DragAndDrop::DragType::MOVE);
dragEvent.SetPosition(cursor);
- mDropWindowTargets[targetIndex].callback(dragEvent);
+ mDropTargets[targetIndex].callback(dragEvent);
}
}
/*
- * 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.
- * 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.
- *
- */
+* 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.
+* 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.
+*
+*/
#include <dali/integration-api/debug.h>
#include <dali/internal/graphics/common/shader-parser.h>
}
}
-} // namespace Dali::Internal::ShaderParser
+} // namespace Dali::Internal::ShaderParser
\ No newline at end of file
void operator()(T* object)
{
- // GLES object deleter should skip discard queue if controller shutting down
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
- {
- // Discard resource (add it to discard queue)
- object->DiscardResource();
- }
- else
- {
- // Destroy and delete object otherwise
- if(DALI_LIKELY(object))
- {
- object->DestroyResource();
- }
- delete object;
- }
+ // Discard resource (add it to discard queue)
+ object->DiscardResource();
}
};
const uint32_t TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB = 1;
DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_EGL, false);
-
-bool gIsShuttingDown = true; ///< Global static flag to ensure that we have single graphics controller instance per each UpdateRender thread loop.
} // namespace
-bool EglGraphicsController::IsShuttingDown()
-{
- return gIsShuttingDown;
-}
-
EglGraphicsController::EglGraphicsController()
: mTextureDependencyChecker(*this),
mSyncPool(*this)
void EglGraphicsController::InitializeGLES(Integration::GlAbstraction& glAbstraction)
{
DALI_LOG_RELEASE_INFO("Initializing Graphics Controller Phase 1\n");
-
mGlAbstraction = &glAbstraction;
mContext = std::make_unique<GLES::Context>(*this, mGlAbstraction);
mCurrentContext = mContext.get();
DALI_LOG_RELEASE_INFO("Initializing Graphics Controller Phase 2\n");
auto* syncImplPtr = static_cast<Internal::Adaptor::EglSyncImplementation*>(&syncImplementation);
- DALI_ASSERT_ALWAYS(gIsShuttingDown && "Don't initialize Phase 2 EglGraphicsController twice");
- gIsShuttingDown = false;
-
mEglSyncImplementation = syncImplPtr;
mGraphics = &graphicsInterface;
}
Flush();
}
-void EglGraphicsController::Shutdown()
-{
- DALI_ASSERT_ALWAYS(!gIsShuttingDown && "Don't call EglGraphicsController::Shutdown twice");
- gIsShuttingDown = true;
-
- // Final flush
- Flush();
-
- if(mContext)
- {
- mContext->GlContextDestroyed();
- }
-
- for(auto&& context : mSurfaceContexts)
- {
- if(context.second)
- {
- context.second->GlContextDestroyed();
- }
- }
-}
-
void EglGraphicsController::PresentRenderTarget(RenderTarget* renderTarget)
{
GLES::CommandBuffer* presentCommandBuffer{nullptr};
return texture;
}
-bool EglGraphicsController::HasClipMatrix() const
-{
- return false;
-}
-
-const Matrix& EglGraphicsController::GetClipMatrix() const
-{
- return Matrix::IDENTITY;
-}
-
} // namespace Dali::Graphics
class EglGraphicsController : public Graphics::Controller
{
public:
- /**
- * @brief Get whether is graphics controller shutting down or not.
- */
- static bool IsShuttingDown();
-
/**
* @brief Constructor
*/
/**
* @copydoc Dali::Graphics::Shutdown()
*/
- void Shutdown() override;
+ void Shutdown() override
+ {
+ mIsShuttingDown = true;
+
+ // Final flush
+ Flush();
+
+ if(mContext)
+ {
+ mContext->GlContextDestroyed();
+ }
+
+ for(auto&& context : mSurfaceContexts)
+ {
+ if(context.second)
+ {
+ context.second->GlContextDestroyed();
+ }
+ }
+ }
/**
* @copydoc Dali::Graphics::Destroy()
public:
[[nodiscard]] Integration::GlAbstraction* GetGL() const
{
- if(DALI_UNLIKELY(IsShuttingDown()))
+ if(mIsShuttingDown)
{
return nullptr;
}
mGLESVersion = glesVersion;
}
+ bool IsShuttingDown() const
+ {
+ return mIsShuttingDown;
+ }
+
/**
* @brief Reset texture cache in the contexts
*/
return mCapacity;
}
- bool HasClipMatrix() const override;
- const Matrix& GetClipMatrix() const override;
-
private:
Integration::GlAbstraction* mGlAbstraction{nullptr};
Integration::GlContextHelperAbstraction* mGlContextHelperAbstraction{nullptr};
GLES::GLESVersion mGLESVersion{GLES::GLESVersion::GLES_20}; ///< Runtime supported GLES version
uint32_t mTextureUploadTotalCPUMemoryUsed{0u};
+ bool mIsShuttingDown{false}; ///< Indicates whether the controller is shutting down
+
std::queue<const GLES::CommandBuffer*> mPresentationCommandBuffers{}; ///< Queue of reusable command buffers used by presentation engine
void* mSharedContext{nullptr}; ///< Shared EGL context
void SyncObject::DestroyResource()
{
- if(DALI_UNLIKELY(EglGraphicsController::IsShuttingDown()))
- {
- return;
- }
- mEglSyncImplementation.DestroySyncObject(mEglSyncObject);
- mEglSyncObject = nullptr;
}
bool SyncObject::InitializeResource()
{
// Called from custom deleter.
// Don't use discard queue, drop immediately.
- DestroyResource();
+ mEglSyncImplementation.DestroySyncObject(mEglSyncObject);
+ mEglSyncObject = nullptr;
}
bool SyncObject::IsSynced()
void Buffer::InitializeGPUBuffer()
{
- if(DALI_UNLIKELY(EglGraphicsController::IsShuttingDown()))
- {
- return;
- }
-
auto context = mController.GetCurrentContext();
auto gl = mController.GetGL();
if(!gl || !context)
// Deestroy GPU allocation
else
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ auto gl = mController.GetGL();
+ if(gl)
{
- auto gl = mController.GetGL();
- if(gl)
- {
- gl->DeleteBuffers(1, &mBufferId);
- }
+ gl->DeleteBuffers(1, &mBufferId);
}
}
}
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
void Framebuffer::DestroyResource()
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ auto context = mController.GetCurrentContext();
+ auto gl = mController.GetGL();
+ if(gl && context && mInitialized)
{
- auto context = mController.GetCurrentContext();
- auto gl = mController.GetGL();
- if(gl && context && mInitialized)
+ if(mDepthBufferId)
{
- if(mDepthBufferId)
- {
- gl->DeleteRenderbuffers(1, &mDepthBufferId);
- }
- if(mStencilBufferId)
- {
- gl->DeleteRenderbuffers(1, &mStencilBufferId);
- }
+ gl->DeleteRenderbuffers(1, &mDepthBufferId);
+ }
+ if(mStencilBufferId)
+ {
+ gl->DeleteRenderbuffers(1, &mStencilBufferId);
+ }
- context->DeleteFramebuffers(1, &mFramebufferId);
+ context->DeleteFramebuffers(1, &mFramebufferId);
- mFramebufferId = 0u;
- mInitialized = false;
- }
+ mFramebufferId = 0u;
+ mInitialized = false;
}
}
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
void operator()(T* object)
{
- // Discard resource (add it to discard queue) if controller is not shutting down
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ // Discard resource (add it to discard queue)
+ object->DiscardResource();
+ }
+};
+
+template<>
+struct CachedObjectDeleter<GLES::Program>
+{
+ CachedObjectDeleter() = default;
+
+ void operator()(GLES::Program* object)
+ {
+ // Program deleter should skip discard queue if controller shutting down
+ if(!object->GetController().IsShuttingDown())
{
object->DiscardResource();
}
else
{
- // Destroy and delete object otherwise
- if(DALI_LIKELY(object))
- {
- object->DestroyResource();
- }
+ // delete object otherwise
delete object;
}
}
for(auto& item : mImpl->shaderEntries)
{
auto& itemInfo = item.shaderImpl->GetCreateInfo();
-
- // Check metadata
if(itemInfo.pipelineStage != shaderCreateInfo.pipelineStage ||
itemInfo.shaderlanguage != shaderCreateInfo.shaderlanguage ||
- itemInfo.sourceMode != shaderCreateInfo.sourceMode)
- {
- continue;
- }
-
- // Get offset of source. Since prefix might be removed after ShaderImpl created,
- // we should compare only after the offset.
- auto sourceOffset = item.shaderImpl->GetSourceOffset();
- if(itemInfo.sourceSize + sourceOffset != shaderCreateInfo.sourceSize)
+ itemInfo.sourceMode != shaderCreateInfo.sourceMode ||
+ itemInfo.sourceSize != shaderCreateInfo.sourceSize)
{
continue;
}
- if(memcmp(itemInfo.sourceData, reinterpret_cast<const uint8_t*>(shaderCreateInfo.sourceData) + sourceOffset, itemInfo.sourceSize) == 0)
+ if(memcmp(itemInfo.sourceData, shaderCreateInfo.sourceData, itemInfo.sourceSize) == 0)
{
return item.shaderImpl.get();
}
void PipelineImpl::Bind(const uint32_t glProgram) const
{
- if(DALI_UNLIKELY(EglGraphicsController::IsShuttingDown()))
- {
- return; // Early out if shutting down
- }
-
if(auto gl = GetController().GetGL())
{
gl->UseProgram(glProgram);
bool ProgramImpl::Destroy()
{
- if(DALI_UNLIKELY(EglGraphicsController::IsShuttingDown()))
- {
- return false; // Early out if shutting down
- }
-
if(mImpl->glProgram)
{
auto gl = mImpl->controller.GetGL();
const auto& extraInfos = reflection.GetStandaloneUniformExtraInfo();
- if(DALI_UNLIKELY(EglGraphicsController::IsShuttingDown()))
- {
- return; // Early out if shutting down
- }
-
auto* gl = GetController().GetGL();
if(!gl)
{
// Make a copy of source code. if code is meant to be used
// by modern parser, skip the prefix part
+ size_t dataStartIndex = 0;
size_t dataSize;
- ShaderImpl::StripLegacyCodeIfNeeded(_createInfo, sourceOffset, glslVersion, dataSize);
+ ShaderImpl::StripLegacyCodeIfNeeded(_createInfo, dataStartIndex, glslVersion, dataSize);
source.resize(dataSize);
- std::copy(reinterpret_cast<const uint8_t*>(_createInfo.sourceData) + sourceOffset,
- reinterpret_cast<const uint8_t*>(_createInfo.sourceData) + sourceOffset + dataSize,
+ std::copy(reinterpret_cast<const uint8_t*>(_createInfo.sourceData) + dataStartIndex,
+ reinterpret_cast<const uint8_t*>(_createInfo.sourceData) + dataStartIndex + dataSize,
source.data());
// Substitute pointer
std::vector<uint8_t> source{};
std::vector<uint8_t> sourcePreprocessed{};
- size_t sourceOffset{0u}; /// byte offset of source data from original CreateInfo.
- /// It will be changed after call StripLegacyCodeIfNeeded
- /// More detail, createInfo.sourceData[0] == source[0] == (original CreateInfo).sourceData[sourceOffset];
-
uint32_t glShader{};
uint32_t refCount{0u};
uint32_t flushCount{0u}; ///< Number of frames at refCount=0
ShaderImpl::~ShaderImpl()
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ if(!mImpl->controller.IsShuttingDown())
{
mImpl->Destroy();
}
return mImpl->glslVersion;
}
-[[nodiscard]] size_t ShaderImpl::GetSourceOffset() const
-{
- return mImpl->sourceOffset;
-}
-
/**
* @brief Compiles shader
*
void ShaderImpl::StripLegacyCodeIfNeeded(const ShaderCreateInfo& info, size_t& startIndex, uint32_t& glslVersion, size_t& finalDataSize)
{
- startIndex = 0u;
-
- // Fast-out if shader is not a text.
- if(info.sourceMode != ShaderSourceMode::TEXT)
- {
- glslVersion = info.shaderVersion;
- finalDataSize = info.sourceSize;
- return;
- }
-
// Make a copy of source code. if code is meant to be used
// by modern parser, skip the prefix part
auto text = reinterpret_cast<const char*>(info.sourceData);
else if(result == 0)
{
char* end;
- startIndex = std::strtoul(reinterpret_cast<const char*>(info.sourceData) + 21, &end, 10);
- glslVersion = info.shaderVersion;
+ startIndex = std::strtoul(reinterpret_cast<const char*>(info.sourceData) + 21, &end, 10);
}
}
else
{
if(!mShader->Release())
{
- if(DALI_UNLIKELY(EglGraphicsController::IsShuttingDown()))
- {
- return; // Early out if shutting down
- }
-
GetImplementation()->GetController().GetPipelineCache().MarkShaderCacheFlushRequired();
}
}
void Shader::DiscardResource()
{
- GetImplementation()->GetController().DiscardResource(this);
+ auto& controller = GetImplementation()->GetController();
+ if(!controller.IsShuttingDown())
+ {
+ controller.DiscardResource(this);
+ }
}
uint32_t Shader::GetGLSLVersion() const
*/
[[nodiscard]] uint32_t GetGLSLVersion() const;
- /**
- * @brief Returns source prefix offset infomation.
- * @return Returns source prefix offset value
- */
- [[nodiscard]] size_t GetSourceOffset() const;
-
private:
friend class Shader;
struct Impl;
void Texture::DestroyResource()
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ auto gl = mController.GetGL();
+ if(!gl)
{
- auto gl = mController.GetGL();
- if(!gl)
- {
- return;
- }
-
- // This is a proper destructor
- if(mTextureId)
- {
- gl->DeleteTextures(1, &mTextureId);
- }
+ return;
+ }
- // TODO : Shouldn't we call DestroyResource even if shutting down?
- // For now, we use EglExtensions API at DestroyResource. So just block for now.
- if(mCreateInfo.nativeImagePtr)
- {
- mCreateInfo.nativeImagePtr->DestroyResource();
- }
+ // This is a proper destructor
+ if(mTextureId)
+ {
+ gl->DeleteTextures(1, &mTextureId);
+ }
+ if(mCreateInfo.nativeImagePtr)
+ {
+ mCreateInfo.nativeImagePtr->DestroyResource();
}
}
void SyncObject::DestroyResource()
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
- {
- auto gl = mController.GetGL();
- if(gl)
- {
- gl->DeleteSync(mGlSyncObject);
- }
- mGlSyncObject = 0;
- }
}
bool SyncObject::InitializeResource()
{
// Called from custom deleter.
// Don't use discard queue, drop immediately.
- DestroyResource();
+ auto gl = mController.GetGL();
+ if(gl)
+ {
+ gl->DeleteSync(mGlSyncObject);
+ }
+ mGlSyncObject = 0;
}
bool SyncObject::IsSynced()
AgingSyncObject::~AgingSyncObject()
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ if(!controller.IsShuttingDown())
{
if(egl)
{
void Memory2::Unlock(bool flush)
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ if(auto gl = mController.GetGL())
{
- if(auto gl = mController.GetGL())
+ // for buffer...
+ if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
{
- // for buffer...
- if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
+ auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
+ if(!buffer->IsCPUAllocated())
{
- auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
- if(!buffer->IsCPUAllocated())
- {
- buffer->Bind(BufferUsage::VERTEX_BUFFER);
- gl->BufferSubData(GL_ARRAY_BUFFER, GLintptr(mMapBufferInfo.offset), GLsizeiptr(mMapBufferInfo.size), mMappedPointer);
- }
+ buffer->Bind(BufferUsage::VERTEX_BUFFER);
+ gl->BufferSubData(GL_ARRAY_BUFFER, GLintptr(mMapBufferInfo.offset), GLsizeiptr(mMapBufferInfo.size), mMappedPointer);
}
+ }
- if(mIsAllocatedLocally)
- {
- free(mMappedPointer);
- mMappedPointer = nullptr;
- }
+ if(mIsAllocatedLocally)
+ {
+ free(mMappedPointer);
+ mMappedPointer = nullptr;
+ }
- if(flush)
- {
- Flush();
- }
+ if(flush)
+ {
+ Flush();
}
}
}
void* Memory3::LockRegion(uint32_t offset, uint32_t size)
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ if(auto gl = mController.GetGL())
{
- if(auto gl = mController.GetGL())
+ if(mMapObjectType == MapObjectType::BUFFER)
{
- if(mMapObjectType == MapObjectType::BUFFER)
- {
- auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
+ auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
- if(buffer->IsCPUAllocated())
- {
- using Ptr = char*;
- mMappedPointer = Ptr(buffer->GetCPUAllocatedAddress()) + offset;
- }
- else
- {
- gl->BindBuffer(GL_COPY_WRITE_BUFFER, buffer->GetGLBuffer());
- void* ptr = nullptr;
- ptr = gl->MapBufferRange(GL_COPY_WRITE_BUFFER, GLintptr(mMapBufferInfo.offset), GLsizeiptr(mMapBufferInfo.size), GL_MAP_WRITE_BIT);
- mMappedPointer = ptr;
- }
- return mMappedPointer;
+ if(buffer->IsCPUAllocated())
+ {
+ using Ptr = char*;
+ mMappedPointer = Ptr(buffer->GetCPUAllocatedAddress()) + offset;
+ }
+ else
+ {
+ gl->BindBuffer(GL_COPY_WRITE_BUFFER, buffer->GetGLBuffer());
+ void* ptr = nullptr;
+ ptr = gl->MapBufferRange(GL_COPY_WRITE_BUFFER, GLintptr(mMapBufferInfo.offset), GLsizeiptr(mMapBufferInfo.size), GL_MAP_WRITE_BIT);
+ mMappedPointer = ptr;
}
+ return mMappedPointer;
}
}
return nullptr;
void Memory3::Unlock(bool flush)
{
- if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+ if(auto gl = mController.GetGL())
{
- if(auto gl = mController.GetGL())
+ if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
{
- if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
+ auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
+ if(!buffer->IsCPUAllocated())
{
- auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
- if(!buffer->IsCPUAllocated())
- {
- gl->BindBuffer(GL_COPY_WRITE_BUFFER, buffer->GetGLBuffer());
- gl->UnmapBuffer(GL_COPY_WRITE_BUFFER);
- }
+ gl->BindBuffer(GL_COPY_WRITE_BUFFER, buffer->GetGLBuffer());
+ gl->UnmapBuffer(GL_COPY_WRITE_BUFFER);
}
+ }
- if(flush)
- {
- Flush();
- }
+ if(flush)
+ {
+ Flush();
}
mMappedPointer = nullptr;
EglSyncImplementation::~EglSyncImplementation()
{
- for(auto& syncObject : mSyncObjects)
- {
- delete static_cast<EglSyncObject*>(syncObject);
- }
- mSyncObjects.Clear();
}
void EglSyncImplementation::Initialize(EglImplementation* eglImpl)
{
BufferImpl* BufferImpl::New(Device& device, size_t size, vk::BufferUsageFlags usageFlags)
{
- return New(device, size, vk::SharingMode(vk::SharingMode::eExclusive), usageFlags, vk::MemoryPropertyFlags(vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent));
+ return New(device, size, vk::SharingMode(vk::SharingMode::eExclusive), usageFlags, vk::MemoryPropertyFlags(vk::MemoryPropertyFlagBits::eHostVisible));
}
BufferImpl* BufferImpl::New(Device& device, size_t size, vk::SharingMode sharingMode, vk::BufferUsageFlags usageFlags, vk::MemoryPropertyFlags memoryProperties)
{
}
-BufferImpl::~BufferImpl()
-{
- Destroy();
-}
-
void BufferImpl::Initialize(vk::MemoryPropertyFlags memoryProperties)
{
// Allocate
requirements.memoryTypeBits,
memoryProperties);
- mMemory = std::make_unique<MemoryImpl>(mDevice, size_t(requirements.size), size_t(requirements.alignment), memoryProperties);
+ mMemory = std::make_unique<MemoryImpl>(mDevice, size_t(requirements.size), size_t(requirements.alignment), ((memoryProperties & vk::MemoryPropertyFlagBits::eHostVisible) == vk::MemoryPropertyFlagBits::eHostVisible));
auto allocateInfo = vk::MemoryAllocateInfo{}
.setMemoryTypeIndex(memoryTypeIndex)
}
}
-void BufferImpl::Destroy()
+void BufferImpl::DestroyNow()
{
- DALI_LOG_INFO(gVulkanFilter, Debug::General, "Destroying buffer: %p\n", static_cast<VkBuffer>(mBuffer));
-
- auto device = mDevice.GetLogicalDevice();
- device.destroyBuffer(mBuffer, mDevice.GetAllocator());
-
- mMemory.reset();
+ DestroyVulkanResources(mDevice.GetLogicalDevice(), mBuffer, mMemory->ReleaseVkObject(), &mDevice.GetAllocator());
mBuffer = nullptr;
mMemory = nullptr;
}
+void BufferImpl::DestroyVulkanResources(vk::Device device, vk::Buffer buffer, vk::DeviceMemory memory, const vk::AllocationCallbacks* allocator)
+{
+ DALI_LOG_INFO(gVulkanFilter, Debug::General, "Invoking deleter function: buffer->%p\n", static_cast<VkBuffer>(buffer));
+
+ device.destroyBuffer(buffer, allocator);
+ device.freeMemory(memory, allocator);
+}
+
Graphics::MemoryRequirements BufferImpl::GetMemoryRequirements()
{
auto requirements = mDevice.GetLogicalDevice().getBufferMemoryRequirements(mBuffer);
#include <dali/graphics-api/graphics-types.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-memory-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-types.h>
#include <dali/internal/graphics/vulkan/vulkan-device.h>
#include <cstdint>
namespace Dali::Graphics::Vulkan
{
-class BufferImpl
+class BufferImpl // : public VkManaged
{
public:
static BufferImpl* New(Vulkan::Device& device, size_t size, vk::BufferUsageFlags usageFlags);
static BufferImpl* New(Vulkan::Device& device, size_t size, vk::SharingMode sharingMode, vk::BufferUsageFlags usageFlags, vk::MemoryPropertyFlags memoryProperties);
- /** Destructor */
- ~BufferImpl();
-
/**
* Returns buffer usage flags
* @return
* @note Calling this function is unsafe and makes any further use of
* buffer invalid.
*/
- void Destroy();
+ void DestroyNow();
BufferImpl(const Buffer&) = delete;
BufferImpl& operator=(const Buffer&) = delete;
#include <dali/public-api/common/dali-common.h>
// EXTERNAL INCLUDES
+#include <cstdint>
namespace Dali::Graphics::Vulkan
{
+
Buffer::Buffer(const Graphics::BufferCreateInfo& createInfo, VulkanGraphicsController& controller)
: BufferResource(createInfo, controller)
{
}
mBufferPtr = nullptr;
}
- else // Destroy GPU allocation
+ // Deestroy GPU allocation
+ else
{
delete(mBufferImpl);
mBufferImpl = nullptr;
* @copydoc Graphics::Vulkan::Resource::InitializeResource();
*/
bool InitializeResource() override;
+ void InitializeCPUBuffer();
+ void InitializeGPUBuffer();
/**
* @return false - Vulkan should always allocate GPU buffers
*/
void DiscardResource() override;
- /**
- * @copydoc Graphics::Vulkan::Resource::GetAllocationCallbacks()
- */
- [[nodiscard]] const Graphics::AllocationCallbacks* GetAllocationCallbacks() const override
- {
- return mCreateInfo.allocationCallbacks;
- }
-
- /**
- * @copydoc Graphics::Vulkan::Resource::InvokeDeleter()
- * Only intended for use by discard queue.
- */
- void InvokeDeleter() override
- {
- this->~Buffer();
- }
-
void Bind(Graphics::BufferUsage bindingTarget) const;
BufferImpl* GetImpl()
return nullptr;
}
-private:
- void InitializeCPUBuffer();
- void InitializeGPUBuffer();
-
private:
union
{
*
*/
-// CLASS HEADER
#include <dali/internal/graphics/vulkan-impl/vulkan-command-buffer-impl.h>
// INTERNAL INCLUDES
#include <dali/internal/graphics/vulkan-impl/vulkan-command-pool-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-framebuffer-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-image-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-image-view-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-pipeline-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-sampler-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-sampler.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-swapchain-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-texture.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-types.h>
#include <dali/internal/graphics/vulkan/vulkan-device.h>
-#include <dali/integration-api/debug.h>
-
-#if defined(DEBUG_ENABLED)
-extern Debug::Filter* gLogCmdBufferFilter;
-#endif
-
namespace Dali
{
namespace Graphics
{
}
-CommandBufferImpl::~CommandBufferImpl()
-{
- Destroy();
-}
-
-void CommandBufferImpl::Destroy()
-{
- // Command buffer Pool cleanup will remove the vulkan command buffer
-}
+CommandBufferImpl::~CommandBufferImpl() = default;
/** Begin recording */
void CommandBufferImpl::Begin(vk::CommandBufferUsageFlags usageFlags,
auto info = vk::CommandBufferBeginInfo{};
vk::CommandBufferInheritanceInfo defaultInheritanceInfo{};
+ defaultInheritanceInfo.sType = vk::StructureType::eCommandBufferInheritanceInfo;
defaultInheritanceInfo.pNext = nullptr;
defaultInheritanceInfo.subpass = 0;
defaultInheritanceInfo.occlusionQueryEnable = false;
// Bind if pipeline is ready (if nullptr, pipeline isn't ready).
// If pipeline is valid, bind it early
-
if(pipelineImpl.GetVkPipeline())
{
mCommandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipelineImpl.GetVkPipeline());
-
- mCurrentProgram = pipelineImpl.GetProgram()->GetImplementation();
- }
- else
- {
- mCurrentProgram = nullptr;
- }
-}
-
-void CommandBufferImpl::BindVertexBuffers(
- uint32_t firstBinding,
- const std::vector<BufferImpl*>& buffers,
- const std::vector<uint32_t>& offsets)
-{
- // update list of used resources and create an array of VkBuffers
- std::vector<vk::Buffer> vkBuffers;
- vkBuffers.reserve(buffers.size());
- for(auto&& buffer : buffers)
- {
- vkBuffers.emplace_back(buffer->GetVkHandle());
- }
- std::vector<vk::DeviceSize> vkOffsets;
- vkOffsets.reserve(offsets.size());
- for(auto&& offset : offsets)
- {
- vkOffsets.emplace_back(static_cast<vk::DeviceSize>(offset));
}
- mCommandBuffer.bindVertexBuffers(firstBinding, vkBuffers.size(), vkBuffers.data(), vkOffsets.data());
-}
-
-void CommandBufferImpl::BindIndexBuffer(
- BufferImpl& buffer,
- uint32_t offset,
- Format format)
-{
- if(format == Graphics::Format::R16_UINT)
- {
- mCommandBuffer.bindIndexBuffer(buffer.GetVkHandle(), offset, vk::IndexType::eUint16);
- }
- else if(format == Graphics::Format::R32_UINT)
- {
- mCommandBuffer.bindIndexBuffer(buffer.GetVkHandle(), offset, vk::IndexType::eUint32);
- }
-}
-
-void CommandBufferImpl::BindUniformBuffers(const std::vector<UniformBufferBinding>& bindings)
-{
- // Needs descriptor set pools.
- bool standalone = true;
- for(const auto& uniformBinding : bindings)
- {
- if(standalone)
- {
- // First buffer is not used in Vulkan (it's a fake buffer in GLES)
- standalone = false;
- continue;
- }
-
- auto buffer = const_cast<Vulkan::Buffer*>(static_cast<const Vulkan::Buffer*>(uniformBinding.buffer));
-
- CommandBufferImpl::DeferredUniformBinding deferredUniformBinding{};
- deferredUniformBinding.buffer = buffer->GetImpl()->GetVkHandle();
- deferredUniformBinding.offset = uniformBinding.offset;
- deferredUniformBinding.range = uniformBinding.dataSize;
- deferredUniformBinding.binding = uniformBinding.binding;
-
- mDeferredUniformBindings.push_back(deferredUniformBinding);
- }
-}
-
-void CommandBufferImpl::BindTextures(const std::vector<TextureBinding>& textureBindings)
-{
- for(const auto& textureBinding : textureBindings)
- {
- auto texture = static_cast<const Vulkan::Texture*>(textureBinding.texture);
- auto sampler = const_cast<Vulkan::Sampler*>(static_cast<const Vulkan::Sampler*>(textureBinding.sampler));
- auto samplerImpl = sampler ? sampler->GetImpl() : texture->GetSampler();
- auto vkSampler = samplerImpl ? samplerImpl->GetVkHandle() : nullptr;
- // @todo If there is still no sampler, fall back to default?
- if(!vkSampler)
- {
- DALI_LOG_INFO(gLogCmdBufferFilter, Debug::Concise, "No sampler for texture binding\n");
- }
-
- auto image = texture->GetImage();
- auto imageView = texture->GetImageView();
-
- // test if image is valid, skip invalid image
- if(!image || !image->GetVkHandle())
- {
- continue;
- }
-
- // Store: imageView, sampler & texture.binding for later use
- // We don't know at this point what pipeline is bound (As dali-core
- // binds the pipeline after calling this API)
-
- mDeferredTextureBindings.emplace_back();
- mDeferredTextureBindings.back().imageView = imageView->GetVkHandle();
- mDeferredTextureBindings.back().sampler = vkSampler;
- mDeferredTextureBindings.back().binding = textureBinding.binding; // zero indexed
- }
-}
-
-void CommandBufferImpl::BindSamplers(const std::vector<SamplerBinding>& samplerBindings)
-{
- // Unused in core
}
vk::CommandBuffer CommandBufferImpl::GetVkHandle() const
return mPoolAllocationIndex;
}
+bool CommandBufferImpl::OnDestroy()
+{
+ mOwnerCommandPool->ReleaseCommandBuffer(*this);
+ return true;
+}
+
void CommandBufferImpl::Draw(uint32_t vertexCount,
uint32_t instanceCount,
uint32_t firstVertex,
uint32_t firstInstance)
{
- // Example of deferred binding descriptors
- if(mCurrentProgram)
- {
- auto set = mCurrentProgram->AllocateDescriptorSet(-1); // allocate from recent pool
- if(set)
- {
- BindResources(set);
- }
- }
- if(instanceCount == 0)
- {
- instanceCount = 1;
- }
- mCommandBuffer.draw(vertexCount, instanceCount, firstVertex, firstInstance);
}
void CommandBufferImpl::DrawIndexed(uint32_t indexCount,
int32_t vertexOffset,
uint32_t firstInstance)
{
- // Example of deferred binding descriptors
- if(mCurrentProgram)
- {
- auto set = mCurrentProgram->AllocateDescriptorSet(-1); // allocate from recent pool
- if(set)
- {
- BindResources(set);
- }
- }
- // draw here
- if(instanceCount == 0)
- {
- instanceCount = 1;
- }
- mCommandBuffer.drawIndexed(indexCount,
- instanceCount,
- firstIndex,
- static_cast<int32_t>(vertexOffset),
- firstInstance);
-}
-
-void CommandBufferImpl::DrawIndexedIndirect(BufferImpl& buffer,
- uint32_t offset,
- uint32_t drawCount,
- uint32_t stride)
-{
- mCommandBuffer.drawIndexedIndirect(buffer.GetVkHandle(), static_cast<vk::DeviceSize>(offset), drawCount, stride);
-}
-
-void CommandBufferImpl::ExecuteCommandBuffers(std::vector<vk::CommandBuffer>& commandBuffers)
-{
- mCommandBuffer.executeCommands(commandBuffers);
-}
-
-void CommandBufferImpl::SetScissor(Rect2D value)
-{
- mCommandBuffer.setScissor(0, 1, reinterpret_cast<vk::Rect2D*>(&value));
}
-void CommandBufferImpl::SetViewport(Viewport value)
+void CommandBufferImpl::DrawIndexedIndirect(Graphics::Buffer& buffer,
+ uint32_t offset,
+ uint32_t drawCount,
+ uint32_t stride)
{
- mCommandBuffer.setViewport(0, 1, reinterpret_cast<vk::Viewport*>(&value));
}
-void CommandBufferImpl::BindResources(vk::DescriptorSet descriptorSet)
+void CommandBufferImpl::ExecuteCommandBuffers(std::vector<const Graphics::CommandBuffer*>&& commandBuffers)
{
- std::vector<vk::DescriptorImageInfo> imageInfos;
- std::vector<vk::DescriptorBufferInfo> bufferInfos;
- std::vector<vk::WriteDescriptorSet> descriptorWrites;
-
- // Deferred uniform buffer bindings:
- for(auto& uniformBinding : mDeferredUniformBindings)
- {
- bufferInfos.emplace_back();
- bufferInfos.back()
- .setOffset(uniformBinding.offset)
- .setRange(uniformBinding.range)
- .setBuffer(uniformBinding.buffer);
-
- descriptorWrites.emplace_back();
- descriptorWrites.back()
- .setPBufferInfo(&bufferInfos.back())
- .setDescriptorType(vk::DescriptorType::eUniformBuffer)
- .setDescriptorCount(1)
- .setDstSet(descriptorSet)
- .setDstBinding(uniformBinding.binding)
- .setDstArrayElement(0);
- }
-
- auto& reflection = mCurrentProgram->GetReflection();
- auto& samplers = reflection.GetSamplers();
-
- // Deferred texture bindings:
- uint32_t binding = 1;
- for(auto& textureBinding : mDeferredTextureBindings)
- {
- imageInfos.emplace_back();
- imageInfos.back()
- .setImageLayout(vk::ImageLayout::eShaderReadOnlyOptimal)
- .setImageView(textureBinding.imageView)
- .setSampler(textureBinding.sampler);
-
- descriptorWrites.emplace_back();
- for(auto& info : samplers)
- {
- if(info.location == textureBinding.binding)
- {
- binding = info.binding;
- break;
- }
- }
-
- descriptorWrites.back()
- .setPImageInfo(&imageInfos.back())
- .setDescriptorType(vk::DescriptorType::eCombinedImageSampler)
- .setDescriptorCount(1)
- .setDstSet(descriptorSet)
- .setDstBinding(binding)
- .setDstArrayElement(0);
- }
- mGraphicsDevice->GetLogicalDevice().updateDescriptorSets(uint32_t(descriptorWrites.size()), descriptorWrites.data(), 0, nullptr);
-
- auto pipelineLayout = reflection.GetVkPipelineLayout();
-
- mCommandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics,
- pipelineLayout,
- 0,
- 1,
- &descriptorSet, // @note - old impl could use multiple sets (possibly)
- 0,
- nullptr);
- mDeferredTextureBindings.clear();
- mDeferredUniformBindings.clear();
}
} // namespace Vulkan
#include <dali/graphics-api/graphics-types.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-buffer-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-image-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-program-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-types.h>
namespace Dali::Graphics::Vulkan
class CommandPool;
class PipelineImpl;
-class CommandBufferImpl
+class CommandBufferImpl : public VkManaged
{
friend class CommandPool;
public:
CommandBufferImpl() = delete;
- ~CommandBufferImpl();
-
- void Destroy();
+ ~CommandBufferImpl() override;
/** Begin recording */
void Begin(vk::CommandBufferUsageFlags usageFlags, vk::CommandBufferInheritanceInfo* inheritanceInfo);
/** Final validation of the pipeline */
void ValidatePipeline();
- void BindVertexBuffers(
- uint32_t firstBinding,
- const std::vector<Vulkan::BufferImpl*>& buffers,
- const std::vector<uint32_t>& offsets);
- void BindIndexBuffer(Vulkan::BufferImpl& buffer, uint32_t offset, Format format);
- void BindUniformBuffers(const std::vector<UniformBufferBinding>& bindings);
- void BindTextures(const std::vector<TextureBinding>& textureBindings);
- void BindSamplers(const std::vector<SamplerBinding>& samplerBindings);
-
/** Returns Vulkan object associated with the buffer */
[[nodiscard]] vk::CommandBuffer GetVkHandle() const;
* @return Returns true if the command buffer is primary
*/
[[nodiscard]] bool IsPrimary() const;
+
/**
* Allows to issue custom VkRenderPassBeginInfo structure
* @param renderPassBeginInfo
void CopyImage(Vulkan::Image* srcImage, vk::ImageLayout srcLayout, Image* dstImage, vk::ImageLayout dstLayout, const std::vector<vk::ImageCopy>& regions);
- void SetScissor(Rect2D value);
- void SetViewport(Viewport value);
+ /**
+ * Implements VkManaged::OnDestroy
+ * @return
+ */
+ bool OnDestroy() override;
void Draw(
uint32_t vertexCount,
uint32_t firstInstance);
void DrawIndexedIndirect(
- BufferImpl& buffer,
- uint32_t offset,
- uint32_t drawCount,
- uint32_t stride);
+ Graphics::Buffer& buffer,
+ uint32_t offset,
+ uint32_t drawCount,
+ uint32_t stride);
- void ExecuteCommandBuffers(std::vector<vk::CommandBuffer>& commandBuffers);
+ void ExecuteCommandBuffers(std::vector<const Graphics::CommandBuffer*>&& commandBuffers);
private:
/**
*/
[[nodiscard]] uint32_t GetPoolAllocationIndex() const;
- /**
- * Bind all deferred resources before drawing
- */
- void BindResources(vk::DescriptorSet set);
-
private:
// Constructor called by the CommandPool only
CommandBufferImpl(
const vk::CommandBufferAllocateInfo& allocateInfo,
vk::CommandBuffer vulkanHandle);
-private: // Struct for deferring texture binding
- struct DeferredTextureBinding
- {
- vk::ImageView imageView;
- vk::Sampler sampler;
- uint32_t binding;
- };
- struct DeferredUniformBinding
- {
- vk::Buffer buffer;
- uint32_t offset;
- uint32_t range;
- uint32_t binding;
- };
-
private:
- CommandPool* mOwnerCommandPool;
- Device* mGraphicsDevice;
- uint32_t mPoolAllocationIndex;
- vk::CommandBufferAllocateInfo mAllocateInfo{};
- std::vector<DeferredTextureBinding> mDeferredTextureBindings;
- std::vector<DeferredUniformBinding> mDeferredUniformBindings;
+ CommandPool* mOwnerCommandPool;
+ Device* mGraphicsDevice;
+ uint32_t mPoolAllocationIndex;
+ vk::CommandBufferAllocateInfo mAllocateInfo{};
vk::CommandBuffer mCommandBuffer{};
- Vulkan::ProgramImpl* mCurrentProgram{nullptr}; /// To test descriptor sets, will collide with other work
-
bool mRecording{false};
};
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-// CLASS HEADER
-#include <dali/internal/graphics/vulkan-impl/vulkan-command-buffer.h>
-// INTERNAL HEADERS
-#include <dali/internal/graphics/vulkan-impl/vulkan-buffer-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-buffer.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-command-buffer-impl.h>
+#include <dali/internal/graphics/vulkan-impl/vulkan-command-buffer.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-command-pool-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-framebuffer-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-graphics-controller.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-program-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-render-pass-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-render-pass.h>
#include <dali/internal/graphics/vulkan/vulkan-device.h>
-
-#include <dali/integration-api/debug.h>
#include <dali/internal/window-system/common/window-render-surface.h>
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogCmdBufferFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VK_COMMAND_BUFFER");
-#endif
+#include <dali/internal/graphics/vulkan-impl/vulkan-command-buffer-impl.h>
namespace Dali::Graphics::Vulkan
{
-template<typename VT, typename GT>
-VT* ConstGraphicsCast(const GT* object)
-{
- return const_cast<VT*>(static_cast<const VT*>(object));
-}
-
CommandBuffer::CommandBuffer(const Graphics::CommandBufferCreateInfo& createInfo, VulkanGraphicsController& controller)
: CommandBufferResource(createInfo, controller),
mCommandBufferImpl(nullptr)
void CommandBuffer::DestroyResource()
{
- // Don't delete the impl, it's pool allocated and should have been
- // returned to the command pool for re-use.
- mCommandBufferImpl = nullptr;
}
bool CommandBuffer::InitializeResource()
void CommandBuffer::DiscardResource()
{
- mController.DiscardResource(this);
}
void CommandBuffer::Begin(const Graphics::CommandBufferBeginInfo& info)
{
if(mCommandBufferImpl)
{
- // Check if there is some extra information about used resources
- // if so then apply optimizations
- if(info.resourceBindings)
- {
- // update programs with descriptor pools
- for(auto& binding : *info.resourceBindings)
- {
- if(binding.type == ResourceType::PROGRAM)
- {
- auto programImpl = static_cast<Vulkan::Program*>(binding.programBinding->program)->GetImplementation();
-
- // Pool index is returned and we may do something with it later (storing it per cmdbuf?)
- [[maybe_unused]] auto poolIndex = programImpl->AddDescriptorPool(binding.programBinding->count, 3); // add new pool, limit pools to 3 per program
- }
- }
- }
-
- vk::CommandBufferInheritanceInfo inheritanceInfo{};
- if(info.renderPass)
- {
- auto renderTarget = ConstGraphicsCast<Vulkan::RenderTarget, Graphics::RenderTarget>(info.renderTarget);
- inheritanceInfo.renderPass = renderTarget->GetRenderPass(info.renderPass)->GetVkHandle();
- inheritanceInfo.subpass = 0;
- inheritanceInfo.framebuffer = renderTarget->GetCurrentFramebufferImpl()->GetVkHandle();
- inheritanceInfo.queryFlags = static_cast<vk::QueryControlFlags>(0);
- inheritanceInfo.pipelineStatistics = static_cast<vk::QueryPipelineStatisticFlags>(0);
- }
- mCommandBufferImpl->Begin(static_cast<vk::CommandBufferUsageFlags>(info.usage), &inheritanceInfo);
+ mCommandBufferImpl->Begin(static_cast<vk::CommandBufferUsageFlags>(info.usage), nullptr);
}
}
}
void CommandBuffer::BindVertexBuffers(uint32_t firstBinding,
- const std::vector<const Graphics::Buffer*>& gfxBuffers,
+ const std::vector<const Graphics::Buffer*>& buffers,
const std::vector<uint32_t>& offsets)
{
- std::vector<BufferImpl*> buffers;
- buffers.reserve(gfxBuffers.size());
- for(auto& gfxBuffer : gfxBuffers)
- {
- buffers.push_back(ConstGraphicsCast<Buffer, Graphics::Buffer>(gfxBuffer)->GetImpl());
- }
- mCommandBufferImpl->BindVertexBuffers(firstBinding, buffers, offsets);
-}
-
-void CommandBuffer::BindIndexBuffer(const Graphics::Buffer& gfxBuffer,
- uint32_t offset,
- Format format)
-{
- auto indexBuffer = ConstGraphicsCast<Buffer, Graphics::Buffer>(&gfxBuffer);
- DALI_ASSERT_DEBUG(indexBuffer && indexBuffer->GetImpl());
- mCommandBufferImpl->BindIndexBuffer(*indexBuffer->GetImpl(), offset, format);
}
void CommandBuffer::BindUniformBuffers(const std::vector<UniformBufferBinding>& bindings)
{
- mCommandBufferImpl->BindUniformBuffers(bindings);
}
void CommandBuffer::BindPipeline(const Graphics::Pipeline& pipeline)
void CommandBuffer::BindTextures(const std::vector<TextureBinding>& textureBindings)
{
- mCommandBufferImpl->BindTextures(textureBindings);
}
void CommandBuffer::BindSamplers(const std::vector<SamplerBinding>& samplerBindings)
{
- mCommandBufferImpl->BindSamplers(samplerBindings);
}
void CommandBuffer::BindPushConstants(void* data,
{
}
+void CommandBuffer::BindIndexBuffer(const Graphics::Buffer& buffer,
+ uint32_t offset,
+ Format format)
+{
+}
+
void CommandBuffer::BeginRenderPass(Graphics::RenderPass* gfxRenderPass,
Graphics::RenderTarget* gfxRenderTarget,
Rect2D renderArea,
auto surface = renderTarget->GetSurface();
auto& device = mController.GetGraphicsDevice();
FramebufferImpl* framebuffer;
- RenderPassHandle renderPassImpl;
+ RenderPassImpl* renderPassImpl;
if(surface)
{
auto window = static_cast<Internal::Adaptor::WindowRenderSurface*>(surface);
auto swapchain = device.GetSwapchainForSurfaceId(surfaceId);
mLastSwapchain = swapchain;
framebuffer = swapchain->GetCurrentFramebuffer();
- renderPassImpl = framebuffer->GetImplFromRenderPass(renderPass);
+ renderPassImpl = framebuffer->GetRenderPass(renderPass);
}
else
{
auto coreFramebuffer = renderTarget->GetFramebuffer();
framebuffer = coreFramebuffer->GetImpl();
- renderPassImpl = framebuffer->GetImplFromRenderPass(renderPass);
+ renderPassImpl = framebuffer->GetRenderPass(renderPass);
}
std::vector<vk::ClearValue> vkClearValues;
.setRenderArea({{0, 0}, {renderArea.width, renderArea.height}})
.setPClearValues(vkClearValues.data())
.setClearValueCount(uint32_t(framebuffer->GetClearValues().size())),
- vk::SubpassContents::eSecondaryCommandBuffers);
+ vk::SubpassContents::eInline);
}
void CommandBuffer::EndRenderPass(Graphics::SyncObject* syncObject)
mCommandBufferImpl->EndRenderPass();
}
-void CommandBuffer::ExecuteCommandBuffers(std::vector<const Graphics::CommandBuffer*>&& gfxCommandBuffers)
+void CommandBuffer::ExecuteCommandBuffers(std::vector<const Graphics::CommandBuffer*>&& commandBuffers)
{
- std::vector<vk::CommandBuffer> vkCommandBuffers;
- vkCommandBuffers.reserve(gfxCommandBuffers.size());
- for(auto& gfxCmdBuf : gfxCommandBuffers)
- {
- vkCommandBuffers.push_back(ConstGraphicsCast<CommandBuffer, Graphics::CommandBuffer>(gfxCmdBuf)->GetImpl()->GetVkHandle());
- }
- mCommandBufferImpl->ExecuteCommandBuffers(vkCommandBuffers);
}
void CommandBuffer::Draw(uint32_t vertexCount,
mCommandBufferImpl->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
}
-void CommandBuffer::DrawIndexedIndirect(Graphics::Buffer& gfxBuffer,
+void CommandBuffer::DrawIndexedIndirect(Graphics::Buffer& buffer,
uint32_t offset,
uint32_t drawCount,
uint32_t stride)
{
- auto buffer = ConstGraphicsCast<Buffer, Graphics::Buffer>(&gfxBuffer)->GetImpl();
-
- mCommandBufferImpl->DrawIndexedIndirect(*buffer, offset, drawCount, stride);
+ mCommandBufferImpl->DrawIndexedIndirect(buffer, offset, drawCount, stride);
}
void CommandBuffer::DrawNative(const DrawNativeInfo* drawInfo)
void CommandBuffer::SetScissor(Rect2D value)
{
- // @todo Vulkan accepts array of scissors... add to API
- mCommandBufferImpl->SetScissor(value);
}
void CommandBuffer::SetScissorTestEnable(bool value)
{
- // Enabled by default. What does disabling test do?!
- // Probably should force pipeline to not use dynamic scissor state
}
void CommandBuffer::SetViewport(Viewport value)
{
- mCommandBufferImpl->SetViewport(value);
}
void CommandBuffer::SetViewportEnable(bool value)
{
- // Enabled by default. What does disabling test do?!
- // Probably should force pipeline to not use dynamic viewport state
}
void CommandBuffer::SetColorMask(bool enabled)
public:
CommandBuffer(const Graphics::CommandBufferCreateInfo& createInfo, VulkanGraphicsController& controller);
~CommandBuffer() override;
+ /**
+ * @brief Called when GL resources are destroyed
+ */
+ void DestroyResource() override;
+
+ /**
+ * @brief Called when initializing the resource
+ *
+ * @return True on success
+ */
+ bool InitializeResource() override;
+
+ /**
+ * @brief Called when UniquePtr<> on client-side dies
+ */
+ void DiscardResource() override;
void Begin(const Graphics::CommandBufferBeginInfo& info) override;
*/
void SetDepthWriteEnable(bool depthWriteEnable) override;
-public: // VulkanResource API
- /**
- * @brief Called when GL resources are destroyed
- */
- void DestroyResource() override;
-
- /**
- * @brief Called when initializing the resource
- *
- * @return True on success
- */
- bool InitializeResource() override;
-
- /**
- * @brief Called when UniquePtr<> on client-side dies
- */
- void DiscardResource() override;
-
- /**
- * @copydoc Graphics::Vulkan::Resource::GetAllocationCallbacks()
- */
- [[nodiscard]] const Graphics::AllocationCallbacks* GetAllocationCallbacks() const override
- {
- return mCreateInfo.allocationCallbacks;
- }
-
- /**
- * @copydoc Graphics::Vulkan::Resource::InvokeDeleter()
- * Only intended for use by discard queue.
- */
- void InvokeDeleter() override
- {
- this->~CommandBuffer();
- }
-
-public: // API
+public: //API
/**
* Get the last swapchain referenced by a BeginRenderPass command in this command buffer.
*
#include <dali/internal/graphics/vulkan-impl/vulkan-command-pool-impl.h>
// INTERNAL INCLUDES
-#include <dali/internal/graphics/vulkan-impl/vulkan-command-buffer-impl.h>
#include <dali/internal/graphics/vulkan/vulkan-device.h>
+#include <dali/internal/graphics/vulkan-impl/vulkan-command-buffer-impl.h>
#include <dali/integration-api/debug.h>
*
* Struct: InternalPool
*/
-CommandPool::InternalPool::Node::Node(uint32_t _nextFreeIndex, CommandBufferImpl* _commandBuffer)
-: nextFreeIndex(_nextFreeIndex),
- commandBuffer(_commandBuffer)
+CommandPool::InternalPool::Node::Node( uint32_t _nextFreeIndex, CommandBufferImpl* _commandBuffer )
+: nextFreeIndex( _nextFreeIndex ),
+ commandBuffer( _commandBuffer )
{
}
-CommandPool::InternalPool::InternalPool(CommandPool& owner, Vulkan::Device* graphics, uint32_t initialCapacity, bool isPrimary)
-: mOwner(owner),
- mGraphicsDevice(graphics),
+CommandPool::InternalPool::InternalPool( CommandPool& owner, Vulkan::Device* graphics,
+ uint32_t initialCapacity, bool isPrimary )
+: mOwner( owner ),
+ mGraphicsDevice( graphics ),
mPoolData{},
- mFirstFree(INVALID_NODE_INDEX),
- mCapacity(initialCapacity),
- mAllocationCount(0u),
- mIsPrimary(isPrimary)
+ mFirstFree( INVALID_NODE_INDEX ),
+ mCapacity( initialCapacity ),
+ mAllocationCount( 0u ),
+ mIsPrimary( isPrimary )
{
// don't allocate anything if initial capacity is 0
- if(initialCapacity)
+ if( initialCapacity )
{
- Resize(initialCapacity);
+ Resize( initialCapacity );
}
}
CommandPool::InternalPool::~InternalPool()
{
// free all buffers here
- for(auto&& cmd : mPoolData)
+ for( auto&& cmd : mPoolData )
{
delete cmd.commandBuffer;
}
}
-std::vector<vk::CommandBuffer>
-CommandPool::InternalPool::AllocateVkCommandBuffers(vk::CommandBufferAllocateInfo allocateInfo)
+std::vector< vk::CommandBuffer >
+CommandPool::InternalPool::AllocateVkCommandBuffers( vk::CommandBufferAllocateInfo allocateInfo )
{
- return VkAssert(mGraphicsDevice->GetLogicalDevice().allocateCommandBuffers(allocateInfo));
+ return VkAssert( mGraphicsDevice->GetLogicalDevice().allocateCommandBuffers( allocateInfo ) );
}
-void CommandPool::InternalPool::Resize(uint32_t newCapacity)
+void CommandPool::InternalPool::Resize( uint32_t newCapacity )
{
- if(newCapacity <= mPoolData.size())
+ if( newCapacity <= mPoolData.size() )
{
return;
}
auto diff = newCapacity - mPoolData.size();
auto allocateInfo = vk::CommandBufferAllocateInfo{}
- .setCommandBufferCount(U32(diff))
- .setCommandPool(mOwner.GetVkHandle())
- .setLevel(mIsPrimary ? vk::CommandBufferLevel::ePrimary : vk::CommandBufferLevel::eSecondary);
- auto newBuffers = AllocateVkCommandBuffers(allocateInfo);
+ .setCommandBufferCount( U32( diff ) )
+ .setCommandPool( mOwner.GetVkHandle() )
+ .setLevel( mIsPrimary ? vk::CommandBufferLevel::ePrimary : vk::CommandBufferLevel::eSecondary );
+ auto newBuffers = AllocateVkCommandBuffers( allocateInfo );
- uint32_t i = U32(mPoolData.size() + 1);
+ uint32_t i = U32( mPoolData.size() + 1 );
- mFirstFree = U32(mPoolData.size());
- if(!mPoolData.empty())
+ mFirstFree = U32( mPoolData.size() );
+ if( !mPoolData.empty() )
{
mPoolData.back()
- .nextFreeIndex = U32(mPoolData.size());
+ .nextFreeIndex = U32( mPoolData.size() );
}
- for(auto&& cmdbuf : newBuffers)
+ for( auto&& cmdbuf : newBuffers )
{
- auto commandBuffer = new CommandBufferImpl(mOwner, i - 1, allocateInfo, cmdbuf);
- mPoolData.emplace_back(i, commandBuffer);
+ auto commandBuffer = new CommandBufferImpl( mOwner, i - 1, allocateInfo, cmdbuf );
+ mPoolData.emplace_back( i, commandBuffer );
++i;
}
mPoolData.back().nextFreeIndex = INVALID_NODE_INDEX;
- mCapacity = U32(mPoolData.size());
+ mCapacity = U32( mPoolData.size() );
}
-CommandBufferImpl* CommandPool::InternalPool::AllocateCommandBuffer(bool reset)
+CommandBufferImpl* CommandPool::InternalPool::AllocateCommandBuffer( bool reset )
{
// resize if no more nodes
- if(mFirstFree == INVALID_NODE_INDEX)
+ if( mFirstFree == INVALID_NODE_INDEX )
{
auto newSize = static_cast<uint32_t>(mPoolData.empty() ? 1 : 2 * mPoolData.size());
- Resize(U32(newSize));
+ Resize( U32( newSize ) );
}
auto& node = mPoolData[mFirstFree];
mFirstFree = node.nextFreeIndex;
- if(reset)
+ if( reset )
{
node.commandBuffer->Reset();
}
return node.commandBuffer;
}
-void CommandPool::InternalPool::ReleaseCommandBuffer(CommandBufferImpl& buffer, bool reset)
+void CommandPool::InternalPool::ReleaseCommandBuffer(CommandBufferImpl& buffer, bool reset )
{
- auto indexInPool = buffer.GetPoolAllocationIndex();
+ auto indexInPool = buffer.GetPoolAllocationIndex();
mPoolData[indexInPool].nextFreeIndex = mFirstFree;
- mFirstFree = indexInPool;
+ mFirstFree = indexInPool;
- if(reset)
+ if( reset )
{
buffer.Reset();
}
return mAllocationCount;
}
-CommandPool* CommandPool::New(Device& graphics, const vk::CommandPoolCreateInfo& createInfo)
+CommandPool* CommandPool::New( Device& graphics, const vk::CommandPoolCreateInfo& createInfo )
{
- auto pool = new CommandPool(graphics, createInfo);
+ auto pool = new CommandPool( graphics, createInfo );
if(pool)
{
return pool;
}
-CommandPool* CommandPool::New(Device& graphics)
+CommandPool* CommandPool::New( Device& graphics )
{
- return New(graphics, vk::CommandPoolCreateInfo{});
+ return New( graphics, vk::CommandPoolCreateInfo{} );
}
bool CommandPool::Initialize()
{
- mCreateInfo.setFlags(vk::CommandPoolCreateFlagBits::eResetCommandBuffer);
- mCommandPool = VkAssert(mGraphicsDevice->GetLogicalDevice().createCommandPool(mCreateInfo, mGraphicsDevice->GetAllocator()));
- mInternalPoolPrimary = std::make_unique<InternalPool>(*this, mGraphicsDevice, 0, true);
- mInternalPoolSecondary = std::make_unique<InternalPool>(*this, mGraphicsDevice, 0, false);
+ mCreateInfo.setFlags( vk::CommandPoolCreateFlagBits::eResetCommandBuffer );
+ mCommandPool = VkAssert( mGraphicsDevice->GetLogicalDevice().createCommandPool( mCreateInfo, mGraphicsDevice->GetAllocator() ) );
+ mInternalPoolPrimary = std::make_unique< InternalPool >( *this, mGraphicsDevice, 0, true );
+ mInternalPoolSecondary = std::make_unique< InternalPool >( *this, mGraphicsDevice, 0, false );
return true;
}
-CommandPool::CommandPool(Device& graphics, const vk::CommandPoolCreateInfo& createInfo)
-: mGraphicsDevice(&graphics),
- mCreateInfo(createInfo)
+CommandPool::CommandPool( Device& graphics, const vk::CommandPoolCreateInfo& createInfo )
+: mGraphicsDevice( &graphics ),
+ mCreateInfo( createInfo )
{
}
-CommandPool::~CommandPool()
-{
- Destroy();
-}
+CommandPool::~CommandPool() = default;
vk::CommandPool CommandPool::GetVkHandle() const
{
return *mGraphicsDevice;
}
-CommandBufferImpl* CommandPool::NewCommandBuffer(const vk::CommandBufferAllocateInfo& allocateInfo)
+CommandBufferImpl* CommandPool::NewCommandBuffer( const vk::CommandBufferAllocateInfo& allocateInfo )
{
- return NewCommandBuffer(allocateInfo.level == vk::CommandBufferLevel::ePrimary);
+ return NewCommandBuffer( allocateInfo.level == vk::CommandBufferLevel::ePrimary );
}
-CommandBufferImpl* CommandPool::NewCommandBuffer(bool isPrimary)
+CommandBufferImpl* CommandPool::NewCommandBuffer( bool isPrimary )
{
auto& usedPool = isPrimary ? *mInternalPoolPrimary : *mInternalPoolSecondary;
- return usedPool.AllocateCommandBuffer(false);
+ return usedPool.AllocateCommandBuffer( false );
}
-void CommandPool::Reset(bool releaseResources)
+void CommandPool::Reset( bool releaseResources )
{
mGraphicsDevice->GetLogicalDevice()
- .resetCommandPool(mCommandPool,
- releaseResources ? vk::CommandPoolResetFlagBits::eReleaseResources
- : vk::CommandPoolResetFlags{});
+ .resetCommandPool( mCommandPool,
+ releaseResources ? vk::CommandPoolResetFlagBits::eReleaseResources
+ : vk::CommandPoolResetFlags{} );
}
-bool CommandPool::ReleaseCommandBuffer(CommandBufferImpl& buffer)
+bool CommandPool::ReleaseCommandBuffer(CommandBufferImpl& buffer )
{
- if(buffer.IsPrimary() && mInternalPoolPrimary)
+ if( buffer.IsPrimary() )
{
- mInternalPoolPrimary->ReleaseCommandBuffer(buffer);
+ mInternalPoolPrimary->ReleaseCommandBuffer( buffer );
}
- else if(mInternalPoolSecondary)
+ else
{
- mInternalPoolSecondary->ReleaseCommandBuffer(buffer);
+ mInternalPoolSecondary->ReleaseCommandBuffer( buffer );
}
return false;
}
mInternalPoolSecondary->GetAllocationCount();
}
-uint32_t CommandPool::GetAllocationCount(vk::CommandBufferLevel level) const
+uint32_t CommandPool::GetAllocationCount( vk::CommandBufferLevel level ) const
{
- return level == vk::CommandBufferLevel::ePrimary ? mInternalPoolPrimary->GetAllocationCount() : mInternalPoolSecondary->GetAllocationCount();
+ return level == vk::CommandBufferLevel::ePrimary ?
+ mInternalPoolPrimary->GetAllocationCount() :
+ mInternalPoolSecondary->GetAllocationCount();
}
-void CommandPool::Destroy()
+bool CommandPool::OnDestroy()
{
- auto device = mGraphicsDevice->GetLogicalDevice();
+ auto device = mGraphicsDevice->GetLogicalDevice();
+ auto commandPool = mCommandPool;
auto allocator = &mGraphicsDevice->GetAllocator();
- if(mCommandPool)
- {
- DALI_LOG_INFO(gVulkanFilter, Debug::General, "Destroying command pool: %p\n", static_cast<VkCommandPool>(mCommandPool));
- device.destroyCommandPool(mCommandPool, allocator);
+ mGraphicsDevice->DiscardResource( [ device, commandPool, allocator ]() {
+ DALI_LOG_INFO( gVulkanFilter, Debug::General, "Invoking deleter function: command pool->%p\n",
+ static_cast< VkCommandPool >( commandPool ) )
+ device.destroyCommandPool( commandPool, allocator );
+ } );
- mCommandPool = nullptr;
- }
+ return false;
}
} // namespace Dali::Graphics::Vulkan
class Device;
class CommandBufferImpl;
-class CommandPool
+class CommandPool : public VkManaged
{
public: // Construction, destruction
/**
CommandPool(Device& graphicsDevice, const vk::CommandPoolCreateInfo& createInfo);
- ~CommandPool();
+ ~CommandPool() override;
vk::CommandPool GetVkHandle() const;
bool Initialize();
- void Destroy();
+ bool OnDestroy() override; // TODO: Queue deleter for destruction
/**
* Resets command pool
namespace Dali::Graphics::Vulkan
{
-std::unique_ptr<FenceImpl> FenceImpl::New(Device& graphicsDevice, const vk::FenceCreateInfo& fenceCreateInfo)
+
+FenceImpl* FenceImpl::New(Device& graphicsDevice, const vk::FenceCreateInfo& fenceCreateInfo)
{
- auto fence = std::unique_ptr<FenceImpl>(new FenceImpl(graphicsDevice));
+ auto fence = new FenceImpl(graphicsDevice);
fence->Initialize(fenceCreateInfo);
return fence;
}
// EXTERNAL INCLUDES
#include <limits>
-#include <memory>
namespace Dali::Graphics::Vulkan
{
class FenceImpl
{
public:
- static std::unique_ptr<FenceImpl> New(Device& graphicsDevice, const vk::FenceCreateInfo& fenceCreateInfo);
+ static FenceImpl* New(Device& graphicsDevice, const vk::FenceCreateInfo& fenceCreateInfo);
FenceImpl(Device& graphicsDevice);
namespace Dali::Graphics::Vulkan
{
-FramebufferAttachment* FramebufferAttachment::NewColorAttachment(std::unique_ptr<ImageView>& imageView,
- vk::ClearColorValue clearColorValue,
- bool presentable)
+FramebufferAttachment* FramebufferAttachment::NewColorAttachment(ImageView* imageView,
+ vk::ClearColorValue clearColorValue,
+ bool presentable)
{
assert(imageView->GetImage()->GetUsageFlags() & vk::ImageUsageFlagBits::eColorAttachment);
}
FramebufferAttachment* FramebufferAttachment::NewDepthAttachment(
- std::unique_ptr<ImageView>& imageView,
- vk::ClearDepthStencilValue clearDepthStencilValue)
+ ImageView* imageView,
+ vk::ClearDepthStencilValue clearDepthStencilValue)
{
assert(imageView->GetImage()->GetUsageFlags() & vk::ImageUsageFlagBits::eDepthStencilAttachment);
return attachment;
}
-FramebufferAttachment::FramebufferAttachment(std::unique_ptr<ImageView>& imageView,
- vk::ClearValue clearColor,
- AttachmentType type,
- bool presentable)
-: mClearValue(clearColor),
+FramebufferAttachment::FramebufferAttachment(ImageView* imageView,
+ vk::ClearValue clearColor,
+ AttachmentType type,
+ bool presentable)
+: mImageView(imageView),
+ mClearValue(clearColor),
mType(type)
{
- mImageView.swap(imageView);
- auto image = mImageView->GetImage();
+ auto image = imageView->GetImage();
auto sampleCountFlags = image->GetSampleCount();
ImageView* FramebufferAttachment::GetImageView() const
{
- return mImageView.get();
+ return mImageView;
}
const vk::AttachmentDescription& FramebufferAttachment::GetDescription() const
bool FramebufferAttachment::IsValid() const
{
- return mImageView != nullptr;
+ return mImageView;
}
// FramebufferImpl -------------------------------
FramebufferImpl* FramebufferImpl::New(
- Vulkan::Device& device,
- RenderPassHandle renderPass,
- OwnedAttachments& attachments,
- uint32_t width,
- uint32_t height,
- bool hasDepthAttachments)
+ Vulkan::Device& device,
+ RenderPassImpl* renderPass,
+ std::vector<FramebufferAttachment*>& attachments,
+ uint32_t width,
+ uint32_t height,
+ bool hasDepthAttachments)
{
- DALI_ASSERT_ALWAYS(renderPass && "You require more render passes!");
-
std::vector<vk::ImageView> imageViewAttachments;
- for(auto& attachment : attachments)
- {
- imageViewAttachments.emplace_back(attachment->GetImageView()->GetVkHandle());
- }
- auto framebufferCreateInfo = vk::FramebufferCreateInfo{}
- .setRenderPass(renderPass->GetVkHandle())
- .setPAttachments(imageViewAttachments.data())
- .setLayers(1)
- .setWidth(width)
- .setHeight(height)
- .setAttachmentCount(U32(attachments.size()));
+ DALI_ASSERT_ALWAYS(renderPass != nullptr && "You require more render passes!");
+
+ std::transform(attachments.cbegin(),
+ attachments.cend(),
+ std::back_inserter(imageViewAttachments),
+ [&](FramebufferAttachment* entry) {
+ return entry->GetImageView()->GetVkHandle();
+ });
+
+ auto framebufferCreateInfo = vk::FramebufferCreateInfo{}.setRenderPass(renderPass->GetVkHandle()).setPAttachments(imageViewAttachments.data()).setLayers(1).setWidth(width).setHeight(height).setAttachmentCount(U32(attachments.size()));
auto vkFramebuffer = VkAssert(device.GetLogicalDevice().createFramebuffer(framebufferCreateInfo, device.GetAllocator()));
return new FramebufferImpl(device,
attachments,
vkFramebuffer,
- renderPass,
+ *renderPass,
width,
height,
hasDepthAttachments);
}
FramebufferImpl* FramebufferImpl::New(
- Vulkan::Device& device,
- RenderPassHandle renderPass,
- OwnedAttachments& colorAttachments,
- std::unique_ptr<FramebufferAttachment>& depthAttachment,
- uint32_t width,
- uint32_t height)
+ Vulkan::Device& device,
+ RenderPassImpl* renderPass,
+ const std::vector<FramebufferAttachment*>& colorAttachments,
+ FramebufferAttachment* depthAttachment,
+ uint32_t width,
+ uint32_t height)
{
assert((!colorAttachments.empty() || depthAttachment) && "Cannot create framebuffer. Please provide at least one attachment");
- auto colorAttachmentsValid = true;
- std::vector<FramebufferAttachment*> attachments;
+ auto colorAttachmentsValid = true;
for(auto& attachment : colorAttachments)
{
- attachments.emplace_back(attachment.get());
if(!attachment->IsValid())
{
colorAttachmentsValid = false;
}
// This vector stores the attachments (vk::ImageViews)
+ auto attachments = std::vector<FramebufferAttachment*>{};
// Flag that indicates if the render pass is externally provided
- if(!renderPass)
+ if(renderPass == nullptr)
{
- // Create compatible vulkan render pass
- renderPass = RenderPassImpl::New(device, attachments, depthAttachment.get());
+ // Create compatible render pass
+ renderPass = RenderPassImpl::New(device, colorAttachments, depthAttachment);
}
-
- OwnedAttachments ownedAttachments(std::move(colorAttachments));
+ attachments.reserve(colorAttachments.size());
+ attachments.insert(attachments.begin(), colorAttachments.begin(), colorAttachments.end());
if(hasDepth)
{
- ownedAttachments.emplace_back(std::move(depthAttachment));
+ attachments.push_back(depthAttachment);
}
- return FramebufferImpl::New(device, renderPass, ownedAttachments, width, height, hasDepth);
+ return FramebufferImpl::New(device, renderPass, attachments, width, height, hasDepth);
}
-FramebufferImpl::FramebufferImpl(Device& graphicsDevice,
- OwnedAttachments& attachments,
- vk::Framebuffer vkHandle,
- RenderPassHandle renderPassImpl,
- uint32_t width,
- uint32_t height,
- bool hasDepthAttachment)
+FramebufferImpl::FramebufferImpl(Device& graphicsDevice,
+ const std::vector<FramebufferAttachment*>& attachments,
+ vk::Framebuffer vkHandle,
+ const RenderPassImpl& renderPassImpl,
+ uint32_t width,
+ uint32_t height,
+ bool hasDepthAttachment)
: mGraphicsDevice(&graphicsDevice),
mWidth(width),
mHeight(height),
- mAttachments(std::move(attachments)),
+ mAttachments(attachments),
mFramebuffer(vkHandle),
mHasDepthAttachment(hasDepthAttachment)
{
- mRenderPasses.emplace_back(RenderPassMapElement{nullptr, renderPassImpl});
-}
-
-void FramebufferImpl::Destroy()
-{
- auto device = mGraphicsDevice->GetLogicalDevice();
-
- mRenderPasses.clear();
- mAttachments.clear();
-
- if(mFramebuffer)
- {
- auto allocator = &mGraphicsDevice->GetAllocator();
-
- DALI_LOG_INFO(gVulkanFilter, Debug::General, "Destroying Framebuffer: %p\n", static_cast<VkFramebuffer>(mFramebuffer));
- device.destroyFramebuffer(mFramebuffer, allocator);
- }
- mFramebuffer = nullptr;
+ mRenderPasses.push_back(RenderPassMapElement{nullptr, const_cast<RenderPassImpl*>(&renderPassImpl)});
}
uint32_t FramebufferImpl::GetWidth() const
{
case AttachmentType::COLOR:
{
- return mAttachments[index].get();
+ return mAttachments[index];
}
case AttachmentType::DEPTH_STENCIL:
{
if(mHasDepthAttachment)
- {
- return mAttachments.back().get();
- }
+ return mAttachments.back();
}
case AttachmentType::INPUT:
case AttachmentType::RESOLVE:
{
auto numColorAttachments = mHasDepthAttachment ? mAttachments.size() - 1 : mAttachments.size();
retval.reserve(numColorAttachments);
- for(size_t i = 0; i < numColorAttachments; ++i)
- {
- retval.emplace_back(mAttachments[i].get());
- }
+ retval.insert(retval.end(), mAttachments.begin(), mAttachments.begin() + numColorAttachments);
break;
}
case AttachmentType::DEPTH_STENCIL:
if(mHasDepthAttachment)
{
retval.reserve(1);
- retval.emplace_back(mAttachments.back().get());
+ retval.push_back(mAttachments.back());
}
break;
}
return uint32_t(mRenderPasses.size());
}
-RenderPassHandle FramebufferImpl::GetRenderPass(uint32_t index) const
+RenderPassImpl* FramebufferImpl::GetRenderPass(uint32_t index) const
{
if(index < mRenderPasses.size())
{
return mRenderPasses[index].renderPassImpl;
}
- return RenderPassHandle{};
+ return nullptr;
}
-RenderPassHandle FramebufferImpl::GetImplFromRenderPass(RenderPass* renderPass)
+RenderPassImpl* FramebufferImpl::GetRenderPass(RenderPass* renderPass)
{
auto attachments = renderPass->GetCreateInfo().attachments;
auto matchLoadOp = attachments->front().loadOp;
}
else
{
- DALI_ASSERT_DEBUG(element.renderPassImpl && "Render pass list doesn't contain impl");
+ DALI_ASSERT_DEBUG(element.renderPassImpl != nullptr && "Render pass list doesn't contain impl");
auto createInfo = element.renderPassImpl->GetCreateInfo();
if(createInfo.attachmentDescriptions[0].loadOp == VkLoadOpType(matchLoadOp).loadOp &&
}
// @todo create new render pass from existing + load/store op, add it to mRenderPasses, and return it.
- // @todo Need to reconsider swapchain/fbo/renderpass creation model.
- // This framebuffer may belong to a swapchain, in which case, there are multiple framebuffers
- // that could share render passes.
- // A) Need to detect this situation - keep owner info?
- // B) Sharing render passes means we
- // 1) need to ref-count to ensure safe ownership, or
- // 2) move ownership of renderpass to swapchain.
- // Onus is on client to determine which interface to use, if it's a surface, use swapchain;
- // if it's an offscreen, use framebuffer. (Kinda need a core interface to wrap surface/offscreen)
+
return mRenderPasses[0].renderPassImpl;
}
{
auto result = std::vector<vk::ClearValue>{};
- // @todo & color clear enabled / depth clear enabled
- for(auto& attachment : mAttachments)
- {
- result.emplace_back(attachment->GetClearValue());
- }
+ std::transform(mAttachments.begin(), // @todo & color clear enabled / depth clear enabled
+ mAttachments.end(),
+ std::back_inserter(result),
+ [](FramebufferAttachment* attachment) {
+ return attachment->GetClearValue();
+ });
return result;
}
+bool FramebufferImpl::OnDestroy()
+{
+ auto device = mGraphicsDevice->GetLogicalDevice();
+ auto frameBuffer = mFramebuffer;
+
+ ///@todo Destroy all render passes.
+ vk::RenderPass renderPass = mRenderPasses[0].renderPassImpl->GetVkHandle();
+
+ auto allocator = &mGraphicsDevice->GetAllocator();
+
+ mGraphicsDevice->DiscardResource([device, frameBuffer, renderPass, allocator]() {
+ DALI_LOG_INFO(gVulkanFilter, Debug::General, "Invoking deleter function: framebuffer->%p\n", static_cast<VkFramebuffer>(frameBuffer))
+ device.destroyFramebuffer(frameBuffer, allocator);
+
+ if(renderPass)
+ {
+ DALI_LOG_INFO(gVulkanFilter, Debug::General, "Invoking deleter function: render pass->%p\n", static_cast<VkRenderPass>(renderPass))
+ device.destroyRenderPass(renderPass, allocator);
+ } });
+
+ return false;
+}
+
} // namespace Dali::Graphics::Vulkan
// Namespace Graphics
#include <dali/internal/graphics/vulkan-impl/vulkan-types.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-image-view-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-render-pass-impl.h>
-
namespace Dali::Graphics::Vulkan
{
class RenderPass;
+class RenderPassImpl;
enum class AttachmentType
{
class Device;
-class FramebufferAttachment
+class FramebufferAttachment : public VkManaged
{
public:
- /**
- * Constructor
- *
- * @param[in] imageView The imageview of the attachment
- * @param[in] clearColor The color used to clear this attachment during CLEAR_OP
- * @param[in] type The attachment type (usually COLOR or DEPTH_STENCIL)
- * @param[in] presentable Whether the attachment is presentable (changes final layout)
- */
- FramebufferAttachment(std::unique_ptr<ImageView>& imageView,
- vk::ClearValue clearColor,
- AttachmentType type,
- bool presentable);
+ FramebufferAttachment(ImageView* imageView,
+ vk::ClearValue clearColor,
+ AttachmentType type,
+ bool presentable);
- /**
- * Creates a new color attachment.
- *
- * @param[in] imageView The imageview of the attachment
- * @param[in] clearColorValue The color used to clear this attachment during CLEAR_OP
- * @param[in] presentable Whether the attachment is presentable (changes final layout)
- */
- static FramebufferAttachment* NewColorAttachment(std::unique_ptr<ImageView>& imageView,
- vk::ClearColorValue clearColorValue,
- bool presentable);
+ static FramebufferAttachment* NewColorAttachment(ImageView* imageView,
+ vk::ClearColorValue clearColorValue,
+ bool presentable);
- /**
- * Creates a new depth attachment.
- *
- * @param[in] imageView The imageview of the attachment
- * @param[in] clearDepthStencilValue The value used to clear this attachment during CLEAR_OP
- */
- static FramebufferAttachment* NewDepthAttachment(std::unique_ptr<ImageView>& imageView,
- vk::ClearDepthStencilValue clearDepthStencilValue);
+ static FramebufferAttachment* NewDepthAttachment(ImageView* imageView,
+ vk::ClearDepthStencilValue clearDepthStencilValue);
[[nodiscard]] ImageView* GetImageView() const;
private:
FramebufferAttachment() = default;
- std::unique_ptr<ImageView> mImageView;
- vk::AttachmentDescription mDescription;
- vk::ClearValue mClearValue;
- AttachmentType mType{AttachmentType::UNDEFINED};
+ ImageView* mImageView{nullptr};
+ vk::AttachmentDescription mDescription;
+ vk::ClearValue mClearValue;
+ AttachmentType mType{AttachmentType::UNDEFINED};
};
-using OwnedAttachments = std::vector<std::unique_ptr<FramebufferAttachment>>;
-
/**
* FramebufferImpl encapsulates following objects:
* - Images ( attachments )
* - FramebufferImpl
* - ImageViews
- * - RenderPasses
*/
-class FramebufferImpl
+class FramebufferImpl : public VkManaged
{
public:
- /**
- * @brief Create a new Framebuffer
- *
- * @param[in] device The vulkan device
- * @param[in] renderPass A shared handle to a compatible render pass.
- * @param[in] attachments The attachments. Framebuffer takes ownership of these
- * @param[in] width Width of the framebuffer
- * @param[in] height Height of the framebuffer
- * @param[in] hasDepthAttachment True if the last attachment is a depth buffer
- *
- * @return A new framebuffer object
- */
static FramebufferImpl* New(
- Vulkan::Device& device,
- RenderPassHandle renderPass,
- OwnedAttachments& attachments,
- uint32_t width,
- uint32_t height,
- bool hasDepthAttachment);
+ Vulkan::Device& device,
+ RenderPassImpl* renderPass,
+ std::vector<FramebufferAttachment*>& attachments,
+ uint32_t width,
+ uint32_t height,
+ bool hasDepthAttachment);
- /**
- * @brief Create a new Framebuffer
- *
- * @param[in] device The vulkan device
- * @param[in] renderPass A shared handle to a compatible render pass.
- * @param[in] attachments The attachments. Framebuffer takes ownership of these
- * @param[in] width Width of the framebuffer
- * @param[in] height Height of the framebuffer
- * @param[in] hasDepthAttachment True if the last attachment is a depth buffer
- *
- * @return A new framebuffer object
- */
static FramebufferImpl* New(
- Vulkan::Device& device,
- RenderPassHandle renderPass,
- OwnedAttachments& colorAttachments,
- std::unique_ptr<FramebufferAttachment>& depthAttachment,
- uint32_t width,
- uint32_t height);
-
- /**
- * @brief Constructor
- *
- * @param[in] graphicsDevice The vulkan device
- * @param[in] attachments The attachments - framebuffer takes ownership
- * @param[in] vkHandle a handle to a created framebuffer
- * @param[in] renderPass a handle to a compatible render pass
- * @param[in] width Width of the framebuffer
- * @param[in] height Height of the framebuffer
- * @param[in] hasDepthAttachment True if the last attachment is a depth buffer
- */
- FramebufferImpl(Device& graphicsDevice,
- OwnedAttachments& attachments,
- vk::Framebuffer vkHandle,
- RenderPassHandle renderPass,
- uint32_t width,
- uint32_t height,
- bool hasDepthAttachment);
-
- void Destroy();
+ Vulkan::Device& device,
+ RenderPassImpl* renderPass,
+ const std::vector<FramebufferAttachment*>& colorAttachments,
+ FramebufferAttachment* depthAttachment,
+ uint32_t width,
+ uint32_t height);
+
+ FramebufferImpl(Device& graphicsDevice,
+ const std::vector<FramebufferAttachment*>& attachments,
+ vk::Framebuffer vkHandle,
+ const RenderPassImpl& renderPass,
+ uint32_t width,
+ uint32_t height,
+ bool hasDepthAttachment);
[[nodiscard]] uint32_t GetWidth() const;
[[nodiscard]] uint32_t GetAttachmentCount(AttachmentType type) const;
- [[nodiscard]] RenderPassHandle GetImplFromRenderPass(RenderPass* renderPass); // May mutate mRenderPasses
+ [[nodiscard]] RenderPassImpl* GetRenderPass(RenderPass* renderPass); // May mutate mRenderPasses
- [[nodiscard]] RenderPassHandle GetRenderPass(uint32_t index) const;
+ [[nodiscard]] RenderPassImpl* GetRenderPass(uint32_t index) const;
[[nodiscard]] uint32_t GetRenderPassCount() const;
[[nodiscard]] std::vector<vk::ClearValue> GetClearValues() const;
+ bool OnDestroy() override;
+
private:
Device* mGraphicsDevice;
*/
struct RenderPassMapElement
{
- RenderPass* renderPass{nullptr};
- RenderPassHandle renderPassImpl{nullptr};
+ RenderPass* renderPass{nullptr};
+ RenderPassImpl* renderPassImpl{nullptr};
};
using RenderPasses = std::vector<RenderPassMapElement>;
- OwnedAttachments mAttachments;
- vk::Framebuffer mFramebuffer;
- RenderPasses mRenderPasses;
- bool mHasDepthAttachment{false};
+ std::vector<FramebufferAttachment*> mAttachments;
+ vk::Framebuffer mFramebuffer;
+ RenderPasses mRenderPasses;
+ bool mHasDepthAttachment{false};
};
} // Namespace Dali::Graphics::Vulkan
#include <dali/internal/graphics/vulkan-impl/vulkan-render-pass-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-render-pass.h>
-namespace Dali::Graphics::Vulkan
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
{
Framebuffer::Framebuffer(const FramebufferCreateInfo& createInfo, VulkanGraphicsController& controller)
: Resource(createInfo, controller),
bool Framebuffer::InitializeResource()
{
// Create attachments
- OwnedAttachments colorAttachments;
+ std::vector<FramebufferAttachment*> colorAttachments;
// for(auto& attachment : mCreateInfo.colorAttachments)
{
// auto graphicsTexture = static_cast<const Vulkan::Texture*>(attachment.texture);
// colorAttachments.push_back(FramebufferAttachment::NewColorAttachment(attachment.texture->GetVkHandle(), clearColor, AttachmentType::COLOR, false);
}
- std::unique_ptr<FramebufferAttachment> depthStencilAttachment;
+ FramebufferAttachment* depthStencilAttachment{nullptr};
if(mCreateInfo.depthStencilAttachment.depthTexture || mCreateInfo.depthStencilAttachment.stencilTexture)
{
// depthStencilAttachment = FramebufferAttachment::NewDepthAttachment();
}
+ // Create initial render pass.
+ auto renderPassImpl = RenderPassImpl::New(mController.GetGraphicsDevice(),
+ colorAttachments,
+ depthStencilAttachment);
+
auto& device = mController.GetGraphicsDevice();
- mFramebufferImpl = FramebufferImpl::New(device, RenderPassHandle{}, colorAttachments, depthStencilAttachment, mCreateInfo.size.width, mCreateInfo.size.height);
+ mFramebufferImpl = FramebufferImpl::New(device, renderPassImpl, colorAttachments, depthStencilAttachment, mCreateInfo.size.width, mCreateInfo.size.height);
return true;
}
{
}
-} // namespace Dali::Graphics::Vulkan
+} // namespace Vulkan
+} // namespace Graphics
+} // namespace Dali
#include <dali/internal/graphics/vulkan-impl/vulkan-graphics-resource.h>
-#include <dali/graphics-api/graphics-framebuffer-create-info.h>
#include <dali/graphics-api/graphics-framebuffer.h>
+#include <dali/graphics-api/graphics-framebuffer-create-info.h>
namespace Dali
{
class FramebufferImpl;
using FramebufferResource = Resource<Graphics::Framebuffer, Graphics::FramebufferCreateInfo>;
-
class Framebuffer : public FramebufferResource
{
public:
~Framebuffer() override;
/**
- * @brief Called when resources are destroyed
+ * @brief Called when GL resources are destroyed
*/
void DestroyResource() override;
*/
void DiscardResource() override;
- /**
- * @copydoc Graphics::Vulkan::ResourceBase::GetAllocationCallbacks()
- */
- [[nodiscard]] const Graphics::AllocationCallbacks* GetAllocationCallbacks() const override
- {
- return mCreateInfo.allocationCallbacks;
- }
-
- /**
- * @copydoc Graphics::Vulkan::ResourceBase::InvokeDeleter()
- * Only intended for use by discard queue.
- */
- void InvokeDeleter() override
- {
- this->~Framebuffer();
- }
-
FramebufferImpl* GetImpl()
{
return mFramebufferImpl;
}
-
private:
FramebufferImpl* mFramebufferImpl;
};
*
* When Graphics object dies the unique pointer (Graphics::UniquePtr)
* doesn't destroy it directly but passes the ownership back
- * to the Controller. The GraphicsDeleter is responsible for passing
- * the graphics object to the discard queue (by calling Resource::DiscardResource()).
+ * to the Controller. The VKDeleter is responsible for passing
+ * the object to the discard queue (by calling Resource::DiscardResource()).
*/
template<typename T>
-struct GraphicsDeleter
+struct VKDeleter
{
- GraphicsDeleter() = default;
+ VKDeleter() = default;
void operator()(T* object)
{
* @param[out] out Unique pointer to the return object
*/
template<class VKType, class GfxCreateInfo, class T>
-auto NewGraphicsObject(const GfxCreateInfo& info, VulkanGraphicsController& controller, T&& oldObject)
+auto NewObject(const GfxCreateInfo& info, VulkanGraphicsController& controller, T&& oldObject)
{
// Use allocator
using Type = typename T::element_type;
sizeof(VKType),
0,
info.allocationCallbacks->userData);
- return UPtr(new(memory) VKType(info, controller), GraphicsDeleter<VKType>());
+ return UPtr(new(memory) VKType(info, controller), VKDeleter<VKType>());
}
else // Use standard allocator
{
// If succeeded, attach the object to the unique_ptr and return it back
if(static_cast<VKType*>(reusedObject)->TryRecycle(info, controller))
{
- return UPtr(reusedObject, GraphicsDeleter<VKType>());
+ return UPtr(reusedObject, VKDeleter<VKType>());
}
else
{
}
}
- // Create brand-new object
- UPtr gfxObject(new VKType(info, controller), GraphicsDeleter<VKType>());
+ // Create brand new object
+ UPtr gfxObject(new VKType(info, controller), VKDeleter<VKType>());
static_cast<VKType*>(gfxObject.get())->InitializeResource(); // @todo Consider using create queues?
return gfxObject;
}
if(!mTextureStagingBuffer ||
mTextureStagingBuffer->GetImpl()->GetSize() < size)
{
- auto workerFunc = [&, size](auto workerIndex)
- {
+ auto workerFunc = [&, size](auto workerIndex) {
Graphics::BufferCreateInfo createInfo{};
createInfo.SetSize(size)
.SetUsage(0u | Dali::Graphics::BufferUsage::TRANSFER_SRC);
}
assert(image);
- auto predicate = [&](auto& item) -> bool
- {
+ auto predicate = [&](auto& item) -> bool {
return image->GetVkHandle() == item.image.GetVkHandle();
};
auto it = std::find_if(requestMap.begin(), requestMap.end(), predicate);
commandBuffer->End();
// submit to the queue
- mGraphicsDevice->Submit(mGraphicsDevice->GetTransferQueue(0u), {Vulkan::SubmissionData{{}, {}, {commandBuffer->GetImpl()}, {}}}, fence.get());
+ mGraphicsDevice->Submit(mGraphicsDevice->GetTransferQueue(0u), {Vulkan::SubmissionData{{}, {}, {commandBuffer->GetImpl()}, {}}}, fence);
fence->Wait();
fence->Reset();
}
// Do not destroy
if(buffer != mTextureStagingBuffer->GetImpl())
{
- buffer->Destroy();
+ buffer->DestroyNow();
}
}
else if(request.requestType == TransferRequestType::IMAGE_TO_IMAGE)
auto& image = request.imageToImageInfo.srcImage;
if(image->GetVkHandle())
{
- image->Destroy();
+ image->DestroyNow();
}
}
}
}
}
- /**
- * @brief Processes a discard queue for objects created with NewObject
- *
- * @param[in,out] queue Reference to the queue
- */
- template<class ResourceType>
- void ProcessResourceDiscardQueue(std::queue<ResourceType*>& queue)
- {
- while(!queue.empty())
- {
- auto* object = const_cast<ResourceType*>(queue.front());
-
- // Destroy
- object->DestroyResource();
-
- auto* allocationCallbacks = object->GetAllocationCallbacks();
- if(allocationCallbacks)
- {
- object->InvokeDeleter();
- allocationCallbacks->freeCallback(object, allocationCallbacks->userData);
- }
- else
- {
- delete object;
- }
- queue.pop();
- }
- }
-
- /**
- * Processes a discard queue for direct instantiated objects
- */
- template<class ResourceType>
- void ProcessDiscardQueue(std::queue<ResourceType*>& queue)
- {
- while(!queue.empty())
- {
- auto* object = queue.front();
-
- // Destroy
- object->DestroyResource();
- delete object;
-
- queue.pop();
- }
- }
-
- void GarbageCollect()
- {
- ProcessResourceDiscardQueue<ResourceWithDeleter>(mResourceDiscardQueue);
- ProcessDiscardQueue<ResourceBase>(mDiscardQueue);
- }
-
- void Flush()
- {
- // Flush any outstanding queues.
-
- GarbageCollect();
- }
-
VulkanGraphicsController& mGraphicsController;
Vulkan::Device* mGraphicsDevice{nullptr};
// used for texture<->buffer<->memory transfers
- std::vector<ResourceTransferRequest> mResourceTransferRequests;
- std::recursive_mutex mResourceTransferMutex{};
- std::queue<Vulkan::ResourceBase*> mDiscardQueue;
- std::queue<Vulkan::ResourceWithDeleter*> mResourceDiscardQueue;
+ std::vector<ResourceTransferRequest> mResourceTransferRequests;
+ std::recursive_mutex mResourceTransferMutex{};
std::unique_ptr<Vulkan::Buffer> mTextureStagingBuffer{};
Dali::SharedFuture mTextureStagingBufferFuture{};
{
}
-VulkanGraphicsController::~VulkanGraphicsController()
-{
- mImpl->GarbageCollect();
-}
+VulkanGraphicsController::~VulkanGraphicsController() = default;
void VulkanGraphicsController::Initialize(Dali::Graphics::VulkanGraphics& graphicsImplementation,
Vulkan::Device& graphicsDevice)
swapchain->Submit(cmdBuffer->GetImpl());
}
}
-
- // If flush bit set, flush all pending tasks
- if(submitInfo.flags & (0 | SubmitFlagBits::FLUSH))
- {
- Flush();
- }
}
void VulkanGraphicsController::PresentRenderTarget(Graphics::RenderTarget* renderTarget)
if(destTexture->GetProperties().directWriteAccessEnabled)
{
- auto taskLambda = [pInfo, sourcePtr, sourceInfoPtr, texture](auto workerIndex)
- {
+ auto taskLambda = [pInfo, sourcePtr, sourceInfoPtr, texture](auto workerIndex) {
const auto& properties = texture->GetProperties();
if(properties.emulated)
// The staging buffer is not allocated yet. The task knows pointer to the pointer which will point
// at staging buffer right before executing tasks. The function will either perform direct copy
// or will do suitable conversion if source format isn't supported and emulation is available.
- auto taskLambda = [ppStagingMemory, currentOffset, pInfo, sourcePtr, texture](auto workerThread)
- {
+ auto taskLambda = [ppStagingMemory, currentOffset, pInfo, sourcePtr, texture](auto workerThread) {
char* pStagingMemory = reinterpret_cast<char*>(*ppStagingMemory);
// Try to initialise` texture resources explicitly if they are not yet initialised
for(auto& item : updateMap)
{
auto pUpdates = &item.second;
- auto task = [pUpdates](auto workerIndex)
- {
+ auto task = [pUpdates](auto workerIndex) {
for(auto& update : *pUpdates)
{
update.copyTask(workerIndex);
void VulkanGraphicsController::RunGarbageCollector(size_t numberOfDiscardedRenderers)
{
- mImpl->GarbageCollect();
}
void VulkanGraphicsController::DiscardUnusedResources()
UniquePtr<Graphics::RenderTarget> VulkanGraphicsController::CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, UniquePtr<Graphics::RenderTarget>&& oldRenderTarget)
{
- return NewGraphicsObject<Vulkan::RenderTarget>(renderTargetCreateInfo, *this, std::move(oldRenderTarget));
+ return NewObject<Vulkan::RenderTarget>(renderTargetCreateInfo, *this, std::move(oldRenderTarget));
}
UniquePtr<Graphics::CommandBuffer> VulkanGraphicsController::CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, UniquePtr<Graphics::CommandBuffer>&& oldCommandBuffer)
{
- return NewGraphicsObject<Vulkan::CommandBuffer>(commandBufferCreateInfo, *this, std::move(oldCommandBuffer));
+ return NewObject<Vulkan::CommandBuffer>(commandBufferCreateInfo, *this, std::move(oldCommandBuffer));
}
UniquePtr<Graphics::RenderPass> VulkanGraphicsController::CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, UniquePtr<Graphics::RenderPass>&& oldRenderPass)
UniquePtr<Graphics::Buffer> VulkanGraphicsController::CreateBuffer(const Graphics::BufferCreateInfo& bufferCreateInfo, UniquePtr<Graphics::Buffer>&& oldBuffer)
{
- return NewGraphicsObject<Vulkan::Buffer>(bufferCreateInfo, *this, std::move(oldBuffer));
+ return NewObject<Vulkan::Buffer>(bufferCreateInfo, *this, std::move(oldBuffer));
}
UniquePtr<Graphics::Texture> VulkanGraphicsController::CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, UniquePtr<Graphics::Texture>&& oldTexture)
{
- return NewGraphicsObject<Vulkan::Texture>(textureCreateInfo, *this, std::move(oldTexture));
+ return NewObject<Vulkan::Texture>(textureCreateInfo, *this, std::move(oldTexture));
}
UniquePtr<Graphics::Framebuffer> VulkanGraphicsController::CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, UniquePtr<Graphics::Framebuffer>&& oldFramebuffer)
UniquePtr<Graphics::Sampler> VulkanGraphicsController::CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, UniquePtr<Graphics::Sampler>&& oldSampler)
{
- return NewGraphicsObject<Vulkan::Sampler>(samplerCreateInfo, *this, std::move(oldSampler));
+ return NewObject<Vulkan::Sampler>(samplerCreateInfo, *this, std::move(oldSampler));
}
UniquePtr<Graphics::SyncObject> VulkanGraphicsController::CreateSyncObject(const Graphics::SyncObjectCreateInfo& syncObjectCreateInfo,
return UniquePtr<Graphics::SyncObject>{};
}
-void VulkanGraphicsController::DiscardResource(Vulkan::ResourceBase* resource)
-{
- mImpl->mDiscardQueue.push(resource);
-}
-
-void VulkanGraphicsController::DiscardResource(Vulkan::ResourceWithDeleter* resource)
-{
- mImpl->mResourceDiscardQueue.push(resource);
-}
-
UniquePtr<Graphics::Memory> VulkanGraphicsController::MapBufferRange(const MapBufferInfo& mapInfo)
{
// @todo: Process create queues
TextureProperties VulkanGraphicsController::GetTextureProperties(const Graphics::Texture& gfxTexture)
{
- auto* texture = const_cast<Vulkan::Texture*>(static_cast<const Vulkan::Texture*>(&gfxTexture));
+ Vulkan::Texture* texture = const_cast<Vulkan::Texture*>(static_cast<const Vulkan::Texture*>(&gfxTexture));
return texture->GetProperties();
}
return "";
}
+void VulkanGraphicsController::Add(Vulkan::RenderTarget* renderTarget)
+{
+ // @todo Add create resource queues?
+ renderTarget->InitializeResource();
+}
+
+void VulkanGraphicsController::DiscardResource(Vulkan::RenderTarget* renderTarget)
+{
+ // @todo Add discard queues
+}
+
+void VulkanGraphicsController::DiscardResource(Vulkan::Buffer* buffer)
+{
+ // @todo Add discard queues
+}
+
+void VulkanGraphicsController::DiscardResource(Vulkan::Pipeline* buffer)
+{
+ // @todo Add discard queues
+}
+
+void VulkanGraphicsController::DiscardResource(Vulkan::Program* program)
+{
+ // @todo Add discard queues
+}
+
+void VulkanGraphicsController::DiscardResource(Vulkan::Sampler* sampler)
+{
+}
+
+void VulkanGraphicsController::DiscardResource(Vulkan::Texture* texture)
+{
+}
+
Vulkan::Device& VulkanGraphicsController::GetGraphicsDevice()
{
return *mImpl->mGraphicsDevice;
return gfxTexture;
}
-void VulkanGraphicsController::Flush()
-{
- mImpl->Flush();
-}
-
std::size_t VulkanGraphicsController::GetCapacity() const
{
return mImpl->mCapacity;
}
-bool VulkanGraphicsController::HasClipMatrix() const
-{
- return true;
-}
-
-const Matrix& VulkanGraphicsController::GetClipMatrix() const
-{
- constexpr float CLIP_MATRIX_DATA[] = {
- 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f};
- static const Matrix CLIP_MATRIX(CLIP_MATRIX_DATA);
- return CLIP_MATRIX;
-}
-
} // namespace Dali::Graphics::Vulkan
UniquePtr<Graphics::SyncObject> CreateSyncObject(const Graphics::SyncObjectCreateInfo& syncObjectCreateInfo,
UniquePtr<Graphics::SyncObject>&& oldSyncObject) override;
- /**
- * Add the graphics resource to a discard queue for later destruction
- * @param[in] resource The graphics resource to discard.
- */
- void DiscardResource(Vulkan::ResourceBase* resource);
-
- void DiscardResource(Vulkan::ResourceWithDeleter* program);
-
/**
* @brief Maps memory associated with Buffer object
*
*/
bool GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData) override;
+ void Add(Vulkan::RenderTarget* renderTarget);
+ void DiscardResource(Vulkan::RenderTarget* renderTarget);
+ void DiscardResource(Vulkan::Buffer* buffer);
+ void DiscardResource(Vulkan::Pipeline* buffer);
+ void DiscardResource(Vulkan::Program* renderProgram);
+ void DiscardResource(Vulkan::Sampler* sampler);
+ void DiscardResource(Vulkan::Texture* texture);
+
public: // Integration::GraphicsConfig
bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) override;
uint32_t GetShaderLanguageVersion() override;
*/
UniquePtr<Graphics::Texture> ReleaseTextureFromResourceId(uint32_t resourceId) override;
- /**
- * @return true if there is a clip space transform matrix
- */
- bool HasClipMatrix() const override;
-
- /**
- * @return the clip space transform matrix
- */
- const Matrix& GetClipMatrix() const override;
-
public: // For debug
void FrameStart();
std::size_t GetCapacity() const;
private:
- /**
- * Flush all outstanding queues.
- */
- void Flush();
-
bool IsAdvancedBlendEquationSupported();
struct Impl;
*
*/
-#include <dali/graphics-api/graphics-types.h>
-
namespace Dali::Graphics::Vulkan
{
class VulkanGraphicsController;
-/**
- * Interface class for graphics resources
- */
-class ResourceBase
-{
-public:
- /**
- * @brief Destroys resource
- *
- * This function must be implemented by the derived class.
- * It should perform final destruction of used GL resources.
- */
- virtual void DestroyResource() = 0;
-
- /**
- * @brief Initializes resource
- *
- * This function must be implemented by the derived class.
- * It should initialize all necessary GL resources.
- *
- * @return True on success
- */
- virtual bool InitializeResource() = 0;
-
- /**
- * @brief Discards resource by adding it to the discard queue
- */
- virtual void DiscardResource() = 0;
-
- virtual ~ResourceBase() = default;
-};
-
-class ResourceWithDeleter : public ResourceBase
-{
-public:
- /**
- * @brief Get the allocation callbacks for this object
- */
- [[nodiscard]] virtual const Graphics::AllocationCallbacks* GetAllocationCallbacks() const = 0;
-
- /**
- * @brief Invoke the deleter of the derived type.
- */
- virtual void InvokeDeleter() = 0;
-
- ~ResourceWithDeleter() override = default;
-};
-
/**
* @brief Base class for the Graphics resource.
- * A graphics resource is any Graphics API object created by the controller that
- * requires lifecycle management.
- * It explicitly does not include Vulkan Impl objects that wrap a vkHandle.
*/
-template<class GraphicsType, class CreateInfo>
-class Resource : public GraphicsType, public ResourceWithDeleter
+template<class BASE, class CreateInfo>
+class Resource : public BASE
{
public:
/**
return mController;
}
+ /**
+ * @brief Destroys resource
+ *
+ * This function must be implemented by the derived class.
+ * It should perform final destruction of used GL resources.
+ */
+ virtual void DestroyResource() = 0;
+
+ /**
+ * @brief Initializes resource
+ *
+ * This function must be implemented by the derived class.
+ * It should initialize all necessary GL resources.
+ *
+ * @return True on success
+ */
+ virtual bool InitializeResource() = 0;
+
+ /**
+ * @brief Discards resource by adding it to the discard queue
+ */
+ virtual void DiscardResource() = 0;
+
/**
* @brief returns pointer to base
* @return
*/
- GraphicsType* GetBase()
+ BASE* GetBase()
{
return this;
}
+++ /dev/null
-#pragma once
-
-/*
- * 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.
- * 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.
- */
-
-namespace Dali::Graphics::Vulkan
-{
-
-template<class T>
-class Handle
-{
-public:
- Handle();
-
- explicit Handle(T* object);
-
- Handle(const Handle& handle);
-
- Handle& operator=(const Handle& handle);
-
- Handle& operator=(Handle&& handle);
-
- Handle(Handle&& handle) noexcept;
-
- ~Handle();
-
- operator bool() const;
-
- T* operator->() const
- {
- return mObject;
- }
-
- uint32_t GetRefCount() const
- {
- return mObject->GetRefCount();
- }
-
- T& operator*() const
- {
- return *mObject;
- }
-
- template<class K>
- Handle<K> StaticCast()
- {
- return Handle<K>(static_cast<K*>(mObject));
- }
-
- template<class K>
- bool operator==(const Handle<K>& object) const
- {
- return mObject == &*object;
- }
-
- template<class K>
- bool operator!=(const Handle<K>& object) const
- {
- return !(mObject == &*object);
- }
-
- template<class K>
- Handle<K> DynamicCast();
-
- void Reset()
- {
- if(mObject)
- {
- mObject->Release();
- mObject = nullptr;
- }
- }
-
-private:
- T* mObject{nullptr};
-};
-
-template<class K, class T>
-static Handle<K> VkTypeCast(const Handle<T>& inval)
-{
- return Handle<K>(static_cast<K*>(&*inval));
-}
-
-template<class T>
-Handle<T>::Handle(T* object)
-: mObject(object)
-{
- if(mObject)
- {
- mObject->Retain();
- }
-}
-
-template<class T>
-Handle<T>::Handle()
-: mObject(nullptr)
-{
-}
-
-template<class T>
-Handle<T>::Handle(const Handle& handle)
-{
- mObject = handle.mObject;
- if(mObject)
- {
- mObject->Retain();
- }
-}
-
-template<class T>
-Handle<T>::Handle(Handle&& handle) noexcept
-{
- mObject = handle.mObject;
- handle.mObject = nullptr;
-}
-
-template<class T>
-Handle<T>::operator bool() const
-{
- return mObject != nullptr;
-}
-
-template<class T>
-Handle<T>& Handle<T>::operator=(Handle&& handle)
-{
- if(mObject)
- {
- mObject->Release();
- }
- mObject = handle.mObject;
- handle.mObject = nullptr;
- return *this;
-}
-
-template<class T>
-Handle<T>& Handle<T>::operator=(const Handle<T>& handle)
-{
- mObject = handle.mObject;
- if(mObject)
- {
- mObject->Retain();
- }
- return *this;
-}
-
-template<class T>
-Handle<T>::~Handle()
-{
- if(mObject)
- {
- mObject->Release();
- }
-}
-
-template<class T>
-template<class K>
-Handle<K> Handle<T>::DynamicCast()
-{
- auto val = dynamic_cast<K*>(mObject);
- if(val)
- {
- return Handle<K>(val);
- }
- return Handle<K>();
-}
-
-template<typename T, typename... Args>
-Handle<T> MakeRef(Args&&... args)
-{
- return Handle<T>(new T(std::forward<Args>(args)...));
-}
-
-template<typename T, typename... Args>
-Handle<T> NewRef(Args&&... args)
-{
- return Handle<T>(T::New(std::forward<Args>(args)...));
-}
-
-class VkSharedResource // E.g. render pass
-{
-public:
- VkSharedResource() = default;
-
- virtual ~VkSharedResource() = default;
-
- void Release()
- {
- OnRelease(--mRefCount);
-
- if(mRefCount == 0)
- {
- // orphaned
- if(!Destroy())
- {
- delete this;
- }
- }
- }
-
- void Retain()
- {
- OnRetain(++mRefCount);
- }
-
- uint32_t GetRefCount()
- {
- return mRefCount;
- }
-
- virtual bool Destroy()
- {
- return OnDestroy();
- }
-
- virtual void OnRetain(uint32_t refcount)
- {
- }
-
- virtual void OnRelease(uint32_t refcount)
- {
- }
-
- virtual bool OnDestroy()
- {
- return false;
- }
-
-private:
- std::atomic_uint mRefCount{0u};
-};
-
-} // namespace Dali::Graphics::Vulkan
{
namespace Vulkan
{
+
Image* Image::New(Device& graphicsDevice, const vk::ImageCreateInfo& createInfo)
{
auto image = new Image(graphicsDevice, createInfo, nullptr);
VkAssert(mDevice.GetLogicalDevice().createImage(&mCreateInfo, &mDevice.GetAllocator("IMAGE"), &mImage));
}
-void Image::Destroy()
-{
- DALI_LOG_INFO(gVulkanFilter, Debug::General, "Destroying image: %p\n", static_cast<VkImage>(mImage));
- auto device = mDevice.GetLogicalDevice();
- if(mImage)
- {
- device.destroyImage(mImage, mDevice.GetAllocator());
- }
- mImage = nullptr;
- mMemory.reset();
-}
-
void Image::AllocateAndBind(vk::MemoryPropertyFlags memoryProperties)
{
auto requirements = mDevice.GetLogicalDevice().getImageMemoryRequirements(mImage);
mMemory = std::make_unique<MemoryImpl>(mDevice,
size_t(requirements.size),
size_t(requirements.alignment),
- memoryProperties);
+ (memoryProperties & vk::MemoryPropertyFlagBits::eHostVisible) == vk::MemoryPropertyFlagBits::eHostVisible);
auto allocateInfo = vk::MemoryAllocateInfo{}
.setMemoryTypeIndex(memoryTypeIndex)
return mCreateInfo.samples;
}
+void Image::DestroyNow()
+{
+ DestroyVulkanResources(mDevice.GetLogicalDevice(), mImage, mMemory->ReleaseVkObject(), &mDevice.GetAllocator());
+ mImage = nullptr;
+ mMemory = nullptr;
+}
+
+bool Image::OnDestroy()
+{
+ if(!mIsExternal)
+ {
+ if(mImage)
+ {
+ auto device = mDevice.GetLogicalDevice();
+ auto image = mImage;
+ auto allocator = &mDevice.GetAllocator();
+ auto memory = mMemory->ReleaseVkObject();
+
+ mDevice.DiscardResource([device, image, memory, allocator]()
+ { DestroyVulkanResources(device, image, memory, allocator); });
+ }
+ }
+
+ return false;
+}
+
+void Image::DestroyVulkanResources(vk::Device device, vk::Image image, vk::DeviceMemory memory, const vk::AllocationCallbacks* allocator)
+{
+ DALI_LOG_INFO(gVulkanFilter, Debug::General, "Invoking deleter function: image->%p\n", static_cast<VkImage>(image))
+ device.destroyImage(image, allocator);
+ device.freeMemory(memory, allocator);
+}
+
} // namespace Vulkan
} // namespace Graphics
*/
void Initialize();
- /**
- * Destroys underlying Vulkan resources on the caller thread.
- *
- * @note Calling this function is unsafe and makes any further use of
- * image invalid.
- */
- void Destroy();
-
/**
* Allocate memory for the image and bind it.
* Kept separate from Initialize because reasons. ?!?!
return mMemory.get();
}
+ bool OnDestroy();
+
+ /**
+ * Destroys underlying Vulkan resources on the caller thread.
+ *
+ * @note Calling this function is unsafe and makes any further use of
+ * image invalid.
+ */
+ void DestroyNow();
+
+ /**
+ * Destroys used Vulkan resource objects
+ * @param device Vulkan device
+ * @param image Vulkan image
+ * @param memory Vulkan device memory
+ * @param allocator Pointer to the Vulkan allocator callbacks
+ */
+ static void DestroyVulkanResources(vk::Device device, vk::Image image, vk::DeviceMemory memory, const vk::AllocationCallbacks* allocator);
+
private:
- Device& mDevice;
- vk::ImageCreateInfo mCreateInfo;
- vk::Image mImage;
- vk::ImageLayout mImageLayout;
- vk::ImageAspectFlags mAspectFlags;
+ Device& mDevice;
+ vk::ImageCreateInfo mCreateInfo;
+ vk::Image mImage;
+ vk::ImageLayout mImageLayout;
+ vk::ImageAspectFlags mAspectFlags;
+
std::unique_ptr<MemoryImpl> mMemory;
bool mIsExternal;
};
Destroy();
}
-void ImageView::Destroy()
-{
- DALI_LOG_INFO(gVulkanFilter, Debug::General, "Destroying ImageView: %p\n", static_cast<VkImageView>(mImageView));
- auto device = mDevice.GetLogicalDevice();
- device.destroyImageView(mImageView, mDevice.GetAllocator());
-}
-
vk::ImageView ImageView::GetVkHandle() const
{
return mImageView;
return vk::ImageAspectFlags();
}
+void ImageView::Destroy()
+{
+ auto device = mDevice.GetLogicalDevice();
+ device.destroyImageView(mImageView, mDevice.GetAllocator());
+}
+
} // namespace Vulkan
} // namespace Graphics
} // namespace Dali
~ImageView();
- void Destroy();
-
/**
*
* @return
*/
[[nodiscard]] vk::ImageAspectFlags GetImageAspectMask() const;
+ void Destroy();
+
private:
Device& mDevice;
const Image& mImage;
namespace Dali::Graphics::Vulkan
{
-MemoryImpl::MemoryImpl(Device& device, size_t memSize, size_t memAlign, vk::MemoryPropertyFlags memoryProperties)
+
+MemoryImpl::MemoryImpl(Device& device, size_t memSize, size_t memAlign, bool isHostVisible)
: mDevice(device),
deviceMemory(nullptr),
size(memSize),
alignment(memAlign),
mappedPtr(nullptr),
mappedSize(0u),
- mMemoryProperties(memoryProperties)
+ hostVisible(isHostVisible)
{
}
}
}
-void MemoryImpl::Flush()
+vk::DeviceMemory MemoryImpl::ReleaseVkObject()
{
- // Don't flush if we are using host coherent memory - it's un-necessary
- if((mMemoryProperties & vk::MemoryPropertyFlagBits::eHostCoherent) != vk::MemoryPropertyFlagBits::eHostCoherent)
- {
- vk::Result result = mDevice.GetLogicalDevice().flushMappedMemoryRanges({vk::MappedMemoryRange{}
- .setSize(mappedSize ? mappedSize : VK_WHOLE_SIZE)
- .setMemory(deviceMemory)
- .setOffset(0u)});
+ auto retval = deviceMemory;
+ deviceMemory = nullptr;
+ return retval;
+}
- DALI_ASSERT_ALWAYS(result == vk::Result::eSuccess); // If it's out of memory, may as well crash.
- }
+void MemoryImpl::Flush()
+{
+ vk::Result result = mDevice.GetLogicalDevice().flushMappedMemoryRanges({vk::MappedMemoryRange{}
+ .setSize(mappedSize)
+ .setMemory(deviceMemory)
+ .setOffset(0u)});
+ DALI_ASSERT_ALWAYS(result == vk::Result::eSuccess); // If it's out of memory, may as well crash.
}
vk::DeviceMemory MemoryImpl::GetVkHandle() const
namespace Dali::Graphics::Vulkan
{
+
class MemoryImpl
{
public:
- MemoryImpl(Device& device, size_t memSize, size_t memAlign, vk::MemoryPropertyFlags memoryProperties);
+ MemoryImpl(Device& device, size_t memSize, size_t memAlign, bool hostVisible);
~MemoryImpl();
void Flush();
+ /**
+ * Releases vk::DeviceMemory object so it can be deleted
+ * externally
+ * @return
+ */
+ vk::DeviceMemory ReleaseVkObject();
+
[[nodiscard]] vk::DeviceMemory GetVkHandle() const;
private:
- Device& mDevice;
- vk::DeviceMemory deviceMemory;
- size_t size;
- size_t alignment;
- void* mappedPtr;
- size_t mappedSize;
- vk::MemoryPropertyFlags mMemoryProperties;
+ Device& mDevice;
+ vk::DeviceMemory deviceMemory;
+ size_t size;
+ size_t alignment;
+ void* mappedPtr;
+ size_t mappedSize;
+ bool hostVisible;
};
} // namespace Dali::Graphics::Vulkan
dynInfo.setDynamicStates(mDynamicStates);
gfxPipelineInfo.setPDynamicState(&dynInfo);
- auto& allocator = mController.GetGraphicsDevice().GetAllocator();
-
- auto rtImpl = static_cast<Vulkan::RenderTarget*>(mCreateInfo.renderTarget);
-
- auto framebuffer = rtImpl->GetFramebuffer();
- auto surface = rtImpl->GetSurface();
+ auto& allocator = mController.GetGraphicsDevice().GetAllocator();
+ auto rtImpl = static_cast<Vulkan::RenderTarget*>(mCreateInfo.renderTarget);
+ auto framebuffer = rtImpl->GetFramebuffer();
+ auto surface = rtImpl->GetSurface();
FramebufferImpl* fbImpl = nullptr;
if(surface)
auto renderPassCount = fbImpl->GetRenderPassCount();
for(auto i = 0u; i < renderPassCount; ++i)
{
- RenderPassHandle impl = fbImpl->GetRenderPass(i);
+ RenderPassImpl* impl = fbImpl->GetRenderPass(i);
gfxPipelineInfo.renderPass = impl->GetVkHandle();
gfxPipelineInfo.subpass = 0;
}
}
-const Vulkan::Program* PipelineImpl::GetProgram() const
-{
- return static_cast<const Vulkan::Program*>(mCreateInfo.programState->program);
-}
-
void PipelineImpl::InitializeVertexInputState(vk::PipelineVertexInputStateCreateInfo& out)
{
std::vector<vk::VertexInputBindingDescription> bindings;
att.setAlphaBlendOp(ConvBlendOp(in->alphaBlendOp));
att.setBlendEnable(in->blendEnable);
- //att.setColorWriteMask()
att.setColorBlendOp(ConvBlendOp(in->colorBlendOp));
att.setColorWriteMask(vk::ColorComponentFlags(in->colorComponentWriteBits));
- att.setColorWriteMask(vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG |
- vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA);
att.setDstAlphaBlendFactor(ConvBlendFactor(in->dstAlphaBlendFactor));
att.setDstColorBlendFactor(ConvBlendFactor(in->dstColorBlendFactor));
att.setSrcAlphaBlendFactor(ConvBlendFactor(in->srcAlphaBlendFactor));
void InitializePipeline();
- const Vulkan::Program* GetProgram() const;
-
private:
void InitializeVertexInputState(vk::PipelineVertexInputStateCreateInfo& out);
void InitializeInputAssemblyState(vk::PipelineInputAssemblyStateCreateInfo& out) const;
mPipeline = std::make_unique<PipelineImpl>(createInfo, controller, pipelineCache);
}
-bool Pipeline::InitializeResource()
-{
- return true;
-}
-
void Pipeline::DiscardResource()
{
// Send pipeline to discard queue if refcount is 0
/**
* @brief Pipeline class wraps the PipelineImpl
*/
-class Pipeline : public Graphics::Pipeline, public Vulkan::ResourceBase
+class Pipeline : public Graphics::Pipeline
{
public:
Pipeline() = delete;
bool operator==(const PipelineImpl* impl) const;
/**
- * @brief Initialize the resource
+ * @brief Run by UniquePtr to discard resource
*/
- bool InitializeResource() override;
-
- /**
- * @brief trigger discard
- */
- void DiscardResource() override;
+ void DiscardResource();
/**
* @brief Destroy resource
+ *
+ * Despite this class doesn't inherit Resource it must provide
+ * (so it won't duplicate same data) same set of functions
+ * so it can work with resource management functions of Controller.
*/
- void DestroyResource() override;
+ void DestroyResource();
private:
std::unique_ptr<PipelineImpl> mPipeline; // TODO: it may need to be changed when we have caching
};
} // namespace Dali::Graphics::Vulkan
-#endif
+#endif
\ No newline at end of file
#include <dali/internal/graphics/vulkan-impl/vulkan-reflection.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-shader-impl.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-shader.h>
-#include <dali/internal/graphics/vulkan/vulkan-device.h>
// EXTERNAL HEADERS
#include <iostream>
std::unique_ptr<Vulkan::Reflection> reflection{nullptr};
std::vector<vk::PipelineShaderStageCreateInfo> mPipelineShaderStageCreateInfoList;
-
- struct DescriptorPool
- {
- vk::DescriptorPoolCreateInfo createInfo;
- vk::DescriptorPool vkPool;
- };
-
- std::vector<DescriptorPool> poolList;
- int32_t currentPoolIndex{-1};
};
ProgramImpl::ProgramImpl(const Graphics::ProgramCreateInfo& createInfo, VulkanGraphicsController& controller)
return mImpl->mPipelineShaderStageCreateInfoList;
}
-[[nodiscard]] int ProgramImpl::AddDescriptorPool(uint32_t poolCapacity, uint32_t maxPoolCounts)
-{
- auto& poolList = mImpl->poolList;
- auto& poolIndex = mImpl->currentPoolIndex;
- poolIndex %= maxPoolCounts;
-
- auto& gfxDevice = mImpl->controller.GetGraphicsDevice();
- auto& allocator = gfxDevice.GetAllocator();
- auto vkDevice = gfxDevice.GetLogicalDevice();
-
- if(poolCapacity != poolList.size())
- {
- poolList.resize(poolCapacity);
- // should error if pool index exceeds pool capacity
- }
-
- // round-robin the pool index
- Impl::DescriptorPool& descriptorPool = mImpl->poolList[poolIndex];
-
- // if pool exists at index...
- if(descriptorPool.vkPool)
- {
- // ...try to reuse the pool
- if(descriptorPool.createInfo.maxSets >= poolCapacity)
- {
- vkDevice.resetDescriptorPool(descriptorPool.vkPool, vk::DescriptorPoolResetFlags{});
- return poolIndex;
- }
-
- // ... else, destroy vulkan object
- vkDevice.destroyDescriptorPool(descriptorPool.vkPool, &allocator);
- }
-
- descriptorPool.createInfo.setMaxSets(poolCapacity);
- std::vector<vk::DescriptorPoolSize> poolSizes;
-
- // Note, first block is for gles emulation, so ignore it.
- auto uniformBlockCount = GetReflection().GetUniformBlockCount() - 1;
- auto samplersCount = GetReflection().GetSamplers().size();
-
- if(uniformBlockCount)
- {
- vk::DescriptorPoolSize item;
- item.setType(vk::DescriptorType::eUniformBuffer);
- item.setDescriptorCount(uniformBlockCount * poolCapacity);
- poolSizes.emplace_back(item);
- }
- if(samplersCount) // For now, we use only combined image sampler type as 'sampler'
- {
- vk::DescriptorPoolSize item;
- item.setType(vk::DescriptorType::eCombinedImageSampler);
- item.setDescriptorCount(samplersCount * poolCapacity);
- poolSizes.emplace_back(item);
- }
-
- // set sizes
- descriptorPool.createInfo.setPoolSizes(poolSizes);
-
- // create pool
- VkAssert(vkDevice.createDescriptorPool(&descriptorPool.createInfo, &allocator, &descriptorPool.vkPool));
-
- return poolIndex;
-}
-
-[[nodiscard]] vk::DescriptorSet ProgramImpl::AllocateDescriptorSet(int poolIndex)
-{
- // if pool index isn't specified, last added pool will be used
- if(poolIndex < 0)
- {
- poolIndex = mImpl->currentPoolIndex;
- }
-
- auto& poolList = mImpl->poolList;
- auto& gfxDevice = mImpl->controller.GetGraphicsDevice();
- auto vkDevice = gfxDevice.GetLogicalDevice();
-
- vk::DescriptorSetAllocateInfo allocateInfo;
- allocateInfo.setDescriptorPool(poolList[poolIndex].vkPool);
-
- auto& layouts = GetReflection().GetVkDescriptorSetLayouts();
- allocateInfo.setSetLayouts(layouts);
- // TODO: making sure only first layout will be use.
- // Reflection supports multiple sets but current architecture of Vulkan backend
- // uses single set only per pipeline/program
- allocateInfo.setDescriptorSetCount(1);
-
- vk::DescriptorSet set;
- VkAssert(vkDevice.allocateDescriptorSets(&allocateInfo, &set));
- return set;
-}
-
}; // namespace Dali::Graphics::Vulkan
*/
bool GetParameter(uint32_t parameterId, void* out);
- /**
- *
- * @param[in] poolCapacity the capacity of pool
- * @param maxPoolCounts number of pools, last added pool will be removed
- * @return index of descriptor pool or -1 if unable to create pool
- */
- [[nodiscard]] int AddDescriptorPool(uint32_t poolCapacity, uint32_t maxPoolCounts);
-
- [[nodiscard]] vk::DescriptorSet AllocateDescriptorSet(int poolIndex);
-
private:
friend class Program;
return GetImplementation()->GetCreateInfo();
}
-bool Program::InitializeResource()
-{
- return true;
-}
-
void Program::DiscardResource()
{
GetController().DiscardResource(this);
}
-void Program::DestroyResource()
-{
- // nothing to do here
-}
-
}; // namespace Dali::Graphics::Vulkan
{
class Reflection;
class ProgramImpl;
-
/**
* @brief Wrapper for the program implementation
*
* within Graphics API is a set of shader stages linked together
* so the reflection can do its work on it.
*/
-class Program : public Graphics::Program, public Vulkan::ResourceBase
+class Program : public Graphics::Program
{
public:
/**
/**
* @brief Returns reference to the Reflection object
+
* @return Reflection
*/
[[nodiscard]] const Vulkan::Reflection& GetReflection() const;
return (program.mProgram != mProgram);
}
- /**
- * @brief Initialize the resource
- */
- bool InitializeResource() override;
-
/**
* @brief Run by UniquePtr to discard resource
*/
- void DiscardResource() override;
+ void DiscardResource();
/**
* @brief Destroying resources
* This function is kept for compatibility with Resource<> class
* so can the object can be use with templated functions.
*/
- void DestroyResource() override;
+ void DestroyResource()
+ {
+ // nothing to do here
+ }
bool TryRecycle(const Graphics::ProgramCreateInfo& createInfo, VulkanGraphicsController& controller)
{
};
} // namespace Dali::Graphics::Vulkan
-#endif // DALI_GRAPHICS_VULKAN_PROGRAM_H
+#endif //DALI_GRAPHICS_VULKAN_PROGRAM_H
{
return VertexInputAttributeFormat::FLOAT;
}
- // case SPV_REFLECT_FORMAT_R32G32_SINT:{
- // return VertexInputAttributeFormat::VEC2
- // }
+ //case SPV_REFLECT_FORMAT_R32G32_SINT:{
+ // return VertexInputAttributeFormat::VEC2
+ //}
case SPV_REFLECT_FORMAT_R32G32_SFLOAT:
{
return VertexInputAttributeFormat::VEC2;
}
- // case SPV_REFLECT_FORMAT_R32G32B32_SINT:{}
+ //case SPV_REFLECT_FORMAT_R32G32B32_SINT:{}
case SPV_REFLECT_FORMAT_R32G32B32_SFLOAT:
{
return VertexInputAttributeFormat::VEC3;
}
- // case SPV_REFLECT_FORMAT_R32G32B32A32_SINT:{};
+ //case SPV_REFLECT_FORMAT_R32G32B32A32_SINT:{};
case SPV_REFLECT_FORMAT_R32G32B32A32_SFLOAT:
{
return VertexInputAttributeFormat::VEC4;
}
// helper lambda if we need to check more types of pipeline stages in the future
- auto CheckStageIfDone = [stage](auto expectedStage, auto& variable, const char* stageName) -> StageCheckResult
- {
+ auto CheckStageIfDone = [stage](auto expectedStage, auto& variable, const char* stageName) -> StageCheckResult {
if(stage == expectedStage)
{
if(!variable)
{
mUniformOpaques.insert(mUniformOpaques.end(), samplers.begin(), samplers.end());
// sort samplers by bindings
- std::sort(mUniformOpaques.begin(), mUniformOpaques.end(), [](auto& lhs, auto& rhs)
- { return lhs.binding < rhs.binding; });
+ std::sort(mUniformOpaques.begin(), mUniformOpaques.end(), [](auto& lhs, auto& rhs) { return lhs.binding < rhs.binding; });
for(auto i = 0u; i < mUniformOpaques.size(); ++i)
{
mUniformOpaques[i].location = i;
return mVkPipelineLayout;
}
-const std::vector<vk::DescriptorSetLayout>& Reflection::GetVkDescriptorSetLayouts() const
-{
- return mVkDescriptorSetLayoutList;
-}
-
void Reflection::BuildVertexAttributeReflection(SpvReflectShaderModule* spvModule)
{
std::vector<SpvReflectInterfaceVariable*> attrs;
/**
* @brief Gets the number of uniform blocks in the shader
- * Note: GLES implementation generates an emulated block at index 0, so we have
- * to handle that here. Reduce the count by 1 to get the number of actual uniform
- * buffers.
+ *
* @return The number of uniform blocks
*/
[[nodiscard]] uint32_t GetUniformBlockCount() const override;
vk::PipelineLayout GetVkPipelineLayout() const;
- const std::vector<vk::DescriptorSetLayout>& GetVkDescriptorSetLayouts() const;
-
protected:
Reflection(Reflection&&) = default;
Reflection& operator=(Reflection&&) = default;
std::vector<vk::DescriptorSetLayoutCreateInfo> mVkDescriptorSetLayoutCreateInfoList; ///< List of DSlayout create structures
std::vector<std::vector<vk::DescriptorSetLayoutBinding>> mVkDescriptorSetLayoutBindingList;
std::vector<vk::DescriptorSetLayout> mVkDescriptorSetLayoutList;
-
- vk::PipelineLayout mVkPipelineLayout;
+ vk::PipelineLayout mVkPipelineLayout;
};
} // namespace Vulkan
namespace Dali::Graphics::Vulkan
{
-RenderPassHandle RenderPassImpl::New(
+
+RenderPassImpl* RenderPassImpl::New(
Vulkan::Device& device,
const std::vector<FramebufferAttachment*>& colorAttachments,
FramebufferAttachment* depthAttachment)
{
auto renderPass = new RenderPassImpl(device, colorAttachments, depthAttachment);
- return RenderPassHandle(renderPass);
+ return renderPass;
}
RenderPassImpl::RenderPassImpl(Vulkan::Device& device,
RenderPassImpl::~RenderPassImpl() = default;
+vk::RenderPass RenderPassImpl::GetVkHandle()
+{
+ return mVkRenderPass;
+}
+
bool RenderPassImpl::OnDestroy()
{
if(mVkRenderPass)
auto device = mGraphicsDevice->GetLogicalDevice();
auto allocator = &mGraphicsDevice->GetAllocator();
auto renderPass = mVkRenderPass;
-
- DALI_LOG_INFO(gVulkanFilter, Debug::General, "Destroying render pass: %p\n", static_cast<VkRenderPass>(renderPass));
- device.destroyRenderPass(renderPass, allocator);
+ mGraphicsDevice->DiscardResource([device, renderPass, allocator]()
+ {
+ DALI_LOG_INFO(gVulkanFilter, Debug::General, "Invoking deleter function: swap chain->%p\n", static_cast<VkRenderPass>(renderPass))
+ device.destroyRenderPass(renderPass, allocator); });
mVkRenderPass = nullptr;
}
- return true;
-}
-
-vk::RenderPass RenderPassImpl::GetVkHandle()
-{
- return mVkRenderPass;
+ return false;
}
std::vector<vk::ImageView>& RenderPassImpl::GetAttachments()
.setDstAccessMask(vk::AccessFlagBits::eMemoryRead)
.setDependencyFlags(vk::DependencyFlagBits::eByRegion)};
- mCreateInfo.createInfo
- .setAttachmentCount(U32(mCreateInfo.attachmentDescriptions.size()))
+ mCreateInfo.createInfo.setAttachmentCount(U32(mCreateInfo.attachmentDescriptions.size()))
.setPAttachments(mCreateInfo.attachmentDescriptions.data())
.setPSubpasses(&mCreateInfo.subpassDesc)
.setSubpassCount(1)
- .setDependencyCount(2)
.setPDependencies(mCreateInfo.subpassDependencies.data());
}
*/
#include <dali/graphics-api/graphics-render-pass-create-info.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-handle.h>
#include <dali/internal/graphics/vulkan-impl/vulkan-types.h>
#include <dali/public-api/common/vector-wrapper.h>
class Device;
class VulkanGraphicsController;
class RenderTarget;
-class RenderPassImpl;
-
-using RenderPassHandle = Handle<class RenderPassImpl>;
/**
* Holder class for Vulkan RenderPass object.
* FramebufferImpl will create a separate compatible RenderPassImpl if a matching
* render pass is NOT found.
*/
-class RenderPassImpl : public VkSharedResource
+class RenderPassImpl final : public Dali::Graphics::Vulkan::VkManaged
{
public:
struct CreateInfo
vk::RenderPassCreateInfo createInfo;
};
- static RenderPassHandle New(Vulkan::Device& device,
- const std::vector<FramebufferAttachment*>& colorAttachments,
- FramebufferAttachment* depthAttachment);
+ static RenderPassImpl* New(
+ Vulkan::Device& device,
+ const std::vector<FramebufferAttachment*>& colorAttachments,
+ FramebufferAttachment* depthAttachment);
RenderPassImpl(Vulkan::Device& device, const std::vector<FramebufferAttachment*>& colorAttachments, FramebufferAttachment* depthAttachment);
- ~RenderPassImpl();
-
- bool OnDestroy() override;
+ ~RenderPassImpl() override;
vk::RenderPass GetVkHandle();
+ bool OnDestroy() override;
+
std::vector<vk::ImageView>& GetAttachments();
CreateInfo& GetCreateInfo()
vk::RenderPass mVkRenderPass;
std::vector<vk::ImageView> mAttachments{};
};
-
} // namespace Dali::Graphics::Vulkan
#endif // DALI_INTERNAL_GRAPHICS_VULKAN_RENDER_PASS_IMPL_H
*/
// CLASS HEADER
-#include <dali/internal/graphics/vulkan-impl/vulkan-render-target.h>
+#include "vulkan-render-target.h"
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-framebuffer-impl.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-framebuffer.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-graphics-controller.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-render-pass.h>
-#include <dali/internal/graphics/vulkan/vulkan-device.h>
-#include <dali/internal/window-system/common/window-render-surface.h>
+#include "vulkan-framebuffer.h"
+#include "vulkan-graphics-controller.h"
namespace Dali::Graphics::Vulkan
{
return mCreateInfo.surface;
}
-Vulkan::FramebufferImpl* RenderTarget::GetCurrentFramebufferImpl() const
-{
- auto framebuffer = GetFramebuffer();
- auto surface = GetSurface();
-
- FramebufferImpl* fbImpl = nullptr;
- if(surface)
- {
- auto& gfxDevice = mController.GetGraphicsDevice();
- auto surfaceId = static_cast<Internal::Adaptor::WindowRenderSurface*>(surface)->GetSurfaceId();
- auto swapchain = gfxDevice.GetSwapchainForSurfaceId(surfaceId);
- fbImpl = swapchain->GetCurrentFramebuffer();
- }
- else if(framebuffer)
- {
- fbImpl = framebuffer->GetImpl();
- }
- return fbImpl;
-}
-
-Vulkan::RenderPassHandle RenderTarget::GetRenderPass(const Graphics::RenderPass* gfxRenderPass) const
-{
- auto renderPass = const_cast<Vulkan::RenderPass*>(static_cast<const Vulkan::RenderPass*>(gfxRenderPass));
- auto framebufferImpl = GetCurrentFramebufferImpl();
- return framebufferImpl->GetImplFromRenderPass(renderPass);
-}
-
} // namespace Dali::Graphics::Vulkan
#include <dali/graphics-api/graphics-render-target-create-info.h>
#include <dali/graphics-api/graphics-render-target.h>
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-render-pass-impl.h>
namespace Dali::Graphics::Vulkan
{
*/
void DiscardResource() override;
- /**
- * @copydoc Graphics::Vulkan::Resource::GetAllocationCallbacks()
- */
- [[nodiscard]] const Graphics::AllocationCallbacks* GetAllocationCallbacks() const override
- {
- return mCreateInfo.allocationCallbacks;
- }
-
- /**
- * @copydoc Graphics::Vulkan::Resource::InvokeDeleter()
- * Only intended for use by discard queue.
- */
- void InvokeDeleter() override
- {
- this->~RenderTarget();
- }
-
/**
* @brief Returns framebuffer associated with the render target
*/
*/
[[nodiscard]] Integration::RenderSurfaceInterface* GetSurface() const;
- /**
- * @brief Returns the current framebuffer impl for this frame.
- * (May be either the swapchain's current fb, or the offscreen's fb).
- * @return the current framebuffer
- */
- [[nodiscard]] Vulkan::FramebufferImpl* GetCurrentFramebufferImpl() const;
+ // Get Swapchain?
- /**
- * Find a matching render pass for this render target
- * @param[in] renderPass A render pass to search for
- * @return a matching render pass implementation from the current framebuffer
- */
- [[nodiscard]] Vulkan::RenderPassHandle GetRenderPass(const Graphics::RenderPass* renderPass) const;
+private:
+ // UniquePtr<Swapchain> mSwapchain;
};
} // namespace Dali::Graphics::Vulkan
-#endif // DALI_INTERNAL_GRAPHICS_VULKAN_RENDER_TARGET_H
+#endif //DALI_INTERNAL_GRAPHICS_VULKAN_RENDER_TARGET_H
bool deferredTransferMode{true}; // Vulkan implementation prefers deferred mode
// delete copy
- ResourceTransferRequest(const ResourceTransferRequest&) = delete;
+ ResourceTransferRequest(const ResourceTransferRequest&) = delete;
ResourceTransferRequest& operator=(const ResourceTransferRequest&) = delete;
- ResourceTransferRequest& operator=(ResourceTransferRequest&& obj) = delete;
+ ResourceTransferRequest& operator=(ResourceTransferRequest&& obj) = delete;
ResourceTransferRequest(ResourceTransferRequest&& obj)
{
imageToImageInfo.dstImage = obj.imageToImageInfo.dstImage;
imageToImageInfo.copyInfo = obj.imageToImageInfo.copyInfo;
}
- else if(requestType == TransferRequestType::LAYOUT_TRANSITION_ONLY)
- {
- imageLayoutTransitionInfo.image = obj.imageLayoutTransitionInfo.image;
- imageLayoutTransitionInfo.srcLayout = obj.imageLayoutTransitionInfo.srcLayout;
- imageLayoutTransitionInfo.dstLayout = obj.imageLayoutTransitionInfo.dstLayout;
- deferredTransferMode = false;
- }
}
};
{
}
-SamplerImpl::~SamplerImpl()
-{
- Destroy();
-}
+SamplerImpl::~SamplerImpl() = default;
void SamplerImpl::Initialize()
{
VkAssert(mDevice.GetLogicalDevice().createSampler(&mCreateInfo, &mDevice.GetAllocator("SAMPLER"), &mSampler));
}
-void SamplerImpl::Destroy()
-{
- if(mSampler)
- {
- mDevice.GetLogicalDevice().destroySampler(mSampler);
- mSampler = nullptr;
- }
-}
-
vk::Sampler SamplerImpl::GetVkHandle() const
{
return mSampler;
void Initialize();
- void Destroy();
-
/**
* Returns VkSampler object
* @return
// INTERNAL INCLUDES
#include <dali/internal/graphics/vulkan-impl/vulkan-graphics-controller.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-sampler-impl.h>
namespace Dali::Graphics::Vulkan
{
-namespace
-{
-constexpr vk::Filter ConvertFilter(Dali::Graphics::SamplerFilter filter)
-{
- switch(filter)
- {
- case Dali::Graphics::SamplerFilter::LINEAR:
- return vk::Filter::eLinear;
- case Dali::Graphics::SamplerFilter::NEAREST:
- return vk::Filter::eNearest;
- }
- return vk::Filter{};
-}
-
-constexpr vk::SamplerAddressMode ConvertAddressMode(Dali::Graphics::SamplerAddressMode mode)
-{
- switch(mode)
- {
- case Dali::Graphics::SamplerAddressMode::CLAMP_TO_EDGE:
- return vk::SamplerAddressMode::eClampToEdge;
- case Dali::Graphics::SamplerAddressMode::CLAMP_TO_BORDER:
- return vk::SamplerAddressMode::eClampToBorder;
- case Dali::Graphics::SamplerAddressMode::MIRROR_CLAMP_TO_EDGE:
- return vk::SamplerAddressMode::eMirrorClampToEdge;
- case Dali::Graphics::SamplerAddressMode::MIRRORED_REPEAT:
- return vk::SamplerAddressMode::eMirroredRepeat;
- case Dali::Graphics::SamplerAddressMode::REPEAT:
- return vk::SamplerAddressMode::eRepeat;
- }
- return vk::SamplerAddressMode{};
-}
-
-constexpr vk::SamplerMipmapMode ConvertMipmapMode(Dali::Graphics::SamplerMipmapMode mode)
-{
- switch(mode)
- {
- case Dali::Graphics::SamplerMipmapMode::NONE:
- return vk::SamplerMipmapMode::eNearest;
- case Dali::Graphics::SamplerMipmapMode::LINEAR:
- return vk::SamplerMipmapMode::eLinear;
- case Dali::Graphics::SamplerMipmapMode::NEAREST:
- return vk::SamplerMipmapMode::eNearest;
- }
- return vk::SamplerMipmapMode{};
-}
-
-} // namespace
-
Sampler::Sampler(const Graphics::SamplerCreateInfo& createInfo, VulkanGraphicsController& controller)
: SamplerResource(createInfo, controller)
{
void Sampler::DestroyResource()
{
- if(mSamplerImpl)
- {
- mSamplerImpl->Destroy();
- mSamplerImpl = nullptr;
- }
+ // For now, no GPU resources are initialized so nothing to destroy
}
bool Sampler::InitializeResource()
{
- vk::SamplerCreateInfo createInfo{};
- createInfo.setMinFilter(ConvertFilter(mCreateInfo.minFilter))
- .setMagFilter(ConvertFilter(mCreateInfo.magFilter))
- .setAddressModeU(ConvertAddressMode(mCreateInfo.addressModeU))
- .setAddressModeV(ConvertAddressMode(mCreateInfo.addressModeV))
- .setAddressModeW(ConvertAddressMode(mCreateInfo.addressModeW))
- .setMipmapMode(ConvertMipmapMode(mCreateInfo.mipMapMode))
- .setCompareEnable(vk::Bool32(mCreateInfo.compareEnable))
- .setUnnormalizedCoordinates(vk::Bool32(mCreateInfo.unnormalizeCoordinates))
- .setBorderColor(vk::BorderColor::eFloatOpaqueBlack)
- .setAnisotropyEnable(vk::Bool32(mCreateInfo.anisotropyEnable))
- .setMaxAnisotropy(mCreateInfo.maxAnisotropy)
- .setMinLod(mCreateInfo.minLod)
- .setMaxLod(mCreateInfo.maxLod);
-
- mSamplerImpl = SamplerImpl::New(mController.GetGraphicsDevice(), createInfo);
-
return true;
}
namespace Dali::Graphics::Vulkan
{
using SamplerResource = Resource<Graphics::Sampler, Graphics::SamplerCreateInfo>;
-class SamplerImpl;
class Sampler : public SamplerResource
{
/**
* @brief Called when GPU resources are destroyed
*/
- void DestroyResource() override;
+ void DestroyResource();
/**
* @brief Called when initializing the resource
* @brief Called when UniquePtr<> on client-side dies
*/
void DiscardResource() override;
-
- SamplerImpl* GetImpl()
- {
- return mSamplerImpl;
- }
-
- /**
- * @copydoc Graphics::Vulkan::Resource::GetAllocationCallbacks()
- */
- [[nodiscard]] const Graphics::AllocationCallbacks* GetAllocationCallbacks() const override
- {
- return mCreateInfo.allocationCallbacks;
- }
-
- /**
- * @copydoc Graphics::Vulkan::Resource::InvokeDeleter()
- * Only intended for use by discard queue.
- */
- void InvokeDeleter() override
- {
- this->~Sampler();
- }
-
-private:
- SamplerImpl* mSamplerImpl;
};
} // namespace Dali::Graphics::Vulkan
return mImpl->refCount;
}
-void ShaderImpl::Destroy()
-{
- mImpl->Destroy();
- mImpl.reset();
-}
-
[[nodiscard]] uint32_t ShaderImpl::IncreaseFlushCount()
{
return ++mImpl->flushCount;
// INTERNAL INCLUDES
#include <dali/graphics-api/graphics-shader-create-info.h>
#include <dali/graphics-api/graphics-shader.h>
-
-#include <dali/internal/graphics/vulkan-impl/vulkan-graphics-controller.h>
-#include <dali/internal/graphics/vulkan-impl/vulkan-types.h>
+#include <dali/internal/graphics/vulkan-impl/vulkan-graphics-resource.h>
// EXTERNAL INCLUDES
#include <vulkan/vulkan.hpp>
* @param[in] createInfo Valid createInfo structure
* @param[in] controller Reference to the controller
*/
- ShaderImpl(const Graphics::ShaderCreateInfo& createInfo, VulkanGraphicsController& controller);
+ ShaderImpl(const Graphics::ShaderCreateInfo& createInfo, Graphics::Vulkan::VulkanGraphicsController& controller);
/**
* @brief destructor
*/
[[nodiscard]] uint32_t GetRefCount() const;
- /**
- * @brief Destroys Vulkan shader module
- */
- void Destroy();
-
/**
* Whilst unreferenced, increase the flush count and return it
*
*/
[[nodiscard]] bool Compile() const;
+ /**
+ * @brief Destroys Vulkan shader module
+ */
+ void Destroy();
+
/**
* @brief Returns Vulkan resource
* @return Valid Vulkan shader resource
#include <dali/internal/graphics/vulkan-impl/vulkan-surface-impl.h>
// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
#include <dali/internal/graphics/vulkan/vulkan-device.h>
+#include <dali/integration-api/debug.h>
#if defined(DEBUG_ENABLED)
extern Debug::Filter* gVulkanFilter;
namespace Dali::Graphics::Vulkan
{
-SurfaceImpl::SurfaceImpl(Device& device, vk::SurfaceKHR surfaceKhr)
-: mGraphicsDevice(device),
+SurfaceImpl::SurfaceImpl( Device& device, vk::SurfaceKHR surfaceKhr)
+: mGraphicsDevice( device ),
mSurface(surfaceKhr)
{
}
-SurfaceImpl::~SurfaceImpl()
-{
- Destroy();
-};
-
-void SurfaceImpl::Destroy()
-{
- if(mSurface)
- {
- auto instance = mGraphicsDevice.GetInstance();
- auto surface = mSurface;
- auto allocator = &mGraphicsDevice.GetAllocator();
-
- DALI_LOG_INFO(gVulkanFilter, Debug::General, "Destroying surface: %p\n", static_cast<VkSurfaceKHR>(surface));
- instance.destroySurfaceKHR(surface, allocator);
- mSurface = nullptr;
- }
-}
+SurfaceImpl::~SurfaceImpl() = default;
vk::SurfaceKHR SurfaceImpl::GetVkHandle() const
{
bool SurfaceImpl::GetSupportedFormats(
vk::SurfaceFormatKHR requestedFormat,
- vk::Format& swapchainImageFormat,
- vk::ColorSpaceKHR& swapchainColorSpace)
+ vk::Format& swapchainImageFormat,
+ vk::ColorSpaceKHR& swapchainColorSpace)
{
- bool found = false;
- auto supportedFormats = VkAssert(mGraphicsDevice.GetPhysicalDevice().getSurfaceFormatsKHR(mSurface));
+ bool found=false;
+ auto supportedFormats = VkAssert( mGraphicsDevice.GetPhysicalDevice().getSurfaceFormatsKHR( mSurface ) );
// If the surface format list only includes one entry with VK_FORMAT_UNDEFINED,
// there is no preferred format, so we assume vk::Format::eB8G8R8A8Unorm
- if(supportedFormats.size() == 1 && supportedFormats[0].format == vk::Format::eUndefined)
+ if( supportedFormats.size() == 1 && supportedFormats[0].format == vk::Format::eUndefined )
{
- swapchainColorSpace = supportedFormats[0].colorSpace;
+ swapchainColorSpace = supportedFormats[0].colorSpace;
swapchainImageFormat = vk::Format::eB8G8R8A8Unorm;
}
else // Try to find the requested format in the list
{
auto iter = std::find_if(supportedFormats.begin(),
supportedFormats.end(),
- [&](vk::SurfaceFormatKHR supportedFormat)
- {
+ [ & ]( vk::SurfaceFormatKHR supportedFormat ) {
return requestedFormat == supportedFormat.format;
- });
+ } );
// If found assign it.
- if(iter != supportedFormats.end())
+ if( iter != supportedFormats.end() )
{
- found = true;
- auto surfaceFormat = *iter;
- swapchainColorSpace = surfaceFormat.colorSpace;
+ found = true;
+ auto surfaceFormat = *iter;
+ swapchainColorSpace = surfaceFormat.colorSpace;
swapchainImageFormat = surfaceFormat.format;
}
else // Requested format not found...attempt to use the first one on the list
{
- auto surfaceFormat = supportedFormats[0];
- swapchainColorSpace = surfaceFormat.colorSpace;
+ auto surfaceFormat = supportedFormats[0];
+ swapchainColorSpace = surfaceFormat.colorSpace;
swapchainImageFormat = surfaceFormat.format;
}
}
- assert(swapchainImageFormat != vk::Format::eUndefined && "Could not find a supported swap chain image format.");
+ assert( swapchainImageFormat != vk::Format::eUndefined && "Could not find a supported swap chain image format." );
return found;
}
return presentModes;
}
-void SurfaceImpl::UpdateSize(unsigned int width, unsigned int height)
+void SurfaceImpl::UpdateSize( unsigned int width, unsigned int height )
{
- mCapabilities.currentExtent.width = width;
+ mCapabilities.currentExtent.width = width;
mCapabilities.currentExtent.height = height;
}
+bool SurfaceImpl::OnDestroy()
+{
+ if( mSurface )
+ {
+ auto instance = mGraphicsDevice.GetInstance();
+ auto surface = mSurface;
+ auto allocator = &mGraphicsDevice.GetAllocator();
+
+ mGraphicsDevice.DiscardResource( [ instance, surface, allocator ]() {
+ DALI_LOG_INFO( gVulkanFilter, Debug::General, "Invoking deleter function: surface->%p\n",
+ static_cast< VkSurfaceKHR >( surface ) )
+ instance.destroySurfaceKHR( surface, allocator );
+ } );
+
+ mSurface = nullptr;
+ }
+ return false;
+}
+
} // namespace Dali::Graphics::Vulkan
{
class Device;
-class SurfaceImpl
+class SurfaceImpl final : public Dali::Graphics::Vulkan::VkManaged
{
public:
explicit SurfaceImpl(Device& device, vk::SurfaceKHR surfaceKhr);
- ~SurfaceImpl();
-
- void Destroy();
+ ~SurfaceImpl() final;
/**
* @return the handle to this surface
*/
bool GetSupportedFormats(
vk::SurfaceFormatKHR requestedFormat,
- vk::Format& swapchainImageFormat,
- vk::ColorSpaceKHR& swapchainColorSpace);
+ vk::Format& swapchainImageFormat,
+ vk::ColorSpaceKHR& swapchainColorSpace);
/**
* Update size of surface
*/
void UpdateSize(unsigned int width, unsigned int height);
+ bool OnDestroy() override;
+
private:
Device& mGraphicsDevice;
vk::SurfaceKHR mSurface;
acquireNextImageSemaphore = graphicsDevice.GetLogicalDevice().createSemaphore({}, graphicsDevice.GetAllocator()).value;
submitSemaphore = graphicsDevice.GetLogicalDevice().createSemaphore({}, graphicsDevice.GetAllocator()).value;
- endOfFrameFence = FenceImpl::New(graphicsDevice, {});
+ endOfFrameFence.reset(FenceImpl::New(graphicsDevice, {}));
}
SwapchainBuffer::~SwapchainBuffer()
{
}
-Swapchain::~Swapchain()
-{
-}
+Swapchain::~Swapchain() = default;
void Swapchain::CreateVkSwapchain(
vk::SwapchainKHR oldSwapchain,
mSwapchainKHR = VkAssert(mGraphicsDevice.GetLogicalDevice().createSwapchainKHR(mSwapchainCreateInfoKHR, mGraphicsDevice.GetAllocator()));
}
-void Swapchain::Destroy()
-{
- if(mSwapchainKHR)
- {
- auto device = mGraphicsDevice.GetLogicalDevice();
- auto swapchain = mSwapchainKHR;
- auto allocator = &mGraphicsDevice.GetAllocator();
- mFramebuffers.clear();
- mSwapchainBuffers.clear();
-
- DALI_LOG_INFO(gVulkanFilter, Debug::General, "Destroying SwapChain: %p\n", static_cast<VkSwapchainKHR>(swapchain));
- device.destroySwapchainKHR(swapchain, allocator);
- mSwapchainKHR = nullptr;
- }
-}
-
void Swapchain::CreateFramebuffers()
{
assert(mSwapchainKHR && "Needs a swapchain before creating framebuffers");
//
// CREATE FRAMEBUFFERS
//
- RenderPassHandle compatibleRenderPass{};
for(auto&& image : images)
{
auto colorImage = mGraphicsDevice.CreateImageFromExternal(image,
mSwapchainCreateInfoKHR.imageFormat,
mSwapchainCreateInfoKHR.imageExtent);
- std::unique_ptr<ImageView> colorImageView;
- colorImageView.reset(ImageView::NewFromImage(mGraphicsDevice, *colorImage));
+ auto colorImageView = ImageView::NewFromImage(mGraphicsDevice, *colorImage);
// A new color attachment for each framebuffer
- OwnedAttachments attachments;
- attachments.emplace_back(FramebufferAttachment::NewColorAttachment(colorImageView,
- clearColor,
- true));
- std::unique_ptr<FramebufferAttachment> depthAttachment;
- std::unique_ptr<FramebufferImpl, void (*)(FramebufferImpl*)> framebuffer(
- FramebufferImpl::New(mGraphicsDevice,
- compatibleRenderPass,
- attachments,
- depthAttachment,
- mSwapchainCreateInfoKHR.imageExtent.width,
- mSwapchainCreateInfoKHR.imageExtent.height),
- [](FramebufferImpl* framebuffer1)
- {
- framebuffer1->Destroy();
- delete framebuffer1;
- });
- mFramebuffers.push_back(std::move(framebuffer));
-
- if(!compatibleRenderPass)
- {
- // use common renderpass for all framebuffers.
- compatibleRenderPass = mFramebuffers.back()->GetRenderPass(0);
- }
+ auto colorAttachment = FramebufferAttachment::NewColorAttachment(colorImageView,
+ clearColor,
+ true); // presentable
+
+ mFramebuffers.push_back(FramebufferImpl::New(mGraphicsDevice,
+ nullptr,
+ {colorAttachment},
+ nullptr,
+ mSwapchainCreateInfoKHR.imageExtent.width,
+ mSwapchainCreateInfoKHR.imageExtent.height));
}
mIsValid = true;
}
FramebufferImpl* Swapchain::GetFramebuffer(uint32_t index) const
{
- return mFramebuffers[index].get();
+ return mFramebuffers[index];
}
FramebufferImpl* Swapchain::AcquireNextFramebuffer(bool shouldCollectGarbageNow)
// cause a stall ( nvidia, ubuntu )
if(mFrameCounter >= mSwapchainBuffers.size())
{
- vk::Result status = swapchainBuffer->endOfFrameFence->GetStatus();
- if(status == vk::Result::eNotReady)
+ vk::Result result = swapchainBuffer->endOfFrameFence->GetStatus();
+ if(result == vk::Result::eNotReady)
{
swapchainBuffer->endOfFrameFence->Wait();
swapchainBuffer->endOfFrameFence->Reset();
}
// mGraphicsDevice.CollectGarbage();
- return mFramebuffers[mSwapchainImageIndex].get();
+ return mFramebuffers[mSwapchainImageIndex];
}
void Swapchain::Submit(CommandBufferImpl* commandBuffer)
mGraphicsDevice.Submit(*mQueue,
{Vulkan::SubmissionData{
{swapchainBuffer->acquireNextImageSemaphore},
- {vk::PipelineStageFlagBits::eFragmentShader},
+ {},
{commandBuffer},
{swapchainBuffer->submitSemaphore}}},
swapchainBuffer->endOfFrameFence.get());
mFrameCounter++;
}
+bool Swapchain::OnDestroy()
+{
+ if(mSwapchainKHR)
+ {
+ auto device = mGraphicsDevice.GetLogicalDevice();
+ auto swapchain = mSwapchainKHR;
+ auto allocator = &mGraphicsDevice.GetAllocator();
+
+ mGraphicsDevice.DiscardResource([device, swapchain, allocator]()
+ {
+ DALI_LOG_INFO(gVulkanFilter, Debug::General, "Invoking deleter function: swap chain->%p\n", static_cast<VkSwapchainKHR>(swapchain))
+ device.destroySwapchainKHR(swapchain, allocator); });
+
+ mSwapchainKHR = nullptr;
+ }
+ return false;
+}
+
bool Swapchain::IsValid() const
{
return mIsValid;
/**
* Creates swapchain for given surface and queue
*/
-class Swapchain
+class Swapchain : public VkManaged
{
public:
static Swapchain* NewSwapchain(
Swapchain(Device& graphicsDevice, Queue& presentationQueue);
- ~Swapchain();
+ ~Swapchain() override;
Swapchain(const Swapchain&) = delete;
Swapchain& operator=(const Swapchain&) = delete;
- void Destroy();
-
/**
* Automatically create framebuffers (generating compatible render passes)
*/
*/
void Present();
+ bool OnDestroy() override;
+
/**
* Returns true when swapchain expired
* @return
/**
* FramebufferImpl object associated with the buffer
*/
- using OwnedFramebuffer = std::unique_ptr<FramebufferImpl, void (*)(FramebufferImpl*)>;
- std::vector<OwnedFramebuffer> mFramebuffers;
+ std::vector<FramebufferImpl*> mFramebuffers;
/**
* Array of swapchain buffers
*/
std::vector<std::unique_ptr<SwapchainBuffer>> mSwapchainBuffers;
- uint32_t mFrameCounter{0u}; ///< Current frame number
+
+ FenceImpl* mBetweenRenderPassFence{};
+
+ uint32_t mFrameCounter{0u}; ///< Current frame number
bool mIsValid; // indicates whether the swapchain is still valid or requires to be recreated
};
// ...and flush
memory->Flush();
}
-
- ResourceTransferRequest transferRequest(TransferRequestType::LAYOUT_TRANSITION_ONLY);
- transferRequest.imageLayoutTransitionInfo.image = mImage;
- transferRequest.imageLayoutTransitionInfo.srcLayout = mImage->GetImageLayout();
- transferRequest.imageLayoutTransitionInfo.dstLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
- transferRequest.deferredTransferMode = false;
-
- // schedule transfer
- mController.ScheduleResourceTransfer(std::move(transferRequest));
}
vk::Format Texture::ValidateFormat(vk::Format sourceFormat)
void Texture::DestroyResource()
{
- if(mImageView)
- {
- mImageView->Destroy();
- mImageView = nullptr;
- }
- if(mImage)
- {
- mImage->Destroy();
- mImage = nullptr;
- }
- if(mSampler)
- {
- mSampler->Destroy();
- mSampler = nullptr;
- }
}
void Texture::DiscardResource()
{
- mController.DiscardResource(this);
}
void Texture::SetFormatAndUsage()
Texture(const Graphics::TextureCreateInfo& createInfo, VulkanGraphicsController& controller);
~Texture();
- /**
- * @copydoc Graphics::Vulkan::Resource::InitializeResource();
- */
bool InitializeResource() override;
- /**
- * @copydoc Graphics::Vulkan::Resource::DiscardResource();
- */
- void DiscardResource() override;
- /**
- * @copydoc Graphics::Vulkan::Resource::DestroyResource();
- */
void DestroyResource() override;
- /**
- * @copydoc Graphics::Vulkan::Resource::GetAllocationCallbacks()
- */
- [[nodiscard]] const Graphics::AllocationCallbacks* GetAllocationCallbacks() const override
- {
- return mCreateInfo.allocationCallbacks;
- }
-
- /**
- * @copydoc Graphics::Vulkan::Resource::InvokeDeleter()
- * Only intended for use by discard queue.
- */
- void InvokeDeleter() override
- {
- this->~Texture();
- }
+ void DiscardResource() override;
bool IsSamplerImmutable() const;
namespace Dali::Graphics
{
+
namespace
{
// Default value use to clear the stencil buffer
namespace Vulkan
{
+
/**
* Forward class declarations
*/
vk::AttachmentStoreOp storeOp{vk::AttachmentStoreOp::eDontCare};
};
+class VkManaged
+{
+public:
+ VkManaged() = default;
+
+ virtual ~VkManaged() = default;
+
+ void Release()
+ {
+ OnRelease(--mRefCount);
+
+ if(mRefCount == 0)
+ {
+ // orphaned
+ if(!Destroy())
+ {
+ delete this;
+ }
+ }
+ }
+
+ void Retain()
+ {
+ OnRetain(++mRefCount);
+ }
+
+ uint32_t GetRefCount()
+ {
+ return mRefCount;
+ }
+
+ virtual bool Destroy()
+ {
+ return OnDestroy();
+ }
+
+ virtual void OnRetain(uint32_t refcount)
+ {
+ }
+
+ virtual void OnRelease(uint32_t refcount)
+ {
+ }
+
+ virtual bool OnDestroy()
+ {
+ return false;
+ }
+
+private:
+ std::atomic_uint mRefCount{0u};
+};
+
} // namespace Vulkan
} // namespace Dali::Graphics
DALI_LOG_STREAM(gVulkanFilter, Debug::General, "DESTROYING GRAPHICS CONTEXT--------------------------------\n");
SwapBuffers();
- ReleaseCommandPools();
// We are done with all resources (technically... . If not we will get a ton of validation layer errors)
// Kill the Vulkan logical device
// Create methods -----------------------------------------------------------------------------------------------
void Device::Create()
{
- auto extensions = PrepareDefaultInstanceExtensions();
- auto instanceLayers = vk::enumerateInstanceLayerProperties();
+ auto extensions = PrepareDefaultInstanceExtensions();
+ auto layers = vk::enumerateInstanceLayerProperties();
std::vector<const char*> validationLayers;
- if(!instanceLayers.value.empty())
+ for(auto&& reqLayer : reqLayers)
{
- for(auto&& prop : instanceLayers.value)
+ for(auto&& prop : layers.value)
{
DALI_LOG_STREAM(gVulkanFilter, Debug::General, prop.layerName);
- for(auto&& reqLayer : reqLayers)
+ if(std::string(prop.layerName) == reqLayer)
{
- if(std::string(prop.layerName) == reqLayer)
- {
- validationLayers.push_back(reqLayer);
- }
+ validationLayers.push_back(reqLayer);
}
}
}
// during replacing the swapchain
auto khr = oldSwapchain->GetVkHandle();
oldSwapchain->SetVkHandle(nullptr);
- oldSwapchain->Destroy();
- delete oldSwapchain;
+ oldSwapchain->Release();
mLogicalDevice.destroySwapchainKHR(khr, *mAllocator);
}
void Device::DiscardResource(std::function<void()> deleter)
{
- // For now, just call immediately.
- deleter();
+ // std::lock_guard< std::mutex > lock( mMutex );
+ // mDiscardQueue[mCurrentBufferIndex].push_back( std::move( deleter ) );
}
Image* Device::CreateImageFromExternal(vk::Image externalImage, vk::Format imageFormat, vk::Extent2D extent)
return commandPool;
}
-void Device::ReleaseCommandPools()
-{
- for(auto& commandPool : mCommandPools)
- {
- commandPool.second->Reset(true);
- delete commandPool.second;
- }
-}
-
void Device::SurfaceResized(unsigned int width, unsigned int height)
{
// Get main window's surface
uint32_t Device::SwapBuffers()
{
- DeviceWaitIdle();
mCurrentBufferIndex = (mCurrentBufferIndex + 1) & 1;
return mCurrentBufferIndex;
}
std::vector<const char*> PrepareDefaultInstanceExtensions();
- void ReleaseCommandPools();
-
private: // Members
vk::PhysicalDevice mPhysicalDevice;
vk::Device mLogicalDevice;
std::vector<vk::QueueFamilyProperties> mQueueFamilyProperties;
// Sets of queues
- std::vector<std::unique_ptr<Queue>> mAllQueues;
- std::vector<Queue*> mGraphicsQueues;
- std::vector<Queue*> mTransferQueues;
- std::vector<Queue*> mComputeQueues;
+ std::vector<std::unique_ptr<Queue> > mAllQueues;
+ std::vector<Queue*> mGraphicsQueues;
+ std::vector<Queue*> mTransferQueues;
+ std::vector<Queue*> mComputeQueues;
CommandPoolMap mCommandPools;
return surfaceId;
}
-void VulkanGraphics::DestroySurface(Graphics::SurfaceId surfaceId)
+void VulkanGraphics::DestroySurface(Graphics::SurfaceId)
{
- mGraphicsDevice.DestroySurface(surfaceId);
+ // @todo Destroy swapchain.
}
bool VulkanGraphics::ReplaceSurface(Graphics::SurfaceId surface, int width, int height)
void VulkanGraphics::PostRender()
{
- mGraphicsDevice.SwapBuffers();
}
void VulkanGraphics::Shutdown()
void VulkanGraphics::Destroy()
{
- mGraphicsController.RunGarbageCollector(0);
}
void VulkanGraphics::Pause()
// If both dimensions have values requested, use them both:
if(requestedWidth != 0 && requestedHeight != 0)
{
- DALI_ASSERT_DEBUG((bitmapWidth > 0 && bitmapHeight > 0) && "Bitmap dimensions are zero");
+ DALI_ASSERT_DEBUG( (bitmapWidth > 0 && bitmapHeight > 0) && "Bitmap dimensions are zero");
if(fittingMode == FittingMode::VISUAL_FITTING)
{
uint32_t adjustedDesiredWidth, adjustedDesiredHeight;
- float aspectOfDesiredSize = (float)requestedHeight / (float)requestedWidth;
- float aspectOfImageSize = (float)bitmapHeight / (float)bitmapWidth;
- if(aspectOfImageSize > aspectOfDesiredSize)
+ float aspectOfDesiredSize = (float)requestedHeight / (float)requestedWidth;
+ float aspectOfImageSize = (float)bitmapHeight / (float)bitmapWidth;
+ if (aspectOfImageSize > aspectOfDesiredSize)
{
- adjustedDesiredWidth = requestedWidth;
- adjustedDesiredHeight = (static_cast<uint64_t>(bitmapHeight) * requestedWidth + bitmapWidth / 2) / bitmapWidth; ///< round up
+ adjustedDesiredWidth = requestedWidth;
+ adjustedDesiredHeight = static_cast<uint64_t>(bitmapHeight) * requestedWidth / bitmapWidth;
}
else
{
- adjustedDesiredWidth = (static_cast<uint64_t>(bitmapWidth) * requestedHeight + bitmapHeight / 2) / bitmapHeight; ///< round up
+ adjustedDesiredWidth = static_cast<uint64_t>(bitmapWidth) * requestedHeight / bitmapHeight;
adjustedDesiredHeight = requestedHeight;
}
- requestedWidth = adjustedDesiredWidth;
+ requestedWidth = adjustedDesiredWidth;
requestedHeight = adjustedDesiredHeight;
}
if(filteredWidth < shrunkWidth || filteredHeight < shrunkHeight)
{
if(samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR ||
- samplingMode == SamplingMode::LANCZOS || samplingMode == SamplingMode::BOX_THEN_LANCZOS ||
samplingMode == SamplingMode::NEAREST || samplingMode == SamplingMode::BOX_THEN_NEAREST)
{
outputBitmap = Dali::Devel::PixelBuffer::New(filteredWidth, filteredHeight, pixelFormat);
{
LinearSample(bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), outStride, pixelFormat, outputBitmap.GetBuffer(), filteredDimensions);
}
- else if(samplingMode == SamplingMode::LANCZOS || samplingMode == SamplingMode::BOX_THEN_LANCZOS)
- {
- LanczosSample(bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), outStride, pixelFormat, outputBitmap.GetBuffer(), filteredDimensions);
- }
else
{
PointSample(bitmap.GetBuffer(), shrunkWidth, shrunkHeight, outStride, pixelFormat, outputBitmap.GetBuffer(), filteredWidth, filteredHeight);
outHeight = inputHeight;
outStride = inputStride;
// Perform power of 2 iterated 4:1 box filtering if the requested filter mode requires it:
- if(samplingMode == SamplingMode::BOX || samplingMode == SamplingMode::BOX_THEN_NEAREST || samplingMode == SamplingMode::BOX_THEN_LINEAR || samplingMode == SamplingMode::BOX_THEN_LANCZOS)
+ if(samplingMode == SamplingMode::BOX || samplingMode == SamplingMode::BOX_THEN_NEAREST || samplingMode == SamplingMode::BOX_THEN_LINEAR)
{
// Check the pixel format is one that is supported:
if(pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 || pixelFormat == Pixel::CHROMINANCE_U || pixelFormat == Pixel::CHROMINANCE_V)
Resample(inPixels, inputDimensions, inputStride, outPixels, desiredDimensions, Resampler::LANCZOS4, 4, true);
}
-void LanczosSample3BPP(const uint8_t* __restrict__ inPixels,
- ImageDimensions inputDimensions,
- uint32_t inputStride,
- uint8_t* __restrict__ outPixels,
- ImageDimensions desiredDimensions)
-{
- Resample(inPixels, inputDimensions, inputStride, outPixels, desiredDimensions, Resampler::LANCZOS4, 3, false);
-}
-
void LanczosSample1BPP(const uint8_t* __restrict__ inPixels,
ImageDimensions inputDimensions,
uint32_t inputStride,
uint8_t* __restrict__ outPixels,
ImageDimensions outDimensions)
{
- // TODO : Need to support LanczosSample various pixel format.
- // Until now, just use LinearSample instead.
- //
// Check the pixel format is one that is supported:
- if(pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::BGRA8888 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8)
+ if(pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::BGRA8888 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8)
{
switch(pixelFormat)
{
- case Pixel::RGB888:
- {
- LanczosSample3BPP(inPixels, inDimensions, inStride, outPixels, outDimensions);
- break;
- }
case Pixel::RGBA8888:
case Pixel::BGRA8888:
{
}
else
{
- LinearSample(inPixels, inDimensions, inStride, pixelFormat, outPixels, outDimensions);
DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not lanczos sampled: unsupported pixel format: %u.\n", static_cast<uint32_t>(pixelFormat));
}
}
case SamplingMode::BOX:
case SamplingMode::BOX_THEN_NEAREST:
case SamplingMode::BOX_THEN_LINEAR:
- case SamplingMode::BOX_THEN_LANCZOS:
case SamplingMode::DONT_CARE:
{
useTurboJpegScaleFactor = true;
case SamplingMode::NO_FILTER:
case SamplingMode::NEAREST:
case SamplingMode::LINEAR:
- case SamplingMode::LANCZOS:
{
useTurboJpegScaleFactor = false;
break;
{
namespace // unnamed namespace
{
-static constexpr int32_t USE_ENVIRONMENT_VALUE = -1;
-static constexpr int32_t USE_CHROMIUM_WEB_ENGINE = 0;
-static constexpr int32_t USE_LIGHT_WEIGHT_WEB_ENGINE = 1;
-static constexpr int32_t DEFAULT_WEB_ENGINE_PLUGIN_TYPE = USE_ENVIRONMENT_VALUE;
-static int32_t webEnginePluginType = DEFAULT_WEB_ENGINE_PLUGIN_TYPE;
-
constexpr char const* const kPluginFullNamePrefix = "libdali2-web-engine-";
constexpr char const* const kPluginFullNamePostfix = "-plugin.so";
constexpr char const* const kPluginFullNameDefault = "libdali2-web-engine-plugin.so";
-constexpr char const* const kPluginFullNameChromium = "libdali2-web-engine-chromium-plugin.so";
-constexpr char const* const kPluginFullNameLwe = "libdali2-web-engine-lwe-plugin.so";
std::string MakePluginName(const char* environmentName)
{
mGetWebEngineCookieManagerPtr{nullptr}
{
std::string pluginName;
-
- if(webEnginePluginType == USE_CHROMIUM_WEB_ENGINE)
- {
- pluginName = kPluginFullNameChromium;
- }
- else if(webEnginePluginType == USE_LIGHT_WEIGHT_WEB_ENGINE)
+ const char* name = EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_WEB_ENGINE_NAME);
+ if(name)
{
- pluginName = kPluginFullNameLwe;
+ pluginName = MakePluginName(name);
}
else
{
- const char* name = EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_WEB_ENGINE_NAME);
- if(name)
- {
- pluginName = MakePluginName(name);
- }
- else
- {
- pluginName = std::string(kPluginFullNameDefault);
- }
+ pluginName = std::string(kPluginFullNameDefault);
}
mHandle = dlopen(pluginName.c_str(), RTLD_LAZY);
} // unnamed namespace
-WebEnginePtr WebEngine::New(int32_t type)
+WebEnginePtr WebEngine::New()
{
- WebEngine* instance = new WebEngine(type);
+ WebEngine* instance = new WebEngine();
if(!instance->Initialize())
{
delete instance;
return nullptr;
}
-WebEngine::WebEngine(int32_t type)
+WebEngine::WebEngine()
: mPlugin(nullptr)
{
- webEnginePluginType = type;
}
WebEngine::~WebEngine()
mPlugin->GetPlainTextAsynchronously(callback);
}
-void WebEngine::WebAuthenticationCancel()
-{
- mPlugin->WebAuthenticationCancel();
-}
-
-void WebEngine::RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback)
-{
- mPlugin->RegisterWebAuthDisplayQRCallback(callback);
-}
-
-void WebEngine::RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback)
-{
- mPlugin->RegisterWebAuthResponseCallback(callback);
-}
-
-void WebEngine::RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback)
-{
- mPlugin->RegisterUserMediaPermissionRequestCallback(callback);
-}
-
-
} // namespace Adaptor
} // namespace Internal
} // namespace Dali
{
public:
/**
- * @brief Create a new WebEngine handle with type (0: Chromium, 1: LWE, otherwise: depend on system environment).
- * @param[in] type The WebEngine type (0: Chromium, 1: LWE, otherwise: depend on system environment).
+ * @brief Create a new WebEngine handle
+ *
* @return WebEngine pointer
*/
- static WebEnginePtr New(int32_t type);
+ static WebEnginePtr New();
/**
* @brief Get context of web engine
*/
void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);
- /**
- * @copydoc Dali::WebEngine::WebAuthenticationCancel()
- */
- void WebAuthenticationCancel();
-
- /**
- * @copydoc Dali::WebEngine::RegisterWebAuthDisplayQRCallback()
- */
- void RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback);
-
- /**
- * @copydoc Dali::WebEngine::RegisterWebAuthResponseCallback()
- */
- void RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback);
-
- /**
- * @copydoc Dali::WebEngine::RegisterUserMediaPermissionRequestCallback()
- */
- void RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback);
-
private:
/**
- * @brief Constructor with WebEngine type (0: Chromium, 1: LWE, otherwise: depend on system environment).
+ * @brief Constructor.
*/
- WebEngine(int32_t type);
+ WebEngine();
/**
* @brief Destructor.
return false;
}
-void WindowBaseAndroid::SetBottom(bool enable)
-{
-}
-
-bool WindowBaseAndroid::IsBottom()
-{
- return false;
-}
-
Any WindowBaseAndroid::GetNativeBuffer() const
{
return 0;
return 0;
}
-void WindowBaseAndroid::SetBehindBlur(int blurRadius)
-{
-}
-
-int WindowBaseAndroid::GetBehindBlur()
-{
- return 0;
-}
-
} // namespace Adaptor
} // namespace Internal
*/
bool IsAlwaysOnTop() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBottom()
- */
- void SetBottom(bool enable) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::IsBottom()
- */
- bool IsBottom() override;
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeBuffer()
*/
*/
bool RelativeMotionUnGrab() override;
- /**
+/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetBackgroundBlur()
*/
void SetBackgroundBlur(int blurRadius, int cornerRadius) override;
+
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetBackgroundBlur()
*/
int GetBackgroundBlur() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBehindBlur()
- */
- void SetBehindBlur(int blurRadius) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::GetBehindBlur()
- */
- int GetBehindBlur() override;
-
private:
/**
* Second stage initialization
/**
* @brief Enables or disables the window always is on top.
*
- * This is valid between windows that have no notification level or a notification level of 'none'.
- * If it has a notification level, this will not do anything.
- *
* @param[in] alwaysOnTop true to enable the window always is on top, false to disable.
*/
virtual void SetAlwaysOnTop(bool alwaysOnTop) = 0;
*/
virtual bool IsAlwaysOnTop() = 0;
- /**
- * @brief Enables or disables the window's layer is changed to bottom.
- *
- * If the enable flag is true, this window will be placed below other windows.
- * Otherwise, if it's called with a false value, it will be located above other windows.
- *
- * @param[in] window The window instance.
- * @param[in] enable true to change the window layer to the bottom.
- */
- virtual void SetBottom(bool enable) = 0;
-
- /**
- * @brief Returns whether the window layer is the bottom or not.
- *
- * @return True if the window layer is the bottom, false otherwise.
- */
- virtual bool IsBottom() = 0;
-
/**
* @brief Get native buffer of window.
* @return The native window buffer handle
* @brief Set the window's background blur.
* If this value is 0, the background blur is disabled.
*
- * @param[in] blurRadius The radius of the blur effect.
- * @param[in] cornerRadius The radius of the corner radius.
+ * @param[in] blurRadius the background blur.
+ * @param[in] cornerRadius the background blur.
*/
virtual void SetBackgroundBlur(int blurRadius, int cornerRadius) = 0;
*/
virtual int GetBackgroundBlur() = 0;
- /**
- * @brief Set the window's behind blur.
- * If this value is 0, the behind blur is disabled.
- *
- * @param[in] blurRadius The radius of the blur effect.
- */
- virtual void SetBehindBlur(int blurRadius) = 0;
-
- /**
- * @brief Returns current behind blur.
- * If this value is 0, behind blur is disabled.
- *
- * @return current behind blur.
- */
- virtual int GetBehindBlur() = 0;
-
// Signals
/**
Window::~Window()
{
+ if(mScene)
+ {
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto rootLayer = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get(rootLayer);
+ bridge->RemoveTopLevelWindow(accessible);
+ // Related to multi-window case. This is called for default window and non-default window, but it is effective for non-default window.
+ bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
+ }
+
if(mAdaptor)
{
mAdaptor->RemoveWindow(this);
void Window::OnAccessibilityDisabled()
{
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto rootLayer = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get(rootLayer);
+
DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
InterceptKeyEventSignal().Disconnect(this, &Window::OnAccessibilityInterceptKeyEvent);
+ bridge->RemoveTopLevelWindow(accessible);
}
bool Window::OnAccessibilityInterceptKeyEvent(const Dali::KeyEvent& keyEvent)
return false;
}
- auto callback = [handle = Dali::Window(this)](Dali::KeyEvent keyEvent, bool consumed)
- {
+ auto callback = [handle = Dali::Window(this)](Dali::KeyEvent keyEvent, bool consumed) {
if(!consumed)
{
Dali::DevelKeyEvent::SetNoInterceptModifier(keyEvent, true);
return mWindowBase->IsAlwaysOnTop();
}
-void Window::SetBottom(bool enable)
-{
- mWindowBase->SetBottom(enable);
-}
-
-bool Window::IsBottom()
-{
- return mWindowBase->IsBottom();
-}
-
Dali::Any Window::GetNativeBuffer() const
{
return mWindowBase->GetNativeBuffer();
if(mBlurInfo.windowBlurType == WindowBlurType::BACKGROUND)
{
- mWindowBase->SetBackgroundBlur(mBlurInfo.windowBlurRadius, mBlurInfo.backgroundCornerRadius);
- }
- else if(mBlurInfo.windowBlurType == WindowBlurType::BEHIND)
- {
- mWindowBase->SetBehindBlur(mBlurInfo.windowBlurRadius);
+ mWindowBase->SetBackgroundBlur(mBlurInfo.windowBlurRadius, mBlurInfo.backgroundBlurRadius);
}
else
{
mWindowBase->SetBackgroundBlur(0, 0);
}
+ // TODO : When new Blur type is append, it will be added
}
WindowBlurInfo Window::GetBlur() const
*/
bool IsAlwaysOnTop();
- /**
- * @copydoc Dali::DevelWindow::SetBottom()
- */
- void SetBottom(bool enable);
-
- /**
- * @copydoc Dali::DevelWindow::IsBottom()
- */
- bool IsBottom();
-
/**
* @copydoc Dali::DevelWindow::GetNativeBuffer()
*/
std::string GetNativeWindowResourceId() override;
/**
- * @copydoc Dali::Internal::Adaptor::WindowBase::CreateWindow()
+ * @copydoc Dali::Internal::Adaptor::WindowBase::CreateWindow()
*/
Dali::Any CreateWindow(int width, int height) override;
*/
bool IsAlwaysOnTop() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBottom()
- */
- void SetBottom(bool enable) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::IsBottom()
- */
- bool IsBottom() override;
-
/**
* @brief Sets front buffer rendering to the window.
* @param[in] enable True to enable front buffer rendering mode, False to otherwise.
*/
int GetBackgroundBlur() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBehindBlur()
- */
- void SetBehindBlur(int blurRadius) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::GetBehindBlur()
- */
- int GetBehindBlur() override;
-
private:
// Undefined
WindowBaseCocoa(const WindowBaseCocoa&) = delete;
return false;
}
-void WindowBaseCocoa::SetBottom(bool enable)
-{
-}
-
-bool WindowBaseCocoa::IsBottom()
-{
- return false;
-}
-
Any WindowBaseCocoa::GetNativeBuffer() const
{
return 0;
return 0;
}
-void WindowBaseCocoa::SetBehindBlur(int blurRadius)
-{
-}
-
-int WindowBaseCocoa::GetBehindBlur()
-{
- return 0;
-}
-
} // namespace Dali::Internal::Adaptor
@implementation CocoaView
mOwnSurface(false),
mBrightnessChangeDone(true),
mIsFrontBufferRendering(false),
- mIsIMEWindowInitialized(false),
- mBottom(false)
+ mIsIMEWindowInitialized(false)
{
Initialize(positionSize, surface, isTransparent);
}
DALI_LOG_RELEASE_INFO("ecore_wl2_window_pin_mode_set, window: [%p], flag [%d]\n", mEcoreWindow, alwaysOnTop);
START_DURATION_CHECK();
ecore_wl2_window_pin_mode_set(mEcoreWindow, alwaysOnTop);
- ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
FINISH_DURATION_CHECK("ecore_wl2_window_pin_mode_set");
}
return ret;
}
-void WindowBaseEcoreWl2::SetBottom(bool enable)
-{
- START_DURATION_CHECK();
- mBottom = enable;
- if(mBottom)
- {
- DALI_LOG_RELEASE_INFO("ecore_wl2_window_stack_mode_set, window: [%p], flag[%d] ECORE_WL2_WINDOW_STACK_BELOW\n", mEcoreWindow, mBottom);
- ecore_wl2_window_stack_mode_set(mEcoreWindow, ECORE_WL2_WINDOW_STACK_BELOW);
- }
- else
- {
- DALI_LOG_RELEASE_INFO("ecore_wl2_window_stack_mode_set, window: [%p], flag[%d] ECORE_WL2_WINDOW_STACK_NONE\n", mEcoreWindow, mBottom);
- ecore_wl2_window_stack_mode_set(mEcoreWindow, ECORE_WL2_WINDOW_STACK_NONE);
- }
- ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
- FINISH_DURATION_CHECK("ecore_wl2_window_stack_mode_set");
-}
-
-bool WindowBaseEcoreWl2::IsBottom()
-{
- return mBottom;
-}
-
Any WindowBaseEcoreWl2::GetNativeBuffer() const
{
DALI_LOG_RELEASE_INFO("Get wl_egl_window, ecore_window: [%p], wl_egl_window [%p]\n", mEcoreWindow, mEglWindow);
return radius;
}
-void WindowBaseEcoreWl2::SetBehindBlur(int blurRadius)
-{
- DALI_LOG_RELEASE_INFO("ecore_wl2_window_behind_blur_set, window: [%p], blur radius [%d]\n", mEcoreWindow, blurRadius);
- START_DURATION_CHECK();
- ecore_wl2_window_behind_blur_set(mEcoreWindow, blurRadius);
- FINISH_DURATION_CHECK("ecore_wl2_window_behind_blur_set");
-}
-
-int WindowBaseEcoreWl2::GetBehindBlur()
-{
- int radius = ecore_wl2_window_behind_blur_get(mEcoreWindow);
- DALI_LOG_RELEASE_INFO("ecore_wl2_window_behind_blur_get, window: [%p], radius [%d]\n", mEcoreWindow, radius);
- return radius;
-}
-
} // namespace Adaptor
} // namespace Internal
*/
bool IsAlwaysOnTop() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBottom()
- */
- void SetBottom(bool enable) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::IsBottom()
- */
- bool IsBottom() override;
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeBuffer()
*/
*/
int GetBackgroundBlur() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBehindBlur()
- */
- void SetBehindBlur(int blurRadius) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::GetBehindBlur()
- */
- int GetBehindBlur() override;
-
private:
/**
* Second stage initialization
bool mBrightnessChangeDone;
bool mIsFrontBufferRendering;
bool mIsIMEWindowInitialized;
- bool mBottom;
};
} // namespace Adaptor
return false;
}
-void WindowBaseEcoreX::SetBottom(bool enable)
-{
-}
-
-bool WindowBaseEcoreX::IsBottom()
-{
- return false;
-}
-
Any WindowBaseEcoreX::GetNativeBuffer() const
{
return 0;
return 0;
}
-void WindowBaseEcoreX::SetBehindBlur(int blurRadius)
-{
-}
-
-int WindowBaseEcoreX::GetBehindBlur()
-{
- return 0;
-}
-
} // namespace Adaptor
} // namespace Internal
*/
bool IsAlwaysOnTop() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBottom()
- */
- void SetBottom(bool enable) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::IsBottom()
- */
- bool IsBottom() override;
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeBuffer()
*/
*/
int GetBackgroundBlur() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBehindBlur()
- */
- void SetBehindBlur(int blurRadius) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::GetBehindBlur()
- */
- int GetBehindBlur() override;
private:
/**
* Second stage initialization
return false;
}
-void WindowBaseWin::SetBottom(bool enable)
-{
-}
-
-bool WindowBaseWin::IsBottom()
-{
- return false;
-}
-
Any WindowBaseWin::GetNativeBuffer() const
{
return 0;
return 0;
}
-void WindowBaseWin::SetBehindBlur(int blurRadius)
-{
-}
-
-int WindowBaseWin::GetBehindBlur()
-{
- return 0;
-}
-
} // namespace Adaptor
} // namespace Internal
*/
bool IsAlwaysOnTop() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBottom()
- */
- void SetBottom(bool enable) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::IsBottom()
- */
- bool IsBottom() override;
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeBuffer()
*/
*/
int GetBackgroundBlur() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBehindBlur()
- */
- void SetBehindBlur(int blurRadius) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::GetBehindBlur()
- */
- int GetBehindBlur() override;
private:
/**
* Second stage initialization
return false;
}
-void WindowBaseX::SetBottom(bool enable)
-{
-}
-
-bool WindowBaseX::IsBottom()
-{
- return false;
-}
-
Any WindowBaseX::GetNativeBuffer()
{
return 0;
return 0;
}
-void WindowBaseX::SetBehindBlur(int blurRadius)
-{
-}
-
-int WindowBaseX::GetBehindBlur()
-{
- return 0;
-}
-
} // namespace Adaptor
} // namespace Internal
*/
bool IsAlwaysOnTop() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBottom()
- */
- void SetBottom(bool enable) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::IsBottom()
- */
- bool IsBottom() override;
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeBuffer()
*/
*/
int GetBackgroundBlur() override;
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::SetBehindBlur()
- */
- void SetBehindBlur(int blurRadius) override;
-
- /**
- * @copydoc Dali::Internal::Adaptor::WindowBase::GetBehindBlur()
- */
- int GetBehindBlur() override;
private:
/**
* Second stage initialization
{
NONE = 0, ///< default value for blur disable
BACKGROUND, ///< the window's background
- BEHIND, ///< the window's behind except background
+ // BEHIND, ///< the window's behind except background
+ // BOTH, ///< both window's background and behind
};
} // namespace Dali
{
const unsigned int ADAPTOR_MAJOR_VERSION = 2;
const unsigned int ADAPTOR_MINOR_VERSION = 3;
-const unsigned int ADAPTOR_MICRO_VERSION = 44;
+const unsigned int ADAPTOR_MICRO_VERSION = 41;
const char* const ADAPTOR_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali2-adaptor
Summary: The DALi Tizen Adaptor
-Version: 2.3.44
+Version: 2.3.41
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT