From 4387b0de650b6f0fd8b1b7c44b71841ca628d977 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Thu, 6 Oct 2022 20:10:50 +0900 Subject: [PATCH] Minor coverity issue fixes Fix some minor coverity issues that might has meanful 1. Implement missing move operation. 2. Remove float equal checks by ==, != operator. 3. unsigned int / unsigned char to uint32_t / uint8_t 4. Change missed value type (a.k.a float v = true;) Change-Id: Ib6eb901919918488f2ff7085301e73a466b98019 Signed-off-by: Eunki, Hong --- .../dali-adaptor-internal/utc-Dali-FontClient.cpp | 14 ++++ .../dali-adaptor/utc-Dali-EncodedImageBuffer.cpp | 25 ++++++++ .../src/dali-adaptor/utc-Dali-GifLoading.cpp | 30 +++++++++ .../src/dali-adaptor/utc-Dali-PixelBuffer.cpp | 39 ++++++++++++ .../adaptor-framework/animated-image-loading.h | 17 ++++- .../adaptor-framework/color-controller.cpp | 17 ++--- .../devel-api/adaptor-framework/color-controller.h | 18 +++++- .../adaptor-framework/offscreen-window.cpp | 6 +- .../devel-api/adaptor-framework/offscreen-window.h | 17 ++++- dali/devel-api/adaptor-framework/pixel-buffer.cpp | 29 ++++----- dali/devel-api/adaptor-framework/pixel-buffer.h | 31 +++++++-- dali/devel-api/adaptor-framework/style-monitor.cpp | 22 +++---- dali/devel-api/adaptor-framework/style-monitor.h | 38 +++++++---- dali/devel-api/adaptor-framework/video-player.cpp | 20 ++---- dali/devel-api/adaptor-framework/video-player.h | 19 +++++- .../adaptor-framework/web-engine/web-engine.cpp | 18 ++---- .../adaptor-framework/web-engine/web-engine.h | 15 +++++ dali/devel-api/text-abstraction/font-client.cpp | 54 +++++++++++++--- dali/devel-api/text-abstraction/font-client.h | 36 +++++++++++ .../accessibility/bridge/bridge-accessible.cpp | 11 ++-- dali/internal/graphics/gles-impl/gles-context.cpp | 11 ++-- dali/internal/imaging/common/image-operations.cpp | 74 +++++++++++----------- dali/internal/imaging/common/pixel-buffer-impl.cpp | 70 ++++++++++---------- dali/internal/imaging/common/pixel-buffer-impl.h | 40 ++++++------ .../adaptor-framework/encoded-image-buffer.cpp | 17 ++--- .../adaptor-framework/encoded-image-buffer.h | 15 +++++ 26 files changed, 493 insertions(+), 210 deletions(-) diff --git a/automated-tests/src/dali-adaptor-internal/utc-Dali-FontClient.cpp b/automated-tests/src/dali-adaptor-internal/utc-Dali-FontClient.cpp index 208deb1..4868e3c 100644 --- a/automated-tests/src/dali-adaptor-internal/utc-Dali-FontClient.cpp +++ b/automated-tests/src/dali-adaptor-internal/utc-Dali-FontClient.cpp @@ -230,6 +230,20 @@ int UtcDaliFontClientAtlasLimitationDisabled(void) DALI_TEST_GREATER(1024u, glyphBufferData2000.width, TEST_LOCATION); //924u DALI_TEST_GREATER(glyphBufferData2000.height, 1024u, TEST_LOCATION); //1148u + // Test GlyphBufferData move + TextAbstraction::FontClient::GlyphBufferData movedGlyphBufferData2000 = std::move(glyphBufferData2000); + + for(int i = 0; i < 50; ++i) + { + TextAbstraction::FontClient::GlyphBufferData dummy = std::move(movedGlyphBufferData2000); + movedGlyphBufferData2000 = std::move(dummy); + + // Test moved GlyphBufferData destruct well + } + + DALI_TEST_GREATER(1024u, movedGlyphBufferData2000.width, TEST_LOCATION); //924u + DALI_TEST_GREATER(movedGlyphBufferData2000.height, 1024u, TEST_LOCATION); //1148u + END_TEST; } diff --git a/automated-tests/src/dali-adaptor/utc-Dali-EncodedImageBuffer.cpp b/automated-tests/src/dali-adaptor/utc-Dali-EncodedImageBuffer.cpp index 36b3f4f..5b2da93 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-EncodedImageBuffer.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-EncodedImageBuffer.cpp @@ -82,6 +82,31 @@ int UtcDaliEncodedImageBufferAssignmentOperator(void) END_TEST; } +int UtcDaliEncodedImageBufferMoveConstructor(void) +{ + EncodedImageBuffer buffer = EncodedImageBuffer::New(tinybuffer()); + EncodedImageBuffer bufferMoved = std::move(buffer); + + DALI_TEST_EQUALS((bool)buffer, false, TEST_LOCATION); + DALI_TEST_EQUALS((bool)bufferMoved, true, TEST_LOCATION); + END_TEST; +} + +int UtcDaliEncodedImageBufferMoveAssignmentOperator(void) +{ + EncodedImageBuffer buffer = EncodedImageBuffer::New(tinybuffer()); + + EncodedImageBuffer buffer2; + DALI_TEST_EQUALS((bool)buffer, true, TEST_LOCATION); + DALI_TEST_EQUALS((bool)buffer2, false, TEST_LOCATION); + + buffer2 = std::move(buffer); + DALI_TEST_EQUALS((bool)buffer, false, TEST_LOCATION); + DALI_TEST_EQUALS((bool)buffer2, true, TEST_LOCATION); + + END_TEST; +} + int UtcDaliEncodedImageBufferGetRawBuffer(void) { EncodedImageBuffer::RawBufferType originBuffer = tinybuffer(); diff --git a/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp b/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp index 03267a7..784d76b 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp @@ -45,6 +45,36 @@ void utc_dali_animated_image_loader_cleanup(void) test_return_value = TET_PASS; } +int UtcDaliAnimatedImageLoadingCopyMoveP(void) +{ + Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true); + + Dali::AnimatedImageLoading copied = animatedImageLoading; + + DALI_TEST_EQUALS((bool)animatedImageLoading, true, TEST_LOCATION); + DALI_TEST_EQUALS((bool)copied, true, TEST_LOCATION); + + Dali::AnimatedImageLoading moved = std::move(animatedImageLoading); + + DALI_TEST_EQUALS((bool)animatedImageLoading, false, TEST_LOCATION); + DALI_TEST_EQUALS((bool)copied, true, TEST_LOCATION); + DALI_TEST_EQUALS((bool)moved, true, TEST_LOCATION); + + Dali::AnimatedImageLoading copiedAssign; + copiedAssign = copied; + + Dali::AnimatedImageLoading movedAssign; + movedAssign = std::move(moved); + + DALI_TEST_EQUALS((bool)animatedImageLoading, false, TEST_LOCATION); + DALI_TEST_EQUALS((bool)copied, true, TEST_LOCATION); + DALI_TEST_EQUALS((bool)moved, false, TEST_LOCATION); + DALI_TEST_EQUALS((bool)copiedAssign, true, TEST_LOCATION); + DALI_TEST_EQUALS((bool)movedAssign, true, TEST_LOCATION); + + END_TEST; +} + int UtcDaliAnimatedImageLoadingGetImageSizeP(void) { Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true); diff --git a/automated-tests/src/dali-adaptor/utc-Dali-PixelBuffer.cpp b/automated-tests/src/dali-adaptor/utc-Dali-PixelBuffer.cpp index bed76e1..2c74145 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-PixelBuffer.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-PixelBuffer.cpp @@ -196,6 +196,45 @@ int UtcDaliPixelBufferNew01P(void) END_TEST; } +int UtcDaliPixelBufferConstructor01P(void) +{ + TestApplication application; + Devel::PixelBuffer pixbuf = Devel::PixelBuffer::New(10, 10, Pixel::RGBA8888); + + Devel::PixelBuffer copiedBuf = pixbuf; + DALI_TEST_CHECK(pixbuf); + DALI_TEST_CHECK(copiedBuf); + DALI_TEST_CHECK(pixbuf.GetBuffer() != NULL); + DALI_TEST_CHECK(copiedBuf.GetBuffer() != NULL); + + Devel::PixelBuffer movedBuf = std::move(pixbuf); + DALI_TEST_CHECK(!pixbuf); + DALI_TEST_CHECK(movedBuf); + DALI_TEST_CHECK(movedBuf.GetBuffer() != NULL); + END_TEST; +} + +int UtcDaliPixelBufferAssign01P(void) +{ + TestApplication application; + Devel::PixelBuffer pixbuf = Devel::PixelBuffer::New(10, 10, Pixel::RGBA8888); + + Devel::PixelBuffer copiedBuf; + copiedBuf = pixbuf; + DALI_TEST_CHECK(pixbuf); + DALI_TEST_CHECK(copiedBuf); + DALI_TEST_CHECK(pixbuf.GetBuffer() != NULL); + DALI_TEST_CHECK(copiedBuf.GetBuffer() != NULL); + + Devel::PixelBuffer movedBuf; + DALI_TEST_CHECK(!movedBuf); + movedBuf = std::move(pixbuf); + DALI_TEST_CHECK(!pixbuf); + DALI_TEST_CHECK(movedBuf); + DALI_TEST_CHECK(movedBuf.GetBuffer() != NULL); + END_TEST; +} + int UtcDaliPixelBufferNew01N(void) { TestApplication application; diff --git a/dali/devel-api/adaptor-framework/animated-image-loading.h b/dali/devel-api/adaptor-framework/animated-image-loading.h index da72e3f..4becd1f 100644 --- a/dali/devel-api/adaptor-framework/animated-image-loading.h +++ b/dali/devel-api/adaptor-framework/animated-image-loading.h @@ -2,7 +2,7 @@ #define DALI_ANIMATED_IMAGE_LOADING_H /* - * Copyright (c) 2021 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. @@ -95,6 +95,21 @@ public: AnimatedImageLoading& operator=(const AnimatedImageLoading& rhs) = default; /** + * @brief Move constructor. + * + * @param[in] move The AnimatedImageLoading to move + */ + AnimatedImageLoading(AnimatedImageLoading&& move) = default; + + /** + * @brief Move assignment operator + * + * @param[in] rhs The AnimatedImageLoading to move + * @return A reference to this + */ + AnimatedImageLoading& operator=(AnimatedImageLoading&& rhs) = default; + + /** * @brief Destructor */ ~AnimatedImageLoading(); diff --git a/dali/devel-api/adaptor-framework/color-controller.cpp b/dali/devel-api/adaptor-framework/color-controller.cpp index 3f8f14a..82518e6 100644 --- a/dali/devel-api/adaptor-framework/color-controller.cpp +++ b/dali/devel-api/adaptor-framework/color-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 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. @@ -27,16 +27,13 @@ ColorController::ColorController() { } -ColorController::ColorController(const ColorController& controller) -: BaseHandle(controller) -{ -} +ColorController::ColorController(const ColorController& controller) = default; -ColorController& ColorController::operator=(const ColorController& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +ColorController& ColorController::operator=(const ColorController& rhs) = default; + +ColorController::ColorController(ColorController&& controller) = default; + +ColorController& ColorController::operator=(ColorController&& rhs) = default; ColorController ColorController::Get() { diff --git a/dali/devel-api/adaptor-framework/color-controller.h b/dali/devel-api/adaptor-framework/color-controller.h index 49ad666..1a12cc6 100644 --- a/dali/devel-api/adaptor-framework/color-controller.h +++ b/dali/devel-api/adaptor-framework/color-controller.h @@ -2,7 +2,7 @@ #define DALI_COLOR_CONTROLLER_H /* - * Copyright (c) 2020 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. @@ -67,6 +67,22 @@ public: ColorController& operator=(const ColorController& rhs); /** + * @brief Creates a move of the handle. + * + * The move will point to the same implementation as the original. + * @param[in] colorController The Color Controller to move from. + */ + ColorController(ColorController&& colorController); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @param [in] rhs A reference to the moved handle + * @return A reference to this + */ + ColorController& operator=(ColorController&& rhs); + + /** * @brief Retrieve the initialized instance of the ColorController. * * @return Handle to ColorController. diff --git a/dali/devel-api/adaptor-framework/offscreen-window.cpp b/dali/devel-api/adaptor-framework/offscreen-window.cpp index 42cc8eb..b6e6876 100644 --- a/dali/devel-api/adaptor-framework/offscreen-window.cpp +++ b/dali/devel-api/adaptor-framework/offscreen-window.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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. @@ -51,6 +51,10 @@ OffscreenWindow::OffscreenWindow(const OffscreenWindow& window) = default; OffscreenWindow& OffscreenWindow::operator=(const OffscreenWindow& window) = default; +OffscreenWindow::OffscreenWindow(OffscreenWindow&& window) = default; + +OffscreenWindow& OffscreenWindow::operator=(OffscreenWindow&& window) = default; + OffscreenWindow::~OffscreenWindow() = default; void OffscreenWindow::Add(Actor actor) diff --git a/dali/devel-api/adaptor-framework/offscreen-window.h b/dali/devel-api/adaptor-framework/offscreen-window.h index 1c2e144..2ba8838 100644 --- a/dali/devel-api/adaptor-framework/offscreen-window.h +++ b/dali/devel-api/adaptor-framework/offscreen-window.h @@ -2,7 +2,7 @@ #define DALI_OFFSCREEN_WINDOW_H /* - * Copyright (c) 2021 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. @@ -85,6 +85,21 @@ public: OffscreenWindow& operator=(const OffscreenWindow& window); /** + * @brief Move constructor + * + * @param [in] window A reference to the moved handle + */ + OffscreenWindow(OffscreenWindow&& window); + + /** + * @brief Move assignment operator + * + * @param [in] window A reference to the moved handle + * @return A reference to this + */ + OffscreenWindow& operator=(OffscreenWindow&& window); + + /** * @brief Destructor */ ~OffscreenWindow(); diff --git a/dali/devel-api/adaptor-framework/pixel-buffer.cpp b/dali/devel-api/adaptor-framework/pixel-buffer.cpp index e033afa..e391463 100644 --- a/dali/devel-api/adaptor-framework/pixel-buffer.cpp +++ b/dali/devel-api/adaptor-framework/pixel-buffer.cpp @@ -28,8 +28,8 @@ namespace Dali { namespace Devel { -PixelBuffer PixelBuffer::New(unsigned int width, - unsigned int height, +PixelBuffer PixelBuffer::New(uint32_t width, + uint32_t height, Dali::Pixel::Format pixelFormat) { Internal::Adaptor::PixelBufferPtr internal = @@ -63,28 +63,25 @@ PixelBuffer::PixelBuffer(Internal::Adaptor::PixelBuffer* internal) { } -PixelBuffer::PixelBuffer(const PixelBuffer& handle) -: BaseHandle(handle) -{ -} +PixelBuffer::PixelBuffer(const PixelBuffer& handle) = default; -PixelBuffer& PixelBuffer::operator=(const PixelBuffer& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +PixelBuffer& PixelBuffer::operator=(const PixelBuffer& rhs) = default; + +PixelBuffer::PixelBuffer(PixelBuffer&& handle) = default; + +PixelBuffer& PixelBuffer::operator=(PixelBuffer&& rhs) = default; -unsigned int PixelBuffer::GetWidth() const +uint32_t PixelBuffer::GetWidth() const { return GetImplementation(*this).GetWidth(); } -unsigned int PixelBuffer::GetHeight() const +uint32_t PixelBuffer::GetHeight() const { return GetImplementation(*this).GetHeight(); } -unsigned int PixelBuffer::GetStride() const +uint32_t PixelBuffer::GetStride() const { return GetImplementation(*this).GetStride(); } @@ -94,12 +91,12 @@ Pixel::Format PixelBuffer::GetPixelFormat() const return GetImplementation(*this).GetPixelFormat(); } -unsigned char* PixelBuffer::GetBuffer() +uint8_t* PixelBuffer::GetBuffer() { return GetImplementation(*this).GetBuffer(); } -const unsigned char* const PixelBuffer::GetBuffer() const +const uint8_t* PixelBuffer::GetBuffer() const { return GetImplementation(*this).GetConstBuffer(); } diff --git a/dali/devel-api/adaptor-framework/pixel-buffer.h b/dali/devel-api/adaptor-framework/pixel-buffer.h index 51c6739..40f3eae 100644 --- a/dali/devel-api/adaptor-framework/pixel-buffer.h +++ b/dali/devel-api/adaptor-framework/pixel-buffer.h @@ -61,8 +61,8 @@ public: /** * Create a PixelBuffer with it's own data buffer. */ - static PixelBuffer New(unsigned int width, - unsigned int height, + static PixelBuffer New(uint32_t width, + uint32_t height, Dali::Pixel::Format pixelFormat); /** @@ -98,6 +98,23 @@ public: PixelBuffer& operator=(const PixelBuffer& rhs); /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @SINCE_2_1.45 + * @param[in] handle A reference to the moved handle + */ + PixelBuffer(PixelBuffer&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @SINCE_2_1.45 + * @param[in] rhs A reference to the moved handle + * @return A reference to this object + */ + PixelBuffer& operator=(PixelBuffer&& rhs); + + /** * Convert to a pixel data and release the pixelBuffer's object. * This handle is left empty. * @@ -127,7 +144,7 @@ public: * @SINCE_1_2.46 * @return The pixel buffer, or NULL. */ - unsigned char* GetBuffer(); + uint8_t* GetBuffer(); /** * @brief Gets the pixel buffer. This is a pointer to the internal @@ -138,7 +155,7 @@ public: * * @return The pixel buffer, or NULL. */ - const unsigned char* const GetBuffer() const; + const uint8_t* GetBuffer() const; /** * @brief Gets the width of the buffer in pixels. @@ -146,7 +163,7 @@ public: * @SINCE_1_2.46 * @return The width of the buffer in pixels */ - unsigned int GetWidth() const; + uint32_t GetWidth() const; /** * @brief Gets the height of the buffer in pixels. @@ -154,7 +171,7 @@ public: * @SINCE_1_2.46 * @return The height of the buffer in pixels */ - unsigned int GetHeight() const; + uint32_t GetHeight() const; /** * @brief Gets the stride of the buffer in pixels. @@ -162,7 +179,7 @@ public: * @SINCE_2_1.17 * @return The stride of the buffer in pixels. 0 means the buffer is tightly packed. */ - unsigned int GetStride() const; + uint32_t GetStride() const; /** * @brief Gets the pixel format. diff --git a/dali/devel-api/adaptor-framework/style-monitor.cpp b/dali/devel-api/adaptor-framework/style-monitor.cpp index 0ceeaa3..233505a 100644 --- a/dali/devel-api/adaptor-framework/style-monitor.cpp +++ b/dali/devel-api/adaptor-framework/style-monitor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 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. @@ -27,10 +27,13 @@ StyleMonitor::StyleMonitor() { } -StyleMonitor::StyleMonitor(const StyleMonitor& monitor) -: BaseHandle(monitor) -{ -} +StyleMonitor::StyleMonitor(const StyleMonitor& monitor) = default; + +StyleMonitor& StyleMonitor::operator=(const StyleMonitor& monitor) = default; + +StyleMonitor::StyleMonitor(StyleMonitor&& monitor) = default; + +StyleMonitor& StyleMonitor::operator=(StyleMonitor&& monitor) = default; StyleMonitor StyleMonitor::StyleMonitor::Get() { @@ -81,15 +84,6 @@ StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal() return GetImplementation(*this).StyleChangeSignal(); } -StyleMonitor& StyleMonitor::operator=(const StyleMonitor& monitor) -{ - if(*this != monitor) - { - BaseHandle::operator=(monitor); - } - return *this; -} - StyleMonitor::StyleMonitor(Internal::Adaptor::StyleMonitor* internal) : BaseHandle(internal) { diff --git a/dali/devel-api/adaptor-framework/style-monitor.h b/dali/devel-api/adaptor-framework/style-monitor.h index d6196b8..2708eec 100644 --- a/dali/devel-api/adaptor-framework/style-monitor.h +++ b/dali/devel-api/adaptor-framework/style-monitor.h @@ -2,7 +2,7 @@ #define DALI_STYLE_MONITOR_H /* - * Copyright (c) 2020 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. @@ -68,6 +68,32 @@ public: // Creation & Destruction StyleMonitor(const StyleMonitor& monitor); /** + * @brief Assignment operator. + * + * The handle points to the same implementation as the one being copied from. + * @param[in] monitor The Style Monitor to copy from. + * @return reference to this object + */ + StyleMonitor& operator=(const StyleMonitor& monitor); + + /** + * @brief Creates a move of the handle. + * + * The move will point to the same implementation as the original. + * @param[in] monitor The Style Monitor to move from. + */ + StyleMonitor(StyleMonitor&& monitor); + + /** + * @brief Move assignment operator. + * + * The handle points to the same implementation as the one being moved from. + * @param[in] monitor The Style Monitor to move from. + * @return reference to this object + */ + StyleMonitor& operator=(StyleMonitor&& monitor); + + /** * @brief Retrieve the initialized instance of the StyleMonitor. * @return Handle to StyleMonitor. */ @@ -145,16 +171,6 @@ public: // Signals */ StyleChangeSignalType& StyleChangeSignal(); -public: // Operators - /** - * @brief Assignment operator. - * - * The handle points to the same implementation as the one being copied from. - * @param[in] monitor The Style Monitor to copy from. - * @return reference to this object - */ - StyleMonitor& operator=(const StyleMonitor& monitor); - public: // Not intended for application developers /** * @brief This constructor is used internally to create a handle from an object pointer. diff --git a/dali/devel-api/adaptor-framework/video-player.cpp b/dali/devel-api/adaptor-framework/video-player.cpp index f98b50a..597ad02 100644 --- a/dali/devel-api/adaptor-framework/video-player.cpp +++ b/dali/devel-api/adaptor-framework/video-player.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 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. @@ -64,19 +64,13 @@ VideoPlayer VideoPlayer::New(Dali::Actor actor, VideoSyncMode syncMode) return VideoPlayer(player.Get()); } -VideoPlayer::VideoPlayer(const VideoPlayer& player) -: BaseHandle(player) -{ -} +VideoPlayer::VideoPlayer(const VideoPlayer& player) = default; -VideoPlayer& VideoPlayer::operator=(const VideoPlayer& player) -{ - if(*this != player) - { - BaseHandle::operator=(player); - } - return *this; -} +VideoPlayer& VideoPlayer::operator=(const VideoPlayer& player) = default; + +VideoPlayer::VideoPlayer(VideoPlayer&& player) = default; + +VideoPlayer& VideoPlayer::operator=(VideoPlayer&& player) = default; VideoPlayer VideoPlayer::DownCast(BaseHandle handle) { diff --git a/dali/devel-api/adaptor-framework/video-player.h b/dali/devel-api/adaptor-framework/video-player.h index 6daae85..8af206e 100644 --- a/dali/devel-api/adaptor-framework/video-player.h +++ b/dali/devel-api/adaptor-framework/video-player.h @@ -2,7 +2,7 @@ #define DALI_VIDEO_PLAYER_H /* - * Copyright (c) 2020 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. @@ -93,6 +93,23 @@ public: VideoPlayer& operator=(const VideoPlayer& player); /** + * @brief Move constructor. + * + * @SINCE_2_1.45 + * @param[in] player VideoPlayer to move. The moved player will point at the same implementation + */ + VideoPlayer(VideoPlayer&& player); + + /** + * @brief Move assignment operator. + * + * @SINCE_2_1.45 + * @param[in] player The VideoPlayer to move assign from. + * @return The updated VideoPlayer. + */ + VideoPlayer& operator=(VideoPlayer&& player); + + /** * @brief Downcast a handle to VideoPlayer handle. * * If handle points to a VideoPlayer the downcast produces valid diff --git a/dali/devel-api/adaptor-framework/web-engine/web-engine.cpp b/dali/devel-api/adaptor-framework/web-engine/web-engine.cpp index bba76f0..9cb82e2 100755 --- a/dali/devel-api/adaptor-framework/web-engine/web-engine.cpp +++ b/dali/devel-api/adaptor-framework/web-engine/web-engine.cpp @@ -67,19 +67,13 @@ Dali::WebEngineCookieManager* WebEngine::GetCookieManager() return Internal::Adaptor::WebEngine::GetCookieManager(); } -WebEngine::WebEngine(const WebEngine& webEngine) -: BaseHandle(webEngine) -{ -} +WebEngine::WebEngine(const WebEngine& webEngine) = default; -WebEngine& WebEngine::operator=(const WebEngine& webEngine) -{ - if(*this != webEngine) - { - BaseHandle::operator=(webEngine); - } - return *this; -} +WebEngine& WebEngine::operator=(const WebEngine& webEngine) = default; + +WebEngine::WebEngine(WebEngine&& webEngine) = default; + +WebEngine& WebEngine::operator=(WebEngine&& webEngine) = default; WebEngine WebEngine::DownCast(BaseHandle handle) { diff --git a/dali/devel-api/adaptor-framework/web-engine/web-engine.h b/dali/devel-api/adaptor-framework/web-engine/web-engine.h index cdc5b21..1c98c00 100755 --- a/dali/devel-api/adaptor-framework/web-engine/web-engine.h +++ b/dali/devel-api/adaptor-framework/web-engine/web-engine.h @@ -87,6 +87,21 @@ public: WebEngine& operator=(const WebEngine& WebEngine); /** + * @brief Move constructor. + * + * @param[in] WebEngine WebEngine to move. The moved WebEngine will point at the same implementation + */ + WebEngine(WebEngine&& WebEngine); + + /** + * @brief Move assignment operator. + * + * @param[in] WebEngine The WebEngine to assign from. + * @return The updated WebEngine. + */ + WebEngine& operator=(WebEngine&& WebEngine); + + /** * @brief Downcast a handle to WebEngine handle. * * If handle points to a WebEngine the downcast produces valid diff --git a/dali/devel-api/text-abstraction/font-client.cpp b/dali/devel-api/text-abstraction/font-client.cpp index a778346..74e6487 100644 --- a/dali/devel-api/text-abstraction/font-client.cpp +++ b/dali/devel-api/text-abstraction/font-client.cpp @@ -58,7 +58,7 @@ FontClient::GlyphBufferData::GlyphBufferData() outlineOffsetX{0}, outlineOffsetY{0}, format{Pixel::A8}, - compressionType(CompressionType::NO_COMPRESSION), + compressionType{CompressionType::NO_COMPRESSION}, isColorEmoji{false}, isColorBitmap{false}, isBufferOwned{false} @@ -73,6 +73,43 @@ FontClient::GlyphBufferData::~GlyphBufferData() } } +FontClient::GlyphBufferData::GlyphBufferData(FontClient::GlyphBufferData&& rhs) noexcept +: buffer{rhs.buffer}, + width{rhs.width}, + height{rhs.height}, + outlineOffsetX{rhs.outlineOffsetX}, + outlineOffsetY{rhs.outlineOffsetY}, + format{rhs.format}, + compressionType{rhs.compressionType}, + isColorEmoji{rhs.isColorEmoji}, + isColorBitmap{rhs.isColorBitmap}, + isBufferOwned{rhs.isBufferOwned} +{ + // Remove moved data + rhs.buffer = nullptr; + rhs.isBufferOwned = false; +} + +FontClient::GlyphBufferData& FontClient::GlyphBufferData::operator=(FontClient::GlyphBufferData&& rhs) noexcept +{ + buffer = rhs.buffer; + width = rhs.width; + height = rhs.height; + outlineOffsetX = rhs.outlineOffsetX; + outlineOffsetY = rhs.outlineOffsetY; + format = rhs.format; + compressionType = rhs.compressionType; + isColorEmoji = rhs.isColorEmoji; + isColorBitmap = rhs.isColorBitmap; + isBufferOwned = rhs.isBufferOwned; + + // Remove moved data + rhs.buffer = nullptr; + rhs.isBufferOwned = false; + + return *this; +} + size_t FontClient::GlyphBufferData::Compress(const uint8_t* const __restrict__ inBuffer, GlyphBufferData& __restrict__ outBufferData) { size_t bufferSize = 0u; @@ -592,16 +629,13 @@ FontClient::~FontClient() { } -FontClient::FontClient(const FontClient& handle) -: BaseHandle(handle) -{ -} +FontClient::FontClient(const FontClient& handle) = default; -FontClient& FontClient::operator=(const FontClient& handle) -{ - BaseHandle::operator=(handle); - return *this; -} +FontClient& FontClient::operator=(const FontClient& handle) = default; + +FontClient::FontClient(FontClient&& handle) = default; + +FontClient& FontClient::operator=(FontClient&& handle) = default; void FontClient::ClearCache() { diff --git a/dali/devel-api/text-abstraction/font-client.h b/dali/devel-api/text-abstraction/font-client.h index 0644ddf..2f75e8c 100644 --- a/dali/devel-api/text-abstraction/font-client.h +++ b/dali/devel-api/text-abstraction/font-client.h @@ -95,6 +95,21 @@ public: */ ~GlyphBufferData(); + /** + * @brief Move constructor. + * + * @param[in] rhs moved data. + */ + GlyphBufferData(GlyphBufferData&& rhs) noexcept; + + /** + * @brief Move assign operator. + * + * @param[in] rhs moved data. + * @return A reference to this. + */ + GlyphBufferData& operator=(GlyphBufferData&& rhs) noexcept; + // Compression method of buffer. Each buffer compressed line by line enum class CompressionType { @@ -138,6 +153,12 @@ public: */ static void DecompressScanline(const GlyphBufferData& inBufferData, uint8_t* outBuffer, uint32_t& offset); + private: + // Delete copy operation. + GlyphBufferData(const GlyphBufferData& rhs) = delete; + GlyphBufferData& operator=(const GlyphBufferData& rhs) = delete; + + public: uint8_t* buffer; ///< The glyph's bitmap buffer data. uint32_t width; ///< The width of the bitmap. uint32_t height; ///< The height of the bitmap. @@ -196,6 +217,21 @@ public: */ FontClient& operator=(const FontClient& handle); + /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @param[in] handle A reference to the moved handle. + */ + FontClient(FontClient&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @param [in] handle A reference to the moved handle. + * @return A reference to this. + */ + FontClient& operator=(FontClient&& handle); + //////////////////////////////////////// // Font management and validation. //////////////////////////////////////// diff --git a/dali/internal/accessibility/bridge/bridge-accessible.cpp b/dali/internal/accessibility/bridge/bridge-accessible.cpp index 1236647..31443ff 100644 --- a/dali/internal/accessibility/bridge/bridge-accessible.cpp +++ b/dali/internal/accessibility/bridge/bridge-accessible.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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. @@ -19,6 +19,8 @@ #include // EXTERNAL INCLUDES +#include + #include #include @@ -60,7 +62,7 @@ std::vector> SplitLines(const std::vector& c // Find first with non-zero area auto first = std::find_if(children.begin(), children.end(), [](Component* child) -> bool { auto extents = child->GetExtents(CoordinateType::WINDOW); - return extents.height != 0.0f && extents.width != 0.0f; + return !Dali::EqualsZero(extents.height) && !Dali::EqualsZero(extents.width); }); if(first == children.end()) @@ -78,7 +80,7 @@ std::vector> SplitLines(const std::vector& c auto child = *it; rect = child->GetExtents(CoordinateType::WINDOW); - if(rect.height == 0.0f || rect.width == 0.0f) + if(Dali::EqualsZero(rect.height) || Dali::EqualsZero(rect.width)) { // Zero area, ignore continue; @@ -156,7 +158,7 @@ static bool IsObjectZeroSize(Component* obj) return false; } auto extents = obj->GetExtents(CoordinateType::WINDOW); - return extents.height == 0 || extents.width == 0; + return Dali::EqualsZero(extents.height) || Dali::EqualsZero(extents.width); } static bool IsObjectAcceptable(Component* obj) @@ -266,7 +268,6 @@ static std::string MakeIndent(unsigned int maxRecursionDepth) return std::string(GET_NAVIGABLE_AT_POINT_MAX_RECURSION_DEPTH - maxRecursionDepth, ' '); } - static bool IsRoleAcceptableWhenNavigatingNextPrev(Accessible* obj) { if(!obj) diff --git a/dali/internal/graphics/gles-impl/gles-context.cpp b/dali/internal/graphics/gles-impl/gles-context.cpp index 06de56a..ff38d44 100644 --- a/dali/internal/graphics/gles-impl/gles-context.cpp +++ b/dali/internal/graphics/gles-impl/gles-context.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "egl-graphics-controller.h" #include "gles-graphics-buffer.h" @@ -650,11 +651,11 @@ void Context::BeginRenderPass(const BeginRenderPassDescriptor& renderPassBegin) const auto clearValues = renderPassBegin.clearValues.Ptr(); - if(!mImpl->mGlStateCache.mClearColorSet || - mImpl->mGlStateCache.mClearColor.r != clearValues[0].color.r || - mImpl->mGlStateCache.mClearColor.g != clearValues[0].color.g || - mImpl->mGlStateCache.mClearColor.b != clearValues[0].color.b || - mImpl->mGlStateCache.mClearColor.a != clearValues[0].color.a) + if(!Dali::Equals(mImpl->mGlStateCache.mClearColor.r, clearValues[0].color.r) || + !Dali::Equals(mImpl->mGlStateCache.mClearColor.g, clearValues[0].color.g) || + !Dali::Equals(mImpl->mGlStateCache.mClearColor.b, clearValues[0].color.b) || + !Dali::Equals(mImpl->mGlStateCache.mClearColor.a, clearValues[0].color.a) || + !mImpl->mGlStateCache.mClearColorSet) { gl.ClearColor(clearValues[0].color.r, clearValues[0].color.g, diff --git a/dali/internal/imaging/common/image-operations.cpp b/dali/internal/imaging/common/image-operations.cpp index 675388e..6123e61 100644 --- a/dali/internal/imaging/common/image-operations.cpp +++ b/dali/internal/imaging/common/image-operations.cpp @@ -2289,19 +2289,19 @@ void Resample(const unsigned char* __restrict__ inPixels, } } -void LanczosSample4BPP(const unsigned char* __restrict__ inPixels, +void LanczosSample4BPP(const uint8_t* __restrict__ inPixels, ImageDimensions inputDimensions, - unsigned int inputStride, - unsigned char* __restrict__ outPixels, + uint32_t inputStride, + uint8_t* __restrict__ outPixels, ImageDimensions desiredDimensions) { Resample(inPixels, inputDimensions, inputStride, outPixels, desiredDimensions, Resampler::LANCZOS4, 4, true); } -void LanczosSample1BPP(const unsigned char* __restrict__ inPixels, +void LanczosSample1BPP(const uint8_t* __restrict__ inPixels, ImageDimensions inputDimensions, - unsigned int inputStride, - unsigned char* __restrict__ outPixels, + uint32_t inputStride, + uint8_t* __restrict__ outPixels, ImageDimensions desiredDimensions) { // For L8 images @@ -2309,11 +2309,11 @@ void LanczosSample1BPP(const unsigned char* __restrict__ inPixels, } // Dispatch to a format-appropriate third-party resampling function: -void LanczosSample(const unsigned char* __restrict__ inPixels, +void LanczosSample(const uint8_t* __restrict__ inPixels, ImageDimensions inDimensions, - unsigned int inStride, + uint32_t inStride, Pixel::Format pixelFormat, - unsigned char* __restrict__ outPixels, + uint8_t* __restrict__ outPixels, ImageDimensions outDimensions) { // Check the pixel format is one that is supported: @@ -2341,25 +2341,25 @@ void LanczosSample(const unsigned char* __restrict__ inPixels, } else { - DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not lanczos sampled: unsupported pixel format: %u.\n", unsigned(pixelFormat)); + DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not lanczos sampled: unsupported pixel format: %u.\n", static_cast(pixelFormat)); } } void RotateByShear(const uint8_t* const pixelsIn, - unsigned int widthIn, - unsigned int heightIn, - unsigned int strideIn, - unsigned int pixelSize, + uint32_t widthIn, + uint32_t heightIn, + uint32_t strideIn, + uint32_t pixelSize, float radians, uint8_t*& pixelsOut, - unsigned int& widthOut, - unsigned int& heightOut) + uint32_t& widthOut, + uint32_t& heightOut) { // @note Code got from https://www.codeproject.com/Articles/202/High-quality-image-rotation-rotate-by-shear by Eran Yariv. // Do first the fast rotations to transform the angle into a (-45..45] range. - float fastRotationPerformed = false; + bool fastRotationPerformed = false; if((radians > Math::PI_4) && (radians <= RAD_135)) { // Angle in (45.0 .. 135.0] @@ -2447,7 +2447,7 @@ void RotateByShear(const uint8_t* const pixelsIn, const uint8_t* const firstHorizontalSkewPixelsIn = fastRotationPerformed ? pixelsOut : pixelsIn; std::unique_ptr tmpPixelsInPtr((fastRotationPerformed ? pixelsOut : nullptr), free); - unsigned int stride = fastRotationPerformed ? widthOut : strideIn; + uint32_t stride = fastRotationPerformed ? widthOut : strideIn; // Reset the input/output widthIn = widthOut; @@ -2464,7 +2464,7 @@ void RotateByShear(const uint8_t* const pixelsIn, // Calculate first shear (horizontal) destination image dimensions - widthOut = widthIn + static_cast(fabs(angleTangent) * static_cast(heightIn)); + widthOut = widthIn + static_cast(fabs(angleTangent) * static_cast(heightIn)); heightOut = heightIn; // Allocate the buffer for the 1st shear @@ -2482,7 +2482,7 @@ void RotateByShear(const uint8_t* const pixelsIn, return; } - for(unsigned int y = 0u; y < heightOut; ++y) + for(uint32_t y = 0u; y < heightOut; ++y) { const float shear = angleTangent * ((angleTangent >= 0.f) ? (0.5f + static_cast(y)) : (0.5f + static_cast(y) - static_cast(heightOut))); @@ -2492,8 +2492,8 @@ void RotateByShear(const uint8_t* const pixelsIn, // Reset the 'pixel in' pointer with the output of the 'First Horizontal Skew' and free the memory allocated by the 'Fast Rotations'. tmpPixelsInPtr.reset(pixelsOut); - unsigned int tmpWidthIn = widthOut; - unsigned int tmpHeightIn = heightOut; + uint32_t tmpWidthIn = widthOut; + uint32_t tmpHeightIn = heightOut; // Reset the input/output pixelsOut = nullptr; @@ -2503,7 +2503,7 @@ void RotateByShear(const uint8_t* const pixelsIn, /////////////////////////////////////// // Calc 2nd shear (vertical) destination image dimensions - heightOut = static_cast(static_cast(widthIn) * fabs(angleSinus) + static_cast(heightIn) * angleCosinus); + heightOut = static_cast(static_cast(widthIn) * fabs(angleSinus) + static_cast(heightIn) * angleCosinus); // Allocate the buffer for the 2nd shear pixelsOut = static_cast(malloc(widthOut * heightOut * pixelSize)); @@ -2522,10 +2522,10 @@ void RotateByShear(const uint8_t* const pixelsIn, // Variable skew offset float offset = angleSinus * ((angleSinus > 0.f) ? static_cast(widthIn - 1u) : -(static_cast(widthIn) - static_cast(widthOut))); - unsigned int column = 0u; + uint32_t column = 0u; for(column = 0u; column < widthOut; ++column, offset -= angleSinus) { - const int shear = static_cast(floor(offset)); + const int32_t shear = static_cast(floor(offset)); VerticalSkew(tmpPixelsInPtr.get(), tmpWidthIn, tmpHeightIn, tmpWidthIn, pixelSize, pixelsOut, widthOut, heightOut, column, shear, offset - static_cast(shear)); } // Reset the 'pixel in' pointer with the output of the 'Vertical Skew' and free the memory allocated by the 'First Horizontal Skew'. @@ -2540,7 +2540,7 @@ void RotateByShear(const uint8_t* const pixelsIn, /////////////////////////////////////// // Calc 3rd shear (horizontal) destination image dimensions - widthOut = static_cast(static_cast(heightIn) * fabs(angleSinus) + static_cast(widthIn) * angleCosinus) + 1u; + widthOut = static_cast(static_cast(heightIn) * fabs(angleSinus) + static_cast(widthIn) * angleCosinus) + 1u; // Allocate the buffer for the 3rd shear pixelsOut = static_cast(malloc(widthOut * heightOut * pixelSize)); @@ -2558,9 +2558,9 @@ void RotateByShear(const uint8_t* const pixelsIn, offset = (angleSinus >= 0.f) ? -angleSinus * angleTangent * static_cast(widthIn - 1u) : angleTangent * (static_cast(widthIn - 1u) * -angleSinus + (1.f - static_cast(heightOut))); - for(unsigned int y = 0u; y < heightOut; ++y, offset += angleTangent) + for(uint32_t y = 0u; y < heightOut; ++y, offset += angleTangent) { - const int shear = static_cast(floor(offset)); + const int32_t shear = static_cast(floor(offset)); HorizontalSkew(tmpPixelsInPtr.get(), tmpWidthIn, tmpWidthIn, pixelSize, pixelsOut, widthOut, y, shear, offset - static_cast(shear)); } @@ -2569,14 +2569,14 @@ void RotateByShear(const uint8_t* const pixelsIn, } void HorizontalShear(const uint8_t* const pixelsIn, - unsigned int widthIn, - unsigned int heightIn, - unsigned int strideIn, - unsigned int pixelSize, + uint32_t widthIn, + uint32_t heightIn, + uint32_t strideIn, + uint32_t pixelSize, float radians, uint8_t*& pixelsOut, - unsigned int& widthOut, - unsigned int& heightOut) + uint32_t& widthOut, + uint32_t& heightOut) { // Calculate the destination image dimensions. @@ -2592,7 +2592,7 @@ void HorizontalShear(const uint8_t* const pixelsIn, return; } - widthOut = widthIn + static_cast(ceil(absRadians * static_cast(heightIn))); + widthOut = widthIn + static_cast(ceil(absRadians * static_cast(heightIn))); heightOut = heightIn; // Allocate the buffer for the shear. @@ -2607,11 +2607,11 @@ void HorizontalShear(const uint8_t* const pixelsIn, return; } - for(unsigned int y = 0u; y < heightOut; ++y) + for(uint32_t y = 0u; y < heightOut; ++y) { const float shear = radians * ((radians >= 0.f) ? (0.5f + static_cast(y)) : (0.5f + static_cast(y) - static_cast(heightOut))); - const int intShear = static_cast(floor(shear)); + const int32_t intShear = static_cast(floor(shear)); HorizontalSkew(pixelsIn, widthIn, strideIn, pixelSize, pixelsOut, widthOut, y, intShear, shear - static_cast(intShear)); } } diff --git a/dali/internal/imaging/common/pixel-buffer-impl.cpp b/dali/internal/imaging/common/pixel-buffer-impl.cpp index 533db68..f4a1743 100644 --- a/dali/internal/imaging/common/pixel-buffer-impl.cpp +++ b/dali/internal/imaging/common/pixel-buffer-impl.cpp @@ -43,11 +43,11 @@ constexpr uint32_t BRIGHTNESS_CONSTANT_G = 587; constexpr uint32_t BRIGHTNESS_CONSTANT_B = 114; } // namespace -PixelBuffer::PixelBuffer(unsigned char* buffer, - unsigned int bufferSize, - unsigned int width, - unsigned int height, - unsigned int stride, +PixelBuffer::PixelBuffer(uint8_t* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + uint32_t stride, Dali::Pixel::Format pixelFormat) : mMetadata(), mBuffer(buffer), @@ -65,24 +65,24 @@ PixelBuffer::~PixelBuffer() ReleaseBuffer(); } -PixelBufferPtr PixelBuffer::New(unsigned int width, - unsigned int height, +PixelBufferPtr PixelBuffer::New(uint32_t width, + uint32_t height, Dali::Pixel::Format pixelFormat) { - unsigned int bufferSize = width * height * Dali::Pixel::GetBytesPerPixel(pixelFormat); - unsigned char* buffer = NULL; + uint32_t bufferSize = width * height * Dali::Pixel::GetBytesPerPixel(pixelFormat); + uint8_t* buffer = NULL; if(bufferSize > 0) { - buffer = static_cast(malloc(bufferSize)); + buffer = static_cast(malloc(bufferSize)); } return new PixelBuffer(buffer, bufferSize, width, height, width, pixelFormat); } -PixelBufferPtr PixelBuffer::New(unsigned char* buffer, - unsigned int bufferSize, - unsigned int width, - unsigned int height, - unsigned int stride, +PixelBufferPtr PixelBuffer::New(uint8_t* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + uint32_t stride, Dali::Pixel::Format pixelFormat) { return new PixelBuffer(buffer, bufferSize, width, height, stride, pixelFormat); @@ -106,12 +106,12 @@ Dali::PixelData PixelBuffer::Convert(PixelBuffer& pixelBuffer) return pixelData; } -unsigned int PixelBuffer::GetWidth() const +uint32_t PixelBuffer::GetWidth() const { return mWidth; } -unsigned int PixelBuffer::GetHeight() const +uint32_t PixelBuffer::GetHeight() const { return mHeight; } @@ -126,28 +126,28 @@ Dali::Pixel::Format PixelBuffer::GetPixelFormat() const return mPixelFormat; } -unsigned char* PixelBuffer::GetBuffer() const +uint8_t* PixelBuffer::GetBuffer() const { return mBuffer; } -const unsigned char* const PixelBuffer::GetConstBuffer() const +const uint8_t* PixelBuffer::GetConstBuffer() const { return mBuffer; } -unsigned int PixelBuffer::GetBufferSize() const +uint32_t PixelBuffer::GetBufferSize() const { return mBufferSize; } Dali::PixelData PixelBuffer::CreatePixelData() const { - unsigned char* destBuffer = NULL; + uint8_t* destBuffer = NULL; if(mBufferSize > 0) { - destBuffer = static_cast(malloc(mBufferSize)); + destBuffer = static_cast(malloc(mBufferSize)); memcpy(destBuffer, mBuffer, mBufferSize); } @@ -349,12 +349,12 @@ PixelBufferPtr PixelBuffer::NewCrop(const PixelBuffer& inBuffer, uint16_t x, uin destStride = (inBuffer.mWidth - x) * bytesPerPixel; } - int srcOffset = x * bytesPerPixel + y * srcStride; - int destOffset = 0; - unsigned char* destBuffer = outBuffer->mBuffer; + int srcOffset = x * bytesPerPixel + y * srcStride; + int destOffset = 0; + uint8_t* destBuffer = outBuffer->mBuffer; // Clamp crop to last row - unsigned int endRow = y + cropDimensions.GetHeight(); + uint16_t endRow = y + cropDimensions.GetHeight(); if(endRow > inBuffer.mHeight) { endRow = inBuffer.mHeight - 1; @@ -456,9 +456,9 @@ void PixelBuffer::MultiplyColorByAlpha() // must be skipped in such case if(Pixel::GetBytesPerPixel(mPixelFormat) && Pixel::HasAlpha(mPixelFormat)) { - unsigned char* pixel = mBuffer; - const unsigned int strideBytes = mStride * bytesPerPixel; - const unsigned int widthBytes = mWidth * bytesPerPixel; + uint8_t* pixel = mBuffer; + const uint32_t strideBytes = mStride * bytesPerPixel; + const uint32_t widthBytes = mWidth * bytesPerPixel; // Collect all valid channel list before lookup whole buffer std::vector validChannelList; @@ -472,11 +472,11 @@ void PixelBuffer::MultiplyColorByAlpha() if(DALI_LIKELY(!validChannelList.empty())) { - for(unsigned int y = 0; y < mHeight; y++) + for(uint32_t y = 0; y < mHeight; y++) { - for(unsigned int x = 0; x < widthBytes; x += bytesPerPixel) + for(uint32_t x = 0; x < widthBytes; x += bytesPerPixel) { - unsigned int alpha = ReadChannel(&pixel[x], mPixelFormat, Adaptor::ALPHA); + uint32_t alpha = ReadChannel(&pixel[x], mPixelFormat, Adaptor::ALPHA); if(alpha < 255) { // If alpha is 255, we don't need to change color. Skip current pixel @@ -515,7 +515,7 @@ uint32_t PixelBuffer::GetBrightness() const if(bytesPerPixel && mWidth && mHeight) { - unsigned char* pixel = mBuffer; + uint8_t* pixel = mBuffer; const uint32_t strideBytes = mStride * bytesPerPixel; const uint32_t widthBytes = mWidth * bytesPerPixel; const uint32_t bufferSize = mWidth * mHeight; @@ -524,9 +524,9 @@ uint32_t PixelBuffer::GetBrightness() const uint64_t green = 0; uint64_t blue = 0; - for(unsigned int y = 0; y < mHeight; y++) + for(uint32_t y = 0; y < mHeight; y++) { - for(unsigned int x = 0; x < widthBytes; x += bytesPerPixel) + for(uint32_t x = 0; x < widthBytes; x += bytesPerPixel) { red += ReadChannel(&pixel[x], mPixelFormat, Adaptor::RED); green += ReadChannel(&pixel[x], mPixelFormat, Adaptor::GREEN); diff --git a/dali/internal/imaging/common/pixel-buffer-impl.h b/dali/internal/imaging/common/pixel-buffer-impl.h index 6e02f3c..0866dd4 100644 --- a/dali/internal/imaging/common/pixel-buffer-impl.h +++ b/dali/internal/imaging/common/pixel-buffer-impl.h @@ -49,8 +49,8 @@ public: * @param [in] height Buffer height in pixels * @param [in] pixelFormat The pixel format */ - static PixelBufferPtr New(unsigned int width, - unsigned int height, + static PixelBufferPtr New(uint32_t width, + uint32_t height, Pixel::Format pixelFormat); /** @@ -63,12 +63,12 @@ public: * @param [in] stride Buffer stride in pixels, 0 means the buffer is tightly packed * @param [in] pixelFormat The pixel format */ - static PixelBufferPtr New(unsigned char* buffer, - unsigned int bufferSize, - unsigned int width, - unsigned int height, - unsigned int stride, - Pixel::Format pixelFormat); + static PixelBufferPtr New(uint8_t* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + uint32_t stride, + Pixel::Format pixelFormat); /** * Convert a pixelBuffer object into a PixelData object. @@ -89,12 +89,12 @@ public: * @param [in] stride Buffer stride in pixels, 0 means the buffer is tightly packed * @param [in] pixelFormat The pixel format */ - PixelBuffer(unsigned char* buffer, - unsigned int bufferSize, - unsigned int width, - unsigned int height, - unsigned int stride, - Pixel::Format pixelFormat); + PixelBuffer(uint8_t* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + uint32_t stride, + Pixel::Format pixelFormat); protected: /** @@ -109,19 +109,19 @@ public: * Get the width of the buffer in pixels. * @return The width of the buffer in pixels */ - unsigned int GetWidth() const; + uint32_t GetWidth() const; /** * Get the height of the buffer in pixels * @return The height of the buffer in pixels */ - unsigned int GetHeight() const; + uint32_t GetHeight() const; /** * @brief Gets the stride of the buffer in pixels. * @return The stride of the buffer in pixels. 0 means the buffer is tightly packed. */ - unsigned int GetStride() const; + uint32_t GetStride() const; /** * Get the pixel format @@ -133,18 +133,18 @@ public: * Get the pixel buffer if it's present. * @return The buffer if exists, or NULL if there is no pixel buffer. */ - unsigned char* GetBuffer() const; + uint8_t* GetBuffer() const; /** * @copydoc Devel::PixelBuffer::GetBuffer() */ - const unsigned char* const GetConstBuffer() const; + const uint8_t* GetConstBuffer() const; /** * Get the size of the buffer in bytes * @return The size of the buffer */ - unsigned int GetBufferSize() const; + uint32_t GetBufferSize() const; /** * Copy the buffer into a new PixelData diff --git a/dali/public-api/adaptor-framework/encoded-image-buffer.cpp b/dali/public-api/adaptor-framework/encoded-image-buffer.cpp index 4b34148..17b70b3 100644 --- a/dali/public-api/adaptor-framework/encoded-image-buffer.cpp +++ b/dali/public-api/adaptor-framework/encoded-image-buffer.cpp @@ -36,10 +36,13 @@ EncodedImageBuffer::EncodedImageBuffer(Internal::EncodedImageBuffer* internal) { } -EncodedImageBuffer::EncodedImageBuffer(const EncodedImageBuffer& handle) -: BaseHandle(handle) -{ -} +EncodedImageBuffer::EncodedImageBuffer(const EncodedImageBuffer& handle) = default; + +EncodedImageBuffer& EncodedImageBuffer::operator=(const EncodedImageBuffer& handle) = default; + +EncodedImageBuffer::EncodedImageBuffer(EncodedImageBuffer&& handle) = default; + +EncodedImageBuffer& EncodedImageBuffer::operator=(EncodedImageBuffer&& handle) = default; const EncodedImageBuffer::RawBufferType& EncodedImageBuffer::GetRawBuffer() const { @@ -51,12 +54,6 @@ const std::size_t EncodedImageBuffer::GetHash() const return GetImplementation(*this).GetHash(); } -EncodedImageBuffer& EncodedImageBuffer::operator=(const EncodedImageBuffer& handle) -{ - BaseHandle::operator=(handle); - return *this; -} - EncodedImageBuffer EncodedImageBuffer::New(const RawBufferType& buffer) { IntrusivePtr internal = Internal::EncodedImageBuffer::New(buffer); diff --git a/dali/public-api/adaptor-framework/encoded-image-buffer.h b/dali/public-api/adaptor-framework/encoded-image-buffer.h index 3e1f65c..4e45adf 100644 --- a/dali/public-api/adaptor-framework/encoded-image-buffer.h +++ b/dali/public-api/adaptor-framework/encoded-image-buffer.h @@ -78,6 +78,21 @@ public: EncodedImageBuffer& operator=(const EncodedImageBuffer& handle); /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @param [in] handle A reference to the moved handle + */ + EncodedImageBuffer(EncodedImageBuffer&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @param [in] handle A reference to the moved handle + * @return A reference to this + */ + EncodedImageBuffer& operator=(EncodedImageBuffer&& handle); + + /** * @brief Get raw buffer data * @note this method return const value. Mean, you cannot change raw buffer * @return A RawBufferType this buffer have -- 2.7.4