[3.0] NativeImageSource with tbm_surface for tizen 3.0 wayland 17/58417/2 accepted/tizen/mobile/20160201.043204 accepted/tizen/tv/20160201.043227 accepted/tizen/wearable/20160201.043248 submit/tizen/20160201.030218
authortaeyoon <taeyoon0.lee@samsung.com>
Thu, 19 Nov 2015 13:01:56 +0000 (22:01 +0900)
committerTaeyoon Lee <taeyoon0.lee@samsung.com>
Mon, 1 Feb 2016 00:19:21 +0000 (16:19 -0800)
Change-Id: I5c8cadd96f87d4d1db9e30101cd647c697e3c7ea

automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp
automated-tests/src/dali/dali-test-suite-utils/test-native-image.h
automated-tests/src/dali/utc-Dali-NativeImage.cpp
dali/devel-api/file.list
dali/devel-api/images/native-image-interface-extension.h [new file with mode: 0644]
dali/integration-api/gl-defines.h
dali/internal/event/images/native-image-impl.cpp
dali/internal/event/images/native-image-impl.h
dali/public-api/images/native-image.cpp
dali/public-api/images/native-image.h

index d143d35..d8ad2ba 100644 (file)
@@ -31,6 +31,7 @@ TestNativeImagePointer TestNativeImage::New(int width, int height)
 TestNativeImage::TestNativeImage(int width, int height)
 : mWidth(width), mHeight(height), mExtensionCreateCalls(0), mExtensionDestroyCalls(0), mTargetTextureCalls(0)
 {
+  mExtension = new TestNativeImageExtension();
 }
 
 TestNativeImage::~TestNativeImage()
index 4a39cb1..8dc6431 100644 (file)
 
 // 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:
@@ -38,6 +47,7 @@ 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);
@@ -49,6 +59,7 @@ public:
   int mExtensionCreateCalls;
   int mExtensionDestroyCalls;
   int mTargetTextureCalls;
+  TestNativeImageExtension* mExtension;
 };
 
 } // Dali
index 1f080a7..3dc7568 100644 (file)
@@ -208,7 +208,29 @@ int UtcDaliNativeImageExtensionP(void)
   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;
+}
index a277021..9631a2e 100644 (file)
@@ -41,7 +41,8 @@ devel_api_core_events_header_files = \
 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 \
diff --git a/dali/devel-api/images/native-image-interface-extension.h b/dali/devel-api/images/native-image-interface-extension.h
new file mode 100644 (file)
index 0000000..ca19c14
--- /dev/null
@@ -0,0 +1,74 @@
+#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__
index 5af7acd..ccc0c4a 100644 (file)
 #endif
 
 
+/* GL_OES_EGL_image_external */
+#ifndef GL_TEXTURE_EXTERNAL_OES
+#define GL_TEXTURE_EXTERNAL_OES                                 0x8D65
+#endif
+
+
 #endif // __DALI_INTERNAL_GL_DEFINES_H__
index 4043f91..6f965cb 100644 (file)
@@ -26,6 +26,7 @@
 #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;
 
@@ -40,14 +41,20 @@ namespace
 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();
@@ -73,6 +80,26 @@ void NativeImage::CreateGlTexture()
   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
index 0f1dfe4..ef580fb 100644 (file)
@@ -18,6 +18,9 @@
  *
  */
 
+// EXTERNAL INCLUDES
+#include <string>
+
 // INTERNAL INCLUDES
 #include <dali/public-api/images/native-image.h>
 #include <dali/internal/event/images/image-impl.h>
@@ -56,12 +59,28 @@ protected:
   /**
    * 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
index fd40713..81fae36 100644 (file)
@@ -64,4 +64,14 @@ NativeImage NativeImage::DownCast( BaseHandle handle )
   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
index c6577f7..2ef665e 100644 (file)
@@ -99,10 +99,24 @@ public:
    * 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* );