#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/bitmap-saver.h>
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
+
+namespace
+{
+const char* FRAGMENT_PREFIX = "#extension GL_OES_EGL_image_external:require\n";
+const char* SAMPLER_TYPE = "samplerExternalOES";
+}
+
+
namespace Dali
{
return success;
}
-bool NativeImageSourceAndroid::EncodeToFile(const std::string& filename) const
-{
- std::vector< unsigned char > pixbuf;
- unsigned int width(0), height(0);
- Pixel::Format pixelFormat;
-
- if( GetPixels( pixbuf, width, height, pixelFormat ) )
- {
- return Dali::EncodeToFile( &pixbuf[0], filename, pixelFormat, width, height );
- }
- return false;
-}
-
void NativeImageSourceAndroid::SetSource( Any source )
{
if( mPixmap )
return true;
}
-bool NativeImageSourceAndroid::GlExtensionCreate()
+bool NativeImageSourceAndroid::CreateResource()
{
// if the image existed previously delete it.
if( mEglImageKHR != NULL )
{
- GlExtensionDestroy();
+ DestroyResource();
}
DALI_ASSERT_ALWAYS( mPixmap );
return mEglImageKHR != NULL;
}
-void NativeImageSourceAndroid::GlExtensionDestroy()
+void NativeImageSourceAndroid::DestroyResource()
{
mEglImageExtensions->DestroyImageKHR( mEglImageKHR );
{
}
+int NativeImageSourceAndroid::GetTextureTarget() const
+{
+ return GL_TEXTURE_2D;
+}
+
+const char* NativeImageSourceAndroid::GetCustomFragmentPrefix() const
+{
+ return nullptr;
+}
+
+const char* NativeImageSourceAndroid::GetCustomSamplerTypename() const
+{
+ return nullptr;
+}
+
+
void* NativeImageSourceAndroid::GetPixmapFromAny(Any pixmap) const
{
if( pixmap.Empty() )
// get the width, height and depth
mBlendingRequired = false;
- AHardwareBuffer_Desc* bufferDescription = nullptr;
- AHardwareBuffer_describe( mPixmap, bufferDescription );
+ AHardwareBuffer_Desc bufferDescription;
+ memset( &bufferDescription, 0, sizeof( AHardwareBuffer_Desc ) );
+ AHardwareBuffer_describe( mPixmap, &bufferDescription );
- mWidth = bufferDescription->width;
- mHeight = bufferDescription->height;
- switch (bufferDescription->format)
+ mWidth = bufferDescription.width;
+ mHeight = bufferDescription.height;
+ switch (bufferDescription.format)
{
case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_32;
}
}
+uint8_t* NativeImageSourceAndroid::AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride )
+{
+ if( mPixmap )
+ {
+ AHardwareBuffer_Desc bufferDescription;
+ memset( &bufferDescription, 0, sizeof( AHardwareBuffer_Desc ) );
+ AHardwareBuffer_describe( mPixmap, &bufferDescription );
+
+ void* buffer = NULL;
+ if( AHardwareBuffer_lock( mPixmap, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL, &buffer ) != 0 )
+ {
+ DALI_LOG_ERROR( "Failed to AHardwareBuffer_lock\n" );
+ return NULL;
+ }
+
+ stride = bufferDescription.stride;
+ width = bufferDescription.width;
+ height = bufferDescription.height;
+
+ return static_cast< uint8_t* >( buffer );
+ }
+
+ return NULL;
+}
+
+
+bool NativeImageSourceAndroid::ReleaseBuffer()
+{
+ if( mPixmap )
+ {
+ if( AHardwareBuffer_unlock( mPixmap, NULL ) != 0 )
+ {
+ DALI_LOG_ERROR( "failed to AHardwareBuffer_unlock\n" );
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
} // namespace Adaptor
} // namespace internal