TestNativeImage::TestNativeImage(int width, int height)
: mWidth(width), mHeight(height), mExtensionCreateCalls(0), mExtensionDestroyCalls(0), mTargetTextureCalls(0)
{
+ mExtension = new TestNativeImageExtension();
}
TestNativeImage::~TestNativeImage()
// INTERNAL INCLUDES
#include <dali/public-api/images/native-image-interface.h>
+#include <dali/devel-api/images/native-image-interface-extension.h>
namespace Dali
{
class TestNativeImage;
typedef IntrusivePtr<TestNativeImage> TestNativeImagePointer;
+class DALI_IMPORT_API TestNativeImageExtension: public Dali::NativeImageInterface::Extension
+{
+public:
+ inline const char* GetCustomFragmentPreFix(){return "#extension GL_OES_EGL_image_external:require\n";}
+ inline const char* GetCustomSamplerTypename(){return "samplerExternalOES";}
+
+};
+
class DALI_IMPORT_API TestNativeImage : public Dali::NativeImageInterface
{
public:
inline virtual unsigned int GetWidth() const {return mWidth;};
inline virtual unsigned int GetHeight() const {return mHeight;};
inline virtual bool RequiresBlending() const {return true;};
+ inline virtual Dali::NativeImageInterface::Extension* GetExtension() {return mExtension;}
private:
TestNativeImage(int width, int height);
int mExtensionCreateCalls;
int mExtensionDestroyCalls;
int mTargetTextureCalls;
+ TestNativeImageExtension* mExtension;
};
} // Dali
TestNativeImagePointer testNativeImage = TestNativeImage::New( 16, 16 );
DALI_TEST_CHECK( testNativeImage );
- DALI_TEST_CHECK( NULL == testNativeImage->GetExtension() );
+ DALI_TEST_CHECK( NULL != testNativeImage->GetExtension() );
END_TEST;
}
+
+int UtcDaliNativeImageGetCustomFragmentPreFixP(void)
+{
+ TestApplication application;
+ TestNativeImagePointer nativeImageInterface = TestNativeImage::New( 16, 16 );
+ NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
+
+ const char* preFix = "#extension GL_OES_EGL_image_external:require\n";
+ DALI_TEST_EQUALS( nativeImage.GetCustomFragmentPreFix(), preFix, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliNativeImageGetCustomSamplerTypenameP(void)
+{
+ TestApplication application;
+ TestNativeImagePointer nativeImageInterface = TestNativeImage::New( 16, 16 );
+ NativeImage nativeImage = NativeImage::New( *(nativeImageInterface.Get()) );
+
+ const char* samplerTypename = "samplerExternalOES";
+ DALI_TEST_EQUALS( nativeImage.GetCustomSamplerTypename(), samplerTypename, TEST_LOCATION );
+ END_TEST;
+}
devel_api_core_images_header_files = \
$(devel_api_src_dir)/images/atlas.h \
$(devel_api_src_dir)/images/distance-field.h \
- $(devel_api_src_dir)/images/pixel-data.h
+ $(devel_api_src_dir)/images/pixel-data.h \
+ $(devel_api_src_dir)/images/native-image-interface-extension.h
devel_api_core_object_header_files = \
$(devel_api_src_dir)/object/property-buffer.h \
--- /dev/null
+#ifndef __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_EXTENSION_H__
+#define __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_EXTENSION_H__
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/images/native-image-interface.h>
+
+namespace Dali
+{
+
+/**
+ * @brief Extension abstract interface to provide platform-specific support for handling image data.
+ *
+ */
+class NativeImageInterface::Extension
+{
+public:
+
+ class Extension2; ///< Forward declare future extension interface
+
+ /**
+ * @brief Get custom fragment prefix for rendering native image.
+ *
+ * @return Custom fragment prefix code as string.
+ */
+ virtual const char* GetCustomFragmentPreFix() = 0;
+
+ /**
+ * @brief Get custom sampler type name for rendering native image.
+ *
+ * @return Custom sampler type name.
+ */
+ virtual const char* GetCustomSamplerTypename() = 0;
+
+ /**
+ * @brief Retrieve the extension for the interface.
+ *
+ * @return Extension2 pointer if available, NULL otherwise
+ */
+ virtual Extension2* GetExtension2()
+ {
+ return NULL;
+ }
+
+protected:
+
+ /**
+ * @brief Destructor.
+ *
+ */
+ virtual ~Extension()
+ {
+ }
+
+};
+
+} // namespace Dali
+
+#endif // __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
#endif
+/* GL_OES_EGL_image_external */
+#ifndef GL_TEXTURE_EXTERNAL_OES
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#endif
+
+
#endif // __DALI_INTERNAL_GL_DEFINES_H__
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/resources/resource-client.h>
#include <dali/internal/event/common/stage-impl.h>
+#include <dali/devel-api/images/native-image-interface-extension.h>
using namespace Dali::Integration;
TypeRegistration mType( typeid(Dali::NativeImage), typeid(Dali::Image), NULL );
}
-NativeImage::NativeImage()
+NativeImage::NativeImage( NativeImageInterface& resourceData )
: Image()
{
+ NativeImageInterface::Extension* extension = resourceData.GetExtension();
+ if( extension != NULL )
+ {
+ mCustomFragmentPreFix = extension->GetCustomFragmentPreFix();
+ mCustomSamplerTypename = extension->GetCustomSamplerTypename();
+ }
}
NativeImagePtr NativeImage::New( NativeImageInterface& resourceData )
{
- NativeImagePtr image = new NativeImage;
+ NativeImagePtr image = new NativeImage( resourceData );
image->Initialize();
ResourceClient &resourceClient = ThreadLocalStorage::Get().GetResourceClient();
resourceClient.CreateGlTexture( GetResourceId() );
}
+const char* NativeImage::GetCustomFragmentPreFix()
+{
+ if( mCustomFragmentPreFix.empty() )
+ {
+ return NULL;
+ }
+
+ return mCustomFragmentPreFix.c_str();
+}
+
+const char* NativeImage::GetCustomSamplerTypename()
+{
+ if( mCustomSamplerTypename.empty() )
+ {
+ return NULL;
+ }
+
+ return mCustomSamplerTypename.c_str();
+}
+
} // namespace Internal
} // namespace Dali
*
*/
+// EXTERNAL INCLUDES
+#include <string>
+
// INTERNAL INCLUDES
#include <dali/public-api/images/native-image.h>
#include <dali/internal/event/images/image-impl.h>
/**
* Constructor
*/
- NativeImage();
+ NativeImage( NativeImageInterface& nativeImageInterface );
/**
* A reference counted object may only be deleted by calling Unreference()
*/
virtual ~NativeImage();
+
+public:
+
+ /**
+ * @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
+ */
+ const char* GetCustomFragmentPreFix();
+
+ /**
+ * @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
+ */
+ const char* GetCustomSamplerTypename();
+
+private:
+ std::string mCustomFragmentPreFix;
+ std::string mCustomSamplerTypename;
};
} // namespace Internal
return NativeImage( dynamic_cast<Internal::NativeImage*>( handle.GetObjectPtr()) );
}
+const char* NativeImage::GetCustomSamplerTypename()
+{
+ return GetImplementation(*this).GetCustomSamplerTypename();
+}
+
+const char* NativeImage::GetCustomFragmentPreFix()
+{
+ return GetImplementation(*this).GetCustomFragmentPreFix();
+}
+
} // namespace Dali
* If handle points to a NativeImage object, the downcast produces valid handle.
* If not, the returned handle is left unintialized.
* @param[in] handle Handle to an object.
- * @return handle to a NativeImage or an uninitialized handle.
+ * @return Handle to a NativeImage or an uninitialized handle.
*/
static NativeImage DownCast( BaseHandle handle );
+ /**
+ * @brief Get custom fragment prefix for rendering a native image.
+ *
+ * @return String for custom fragment prefix
+ */
+ const char* GetCustomFragmentPreFix();
+
+ /**
+ * @brief Get custom sampler type name for rendering a native image.
+ *
+ * @return String for custom sampler type name
+ */
+ const char* GetCustomSamplerTypename();
+
public: // Not intended for application developers
explicit DALI_INTERNAL NativeImage( Internal::NativeImage* );