636874ace511c648d5606944fad8f77afd75819f
[platform/core/uifw/dali-core.git] / dali / devel-api / scripting / scripting.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/scripting/scripting.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/images/resource-image.h>
24 #include <dali/public-api/object/type-registry.h>
25 #include <dali/public-api/object/property-array.h>
26 #include <dali/internal/common/image-attributes.h>
27 #include <dali/internal/event/images/resource-image-impl.h>
28 #include <dali/internal/event/images/frame-buffer-image-impl.h>
29 #include <dali/internal/event/images/buffer-image-impl.h>
30 #include <dali/internal/event/effects/shader-effect-impl.h>
31
32 namespace Dali
33 {
34
35 namespace Scripting
36 {
37
38 namespace
39 {
40
41 // Tables used here for converting strings to the enumerations and vice versa
42
43 const StringEnum< ColorMode > COLOR_MODE_TABLE[] =
44 {
45   { "USE_OWN_COLOR",                    USE_OWN_COLOR                    },
46   { "USE_PARENT_COLOR",                 USE_PARENT_COLOR                 },
47   { "USE_OWN_MULTIPLY_PARENT_COLOR",    USE_OWN_MULTIPLY_PARENT_COLOR    },
48   { "USE_OWN_MULTIPLY_PARENT_ALPHA",    USE_OWN_MULTIPLY_PARENT_ALPHA    },
49 };
50 const unsigned int COLOR_MODE_TABLE_COUNT = sizeof( COLOR_MODE_TABLE ) / sizeof( COLOR_MODE_TABLE[0] );
51
52 const StringEnum< PositionInheritanceMode > POSITION_INHERITANCE_MODE_TABLE[] =
53 {
54   { "INHERIT_PARENT_POSITION",                    INHERIT_PARENT_POSITION                    },
55   { "USE_PARENT_POSITION",                        USE_PARENT_POSITION                        },
56   { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION",    USE_PARENT_POSITION_PLUS_LOCAL_POSITION    },
57   { "DONT_INHERIT_POSITION",                      DONT_INHERIT_POSITION                      },
58 };
59 const unsigned int POSITION_INHERITANCE_MODE_TABLE_COUNT = sizeof( POSITION_INHERITANCE_MODE_TABLE ) / sizeof( POSITION_INHERITANCE_MODE_TABLE[0] );
60
61 const StringEnum< DrawMode::Type > DRAW_MODE_TABLE[] =
62 {
63   { "NORMAL",     DrawMode::NORMAL     },
64   { "OVERLAY",    DrawMode::OVERLAY    },
65   { "STENCIL",    DrawMode::STENCIL    },
66 };
67 const unsigned int DRAW_MODE_TABLE_COUNT = sizeof( DRAW_MODE_TABLE ) / sizeof( DRAW_MODE_TABLE[0] );
68
69 const StringEnum< Vector3 > ANCHOR_CONSTANT_TABLE[] =
70 {
71   { "TOP_LEFT",               ParentOrigin::TOP_LEFT               },
72   { "TOP_CENTER",             ParentOrigin::TOP_CENTER             },
73   { "TOP_RIGHT",              ParentOrigin::TOP_RIGHT              },
74   { "CENTER_LEFT",            ParentOrigin::CENTER_LEFT            },
75   { "CENTER",                 ParentOrigin::CENTER                 },
76   { "CENTER_RIGHT",           ParentOrigin::CENTER_RIGHT           },
77   { "BOTTOM_LEFT",            ParentOrigin::BOTTOM_LEFT            },
78   { "BOTTOM_CENTER",          ParentOrigin::BOTTOM_CENTER          },
79   { "BOTTOM_RIGHT",           ParentOrigin::BOTTOM_RIGHT           },
80 };
81 const unsigned int ANCHOR_CONSTANT_TABLE_COUNT = sizeof( ANCHOR_CONSTANT_TABLE ) / sizeof( ANCHOR_CONSTANT_TABLE[0] );
82
83 const StringEnum< ResourceImage::LoadPolicy > IMAGE_LOAD_POLICY_TABLE[] =
84 {
85   { "IMMEDIATE", ResourceImage::IMMEDIATE },
86   { "ON_DEMAND", ResourceImage::ON_DEMAND },
87 };
88 const unsigned int IMAGE_LOAD_POLICY_TABLE_COUNT = sizeof( IMAGE_LOAD_POLICY_TABLE ) / sizeof( IMAGE_LOAD_POLICY_TABLE[0] );
89
90 const StringEnum< Image::ReleasePolicy > IMAGE_RELEASE_POLICY_TABLE[] =
91 {
92   { "UNUSED", Image::UNUSED },
93   { "NEVER",  Image::NEVER  },
94 };
95 const unsigned int IMAGE_RELEASE_POLICY_TABLE_COUNT = sizeof( IMAGE_RELEASE_POLICY_TABLE ) / sizeof( IMAGE_RELEASE_POLICY_TABLE[0] );
96
97 const StringEnum< Pixel::Format > PIXEL_FORMAT_TABLE[] =
98 {
99   { "A8",                                           Pixel::A8                                           },
100   { "L8",                                           Pixel::L8                                           },
101   { "LA88",                                         Pixel::LA88                                         },
102   { "RGB565",                                       Pixel::RGB565                                       },
103   { "BGR565",                                       Pixel::BGR565                                       },
104   { "RGBA4444",                                     Pixel::RGBA4444                                     },
105   { "BGRA4444",                                     Pixel::BGRA4444                                     },
106   { "RGBA5551",                                     Pixel::RGBA5551                                     },
107   { "BGRA5551",                                     Pixel::BGRA5551                                     },
108   { "RGB888",                                       Pixel::RGB888                                       },
109   { "RGB8888",                                      Pixel::RGB8888                                      },
110   { "BGR8888",                                      Pixel::BGR8888                                      },
111   { "RGBA8888",                                     Pixel::RGBA8888                                     },
112   { "BGRA8888",                                     Pixel::BGRA8888                                     },
113   { "COMPRESSED_R11_EAC",                           Pixel::COMPRESSED_R11_EAC                           },
114   { "COMPRESSED_SIGNED_R11_EAC",                    Pixel::COMPRESSED_SIGNED_R11_EAC                    },
115   { "COMPRESSED_SIGNED_RG11_EAC",                   Pixel::COMPRESSED_SIGNED_RG11_EAC                   },
116   { "COMPRESSED_RG11_EAC",                          Pixel::COMPRESSED_RG11_EAC                          },
117   { "COMPRESSED_RGB8_ETC2",                         Pixel::COMPRESSED_RGB8_ETC2                         },
118   { "COMPRESSED_SRGB8_ETC2",                        Pixel::COMPRESSED_SRGB8_ETC2                        },
119   { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",     Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2     },
120   { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",    Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2    },
121   { "COMPRESSED_RGBA8_ETC2_EAC",                    Pixel::COMPRESSED_RGBA8_ETC2_EAC                    },
122   { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",             Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC             },
123   { "COMPRESSED_RGB8_ETC1",                         Pixel::COMPRESSED_RGB8_ETC1                         },
124   { "COMPRESSED_RGB_PVRTC_4BPPV1",                  Pixel::COMPRESSED_RGB_PVRTC_4BPPV1                  },
125 };
126 const unsigned int PIXEL_FORMAT_TABLE_COUNT = sizeof( PIXEL_FORMAT_TABLE ) / sizeof( PIXEL_FORMAT_TABLE[0] );
127
128 const StringEnum< FittingMode::Type > IMAGE_FITTING_MODE_TABLE[] =
129 {
130   { "SHRINK_TO_FIT", FittingMode::SHRINK_TO_FIT },
131   { "SCALE_TO_FILL", FittingMode::SCALE_TO_FILL },
132   { "FIT_WIDTH",     FittingMode::FIT_WIDTH    },
133   { "FIT_HEIGHT",    FittingMode::FIT_HEIGHT   },
134 };
135 const unsigned int IMAGE_FITTING_MODE_TABLE_COUNT = sizeof( IMAGE_FITTING_MODE_TABLE ) / sizeof( IMAGE_FITTING_MODE_TABLE[0] );
136
137 const StringEnum< SamplingMode::Type > IMAGE_SAMPLING_MODE_TABLE[] =
138 {
139   { "BOX",              SamplingMode::BOX            },
140   { "NEAREST",          SamplingMode::NEAREST        },
141   { "LINEAR",           SamplingMode::LINEAR         },
142   { "BOX_THEN_NEAREST", SamplingMode::BOX_THEN_NEAREST },
143   { "BOX_THEN_LINEAR",  SamplingMode::BOX_THEN_LINEAR  },
144   { "NO_FILTER",        SamplingMode::NO_FILTER       },
145   { "DONT_CARE",        SamplingMode::DONT_CARE       },
146 };
147 const unsigned int IMAGE_SAMPLING_MODE_TABLE_COUNT = sizeof( IMAGE_SAMPLING_MODE_TABLE ) / sizeof( IMAGE_SAMPLING_MODE_TABLE[0] );
148
149 } // unnamed namespace
150
151 bool CompareEnums( const char * a, const char * b )
152 {
153   while( ( *a != '\0' ) && ( *b != '\0' ) )
154   {
155     char ca = *a;
156     char cb = *b;
157
158     if( ( ( ca == '-' ) || ( ca == '_') ) &&
159         ( ( cb == '-' ) || ( cb == '_') ) )
160     {
161       ++a;
162       ++b;
163       continue;
164     }
165
166     if( ( 'A' <= ca ) && ( ca <= 'Z') )
167     {
168       ca = ca + ( 'a' - 'A' );
169     }
170
171     if( ( 'A' <= cb ) && ( cb <= 'Z') )
172     {
173       cb = cb + ( 'a' - 'A' );
174     }
175
176     if( ca != cb )
177     {
178       return false;
179     }
180
181     ++a;
182     ++b;
183   }
184
185   if( ( *a == '\0' ) && ( *b == '\0' ) )
186   {
187     return true;
188   }
189
190   return false;
191 }
192
193
194 ColorMode GetColorMode( const std::string& value )
195 {
196   return GetEnumeration< ColorMode >( value.c_str(), COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT );
197 }
198
199
200 std::string GetColorMode( ColorMode value )
201 {
202   return GetEnumerationName< ColorMode >( value, COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT );
203 }
204
205 PositionInheritanceMode GetPositionInheritanceMode( const std::string& value )
206 {
207   return GetEnumeration< PositionInheritanceMode >( value.c_str(), POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT );
208 }
209
210
211 std::string GetPositionInheritanceMode( PositionInheritanceMode value )
212 {
213   return GetEnumerationName< PositionInheritanceMode >( value, POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT );
214 }
215
216
217 DrawMode::Type GetDrawMode( const std::string& value )
218 {
219   return GetEnumeration< DrawMode::Type >( value.c_str(), DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT );
220 }
221
222
223 std::string GetDrawMode( DrawMode::Type value )
224 {
225   return GetEnumerationName< DrawMode::Type >( value, DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT );
226 }
227
228
229 Vector3 GetAnchorConstant( const std::string& value )
230 {
231   return GetEnumeration< Vector3 >( value.c_str(), ANCHOR_CONSTANT_TABLE, ANCHOR_CONSTANT_TABLE_COUNT );
232 }
233
234
235 Image NewImage( const Property::Value& map )
236 {
237   Image ret;
238
239   std::string filename;
240   ResourceImage::LoadPolicy loadPolicy    = Dali::Internal::IMAGE_LOAD_POLICY_DEFAULT;
241   Image::ReleasePolicy releasePolicy = Dali::Internal::IMAGE_RELEASE_POLICY_DEFAULT;
242   Internal::ImageAttributes attributes = Internal::ImageAttributes::New();
243
244   if( Property::MAP == map.GetType() )
245   {
246     std::string field = "filename";
247     if( map.HasKey(field) )
248     {
249       DALI_ASSERT_ALWAYS(map.GetValue(field).GetType() == Property::STRING && "Image filename property is not a string" );
250       filename = map.GetValue(field).Get<std::string>();
251     }
252
253     field = "load-policy";
254     if( map.HasKey(field) )
255     {
256       DALI_ASSERT_ALWAYS(map.GetValue(field).GetType() == Property::STRING && "Image load-policy property is not a string" );
257       std::string v(map.GetValue(field).Get<std::string>());
258       loadPolicy = GetEnumeration< ResourceImage::LoadPolicy >( v.c_str(), IMAGE_LOAD_POLICY_TABLE, IMAGE_LOAD_POLICY_TABLE_COUNT );
259     }
260
261     field = "release-policy";
262     if( map.HasKey(field) )
263     {
264       DALI_ASSERT_ALWAYS(map.GetValue(field).GetType() == Property::STRING && "Image release-policy property is not a string" );
265       std::string v(map.GetValue(field).Get<std::string>());
266       releasePolicy = GetEnumeration< Image::ReleasePolicy >( v.c_str(), IMAGE_RELEASE_POLICY_TABLE, IMAGE_RELEASE_POLICY_TABLE_COUNT );
267     }
268
269     // Width and height can be set individually. Dali derives the unspecified
270     // dimension from the aspect ratio of the raw image.
271     unsigned int width = 0, height = 0;
272
273     field = "width";
274     if( map.HasKey( field ) )
275     {
276       Property::Value &value = map.GetValue( field );
277
278       // handle floats and integer the same for json script
279       if( value.GetType() == Property::FLOAT )
280       {
281         width = static_cast<unsigned int>( value.Get<float>() );
282       }
283       else
284       {
285         DALI_ASSERT_ALWAYS( value.GetType() == Property::INTEGER && "Image width property is not a number" );
286         width = value.Get<int>();
287       }
288     }
289
290     field = "height";
291     if( map.HasKey( field ) )
292     {
293       Property::Value &value = map.GetValue( field );
294       if( value.GetType() == Property::FLOAT )
295       {
296         height = static_cast<unsigned int>( value.Get<float>() );
297       }
298       else
299       {
300         DALI_ASSERT_ALWAYS( value.GetType() == Property::INTEGER && "Image width property is not a number" );
301         height = value.Get<int>();
302       }
303     }
304
305     attributes.SetSize( width, height );
306
307     field = "pixel-format";
308     Pixel::Format pixelFormat = Pixel::RGBA8888;
309     if( map.HasKey(field) )
310     {
311       DALI_ASSERT_ALWAYS( map.GetValue(field).GetType() == Property::STRING && "Image release-policy property is not a string" );
312       std::string s( map.GetValue(field).Get<std::string>() );
313       pixelFormat = GetEnumeration< Pixel::Format >( s.c_str(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
314     }
315
316     field = "fitting-mode";
317     if( map.HasKey( field ) )
318     {
319       Property::Value& value = map.GetValue( field );
320       DALI_ASSERT_ALWAYS( value.GetType() == Property::STRING && "Image fitting-mode property is not a string" );
321       std::string s( value.Get<std::string>() );
322       attributes.SetScalingMode( GetEnumeration< FittingMode::Type >( s.c_str(), IMAGE_FITTING_MODE_TABLE, IMAGE_FITTING_MODE_TABLE_COUNT ) );
323     }
324
325     field = "sampling-mode";
326     if( map.HasKey( field ) )
327     {
328       Property::Value& value = map.GetValue( field );
329       DALI_ASSERT_ALWAYS( value.GetType() == Property::STRING && "Image sampling-mode property is not a string" );
330       std::string s( value.Get<std::string>() );
331       attributes.SetFilterMode( GetEnumeration< SamplingMode::Type >( s.c_str(), IMAGE_SAMPLING_MODE_TABLE, IMAGE_SAMPLING_MODE_TABLE_COUNT ) );
332     }
333
334     field = "orientation";
335     if( map.HasKey( field ) )
336     {
337       Property::Value& value = map.GetValue( field );
338       DALI_ASSERT_ALWAYS( value.GetType() == Property::BOOLEAN && "Image orientation property is not a boolean" );
339       bool b = value.Get<bool>();
340       attributes.SetOrientationCorrection( b );
341     }
342
343     if( map.HasKey("type") )
344     {
345       DALI_ASSERT_ALWAYS( map.GetValue("type").GetType() == Property::STRING );
346       std::string s(map.GetValue("type").Get<std::string>());
347       if("FrameBufferImage" == s)
348       {
349         ret = FrameBufferImage::New(attributes.GetWidth(),
350                                     attributes.GetHeight(),
351                                     pixelFormat,
352                                     releasePolicy);
353       }
354       else if("BufferImage" == s)
355       {
356         ret = BufferImage::New(attributes.GetWidth(),
357                                attributes.GetHeight(),
358                                pixelFormat,
359                                releasePolicy);
360       }
361       else if("ResourceImage" == s)
362       {
363         ret = ResourceImage::New( filename, loadPolicy, releasePolicy, ImageDimensions( attributes.GetSize().x, attributes.GetSize().y ), attributes.GetScalingMode(), attributes.GetFilterMode(), attributes.GetOrientationCorrection() );
364       }
365       else
366       {
367         DALI_ASSERT_ALWAYS( !"Unknown image type" );
368       }
369     }
370     else
371     {
372       ret = ResourceImage::New( filename, loadPolicy, releasePolicy, ImageDimensions( attributes.GetSize().x, attributes.GetSize().y ), attributes.GetScalingMode(), attributes.GetFilterMode(), attributes.GetOrientationCorrection() );
373     }
374   }
375
376   return ret;
377
378 } // Image NewImage( Property::Value map )
379
380
381 ShaderEffect NewShaderEffect( const Property::Value& map )
382 {
383   Internal::ShaderEffectPtr ret;
384
385   if( map.GetType() == Property::MAP )
386   {
387     ret = Internal::ShaderEffect::New(Dali::ShaderEffect::HINT_NONE); // hint can be reset if in map
388
389     if( map.HasKey("program") )
390     {
391       Property::Index index = ret->GetPropertyIndex("program");
392       DALI_ASSERT_DEBUG( map.GetValue("program").GetType() == Property::MAP );
393       ret->SetProperty(index, map.GetValue("program"));
394     }
395
396     for(int i = 0; i < map.GetSize(); ++i)
397     {
398       const std::string& key = map.GetKey(i);
399       if(key != "program")
400       {
401         Property::Index index = ret->GetPropertyIndex( key );
402
403         if( Property::INVALID_INDEX != index )
404         {
405           ret->SetProperty(index, map.GetItem(i));
406         }
407         else
408         {
409           // if its not a property then register it as a uniform (making a custom property)
410
411           if(map.GetItem(i).GetType() == Property::INTEGER)
412           {
413             // valid uniforms are floats, vec3's etc so we recast if the user accidentally
414             // set as integer. Note the map could have come from json script.
415             Property::Value asFloat( static_cast<float>( map.GetItem(i).Get<int>() ) );
416             ret->SetUniform( key, asFloat, Dali::ShaderEffect::COORDINATE_TYPE_DEFAULT );
417           }
418           else
419           {
420             ret->SetUniform( key, map.GetItem(i), Dali::ShaderEffect::COORDINATE_TYPE_DEFAULT );
421           }
422         }
423       }
424     }
425   }
426
427   return Dali::ShaderEffect(ret.Get());
428 }
429
430
431 Actor NewActor( const Property::Map& map )
432 {
433   BaseHandle handle;
434
435   // First find type and create Actor
436   Property::Value* typeValue = map.Find( "type" );
437   if ( typeValue )
438   {
439     TypeInfo type = TypeRegistry::Get().GetTypeInfo( typeValue->Get< std::string >() );
440     if ( type )
441     {
442       handle = type.CreateInstance();
443     }
444   }
445
446   if ( !handle )
447   {
448     DALI_LOG_ERROR( "Actor type not provided, returning empty handle" );
449     return Actor();
450   }
451
452   Actor actor( Actor::DownCast( handle ) );
453
454   if ( actor )
455   {
456     // Now set the properties, or create children
457     for ( unsigned int i = 0, mapCount = map.Count(); i < mapCount; ++i )
458     {
459       const StringValuePair& pair( map.GetPair( i ) );
460       const std::string& key( pair.first );
461       if ( key == "type" )
462       {
463         continue;
464       }
465
466       const Property::Value& value( pair.second );
467
468       if ( key == "actors" )
469       {
470         // Create children
471
472         Property::Array actorArray = value.Get< Property::Array >();
473         for ( size_t i = 0; i < actorArray.Size(); ++i)
474         {
475           actor.Add( NewActor( actorArray[i].Get< Property::Map >() ) );
476         }
477       }
478       else if ( key == "signals" )
479       {
480         DALI_LOG_ERROR( "signals not supported" );
481       }
482       else if( key ==  "parent-origin" )
483       {
484         // Parent Origin can be a string constant as well as a Vector3
485
486         const Property::Type type( value.GetType() );
487         if ( type == Property::VECTOR3 )
488         {
489           actor.SetParentOrigin( value.Get< Vector3 >() );
490         }
491         else if( type == Property::STRING )
492         {
493           actor.SetParentOrigin( GetAnchorConstant( value.Get< std::string >() ) );
494         }
495       }
496       else if( key ==  "anchor-point" )
497       {
498         // Anchor Point can be a string constant as well as a Vector3
499
500         const Property::Type type( value.GetType() );
501         if ( type == Property::VECTOR3 )
502         {
503           actor.SetAnchorPoint( value.Get< Vector3 >() );
504         }
505         else if( type == Property::STRING )
506         {
507           actor.SetAnchorPoint( GetAnchorConstant( value.Get< std::string >() ) );
508         }
509       }
510       else
511       {
512         Property::Index index( actor.GetPropertyIndex( key ) );
513
514         if ( index != Property::INVALID_INDEX )
515         {
516           actor.SetProperty( index, value );
517         }
518       }
519     }
520   }
521
522   return actor;
523 }
524
525 void CreatePropertyMap( Actor actor, Property::Map& map )
526 {
527   map.Clear();
528
529   if ( actor )
530   {
531     map[ "type" ] = actor.GetTypeName();
532
533     // Default properties
534     Property::IndexContainer indices;
535     actor.GetPropertyIndices( indices );
536     const Property::IndexContainer::ConstIterator endIter = indices.End();
537
538     for ( Property::IndexContainer::Iterator iter = indices.Begin(); iter != endIter; ++iter )
539     {
540       map[ actor.GetPropertyName( *iter ) ] = actor.GetProperty( *iter );
541     }
542
543     // Children
544     unsigned int childCount( actor.GetChildCount() );
545     if ( childCount )
546     {
547       Property::Array childArray;
548       for ( unsigned int child = 0; child < childCount; ++child )
549       {
550         Property::Map childMap;
551         CreatePropertyMap( actor.GetChildAt( child ), childMap );
552         childArray.PushBack( childMap );
553       }
554       map[ "actors" ] = childArray;
555     }
556   }
557 }
558
559 void CreatePropertyMap( Image image, Property::Map& map )
560 {
561   map.Clear();
562
563   if ( image )
564   {
565     std::string imageType( "ResourceImage" );
566
567     // Get Type - cannot use TypeRegistry as Image is not an Object and thus, not registered
568     BufferImage bufferImage = BufferImage::DownCast( image );
569     if ( bufferImage )
570     {
571       imageType = "BufferImage";
572       map[ "pixel-format" ] = GetEnumerationName< Pixel::Format >( bufferImage.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
573     }
574     else if ( FrameBufferImage::DownCast( image ) )
575     {
576       imageType = "FrameBufferImage";
577     }
578
579     map[ "type" ] = imageType;
580     map[ "release-policy" ] = GetEnumerationName< Image::ReleasePolicy >( image.GetReleasePolicy(), IMAGE_RELEASE_POLICY_TABLE, IMAGE_RELEASE_POLICY_TABLE_COUNT );
581
582     ResourceImage resourceImage = ResourceImage::DownCast( image );
583     if( resourceImage )
584     {
585       map[ "filename" ] = resourceImage.GetUrl();
586       map[ "load-policy" ] = GetEnumerationName< ResourceImage::LoadPolicy >( resourceImage.GetLoadPolicy(), IMAGE_LOAD_POLICY_TABLE, IMAGE_LOAD_POLICY_TABLE_COUNT );
587     }
588
589     int width( image.GetWidth() );
590     int height( image.GetHeight() );
591
592     if ( width && height )
593     {
594       map[ "width" ] = width;
595       map[ "height" ] = height;
596     }
597   }
598 }
599
600
601 DALI_IMPORT_API bool SetRotation( const Property::Value& value, Quaternion& quaternion )
602 {
603   bool done = false;
604   Property::Type type = value.GetType();
605   if( Property::VECTOR3 == type )
606   {
607     Vector3 v3;
608     value.Get(v3);
609     quaternion.SetEuler( Radian(Degree(v3.x)), Radian(Degree(v3.y)), Radian(Degree(v3.z)) );
610     done = true;
611   }
612   else if( Property::VECTOR4 == type )
613   {
614     Vector4 v4;
615     value.Get(v4);
616     quaternion = Quaternion(v4);
617     done = true;
618   }
619   else if( Property::ROTATION == type )
620   {
621     value.Get(quaternion);
622     done = true;
623   }
624
625   return done;
626 }
627
628 } // namespace scripting
629
630 } // namespace Dali
631
632
633
634