X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fimaging%2Fcommon%2Fnative-image-source-impl.h;h=d0a80107b47c91ba33ec8b1d8e8d5b23f65792ad;hb=0bd8ccbb0013ba5d51fd1744522f432b6d420fac;hp=d5f292fd43607bbc905d3945e1e9f4f3f65bf949;hpb=a6f211ea194a64bda86d9e2237a9a91e8620b208;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/imaging/common/native-image-source-impl.h b/dali/internal/imaging/common/native-image-source-impl.h index d5f292f..d0a8010 100755 --- a/dali/internal/imaging/common/native-image-source-impl.h +++ b/dali/internal/imaging/common/native-image-source-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -37,6 +38,8 @@ class NativeImageSource { public: + static constexpr uint32_t DEFAULT_QUALITY = 100; + /** * Create a new NativeImageSource internally. * Depending on hardware the width and height may have to be a power of two. @@ -61,11 +64,6 @@ public: virtual bool GetPixels(std::vector &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const = 0; /** - * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& ) - */ - virtual bool EncodeToFile(const std::string& filename) const = 0; - - /** * @copydoc Dali::NativeImageSource::SetSource( Any source ) */ virtual void SetSource( Any source ) = 0; @@ -81,14 +79,14 @@ public: virtual ~NativeImageSource() = default; /** - * @copydoc Dali::NativeImageSource::GlExtensionCreate() + * @copydoc Dali::NativeImageSource::CreateResource() */ - virtual bool GlExtensionCreate() = 0; + virtual bool CreateResource() = 0; /** - * @copydoc Dali::NativeImageSource::GlExtensionDestroy() + * @copydoc Dali::NativeImageSource::DestroyResource() */ - virtual void GlExtensionDestroy() = 0; + virtual void DestroyResource() = 0; /** * @copydoc Dali::NativeImageSource::TargetTexture() @@ -116,6 +114,31 @@ public: virtual bool RequiresBlending() const = 0; /** + * @copydoc Dali::NativeImageSource::GetTextureTarget() + */ + virtual int GetTextureTarget() const = 0; + + /** + * @copydoc Dali::NativeImageSource::GetCustomFragmentPrefix() + */ + virtual const char* GetCustomFragmentPrefix() const = 0; + + /** + * @copydoc Dali::NativeImageSource::GetCustomSamplerTypename() + */ + virtual const char* GetCustomSamplerTypename() const = 0; + + /** + * @copydoc Dali::NativeImageSource::GetNativeImageHandle() + */ + virtual Any GetNativeImageHandle() const = 0; + + /** + * @copydoc Dali::NativeImageSource::SourceChanged() + */ + virtual bool SourceChanged() const = 0; + + /** * @copydoc Dali::NativeImageInterface::GetExtension() */ virtual NativeImageInterface::Extension* GetNativeImageInterfaceExtension() = 0; @@ -130,6 +153,37 @@ public: */ virtual bool ReleaseBuffer() = 0; + /** + * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& ) + */ + inline bool EncodeToFile( const std::string& filename ) const + { + return EncodeToFile( filename, DEFAULT_QUALITY ); + } + + /** + * @brief Converts the current pixel contents to either a JPEG or PNG format + * and write that to the filesystem. + * + * @param[in] filename Identify the filesystem location at which to write the encoded image. + * The extension determines the encoding used. + * The two valid encoding are (".jpeg"|".jpg") and ".png". + * @param[in] quality The quality of encoded jpeg image + * @return @c true if the pixels were written, and @c false otherwise + */ + inline bool EncodeToFile( const std::string& filename, const uint32_t quality ) const + { + std::vector< uint8_t > pixbuf; + uint32_t width( 0 ), height( 0 ); + Pixel::Format pixelFormat; + + if( GetPixels( pixbuf, width, height, pixelFormat ) ) + { + return Dali::EncodeToFile( &pixbuf[0], filename, pixelFormat, width, height, quality ); + } + return false; + } + public: inline static Internal::Adaptor::NativeImageSource& GetImplementation( Dali::NativeImageSource& image ) { return *image.mImpl; } };