From cecae59847de623ded910962d2ea936b77d42723 Mon Sep 17 00:00:00 2001 From: taeyoon Date: Wed, 30 Dec 2015 11:32:54 +0900 Subject: [PATCH] Revert "[3.0] Added EventThreadCallback class & BitmapLoader::Load() API" This reverts commit 8f305a3954a878ebbbed85fda948ffa9a8e228a0. Change-Id: Iea84d07a0a517b28342e1a9e4f600cea70787afb --- adaptors/common/bitmap-loader-impl.cpp | 66 ++++++-------------- adaptors/common/bitmap-loader-impl.h | 38 ++++-------- .../devel-api/adaptor-framework/bitmap-loader.cpp | 28 ++++----- .../devel-api/adaptor-framework/bitmap-loader.h | 43 +++---------- .../adaptor-framework/event-thread-callback.cpp | 60 ------------------ .../adaptor-framework/event-thread-callback.h | 72 ---------------------- adaptors/devel-api/file.list | 2 - 7 files changed, 53 insertions(+), 256 deletions(-) delete mode 100644 adaptors/devel-api/adaptor-framework/event-thread-callback.cpp delete mode 100644 adaptors/devel-api/adaptor-framework/event-thread-callback.h diff --git a/adaptors/common/bitmap-loader-impl.cpp b/adaptors/common/bitmap-loader-impl.cpp index 1e6c545..69505df 100644 --- a/adaptors/common/bitmap-loader-impl.cpp +++ b/adaptors/common/bitmap-loader-impl.cpp @@ -17,6 +17,9 @@ // EXTERNAL INCLUDES #include +#include +#include + // INTERNAL INCLUDES #include "bitmap-loader-impl.h" #include "image-loaders/image-loader.h" @@ -26,25 +29,15 @@ namespace Dali namespace Internal { -IntrusivePtr BitmapLoader::New(const std::string& url, - ImageDimensions size, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection) +IntrusivePtr BitmapLoader::New(const std::string& filename) { - IntrusivePtr internal = new BitmapLoader( url, size, fittingMode, samplingMode, orientationCorrection ); + IntrusivePtr internal = new BitmapLoader(); + internal->Initialize(filename); return internal; } -BitmapLoader::BitmapLoader(const std::string& url, - ImageDimensions size, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection) -: mResourceType( size, fittingMode, samplingMode, orientationCorrection ), - mBitmap(NULL), - mUrl(url), - mIsLoaded( false ) +BitmapLoader::BitmapLoader() +: mBitmap(NULL) { } @@ -52,57 +45,38 @@ BitmapLoader::~BitmapLoader() { } -void BitmapLoader::Load() +void BitmapLoader::Initialize(const std::string& filename) { - IntrusivePtr resource = TizenPlatform::ImageLoader::LoadResourceSynchronously( mResourceType, mUrl ); + // Load with default scaling and orientation correction: + Integration::BitmapResourceType bitmapResourceType; + Integration::ResourcePointer resource = TizenPlatform::ImageLoader::LoadResourceSynchronously( bitmapResourceType, filename ); mBitmap = static_cast(resource.Get()); - mIsLoaded = true; -} - -bool BitmapLoader::IsLoaded() -{ - return mIsLoaded; } unsigned char* BitmapLoader::GetPixelData() const { - if( mIsLoaded ) - { - return mBitmap->GetBuffer(); - } - - return NULL; + return mBitmap->GetBuffer(); } unsigned int BitmapLoader::GetImageHeight() const { - if( mIsLoaded ) - { - return mBitmap->GetImageHeight(); - } - - return 0u; + return mBitmap->GetImageHeight(); } unsigned int BitmapLoader::GetImageWidth() const { - if( mIsLoaded ) - { - return mBitmap->GetImageWidth(); - } + return mBitmap->GetImageWidth(); +} - return 0u; +unsigned int BitmapLoader::GetBufferStride() const +{ + return mBitmap->GetPackedPixelsProfile()->GetBufferStride(); } Pixel::Format BitmapLoader::GetPixelFormat() const { - if( mIsLoaded ) - { - return mBitmap->GetPixelFormat(); - } - - return Pixel::RGBA8888; + return mBitmap->GetPixelFormat(); } } // namespace Internal diff --git a/adaptors/common/bitmap-loader-impl.h b/adaptors/common/bitmap-loader-impl.h index 143fef1..c9f8ff4 100644 --- a/adaptors/common/bitmap-loader-impl.h +++ b/adaptors/common/bitmap-loader-impl.h @@ -23,7 +23,6 @@ #include #include #include -#include // INTERNAL INCLUDES #include @@ -36,24 +35,12 @@ namespace Internal class BitmapLoader : public BaseObject { public: - - /** - * @copydoc Dali::BitmapLoader::New - */ - static IntrusivePtr New( const std::string& url, - ImageDimensions size, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection); + static IntrusivePtr New(const std::string& filename); /** * Create the bitmap loader object. */ - BitmapLoader(const std::string& url, - ImageDimensions size, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection); + BitmapLoader(); protected: /** @@ -61,17 +48,13 @@ protected: */ ~BitmapLoader(); -public: - /** - * @copydoc Dali::BitmapLoader::Load + * Second stage initialization - this will load the image synchronously. + * @param[in] filename Filename of the bitmap image to load. */ - void Load(); + void Initialize(const std::string& filename); - /** - * @copydoc Dali::BitmapLoader::IsLoaded - */ - bool IsLoaded(); +public: /** * Get the raw pixel data. @@ -93,15 +76,18 @@ public: unsigned int GetImageWidth() const; /** + * Get the number of bytes in each row of pixels + * @return The buffer stride in bytes. + */ + unsigned int GetBufferStride() const; + + /** * Get the pixel format of the loaded bitmap. */ Pixel::Format GetPixelFormat() const; private: - Integration::BitmapResourceType mResourceType; Integration::BitmapPtr mBitmap; - const std::string mUrl; - bool mIsLoaded; }; } // Internal diff --git a/adaptors/devel-api/adaptor-framework/bitmap-loader.cpp b/adaptors/devel-api/adaptor-framework/bitmap-loader.cpp index dabfbd1..142e600 100644 --- a/adaptors/devel-api/adaptor-framework/bitmap-loader.cpp +++ b/adaptors/devel-api/adaptor-framework/bitmap-loader.cpp @@ -20,19 +20,20 @@ // EXTERNAL INCLUDES #include +#include +#include +#include + // INTERNAL INCLUDES +#include "image-loaders/image-loader.h" #include namespace Dali { -BitmapLoader BitmapLoader::New( const std::string& url, - ImageDimensions size, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection) +BitmapLoader BitmapLoader::New(const std::string& filename) { - IntrusivePtr internal = Internal::BitmapLoader::New(url, size, fittingMode, samplingMode, orientationCorrection); + IntrusivePtr internal = Internal::BitmapLoader::New(filename); return BitmapLoader( internal.Get() ); } @@ -60,16 +61,6 @@ BitmapLoader& BitmapLoader::operator=(const BitmapLoader& rhs) return *this; } -void BitmapLoader::Load() -{ - GetImplementation(*this).Load(); -} - -bool BitmapLoader::IsLoaded() -{ - return GetImplementation(*this).IsLoaded(); -} - unsigned char* BitmapLoader::GetPixelData() const { return GetImplementation(*this).GetPixelData(); @@ -85,6 +76,11 @@ unsigned int BitmapLoader::GetImageWidth() const return GetImplementation(*this).GetImageWidth(); } +unsigned int BitmapLoader::GetBufferStride() const +{ + return GetImplementation(*this).GetBufferStride(); +} + Pixel::Format BitmapLoader::GetPixelFormat() const { return GetImplementation(*this).GetPixelFormat(); diff --git a/adaptors/devel-api/adaptor-framework/bitmap-loader.h b/adaptors/devel-api/adaptor-framework/bitmap-loader.h index af5ac92..12971bd 100644 --- a/adaptors/devel-api/adaptor-framework/bitmap-loader.h +++ b/adaptors/devel-api/adaptor-framework/bitmap-loader.h @@ -21,7 +21,6 @@ #include #include #include -#include #include namespace Dali @@ -31,33 +30,15 @@ namespace Internal class BitmapLoader; } -/** - * @brief The BitmapLoader class is used to load bitmap from the URL synchronously. - * - * As the loading is synchronous, it will block the loop whilst executing. - * Therefore, it should be used sparingly in the main event thread, and better to be called in the worker thread. - * The Load() API is thread safe, it can be called from any thread without changing the state of DALI. - */ class DALI_IMPORT_API BitmapLoader : public BaseHandle { public: - /** - * @brief Create an initialized bitmap loader. - * - * By calling Load(), the synchronous loading is started immediately. + * @brief Create an initialized bitmap loader. This will automatically load the image. * - * @param [in] url The URL of the image file to load. - * @param [in] size The width and height to fit the loaded image to. - * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter. - * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size. - * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header. + * @param[in] filename Filename of the bitmap image to load. */ - static BitmapLoader New( const std::string& url, - ImageDimensions size = ImageDimensions( 0, 0 ), - FittingMode::Type fittingMode = FittingMode::DEFAULT, - SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR, - bool orientationCorrection = true); + static BitmapLoader New(const std::string& filename); /** * @brief Create an empty handle. @@ -89,18 +70,6 @@ public: public: /** - * @brief Start the synchronous loading. - */ - void Load(); - - /** - * @brief Query whether the image is loaded. - * - * @reture true if the image is loaded, false otherwise. - */ - bool IsLoaded(); - - /** * Get the raw pixel data. * @return The pixel data. Use the GetHeight(), GetWidth(), GetStride() and GetPixelFormat() methods * to decode the data. @@ -120,6 +89,12 @@ public: unsigned int GetImageWidth() const; /** + * Get the number of bytes in each row of pixels + * @return The buffer stride in bytes. + */ + unsigned int GetBufferStride() const; + + /** * Get the pixel format of the loaded bitmap. */ Pixel::Format GetPixelFormat() const; diff --git a/adaptors/devel-api/adaptor-framework/event-thread-callback.cpp b/adaptors/devel-api/adaptor-framework/event-thread-callback.cpp deleted file mode 100644 index a36775f..0000000 --- a/adaptors/devel-api/adaptor-framework/event-thread-callback.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// CLASS HEADER -#include "event-thread-callback.h" - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -struct EventThreadCallback::Impl -{ - TriggerEventInterface* eventTrigger; -}; - -EventThreadCallback::EventThreadCallback( CallbackBase* callback ) -: mImpl( new Impl() ) -{ - mImpl->eventTrigger = NULL; - if ( Adaptor::IsAvailable() ) - { - Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ); - mImpl->eventTrigger = adaptorImpl.GetTriggerEventFactoryInterface().CreateTriggerEvent( callback, TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ); - } -} - -EventThreadCallback::~EventThreadCallback() -{ - if ( Adaptor::IsAvailable() ) - { - Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ); - adaptorImpl.GetTriggerEventFactoryInterface().DestroyTriggerEvent( mImpl->eventTrigger ); - } - delete mImpl; -} - -void EventThreadCallback::Trigger() -{ - if( mImpl->eventTrigger ) - { - mImpl->eventTrigger->Trigger(); - } -} - -} diff --git a/adaptors/devel-api/adaptor-framework/event-thread-callback.h b/adaptors/devel-api/adaptor-framework/event-thread-callback.h deleted file mode 100644 index f15cf07..0000000 --- a/adaptors/devel-api/adaptor-framework/event-thread-callback.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef __DALI_EVENT_THREAD_CALLBACK_H_ -#define __DALI_EVENT_THREAD_CALLBACK_H_ - -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -/** - * @brief The EventThreadCallback class provides a mechanism for the worker thread to trigger the execution of a given callback in main event thread . - * - * @note The EventThreadCallback object should only be created in the main thread. - */ -class DALI_IMPORT_API EventThreadCallback -{ -public: - - /** - * @brief Constructor. Create an object that will call the given callback in main event thread. - * - * @param[in] callback The callback to call. - */ - EventThreadCallback( CallbackBase* callback ); - - /** - * @brief Destructor. - */ - ~EventThreadCallback(); - - /** - * @brief Trigger the calling of callback. - * - * The method can be used from worker threads to notify the main thread as main thread is running the event loop and thus cannot be blocked - */ - void Trigger(); - -private: - - // undefined copy constructor. - EventThreadCallback( const EventThreadCallback& ); - - // undefined assignment operator - EventThreadCallback& operator=( const EventThreadCallback& ); - -private: - - struct Impl; - Impl* mImpl; - -}; - -} -#endif /* __DALI_EVENT_THREAD_CALLBACK_H_ */ diff --git a/adaptors/devel-api/file.list b/adaptors/devel-api/file.list index 39d7d50..64d4221 100644 --- a/adaptors/devel-api/file.list +++ b/adaptors/devel-api/file.list @@ -7,7 +7,6 @@ devel_api_src_files = \ $(adaptor_devel_api_dir)/adaptor-framework/color-controller.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/drag-and-drop-detector.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/event-feeder.cpp \ - $(adaptor_devel_api_dir)/adaptor-framework/event-thread-callback.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/feedback-player.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/file-loader.cpp \ $(adaptor_devel_api_dir)/adaptor-framework/imf-manager.cpp \ @@ -33,7 +32,6 @@ devel_api_adaptor_framework_header_files = \ $(adaptor_devel_api_dir)/adaptor-framework/color-controller.h \ $(adaptor_devel_api_dir)/adaptor-framework/drag-and-drop-detector.h \ $(adaptor_devel_api_dir)/adaptor-framework/event-feeder.h \ - $(adaptor_devel_api_dir)/adaptor-framework/event-thread-callback.h \ $(adaptor_devel_api_dir)/adaptor-framework/feedback-plugin.h \ $(adaptor_devel_api_dir)/adaptor-framework/feedback-player.h \ $(adaptor_devel_api_dir)/adaptor-framework/file-loader.h \ -- 2.7.4