#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;
}
- uint32_t size = bufferDescription.stride * bufferDescription.height;
- pixbuf.resize( size );
- memcpy( pixbuf.data(), buffer, size );
+ uint32_t pixelBytes = GetBytesPerPixel(pixelFormat);
+ if ( bufferDescription.stride < (pixelBytes * bufferDescription.width) )
+ {
+ //On Android device, bufferDescription.stride doesn't seem to mean (width * pixelbytes)
+ //in an actual case, (AHardwareBuffer_Desc) bufferDescription = (width = 1080, height = 1060, layers = 1, format = 1, usage = 306, stride = 1088, rfu0 = 0, rfu1 = 0)
+ //deal with situation
+ uint32_t dstStride = pixelBytes * bufferDescription.width;
+ uint32_t srcStride = pixelBytes * bufferDescription.stride;
+ uint32_t size = dstStride * bufferDescription.height;
+ pixbuf.resize( size );
+ //copy each row over
+ const unsigned char* ptrSrc = reinterpret_cast<const unsigned char*>(buffer);
+ unsigned char* ptrDst = pixbuf.data();
+ for (int y=0; y < bufferDescription.height; y++, ptrSrc += srcStride, ptrDst += dstStride )
+ {
+ memcpy( ptrDst, ptrSrc, dstStride );
+ }
+ }
+ else
+ {
+ uint32_t size = bufferDescription.stride * bufferDescription.height;
+ pixbuf.resize( size );
+ memcpy( pixbuf.data(), buffer, size );
+ }
ret = AHardwareBuffer_unlock( mPixmap, NULL );
if( ret != 0 )
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() )