/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
return CreateBufferImage(4, 4, Color::WHITE);
}
+void PrepareResourceImage( TestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
+{
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetClosestImageSize(Vector2( imageWidth, imageHeight));
+
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
+ Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
+ unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
+ unsigned int initialColor = 0xFF;
+ memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel);
+
+ Integration::ResourcePointer resourcePtr(bitmap);
+ platform.SetSynchronouslyLoadedResource( resourcePtr );
+}
+
namespace Test
{
#define __DALI_TEST_SUITE_UTILS_H__
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
return false;
}
+ bool result = false;
switch(type)
{
case Property::BOOLEAN:
bool a, b;
q1.Get(a);
q2.Get(b);
- return a == b;
+ result = a == b;
break;
}
case Property::INTEGER:
int a, b;
q1.Get(a);
q2.Get(b);
- return a == b;
+ result = a == b;
break;
}
case Property::FLOAT:
float a, b;
q1.Get(a);
q2.Get(b);
- return CompareType<float>(a, b, epsilon);
+ result = CompareType<float>(a, b, epsilon);
break;
}
case Property::VECTOR2:
Vector2 a, b;
q1.Get(a);
q2.Get(b);
- return CompareType<Vector2>(a, b, epsilon);
+ result = CompareType<Vector2>(a, b, epsilon);
break;
}
case Property::VECTOR3:
Vector3 a, b;
q1.Get(a);
q2.Get(b);
- return CompareType<Vector3>(a, b, epsilon);
+ result = CompareType<Vector3>(a, b, epsilon);
break;
}
case Property::RECTANGLE:
Vector4 a, b;
q1.Get(a);
q2.Get(b);
- return CompareType<Vector4>(a, b, epsilon);
+ result = CompareType<Vector4>(a, b, epsilon);
break;
}
case Property::ROTATION:
Quaternion a, b;
q1.Get(a);
q2.Get(b);
- return CompareType<Quaternion>(a, b, epsilon);
+ result = CompareType<Quaternion>(a, b, epsilon);
+ break;
+ }
+ case Property::MATRIX:
+ case Property::MATRIX3:
+ case Property::STRING:
+ case Property::ARRAY:
+ case Property::MAP:
+ {
+ //TODO: Implement this?
+ DALI_ASSERT_ALWAYS( 0 && "Not implemented");
+ result = false;
+ break;
+ }
+ case Property::NONE:
+ {
+ result = false;
break;
}
- default:
- return false;
}
- return false;
+ return result;
}
BufferImage CreateBufferImage();
BufferImage CreateBufferImage(int width, int height, const Vector4& color);
+// Prepare a resource image to be loaded. Should be called before creating the ResourceImage
+void PrepareResourceImage( TestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat );
+
// Test namespace to prevent pollution of Dali namespace, add Test helper functions here
namespace Test
{
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
#define __DALI_TEST_APPLICATION_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
{
}
+
+TestNativeImageNoExtPointer TestNativeImageNoExt::New(int width, int height)
+{
+ return new TestNativeImageNoExt(width, height);
+}
+
+TestNativeImageNoExt::TestNativeImageNoExt(int width, int height)
+: mWidth(width), mHeight(height), mExtensionCreateCalls(0), mExtensionDestroyCalls(0), mTargetTextureCalls(0),createResult(true)
+{
+}
+
+TestNativeImageNoExt::~TestNativeImageNoExt()
+{
+}
+
} // namespace dali
#define __TEST_NATIVE_IMAGE_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
*/
// INTERNAL INCLUDES
-
-// EXTERNAL INCLUDES
#include <dali/public-api/images/native-image-interface.h>
#include <dali/devel-api/images/native-image-interface-extension.h>
#include <dali/integration-api/gl-defines.h>
namespace Dali
{
class TestNativeImage;
+class TestNativeImageNoExt;
typedef IntrusivePtr<TestNativeImage> TestNativeImagePointer;
+typedef IntrusivePtr<TestNativeImageNoExt> TestNativeImageNoExtPointer;
class DALI_IMPORT_API TestNativeImageExtension: public Dali::NativeImageInterface::Extension
{
inline const char* GetCustomFragmentPreFix(){return "#extension GL_OES_EGL_image_external:require\n";}
inline const char* GetCustomSamplerTypename(){return "samplerExternalOES";}
- inline int GetEglImageTextureTarget(){return GL_TEXTURE_2D;}
+ inline int GetEglImageTextureTarget(){return GL_TEXTURE_EXTERNAL_OES;}
};
inline void SetGlExtensionCreateResult(bool result){ createResult = result;}
inline virtual bool GlExtensionCreate() { ++mExtensionCreateCalls; return createResult;};
inline virtual void GlExtensionDestroy() { ++mExtensionDestroyCalls; };
- inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 1;};
+ inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 0;};
inline virtual void PrepareTexture() {};
inline virtual unsigned int GetWidth() const {return mWidth;};
inline virtual unsigned int GetHeight() const {return mHeight;};
TestNativeImageExtension* mExtension;
};
+
+class DALI_IMPORT_API TestNativeImageNoExt : public Dali::NativeImageInterface
+{
+public:
+ static TestNativeImageNoExtPointer New(int width, int height);
+
+ inline void SetGlExtensionCreateResult(bool result){ createResult = result;}
+ inline virtual bool GlExtensionCreate() { ++mExtensionCreateCalls; return createResult;};
+ inline virtual void GlExtensionDestroy() { ++mExtensionDestroyCalls; };
+ inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 1;};
+ inline virtual void PrepareTexture() {};
+ inline virtual unsigned int GetWidth() const {return mWidth;};
+ inline virtual unsigned int GetHeight() const {return mHeight;};
+ inline virtual bool RequiresBlending() const {return true;};
+
+private:
+ TestNativeImageNoExt(int width, int height);
+ virtual ~TestNativeImageNoExt();
+
+ int mWidth;
+ int mHeight;
+public:
+ int mExtensionCreateCalls;
+ int mExtensionDestroyCalls;
+ int mTargetTextureCalls;
+ bool createResult;
+};
+
} // Dali
#endif
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
Integration::BitmapPtr TestPlatformAbstraction::DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size )
{
mTrace.PushCall("DecodeBuffer", "");
- return Integration::BitmapPtr();
+ return mDecodedBitmap;
}
void TestPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId)
mResourceRequests.Clear();
mIsLoadingResult=false;
mSynchronouslyLoadedResource.Reset();
+ mDecodedBitmap.Reset();
}
bool TestPlatformAbstraction::WasCalled(TestFuncEnum func)
mLoadedResourcesQueue.clear();
mFailedLoadQueue.clear();
mSynchronouslyLoadedResource.Reset();
+ mDecodedBitmap.Reset();
}
void TestPlatformAbstraction::SetResourceLoaded(Integration::ResourceId loadedId,
mSynchronouslyLoadedResource = resource;
}
+void TestPlatformAbstraction::SetDecodedBitmap( Integration::BitmapPtr bitmap )
+{
+ mDecodedBitmap = bitmap;
+}
+
} // namespace Dali
#define __DALI_TEST_PLATFORM_ABSTRACTION_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
*/
void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource );
+ /**
+ * @brief Sets the bitmap returned by DecodeBuffer()
+ * @param[in] bitmap The decoded bitmap
+ */
+ void SetDecodedBitmap( Integration::BitmapPtr bitmap );
+
+private:
+
+ TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined
+ TestPlatformAbstraction& operator=( const TestPlatformAbstraction& ); ///< Undefined
+
private:
struct LoadedResource
bool mSaveFileResult;
Integration::ResourcePointer mSynchronouslyLoadedResource;
+ Integration::BitmapPtr mDecodedBitmap;
};
} // Dali
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
std::stringstream params;
- params << GL_TEXTURE_2D << ", " << 23;
+ params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
END_TEST;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
std::stringstream nextTextureParams;
- nextTextureParams << GL_TEXTURE_2D << ", " << 24;
+ nextTextureParams << GL_TEXTURE_EXTERNAL_OES << ", " << 24;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
END_TEST;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
std::stringstream params;
- params << GL_TEXTURE_2D << ", " << 23;
+ params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
width = 200;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
std::stringstream params;
- params << GL_TEXTURE_2D << ", " << 23;
+ params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
END_TEST;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
std::stringstream nativeImageParams;
- nativeImageParams << GL_TEXTURE_2D << ", " << 24;
+ nativeImageParams << GL_TEXTURE_EXTERNAL_OES << ", " << 24;
DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nativeImageParams.str()) );