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;
}
/**
// 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>
*/
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()
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
$(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 \
{ "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 },
#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>
{ "BufferImage", ImageWrapper::NewImage },
{ "NinePatchImage", ImageWrapper::NewImage },
{ "FrameBufferImage", ImageWrapper::NewImage },
- { "ImageAttributes", ImageAttributesWrapper::NewImageAttributes },
{ "Animation", AnimationWrapper::NewAnimation},
{ "ShaderEffect", ShaderEffectWrapper::NewShaderEffect},
{ "Builder", BuilderWrapper::NewBuilder},
+++ /dev/null
-/*
- * 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, ¶ms[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
+++ /dev/null
-#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__
+++ /dev/null
-/*
- * 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
+++ /dev/null
-#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
// 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
{
* @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
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] );
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() )
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 );
}
/**
/**
* 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
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
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