Merge "Size negotiation patch 4: Remove SetRelayoutEnabled" into tizen
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Mon, 20 Apr 2015 17:13:44 +0000 (10:13 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Mon, 20 Apr 2015 17:13:44 +0000 (10:13 -0700)
13 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h
dali-toolkit/internal/controls/slider/slider-impl.cpp
dali-toolkit/public-api/shader-effects/nine-patch-mask-effect.cpp
plugins/dali-script-v8/file.list
plugins/dali-script-v8/src/constants/constants-wrapper.cpp
plugins/dali-script-v8/src/dali-wrapper.cpp
plugins/dali-script-v8/src/image/image-attributes-api.cpp [deleted file]
plugins/dali-script-v8/src/image/image-attributes-api.h [deleted file]
plugins/dali-script-v8/src/image/image-attributes-wrapper.cpp [deleted file]
plugins/dali-script-v8/src/image/image-attributes-wrapper.h [deleted file]
plugins/dali-script-v8/src/image/resource-image-api.cpp
plugins/dali-script-v8/src/image/resource-image-api.h

index 3d4d1d5..ddf0356 100644 (file)
@@ -64,20 +64,26 @@ void TestPlatformAbstraction::Resume()
   mTrace.PushCall("Resume", "");
 }
 
-void TestPlatformAbstraction::GetClosestImageSize( const std::string& filename,
-                                                   const ImageAttributes& attributes,
-                                                   Vector2& closestSize)
+ImageDimensions TestPlatformAbstraction::GetClosestImageSize( const std::string& filename,
+                                                              ImageDimensions size,
+                                                              FittingMode::Type scalingMode,
+                                                              SamplingMode::Type samplingMode,
+                                                              bool orientationCorrection )
 {
-  closestSize = mClosestSize;
+  ImageDimensions closestSize = ImageDimensions( mClosestSize.x, mClosestSize.y );
   mTrace.PushCall("GetClosestImageSize", "");
+  return closestSize;
 }
 
-void TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                                                   const ImageAttributes& attributes,
-                                                   Vector2& closestSize)
+ImageDimensions TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+                                                   ImageDimensions size,
+                                                   FittingMode::Type scalingMode,
+                                                   SamplingMode::Type samplingMode,
+                                                   bool orientationCorrection )
 {
-  closestSize = mClosestSize;
+  ImageDimensions closestSize = ImageDimensions( mClosestSize.x, mClosestSize.y );
   mTrace.PushCall("GetClosestImageSize", "");
+  return closestSize;
 }
 
 /**
index a4ec8d3..c3beebe 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <stdint.h>
 #include <cstring>
+#include <dali/public-api/images/image-operations.h>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/set-wrapper.h>
@@ -97,13 +98,23 @@ public:
    */
   virtual void Resume();
 
-  virtual void GetClosestImageSize( const std::string& filename,
-                                    const ImageAttributes& attributes,
-                                    Vector2& closestSize);
+  /**
+   * @copydoc PlatformAbstraction::GetClosestImageSize()
+   */
+  virtual ImageDimensions GetClosestImageSize( const std::string& filename,
+                                                 ImageDimensions size,
+                                                 FittingMode::Type scalingMode,
+                                                 SamplingMode::Type samplingMode,
+                                                 bool orientationCorrection );
 
-  virtual void GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                                    const ImageAttributes& attributes,
-                                    Vector2& closestSize);
+  /**
+   * @copydoc PlatformAbstraction::GetClosestImageSize()
+   */
+  virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+                                               ImageDimensions size,
+                                               FittingMode::Type scalingMode,
+                                               SamplingMode::Type samplingMode,
+                                               bool orientationCorrection );
 
   /**
    * @copydoc PlatformAbstraction::LoadResource()
index 8acd72c..45e4795 100755 (executable)
@@ -327,15 +327,7 @@ void Slider::DisplayValue( float value, bool raiseSignals )
   // Progress bar
   if( mProgress )
   {
-    if( clampledValue > 0.0f )
-    {
-      mProgress.SetVisible( true ); // Deliberately set this in case multiple SetValues are fired at once
-      mProgress.SetSize( x, GetBackingRegion().y );
-    }
-    else
-    {
-      mProgress.SetVisible( false );
-    }
+    mProgress.SetSize( x, GetBackingRegion().y );
   }
 
   // Signals
index d2b8967..79c8752 100644 (file)
@@ -108,19 +108,19 @@ static void DoApply( ImageActor actor, const std::string& maskImage, const Vecto
 
 void Apply( ImageActor actor, const std::string& maskImage )
 {
-  Vector2 maskSize = ResourceImage::GetImageSize( maskImage );
+  const Uint16Pair maskSize = ResourceImage::GetImageSize( maskImage );
 
-  const float leftRight = (maskSize.width  - 1.0f) * 0.5f;
-  const float topBottom = (maskSize.height - 1.0f) * 0.5f;
+  const float leftRight = (maskSize.GetWidth()  - 1.0f) * 0.5f;
+  const float topBottom = (maskSize.GetHeight() - 1.0f) * 0.5f;
 
-  DoApply( actor, maskImage, maskSize, Vector4( leftRight, topBottom, leftRight, topBottom ) );
+  DoApply( actor, maskImage, Vector2( maskSize.GetWidth(), maskSize.GetHeight() ), Vector4( leftRight, topBottom, leftRight, topBottom ) );
 }
 
 void Apply( ImageActor actor, const std::string& maskImage, const Vector4& maskBorder )
 {
-  Vector2 maskSize = ResourceImage::GetImageSize( maskImage );
+  const Uint16Pair maskSize = ResourceImage::GetImageSize( maskImage );
 
-  DoApply( actor, maskImage, maskSize, maskBorder );
+  DoApply( actor, maskImage, Vector2( maskSize.GetWidth(), maskSize.GetHeight() ), maskBorder );
 }
 
 } // namespace NinePatchMaskEffect
index 91b3661..9dc4293 100644 (file)
@@ -27,10 +27,8 @@ script_v8_plugin_src_files = \
    $(v8_plugin_dir)/events/pan-gesture-detector-api.cpp \
    $(v8_plugin_dir)/events/pan-gesture-detector-wrapper.cpp \
    $(v8_plugin_dir)/stage/stage-api.cpp \
-   $(v8_plugin_dir)/image/image-attributes-api.cpp \
    $(v8_plugin_dir)/shader-effects/shader-effect-api.cpp \
    $(v8_plugin_dir)/shader-effects/shader-effect-wrapper.cpp \
-   $(v8_plugin_dir)/image/image-attributes-wrapper.cpp \
    $(v8_plugin_dir)/image/image-wrapper.cpp \
    $(v8_plugin_dir)/image/image-api.cpp \
    $(v8_plugin_dir)/image/buffer-image-api.cpp \
index 9815aa7..4217d98 100644 (file)
@@ -168,8 +168,18 @@ const IntegerPair EnumTable[] =
     { "RESOURCE_LOADING_SUCCEEDED",                         Dali::ResourceLoadingSucceeded  },
     { "RESOUCE_LOADING_FAILED",                             Dali::ResourceLoadingFailed  },
 
-
-
+    { "FITTING_MODE_SHRINK_TO_FIT",     FittingMode::SHRINK_TO_FIT },
+    { "FITTING_MODE_SCALE_TO_FILL",     FittingMode::SCALE_TO_FILL },
+    { "FITTING_MODE_FIT_WIDTH",         FittingMode::FIT_WIDTH },
+    { "FITTING_MODE_FIT_HEIGHT",        FittingMode::FIT_HEIGHT },
+
+    { "SAMPLING_MODE_BOX",              SamplingMode::BOX },
+    { "SAMPLING_MODE_NEAREST",          SamplingMode::NEAREST },
+    { "SAMPLING_MODE_LINEAR",           SamplingMode::LINEAR },
+    { "SAMPLING_MODE_BOX_THEN_NEAREST", SamplingMode::BOX_THEN_NEAREST },
+    { "SAMPLING_MODE_BOX_THEN_LINEAR",  SamplingMode::BOX_THEN_LINEAR },
+    { "SAMPLING_MODE_NO_FILTER",        SamplingMode::NO_FILTER },
+    { "SAMPLING_MODE_DONT_CARE",        SamplingMode::DONT_CARE },
 
     { "BLEND_FACTOR_ZERO",                                  BlendingFactor::ZERO                    },
     { "BLEND_FACTOR_ONE",                                   BlendingFactor::ONE                     },
index f674551..38231b8 100644 (file)
@@ -24,7 +24,6 @@
 #include <dali/integration-api/debug.h>
 #include <actors/actor-wrapper.h>
 #include <stage/stage-wrapper.h>
-#include <image/image-attributes-wrapper.h>
 #include <image/image-wrapper.h>
 #include <animation/path-wrapper.h>
 #include <animation/path-constraint-wrapper.h>
@@ -72,7 +71,6 @@ const ApiFunction ConstructorFunctionTable[]=
     { "BufferImage",        ImageWrapper::NewImage },
     { "NinePatchImage",     ImageWrapper::NewImage },
     { "FrameBufferImage",   ImageWrapper::NewImage },
-    { "ImageAttributes",    ImageAttributesWrapper::NewImageAttributes },
     { "Animation",          AnimationWrapper::NewAnimation},
     { "ShaderEffect",       ShaderEffectWrapper::NewShaderEffect},
     { "Builder",            BuilderWrapper::NewBuilder},
diff --git a/plugins/dali-script-v8/src/image/image-attributes-api.cpp b/plugins/dali-script-v8/src/image/image-attributes-api.cpp
deleted file mode 100644 (file)
index 5e7006e..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include "image-attributes-api.h"
-
-// INTERNAL INCLUDES
-#include <v8-utils.h>
-#include <image/image-attributes-wrapper.h>
-#include <object/property-value-wrapper.h>
-#include <shared/base-wrapped-object.h>
-
-namespace Dali
-{
-
-namespace V8Plugin
-{
-
-ImageAttributes ImageAttributesApi::GetImageAttributesFromObject( v8::Isolate* isolate, v8::Local<v8::Object> object )
-{
-  v8::HandleScope handleScope( isolate);
-
-  if( BaseWrappedObject::IsWrappedType ( isolate, object, BaseWrappedObject::IMAGE_ATTRIBUTES ))
-  {
-    v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
-    void* ptr = field->Value();
-    BaseWrappedObject* wrappedObject = static_cast< BaseWrappedObject *>(ptr);
-    ImageAttributesWrapper* wrapper = static_cast< ImageAttributesWrapper*>( wrappedObject );;
-    return  wrapper->GetImageAttributes();
-  }
-  else
-  {
-    DALI_SCRIPT_EXCEPTION( isolate, "bad image attributes url");
-    return ImageAttributes();
-  }
-
-}
-
-/***************************************
- * IMAGE ATTRIBUTES FUNCTIONS
- *
- ****************************************/
-ImageAttributes ImageAttributesApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  // two combinations of constructor
-  // 1 = no parameters
-  // 2 = width, height
-  bool foundParams( false );
-  int params[2];
-
-  V8Utils::ReadIntegerArguments( foundParams, &params[0],2,args,0);
-  if( !foundParams )
-  {
-    if( args.Length() != 0 )
-    {
-      DALI_SCRIPT_EXCEPTION( isolate, " ImageAttributes::New invalid params");
-      return Dali::ImageAttributes();
-    }
-    return Dali::ImageAttributes::New();
-  }
-  else
-  {
-    return  Dali::ImageAttributes::New( params[0], params[1] );
-  }
-
-}
-
-ImageAttributes& ImageAttributesApi::GetImageAttributes( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Local<v8::Object> object = args.This();
-  v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
-  void* ptr = field->Value();
-
-  ImageAttributesWrapper* wrapper = static_cast< ImageAttributesWrapper *>(ptr);
-  return wrapper->GetImageAttributes();
-}
-
-void ImageAttributesApi::SetSize( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-  ImageAttributes& attribs( GetImageAttributes( isolate, args ));
-
-  bool found;
-  Vector2 size = V8Utils::GetVector2Parameter( PARAMETER_0, found, isolate, args );
-  if (!found)
-  {
-    DALI_SCRIPT_EXCEPTION( isolate, "invalid size parameter" );
-    return;
-  }
-  else
-  {
-    attribs.SetSize( size );
-  }
-}
-
-void ImageAttributesApi::SetScalingMode( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-  ImageAttributes& attribs( GetImageAttributes( isolate, args ));
-
-  bool found(false);
-  int value = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0);
-  if( !found  )
-  {
-    DALI_SCRIPT_EXCEPTION( isolate, "invalid scaling mode parameter");
-    return;
-  }
-  if( value!= ImageAttributes::ShrinkToFit ||
-      value!= ImageAttributes::ScaleToFill ||
-      value!= ImageAttributes::FitWidth ||
-      value!= ImageAttributes::FitHeight )
-  {
-     DALI_SCRIPT_EXCEPTION( isolate, "invalid scaling mode parameter");
-     return;
-  }
-
-  attribs.SetScalingMode(static_cast<ImageAttributes::ScalingMode >( value) );
-}
-
-void ImageAttributesApi::SetOrientationCorrection( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-  ImageAttributes& attribs( GetImageAttributes( isolate, args ));
-
-  bool parameterFound(false);
-  bool value = V8Utils::GetBooleanParameter( PARAMETER_0 , parameterFound, isolate, args );
-
-  if( !parameterFound )
-  {
-    DALI_SCRIPT_EXCEPTION( isolate, "boolean parameter not found");
-    return;
-  }
-  attribs.SetOrientationCorrection( value );
-}
-
-void ImageAttributesApi::GetWidth( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-  ImageAttributes& attribs( GetImageAttributes( isolate, args ));
-
-  args.GetReturnValue().Set( v8::Integer::New( isolate, attribs.GetWidth() ) );
-}
-
-void ImageAttributesApi::GetHeight( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-  ImageAttributes& attribs( GetImageAttributes( isolate, args ));
-
-  args.GetReturnValue().Set( v8::Integer::New( isolate, attribs.GetHeight() ) );
-
-}
-
-void ImageAttributesApi::GetSize( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-  ImageAttributes& attribs( GetImageAttributes( isolate, args ));
-
-  Vector2 vec( attribs.GetSize() );
-  Dali::Property::Value value( vec );
-
-  v8::Local <v8::Object> object = PropertyValueWrapper::WrapDaliProperty( isolate, value);
-  args.GetReturnValue().Set(  object );
-}
-
-void ImageAttributesApi::GetScalingMode( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-  ImageAttributes& attribs( GetImageAttributes( isolate, args ));
-
-  args.GetReturnValue().Set( v8::Integer::New( isolate, attribs.GetScalingMode() ) );
-
-}
-
-void ImageAttributesApi::GetOrientationCorrection( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-  ImageAttributes& attribs( GetImageAttributes( isolate, args ));
-
-  args.GetReturnValue().Set(  v8::Boolean::New(  isolate, attribs.GetOrientationCorrection() ) );
-
-}
-
-
-} // namespace V8Plugin
-
-} // namespace Dali
diff --git a/plugins/dali-script-v8/src/image/image-attributes-api.h b/plugins/dali-script-v8/src/image/image-attributes-api.h
deleted file mode 100644 (file)
index c474ef0..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef __DALI_V8PLUGIN_IMAGE_ATTRIBUTES_API_H__
-#define __DALI_V8PLUGIN_IMAGE_ATTRIBUTES_API_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <v8.h>
-#include <dali/public-api/images/image-attributes.h>
-
-
-namespace Dali
-{
-
-namespace V8Plugin
-{
-
-namespace ImageAttributesApi
-{
-  ImageAttributes& GetImageAttributes( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
-
-  ImageAttributes GetImageAttributesFromObject( v8::Isolate* isolate, v8::Local<v8::Object> object );
-
-  /**
-   * @brief Creates a new Image Attribute object based on some JavaScript parameters.
-   * @param[in] args constructor parameters
-   * @return ImageAttributes
-   */
-  ImageAttributes New( const v8::FunctionCallbackInfo< v8::Value >& args );
-
-  /**
-   * ImageAttributes API see image-attributes.h for a description
-   */
-  void SetSize( const v8::FunctionCallbackInfo< v8::Value >& args );
-  void SetScalingMode( const v8::FunctionCallbackInfo< v8::Value >& args );
-  void SetOrientationCorrection( const v8::FunctionCallbackInfo< v8::Value >& args );
-  void GetWidth( const v8::FunctionCallbackInfo< v8::Value >& args );
-  void GetHeight( const v8::FunctionCallbackInfo< v8::Value >& args );
-  void GetSize( const v8::FunctionCallbackInfo< v8::Value >& args );
-  void GetScalingMode( const v8::FunctionCallbackInfo< v8::Value >& args );
-  void GetOrientationCorrection( const v8::FunctionCallbackInfo< v8::Value >& args );
-
-}; // namespace ImageAttributesApi
-
-} // namespace V8Plugin
-
-} // namespace Dali
-
-#endif // header __DALI_V8PLUGIN_IMAGE_ATTRIBUTES_API_H__
diff --git a/plugins/dali-script-v8/src/image/image-attributes-wrapper.cpp b/plugins/dali-script-v8/src/image/image-attributes-wrapper.cpp
deleted file mode 100644 (file)
index fa89f79..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include "image-attributes-wrapper.h"
-
-// INTERNAL INCLUDES
-#include <v8-utils.h>
-#include <image/image-attributes-api.h>
-#include <dali-wrapper.h>
-#include <shared/api-function.h>
-#include <shared/object-template-helper.h>
-
-namespace Dali
-{
-
-namespace V8Plugin
-{
-
-v8::Persistent<v8::ObjectTemplate> ImageAttributesWrapper::mImageAttributesTemplate;
-
-namespace
-{
-
-/**
- * Contains a list of all functions that can be called
- */
-const ApiFunction ImageAttributeFunctionTable[]=
-{
-    /**************************************
-    * ImageAttributes API (in order of image-attributes.h)
-    **************************************/
-    { "SetSize",                    ImageAttributesApi::SetSize },
-    { "SetScalingMode",             ImageAttributesApi::SetScalingMode },
-    { "SetOrientationCorrection",   ImageAttributesApi::SetOrientationCorrection },
-    { "GetWidth",                   ImageAttributesApi::GetWidth },
-    { "GetHeight",                  ImageAttributesApi::GetHeight },
-    { "GetSize",                    ImageAttributesApi::GetSize },
-    { "GetScalingMode",             ImageAttributesApi::GetScalingMode },
-    { "GetOrientationCorrection",   ImageAttributesApi::GetOrientationCorrection },
-};
-
-const unsigned int ImageAttributeFunctionTableCount = sizeof(ImageAttributeFunctionTable)/sizeof(ImageAttributeFunctionTable[0]);
-} //un-named space
-
-
-ImageAttributesWrapper::ImageAttributesWrapper( const Dali::ImageAttributes& imageAttributes, GarbageCollectorInterface& gc )
-: BaseWrappedObject( BaseWrappedObject::IMAGE_ATTRIBUTES , gc )
-{
-    mImageAttributes = imageAttributes;
-}
-
-v8::Handle<v8::Object> ImageAttributesWrapper::WrapImageAttributes(v8::Isolate* isolate, const Dali::ImageAttributes& attributes )
-{
-  v8::EscapableHandleScope handleScope( isolate );
-  v8::Local<v8::ObjectTemplate> objectTemplate;
-
-  objectTemplate = GetImageAttributesTemplate( isolate);
-
-  // create an instance of the template
-  v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
-
-  // create the ImageAttributes wrapper
-  ImageAttributesWrapper* pointer =  new ImageAttributesWrapper( attributes, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
-
-  // assign the JavaScript object to the wrapper.
-  pointer->SetJavascriptObject( isolate, localObject );
-
-  return handleScope.Escape( localObject );
-}
-
-v8::Local<v8::ObjectTemplate> ImageAttributesWrapper::GetImageAttributesTemplate( v8::Isolate* isolate)
-{
-  v8::EscapableHandleScope handleScope( isolate );
-  v8::Local<v8::ObjectTemplate> objectTemplate;
-
-
-  if( mImageAttributesTemplate.IsEmpty() )
-  {
-    objectTemplate = MakeImageAttributesTemplate( isolate );
-    mImageAttributesTemplate.Reset( isolate, objectTemplate );
-  }
-  else
-  {
-    // get the object template
-    objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mImageAttributesTemplate );
-  }
-  return handleScope.Escape( objectTemplate );
-}
-
-v8::Handle<v8::ObjectTemplate> ImageAttributesWrapper::MakeImageAttributesTemplate( v8::Isolate* isolate )
-{
-  v8::EscapableHandleScope handleScope( isolate );
-
-  v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
-
-  objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
-
-  // add our function properties
-  ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, ImageAttributeFunctionTable, ImageAttributeFunctionTableCount );
-
-  return handleScope.Escape( objTemplate );
-}
-
-void ImageAttributesWrapper::NewImageAttributes( const v8::FunctionCallbackInfo< v8::Value >& args)
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate);
-
-  if(!args.IsConstructCall())
-  {
-      DALI_SCRIPT_EXCEPTION(isolate, "ImageAttributes constructor called without 'new'");
-      return;
-  }
-
-  // attribs can be passed by value
-  Dali::ImageAttributes attribs = ImageAttributesApi::New( args );
-  v8::Local<v8::Object> localObject = WrapImageAttributes( isolate, attribs );
-  args.GetReturnValue().Set( localObject );
-}
-
-
-ImageAttributes& ImageAttributesWrapper::GetImageAttributes()
-{
-  return mImageAttributes;
-}
-
-
-} // namespace V8Plugin
-
-} // namespace Dali
diff --git a/plugins/dali-script-v8/src/image/image-attributes-wrapper.h b/plugins/dali-script-v8/src/image/image-attributes-wrapper.h
deleted file mode 100644 (file)
index 91511ea..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef __DALI_V8PLUGIN_IMAGE_ATTRIBUTES_WRAPPER_H__
-#define __DALI_V8PLUGIN_IMAGE_ATTRIBUTES_WRAPPER_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <v8.h>
-#include <dali/public-api/images/image-attributes.h>
-
-// INTERNAL INCLUDES
-#include <shared/base-wrapped-object.h>
-
-namespace Dali
-{
-
-namespace V8Plugin
-{
-
-
-/**
- * An Image Attributes wrapper.
- * Provides access to ImageAttributes specific functionality and V8 memory handling.
- */
-class ImageAttributesWrapper : public BaseWrappedObject
-{
-
-public:
-
-  /**
-   * Constructor
-   */
-  ImageAttributesWrapper( const ImageAttributes& imageAttributes,
-                GarbageCollectorInterface& gc );
-
-  /**
-    * Destructor
-    */
-  virtual ~ImageAttributesWrapper(){};
-
-  /**
-   * Constructors
-   */
-  static void NewImageAttributes( const v8::FunctionCallbackInfo< v8::Value >& args);
-
-  /**
-   * Wraps an image attributes
-   */
-  static v8::Handle<v8::Object> WrapImageAttributes(v8::Isolate* isolate, const Dali::ImageAttributes& attributes);
-
-
-  // The ImageAttribute ObjectTemplate, we cache templates so we don't have
-  // keep generating them everytime we want to create an ImageAttribute
-  static v8::Persistent<v8::ObjectTemplate> mImageAttributesTemplate;
-
-  ImageAttributes& GetImageAttributes();
-private:
-
-  // ImageAttributes
-  ImageAttributes mImageAttributes;
-
-  static v8::Handle<v8::ObjectTemplate> MakeImageAttributesTemplate( v8::Isolate* isolate );
-  static v8::Local<v8::ObjectTemplate> GetImageAttributesTemplate( v8::Isolate* isolate );
-
-};
-
-} // namespace V8Plugin
-
-} // namespace Dali
-
-#endif // header
index fe4ff2a..8e7df33 100644 (file)
 // CLASS HEADER
 #include "resource-image-api.h"
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/image-operations.h>
+
 // INTERNAL INCLUDES
 #include <v8-utils.h>
 #include <image/image-wrapper.h>
-#include <image/image-attributes-wrapper.h>
-#include <image/image-attributes-api.h>
-
 
 namespace Dali
 {
@@ -51,7 +51,6 @@ ResourceImage ResourceImageApi::GetResourceImage( v8::Isolate* isolate, const v8
  * @for ResourceImage
  * @param {Object} options
  * @param {String} options.url The URL of the image file to use.
- * @param {Object} [option.imageAttributes] image attributes object
  * @param {Integer} [options.loadPolicy] The LoadPolicy to apply when loading the image resource.
  * @param {Integer} [options.releasePolicy] optionally release memory when image is not visible on screen.
  * @return {Object} Image
@@ -62,10 +61,12 @@ Image ResourceImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
   v8::HandleScope handleScope( isolate );
 
   std::string url;
+  ImageDimensions dimensions;
+  FittingMode::Type fittingMode = FittingMode::DEFAULT;
+  SamplingMode::Type samplingMode = SamplingMode::DEFAULT;
+  bool orientationCorrection = true;
   ResourceImage::LoadPolicy loadPolicy( ResourceImage::IMMEDIATE );
   Image::ReleasePolicy releasePolicy( Image::NEVER);
-  ImageAttributes imageAttributes;
-  bool useImageAttributes = false;
 
   v8::Local<v8::Value> options( args[0] );
 
@@ -88,13 +89,37 @@ Image ResourceImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
     return Image();
   }
 
-  v8::Local<v8::Value> imageAttribsValue= optionsObject->Get( v8::String::NewFromUtf8( isolate, "imageAttributes" ) );
-  if( imageAttribsValue->IsObject() )
+  v8::Local<v8::Value> widthValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "width" ) );
+  if( widthValue->IsUint32() )
   {
-    imageAttributes = ImageAttributesApi::GetImageAttributesFromObject( isolate, imageAttribsValue->ToObject() );
+    const uint32_t width = widthValue->ToUint32()->Value();
+    dimensions = ImageDimensions( width, dimensions.GetHeight() );
   }
 
+  v8::Local<v8::Value> heightValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "height" ) );
+  if( heightValue->IsUint32() )
+  {
+    const uint32_t height = heightValue->ToUint32()->Value();
+    dimensions = ImageDimensions( dimensions.GetWidth(), height );
+  }
 
+  v8::Local<v8::Value> fittingModeValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "fittingMode" ) );
+  if( fittingModeValue->IsUint32() )
+  {
+    fittingMode = static_cast<FittingMode::Type>( fittingModeValue->ToUint32()->Value() );
+  }
+
+  v8::Local<v8::Value> samplingModeValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "samplingMode" ) );
+  if( samplingModeValue->IsUint32() )
+  {
+    samplingMode = static_cast<SamplingMode::Type>( samplingModeValue->ToUint32()->Value() );
+  }
+
+  v8::Local<v8::Value> orientationCorrectionValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "orientationCorrection" ) );
+  if( orientationCorrectionValue->IsBoolean() )
+  {
+    orientationCorrection = orientationCorrectionValue->ToBoolean()->Value();
+  }
 
   v8::Local<v8::Value> releasePolicyValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "releasePolicy" ) );
   if( releasePolicyValue->IsUint32() )
@@ -108,14 +133,7 @@ Image ResourceImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
     loadPolicy = static_cast< ResourceImage::LoadPolicy >( loadPolicyValue->ToUint32()->Value());
   }
 
-  if( useImageAttributes )
-  {
-    return ResourceImage::New( url, imageAttributes, loadPolicy, releasePolicy);
-  }
-  else
-  {
-    return ResourceImage::New( url, loadPolicy, releasePolicy);
-  }
+  return ResourceImage::New( url, loadPolicy, releasePolicy, dimensions, fittingMode, samplingMode, orientationCorrection );
 }
 
 /**
@@ -176,7 +194,6 @@ void ResourceImageApi::GetUrl( const v8::FunctionCallbackInfo< v8::Value >& args
 
 /**
  * Reload the image
- * The set ImageAttributes are used when requesting the image again.
  * @note if Image is offstage and OnDemand policy is set, reload request is ignored.
  * @method reload
  * @for ResourceImage
@@ -190,28 +207,6 @@ void ResourceImageApi::Reload( const v8::FunctionCallbackInfo< v8::Value >& args
   image.Reload();
 }
 
-
-/**
- * Return attributes for the image
- * Only to be used after the image has finished loading.
- * (Ticket's LoadingSucceeded callback was called)
- * The returned value will reflect the true image dimensions once the asynchronous loading has finished.
- *
- * @method getAttributes
- * @for ResourceImage
- * @return {Object} ImageAttributes
- */
-void ResourceImageApi::GetAttributes( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
-  v8::Isolate* isolate = args.GetIsolate();
-  v8::HandleScope handleScope( isolate );
-
-  ResourceImage image = GetResourceImage( isolate, args );
-
-  v8::Local<v8::Object> localObject = ImageAttributesWrapper::WrapImageAttributes(isolate, image.GetAttributes());
-
-  args.GetReturnValue().Set( localObject );
-}
 } // namespace V8Plugin
 
 } // namespace Dali
index 46d7d13..a9af141 100644 (file)
@@ -49,7 +49,6 @@ namespace ResourceImageApi
   void GetLoadingState( const v8::FunctionCallbackInfo< v8::Value >& args );
   void GetUrl( const v8::FunctionCallbackInfo< v8::Value >& args );
   void Reload( const v8::FunctionCallbackInfo< v8::Value >& args );
-  void GetAttributes( const v8::FunctionCallbackInfo< v8::Value >& args );
 
 }; // namespace ResourceImageApi