#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_H
/*
- * Copyright (c) 2017 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.
// EXTERNAL INCLUDES
#include <tbm_surface.h>
-#include <dali/devel-api/images/native-image-interface-extension.h>
+#include <dali/devel-api/threading/mutex.h>
#include <dali/public-api/common/dali-vector.h>
// INTERNAL INCLUDES
namespace Adaptor
{
+class EglGraphics;
class EglImageExtensions;
/**
* Dali internal NativeImageSource.
*/
-class NativeImageSourceTizen: public Internal::Adaptor::NativeImageSource, public NativeImageInterface::Extension
+class NativeImageSourceTizen: public Internal::Adaptor::NativeImageSource
{
public:
* @param[in] nativeImageSource contains tbm_surface_h or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSourceTizen* New(unsigned int width,
- unsigned int height,
+ static NativeImageSourceTizen* New(uint32_t width,
+ uint32_t height,
Dali::NativeImageSource::ColorDepth depth,
Any nativeImageSource);
/**
* @copydoc Dali::NativeImageSource::GetPixels()
*/
- bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override;
-
- /**
- * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
- */
- bool EncodeToFile(const std::string& filename) const override;
+ bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const override;
/**
* @copydoc Dali::NativeImageSource::SetSource( Any source )
~NativeImageSourceTizen() override;
/**
- * @copydoc Dali::NativeImageSource::GlExtensionCreate()
+ * @copydoc Dali::NativeImageSource::CreateResource()
*/
- bool GlExtensionCreate() override;
+ bool CreateResource() override;
/**
- * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
+ * @copydoc Dali::NativeImageSource::DestroyResource()
*/
- void GlExtensionDestroy() override;
+ void DestroyResource() override;
/**
* @copydoc Dali::NativeImageSource::TargetTexture()
*/
- unsigned int TargetTexture() override;
+ uint32_t TargetTexture() override;
/**
* @copydoc Dali::NativeImageSource::PrepareTexture()
/**
* @copydoc Dali::NativeImageSource::GetWidth()
*/
- unsigned int GetWidth() const override
+ uint32_t GetWidth() const override
{
return mWidth;
}
/**
* @copydoc Dali::NativeImageSource::GetHeight()
*/
- unsigned int GetHeight() const override
+ uint32_t GetHeight() const override
{
return mHeight;
}
}
/**
+ * @copydoc Dali::NativeImageInterface::GetCustomFragmentPrefix()
+ */
+ const char* GetCustomFragmentPrefix() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::GetCustomSamplerTypename()
+ */
+ const char* GetCustomSamplerTypename() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::GetTextureTarget()
+ */
+ int GetTextureTarget() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::GetNativeImageHandle()
+ */
+ Any GetNativeImageHandle() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::SourceChanged()
+ */
+ bool SourceChanged() const override;
+
+ /**
* @copydoc Dali::NativeImageInterface::GetExtension()
*/
NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
{
- return this;
+ return nullptr;
}
/**
- * @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
+ * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
*/
- const char* GetCustomFragmentPreFix() override;
+ uint8_t* AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) override;
/**
- * @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
+ * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
*/
- const char* GetCustomSamplerTypename() override;
+ bool ReleaseBuffer() override;
/**
- * @copydoc Dali::NativeImageInterface::Extension::GetEglImageTextureTarget()
+ * @copydoc Dali::NativeImageSource::SetResourceDestructionCallback()
*/
- int GetEglImageTextureTarget() override;
+ void SetResourceDestructionCallback(EventThreadCallback* callback) override;
private:
* @param[in] colour depth of the image.
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
- NativeImageSourceTizen(unsigned int width,
+ NativeImageSourceTizen(uint32_t width,
unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
Any nativeImageSource);
bool CheckBlending( tbm_format format );
-private:
+ void DestroySurface();
- unsigned int mWidth; ///< image width
- unsigned int mHeight; ///< image height
+private:
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image height
bool mOwnTbmSurface; ///< Whether we created pixmap or not
tbm_surface_h mTbmSurface;
tbm_format mTbmFormat;
bool mBlendingRequired; ///< Whether blending is required
Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
void* mEglImageKHR; ///< From EGL extension
+ EglGraphics* mEglGraphics; ///< EGL Graphics
EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
bool mSetSource;
+ mutable Dali::Mutex mMutex;
+ bool mIsBufferAcquired; ///< Whether AcquireBuffer is called
+ std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;
};
} // namespace Adaptor