Blending enum clean-up
[platform/core/uifw/dali-adaptor.git] / adaptors / emscripten / wrappers / dali-wrapper.cpp
1 /*
2  * Copyright (c) 2016 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
19 // EXTERNAL INCLUDES
20 #include <sstream>
21
22 #include <dali/devel-api/scripting/scripting.h>
23 #include <dali/devel-api/events/hit-test-algorithm.h>
24 #include <dali/devel-api/rendering/geometry.h>
25 #include <dali/devel-api/rendering/shader.h>
26 #include <dali/devel-api/rendering/sampler.h>
27 #include <dali/devel-api/rendering/texture-set.h>
28 #include <dali/devel-api/rendering/renderer.h>
29 #include "emscripten/emscripten.h"
30 #include "emscripten/bind.h"
31 #include "emscripten/val.h"
32
33 // INTERNAL INCLUDES
34 #include "platform-abstractions/emscripten/emscripten-callbacks.h"
35 #include "platform-abstractions/emscripten/emscripten-platform-abstraction.h"
36 #include "sdl-application.h"
37 #include "actor-wrapper.h"
38 #include "animation-wrapper.h"
39 #include "emscripten-utils.h"
40 #include "geometry-wrapper.h"
41 #include "handle-wrapper.h"
42 #include "image-wrapper.h"
43 #include "property-buffer-wrapper.h"
44 #include "property-value-wrapper.h"
45 #include "render-task-wrapper.h"
46 #include "shader-effect-wrapper.h"
47 #include "signal-holder.h"
48 #include "type-info-wrapper.h"
49
50 ////////////////////////////////////////////////////////////////////////////////
51 //
52 // The browser javascript wrapper consists of this cpp file and a counterpart
53 // javascript file.
54 //
55 // They work in tandem to help make the interface natural and convenient
56 // for a Javascript programmer.
57 //
58 // Unfortunately there is no finalize/destruction in javascript so any cpp
59 // objects created must be explicitly deleted. Sometimes this wrapper can
60 // hide the details and simple types can be immediately marshalled to and
61 // from javascript values. More often objects created must have
62 // object.delete() called at the correct time.
63 //
64 ////////////////////////////////////////////////////////////////////////////////
65
66 extern void EmscriptenMouseEvent(double x, double y, int mouseIsDown);
67 extern void EmscriptenUpdateOnce();
68 extern void EmscriptenRenderOnce();
69
70 namespace Dali
71 {
72 namespace Internal
73 {
74 namespace Emscripten
75 {
76
77 // Javascript callbacks. These are set in the Javascript wrapper source and called
78 // from the c++ wrapper source
79 extern emscripten::val JSGetGlyphImage;
80 extern emscripten::val JSGetImage;
81 extern emscripten::val JSGetImageMetaData;
82 extern emscripten::val JSRenderFinished;
83
84 using namespace emscripten;
85
86 /**
87  * Dali Vector access for Emscripten wrapping of Dali::Vector
88  */
89 template<typename DaliVectorType>
90 struct DaliVectorAccess
91 {
92   static emscripten::val Get( const DaliVectorType& v, typename DaliVectorType::SizeType index )
93   {
94     if (index < v.Size())
95     {
96       return emscripten::val(v[index]);
97     }
98     else
99     {
100       return emscripten::val::undefined();
101     }
102   }
103
104   static bool Set( DaliVectorType& v, typename DaliVectorType::SizeType index, const typename DaliVectorType::ItemType& value)
105   {
106     v[index] = value;
107     return true;
108   }
109
110   static size_t Size( DaliVectorType& v)
111   {
112     return v.Size();
113   }
114 };
115
116 /**
117  * Registering a Dali Vector with Emscripten to wrap for JavaScript
118  */
119 template<typename T>
120 class_<Dali::Vector<T>> register_dali_vector(const char* name)
121 {
122   typedef Dali::Vector<T> DaliVecType;
123
124   void (DaliVecType::*PushBack)(const T&) = &DaliVecType::PushBack;
125   void (DaliVecType::*Resize)(const size_t, const T&) = &DaliVecType::Resize;
126   return class_<DaliVecType>(name)
127     .template constructor<>()
128     .function("push_back", PushBack)
129     .function("resize", Resize)
130     .function("size", &DaliVectorAccess<DaliVecType>::Size)
131     .function("get", &DaliVectorAccess<DaliVecType>::Get)
132     .function("set", &DaliVectorAccess<DaliVecType>::Set)
133 ;
134 };
135
136
137 namespace
138 {
139
140 std::string VersionString()
141 {
142   std::stringstream versionString;
143   versionString <<  "DALi Core:      " << Dali::CORE_MAJOR_VERSION << "." << Dali::CORE_MINOR_VERSION << "." << Dali::CORE_MICRO_VERSION << " (" << Dali::CORE_BUILD_DATE << ")" << std::endl;
144   return versionString.str();
145 }
146
147 /**
148  * Creates an Actor previously registered with the TypeRegistry by name
149  * Actors are currently differentiated in the dali-wrapper.js and have accessor functions
150  * to support 'property.name=' access in the Javascript side object
151  */
152 Dali::Actor CreateActor(const std::string& name)
153 {
154   Dali::Actor ret;
155
156   Dali::TypeRegistry registry = Dali::TypeRegistry::Get();
157
158   Dali::TypeInfo typeInfo = registry.GetTypeInfo( name );
159
160   if(!typeInfo)
161   {
162     EM_ASM( throw "Invalid type name" );
163   }
164   else
165   {
166     Dali::BaseHandle handle = typeInfo.CreateInstance();
167
168     if(!handle)
169     {
170       EM_ASM( throw "Invalid handle. Cannot downcast (not an actor)" );
171     }
172
173     if( Dali::Actor actor = Dali::Actor::DownCast(handle) )
174     {
175       ret = actor;
176     }
177   }
178
179   return ret;
180 }
181
182 /**
183  * Creates any Handle from the TypeRegistry by name
184  */
185 Dali::Handle CreateHandle(const std::string& name)
186 {
187   Dali::Handle ret;
188
189   Dali::TypeRegistry registry = Dali::TypeRegistry::Get();
190
191   Dali::TypeInfo typeInfo = registry.GetTypeInfo( name );
192
193   if(!typeInfo)
194   {
195     EM_ASM( throw "Invalid type name" );
196   }
197   else
198   {
199     Dali::BaseHandle base = typeInfo.CreateInstance();
200     if(!base)
201     {
202       EM_ASM( throw "Cannot create instance (not a handle)" );
203     }
204     Dali::Handle handle = Dali::Handle::DownCast(base);
205
206     if(!handle)
207     {
208       EM_ASM( throw "Invalid handle. Cannot downcast" );
209     }
210
211     ret = handle;
212   }
213
214   return ret;
215 }
216
217 /**
218  * The functor to be used in the hit-test algorithm to check whether the actor is hittable.
219  */
220 bool IsActorHittableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::TraverseType type)
221 {
222   const std::string& name = actor.GetName();
223   // by convention if not visible, or with a * starting the name or if the root layer
224   return actor.IsVisible() && (name.size() ? name[0] != '*' : true);
225 };
226
227 /*
228  * Hit Test wrapper
229  *
230  */
231 Dali::Actor HitTest(float x, float y)
232 {
233   Dali::HitTestAlgorithm::Results results;
234   Dali::HitTestAlgorithm::HitTest( Dali::Stage::GetCurrent(), Dali::Vector2(x,y), results, IsActorHittableFunction );
235   return results.actor;
236 }
237
238 /**
239  * Creates a solid colour actor
240  */
241 Dali::Actor CreateSolidColorActor( const Dali::Vector4& color, bool border, const Dali::Vector4& borderColor, const unsigned int borderSize )
242 {
243   static const unsigned int MAX_BORDER_SIZE( 9 );
244
245   Dali::ImageActor image;
246   if( borderSize > MAX_BORDER_SIZE )
247   {
248     return image;
249   }
250
251   const unsigned int bitmapWidth = borderSize * 2 + 2;
252
253   // Using a (2 + border) x (2 + border) image gives a better blend with the GL implementation
254   // than a (1 + border) x (1 + border) image
255   const unsigned int bitmapSize = bitmapWidth * bitmapWidth;
256   const unsigned int topLeft = bitmapWidth * borderSize + borderSize;
257   const unsigned int topRight = topLeft + 1;
258   const unsigned int bottomLeft = bitmapWidth * (borderSize + 1) + borderSize;
259   const unsigned int bottomRight = bottomLeft + 1;
260
261   Dali::BufferImage imageData;
262   if(color.a != 1.0 || borderColor.a != 1.0)
263   {
264     imageData = Dali::BufferImage::New( bitmapWidth, bitmapWidth, Dali::Pixel::RGBA8888 );
265
266     // Create the image
267     Dali::PixelBuffer* pixbuf = imageData.GetBuffer();
268     Dali::Vector4 outerColor = color;
269     if ( border )
270     {
271       outerColor = borderColor;
272     }
273
274     for( size_t i = 0; i < bitmapSize; ++i )
275     {
276       if( i == topLeft ||
277           i == topRight ||
278           i == bottomLeft ||
279           i == bottomRight )
280       {
281         pixbuf[i*4+0] = 0xFF * color.r;
282         pixbuf[i*4+1] = 0xFF * color.g;
283         pixbuf[i*4+2] = 0xFF * color.b;
284         pixbuf[i*4+3] = 0xFF * color.a;
285       }
286       else
287       {
288         pixbuf[i*4+0] = 0xFF * outerColor.r;
289         pixbuf[i*4+1] = 0xFF * outerColor.g;
290         pixbuf[i*4+2] = 0xFF * outerColor.b;
291         pixbuf[i*4+3] = 0xFF * outerColor.a;
292       }
293     }
294   }
295   else
296   {
297     imageData = Dali::BufferImage::New( bitmapWidth, bitmapWidth, Dali::Pixel::RGB888 );
298
299     // Create the image
300     Dali::PixelBuffer* pixbuf = imageData.GetBuffer();
301     Dali::Vector4 outerColor = color;
302     if ( border )
303     {
304       outerColor = borderColor;
305     }
306
307     for( size_t i = 0; i < bitmapSize; ++i )
308     {
309       if( i == topLeft ||
310           i == topRight ||
311           i == bottomLeft ||
312           i == bottomRight )
313       {
314         pixbuf[i*3+0] = 0xFF * color.r;
315         pixbuf[i*3+1] = 0xFF * color.g;
316         pixbuf[i*3+2] = 0xFF * color.b;
317       }
318       else
319       {
320         pixbuf[i*3+0] = 0xFF * outerColor.r;
321         pixbuf[i*3+1] = 0xFF * outerColor.g;
322         pixbuf[i*3+2] = 0xFF * outerColor.b;
323       }
324     }
325   }
326
327   imageData.Update();
328   image = Dali::ImageActor::New( imageData );
329   image.SetAnchorPoint( Dali::AnchorPoint::CENTER );
330   image.SetParentOrigin( Dali::ParentOrigin::CENTER );
331
332   // if( border )
333   // {
334   //   image.SetStyle( Dali::ImageActor::STYLE_NINE_PATCH );
335   //   image.SetNinePatchBorder( Dali::Vector4::ONE * (float)borderSize * 2.0f );
336   // }
337
338   return image;
339 }
340
341 } // anon namespace
342
343 /**
344  * Sets the callback to getting a glyph (from dali-wrapper.js/browser)
345  */
346 void SetCallbackGetGlyphImage(const emscripten::val& callback)
347 {
348   JSGetGlyphImage = callback;
349 }
350
351 /**
352  * Sets the callback to get an image (from dali-wrapper.js/browser)
353  */
354 void SetCallbackGetImage(const emscripten::val& callback)
355 {
356   JSGetImage = callback;
357 }
358
359 /**
360  * Sets the callback to get image meta data (from dali-wrapper.js/browser)
361  */
362 void SetCallbackGetImageMetadata(const emscripten::val& callback)
363 {
364   JSGetImageMetaData = callback;
365 }
366
367 /**
368  * Sets the callback to signal render finished to dali-wrapper.js/browser
369  */
370 void SetCallbackRenderFinished(const emscripten::val& callback)
371 {
372   JSRenderFinished = callback;
373 }
374
375 /**
376  * Generates control points for a Path
377  */
378 void GenerateControlPoints(Dali::Handle& handle, float curvature)
379 {
380   if( handle )
381   {
382     Dali::Path path = Dali::Path::DownCast(handle);
383     if(path)
384     {
385       path.GenerateControlPoints(curvature);
386     }
387     else
388     {
389       EM_ASM( throw "Handle is not a path object" );
390     }
391   }
392   else
393   {
394     EM_ASM( throw "Handle is empty" );
395   }
396
397 }
398
399 /**
400  * Creating property Value Objects
401  *   javascript can't select on type so we have renamed constructors
402  *
403  * Emscripten can convert some basic types and ones we've declared as value_array(s)
404  * (These are given member access offsets/functions and are for simple structs etc)
405  *
406  * The composite types need converting.
407  */
408 Dali::Property::Value PropertyValueBoolean(bool v)
409 {
410   return Dali::Property::Value(v);
411 }
412
413 Dali::Property::Value PropertyValueFloat(float v)
414 {
415   return Dali::Property::Value(v);
416 }
417
418 Dali::Property::Value PropertyValueInteger(int v)
419 {
420   return Dali::Property::Value(v);
421 }
422
423 Dali::Property::Value PropertyValueVector2( const Dali::Vector2& v )
424 {
425   return Dali::Property::Value(v);
426 }
427
428 Dali::Property::Value PropertyValueVector3( const Dali::Vector3& v )
429 {
430   return Dali::Property::Value(v);
431 }
432
433 Dali::Property::Value PropertyValueVector4( const Dali::Vector4& v )
434 {
435   return Dali::Property::Value(v);
436 }
437
438 Dali::Property::Value PropertyValueIntRect( int a, int b, int c, int d )
439 {
440   return Dali::Property::Value(Dali::Rect<int>( a, b, c, d));
441 }
442
443 Dali::Property::Value PropertyValueMatrix( const Dali::Matrix& v )
444 {
445   return Dali::Property::Value(v);
446 }
447
448 Dali::Property::Value PropertyValueMatrix3( const Dali::Matrix3& v )
449 {
450   return Dali::Property::Value(v);
451 }
452
453 Dali::Property::Value PropertyValueEuler( const Dali::Vector3& v )
454 {
455   return Dali::Property::Value( Dali::Quaternion(
456                                   Dali::Radian(Dali::Degree(v.x)),
457                                   Dali::Radian(Dali::Degree(v.y)),
458                                   Dali::Radian(Dali::Degree(v.z)) ) );
459 }
460
461 Dali::Property::Value PropertyValueAxisAngle( const Dali::Vector4& v )
462 {
463   return Dali::Quaternion( Dali::Radian(Dali::Degree(v[3])), Dali::Vector3(v) );
464 }
465
466 Dali::Property::Value PropertyValueString( const std::string& v )
467 {
468   return Dali::Property::Value(v);
469 }
470
471 Dali::Property::Value PropertyValueContainer( const emscripten::val& v )
472 {
473   Dali::Property::Value ret;
474   RecursiveSetProperty( ret, v );
475   return ret;
476 }
477
478 /**
479  * Property value accessors from Dali Property Value
480  */
481 bool PropertyGetBoolean(const Dali::Property::Value& v)
482 {
483   return v.Get<bool>();
484 }
485
486 float PropertyGetFloat(const Dali::Property::Value& v)
487 {
488   return v.Get<float>();
489 }
490
491 int PropertyGetInteger(const Dali::Property::Value& v)
492 {
493   return v.Get<int>();
494 }
495
496 Dali::Vector2 PropertyGetVector2(const Dali::Property::Value& v)
497 {
498   return v.Get<Dali::Vector2>();
499 }
500
501 Dali::Vector3 PropertyGetVector3(const Dali::Property::Value& v)
502 {
503   return v.Get<Dali::Vector3>();
504 }
505
506 Dali::Vector4 PropertyGetVector4(const Dali::Property::Value& v)
507 {
508   return v.Get<Dali::Vector4>();
509 }
510
511 emscripten::val PropertyGetIntRect(const Dali::Property::Value& v)
512 {
513   return JavascriptValue(v);
514 }
515
516 std::string PropertyGetString(const Dali::Property::Value& v)
517 {
518   return v.Get<std::string>();
519 }
520
521 emscripten::val PropertyGetMap(const Dali::Property::Value& v)
522 {
523   return JavascriptValue(v);
524 }
525
526 emscripten::val PropertyGetArray(const Dali::Property::Value& v)
527 {
528   return JavascriptValue(v);
529 }
530
531 emscripten::val PropertyGetMatrix(const Dali::Property::Value& v)
532 {
533   return JavascriptValue(v);
534 }
535
536 emscripten::val PropertyGetMatrix3(const Dali::Property::Value& v)
537 {
538   return JavascriptValue(v);
539 }
540
541 emscripten::val PropertyGetEuler(const Dali::Property::Value& v)
542 {
543   return JavascriptValue(v);
544 }
545
546 emscripten::val PropertyGetRotation(const Dali::Property::Value& v)
547 {
548   return JavascriptValue(v);
549 }
550
551 int PropertyGetType(Dali::Property::Value& v)
552 {
553   return (int)v.GetType();
554 }
555
556 std::string PropertyGetTypeName(Dali::Property::Value& v)
557 {
558   return Dali::PropertyTypes::GetName(v.GetType());
559 }
560
561 template <typename T>
562 float MatrixGetter(T &v, int n)
563 {
564   return *(v.AsFloat() + n);
565 }
566
567 template <typename T>
568 void MatrixSetter(T &v, float f, int n)
569 {
570   *(v.AsFloat() + n) = f;
571 }
572
573 float MatrixGetter0(const Dali::Matrix &v)        { return MatrixGetter(v, 0); }
574 float MatrixGetter1(const Dali::Matrix &v)        { return MatrixGetter(v, 1); }
575 float MatrixGetter2(const Dali::Matrix &v)        { return MatrixGetter(v, 2); }
576 float MatrixGetter3(const Dali::Matrix &v)        { return MatrixGetter(v, 3); }
577 float MatrixGetter4(const Dali::Matrix &v)        { return MatrixGetter(v, 4); }
578 float MatrixGetter5(const Dali::Matrix &v)        { return MatrixGetter(v, 5); }
579 float MatrixGetter6(const Dali::Matrix &v)        { return MatrixGetter(v, 6); }
580 float MatrixGetter7(const Dali::Matrix &v)        { return MatrixGetter(v, 7); }
581 float MatrixGetter8(const Dali::Matrix &v)        { return MatrixGetter(v, 8); }
582 float MatrixGetter9(const Dali::Matrix &v)        { return MatrixGetter(v, 9); }
583 float MatrixGetter10(const Dali::Matrix &v)        { return MatrixGetter(v,10); }
584 float MatrixGetter11(const Dali::Matrix &v)        { return MatrixGetter(v,11); }
585 float MatrixGetter12(const Dali::Matrix &v)        { return MatrixGetter(v,12); }
586 float MatrixGetter13(const Dali::Matrix &v)        { return MatrixGetter(v,13); }
587 float MatrixGetter14(const Dali::Matrix &v)        { return MatrixGetter(v,14); }
588 float MatrixGetter15(const Dali::Matrix &v)        { return MatrixGetter(v,15); }
589 float MatrixGetter16(const Dali::Matrix &v)        { return MatrixGetter(v,16); }
590
591 void MatrixSetter0(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 0); }
592 void MatrixSetter1(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 1); }
593 void MatrixSetter2(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 2); }
594 void MatrixSetter3(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 3); }
595 void MatrixSetter4(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 4); }
596 void MatrixSetter5(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 5); }
597 void MatrixSetter6(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 6); }
598 void MatrixSetter7(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 7); }
599 void MatrixSetter8(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 8); }
600 void MatrixSetter9(Dali::Matrix &v, float f)      { MatrixSetter(v, f, 9); }
601 void MatrixSetter10(Dali::Matrix &v, float f)      { MatrixSetter(v, f,10); }
602 void MatrixSetter11(Dali::Matrix &v, float f)      { MatrixSetter(v, f,11); }
603 void MatrixSetter12(Dali::Matrix &v, float f)      { MatrixSetter(v, f,12); }
604 void MatrixSetter13(Dali::Matrix &v, float f)      { MatrixSetter(v, f,13); }
605 void MatrixSetter14(Dali::Matrix &v, float f)      { MatrixSetter(v, f,14); }
606 void MatrixSetter15(Dali::Matrix &v, float f)      { MatrixSetter(v, f,15); }
607 void MatrixSetter16(Dali::Matrix &v, float f)      { MatrixSetter(v, f,16); }
608
609 float Matrix3Getter0(const Dali::Matrix3 &v)        { return MatrixGetter(v, 0); }
610 float Matrix3Getter1(const Dali::Matrix3 &v)        { return MatrixGetter(v, 1); }
611 float Matrix3Getter2(const Dali::Matrix3 &v)        { return MatrixGetter(v, 2); }
612 float Matrix3Getter3(const Dali::Matrix3 &v)        { return MatrixGetter(v, 3); }
613 float Matrix3Getter4(const Dali::Matrix3 &v)        { return MatrixGetter(v, 4); }
614 float Matrix3Getter5(const Dali::Matrix3 &v)        { return MatrixGetter(v, 5); }
615 float Matrix3Getter6(const Dali::Matrix3 &v)        { return MatrixGetter(v, 6); }
616 float Matrix3Getter7(const Dali::Matrix3 &v)        { return MatrixGetter(v, 7); }
617 float Matrix3Getter8(const Dali::Matrix3 &v)        { return MatrixGetter(v, 8); }
618
619 void Matrix3Setter0(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 0); }
620 void Matrix3Setter1(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 1); }
621 void Matrix3Setter2(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 2); }
622 void Matrix3Setter3(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 3); }
623 void Matrix3Setter4(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 4); }
624 void Matrix3Setter5(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 5); }
625 void Matrix3Setter6(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 6); }
626 void Matrix3Setter7(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 7); }
627 void Matrix3Setter8(Dali::Matrix3 &v, float f)      { MatrixSetter(v, f, 8); }
628
629 val JavascriptUpdateCallback( val::undefined() );
630 bool JavascriptUpdateCallbackSet = false;
631
632 void JavascriptUpdate(int dt)
633 {
634   if( JavascriptUpdateCallbackSet )
635   {
636     JavascriptUpdateCallback( val(dt) );
637   }
638 }
639
640 void SetUpdateFunction( const emscripten::val& function )
641 {
642   JavascriptUpdateCallback = function;
643   JavascriptUpdateCallbackSet = true;
644 }
645
646 const emscripten::val& GetUpdateFunction()
647 {
648   return JavascriptUpdateCallback;
649 }
650
651 /**
652  * Emscripten Bindings
653  *
654  * This uses Emscripten 'bind' (similar in design to Boost's python wrapper library).
655  * It provides a simplified way to wrap C++ classes and wraps Emscriptens type
656  * registration API.
657  *
658  * A convention below is that where there is a function or method name prepended
659  * with '__' there is a corresponding Javascript helper function to help with
660  * marshalling parameters and return values.
661  *
662  */
663 EMSCRIPTEN_BINDINGS(dali_wrapper)
664 {
665   // With a little help embind knows about vectors so we tell it which ones to instantiate
666   register_dali_vector<int>("DaliVectorInt");
667   register_vector<std::string>("VectorString");
668   register_vector<int>("VectorInt");
669   register_vector<float>("VectorFloat");
670   register_vector<Dali::Actor>("VectorActor");
671
672   //
673   // Creation functions.
674   //
675   emscripten::function("VersionString", &VersionString);
676   emscripten::function("__createActor", &CreateActor);
677   emscripten::function("__createHandle", &CreateHandle);
678   emscripten::function("__createSolidColorActor", &CreateSolidColorActor);
679
680   //
681   // Helper functions
682   //
683   emscripten::function("javascriptValue", &JavascriptValue);
684   emscripten::function("__hitTest", &HitTest);
685   emscripten::function("sendMouseEvent", &EmscriptenMouseEvent);
686   emscripten::function("__updateOnce", &EmscriptenUpdateOnce);
687   emscripten::function("__renderOnce", &EmscriptenRenderOnce);
688   emscripten::function("generateControlPoints", &GenerateControlPoints);
689
690   //
691   // Global callback functions
692   //
693   emscripten::function("setCallbackGetGlyphImage", &SetCallbackGetGlyphImage);
694   emscripten::function("setCallbackGetImage", &SetCallbackGetImage);
695   emscripten::function("setCallbackGetImageMetadata", &SetCallbackGetImageMetadata);
696   emscripten::function("setCallbackRenderFinished", &SetCallbackRenderFinished);
697   emscripten::function("setUpdateFunction", &SetUpdateFunction);
698   emscripten::function("getUpdateFunction", &GetUpdateFunction);
699
700   //
701   // Property value creation (Javascript can't select on type)
702   //
703   emscripten::function("PropertyValueBoolean", &PropertyValueBoolean);
704   emscripten::function("PropertyValueFloat", &PropertyValueFloat);
705   emscripten::function("PropertyValueInteger", &PropertyValueInteger);
706   emscripten::function("PropertyValueString", &PropertyValueString);
707   emscripten::function("PropertyValueVector2", &PropertyValueVector2);
708   emscripten::function("PropertyValueVector3", &PropertyValueVector3);
709   emscripten::function("PropertyValueVector4", &PropertyValueVector4);
710   emscripten::function("PropertyValueMatrix", &PropertyValueMatrix);
711   emscripten::function("PropertyValueMatrix3", &PropertyValueMatrix3);
712   emscripten::function("PropertyValueMap", &PropertyValueContainer);
713   emscripten::function("PropertyValueArray", &PropertyValueContainer);
714   emscripten::function("PropertyValueEuler", &PropertyValueEuler);
715   emscripten::function("PropertyValueAxisAngle", &PropertyValueAxisAngle);
716   emscripten::function("PropertyValueString", &PropertyValueString);
717   emscripten::function("PropertyValueIntRect", &PropertyValueIntRect);
718
719   //
720   // One unfortunate aspect of wrapping for the browser is that we get no notification
721   // of object deletion so all JS wrapper objects must be wrapper.delete() correctly.
722   //
723   // Embind has a mechanism around this for simple c style structs decared as value_arrays.
724   // These are immediately transformed to Javascript arrays and don't need explicit
725   // destruction, however the API needs a member offset.
726   //
727   value_array<Dali::Internal::Emscripten::Statistics>("Statistics")
728     .element(&Dali::Internal::Emscripten::Statistics::on)
729     .element(&Dali::Internal::Emscripten::Statistics::frameCount)
730     .element(&Dali::Internal::Emscripten::Statistics::lastFrameDeltaSeconds)
731     .element(&Dali::Internal::Emscripten::Statistics::lastSyncTimeMilliseconds)
732     .element(&Dali::Internal::Emscripten::Statistics::nextSyncTimeMilliseconds)
733     .element(&Dali::Internal::Emscripten::Statistics::keepUpdating)
734     .element(&Dali::Internal::Emscripten::Statistics::needsNotification)
735     .element(&Dali::Internal::Emscripten::Statistics::secondsFromLastFrame)
736 ;
737
738   value_array<Dali::Vector2>("Vector2")
739     .element(&Dali::Vector2::x)
740     .element(&Dali::Vector2::y)
741 ;
742
743   value_array<Dali::Vector3>("Vector3")
744     .element(&Dali::Vector3::x)
745     .element(&Dali::Vector3::y)
746     .element(&Dali::Vector3::z)
747 ;
748
749   value_array<Dali::Vector4>("Vector4")
750     .element(&Dali::Vector4::x)
751     .element(&Dali::Vector4::y)
752     .element(&Dali::Vector4::z)
753     .element(&Dali::Vector4::w)
754 ;
755
756   value_array<Dali::Matrix>("Matrix")
757     .element(&MatrixGetter0, &MatrixSetter0)
758     .element(&MatrixGetter1, &MatrixSetter1)
759     .element(&MatrixGetter2, &MatrixSetter2)
760     .element(&MatrixGetter3, &MatrixSetter3)
761     .element(&MatrixGetter4, &MatrixSetter4)
762     .element(&MatrixGetter5, &MatrixSetter5)
763     .element(&MatrixGetter6, &MatrixSetter6)
764     .element(&MatrixGetter7, &MatrixSetter7)
765     .element(&MatrixGetter8, &MatrixSetter8)
766     .element(&MatrixGetter9, &MatrixSetter9)
767     .element(&MatrixGetter10, &MatrixSetter10)
768     .element(&MatrixGetter11, &MatrixSetter11)
769     .element(&MatrixGetter12, &MatrixSetter12)
770     .element(&MatrixGetter13, &MatrixSetter13)
771     .element(&MatrixGetter14, &MatrixSetter14)
772     .element(&MatrixGetter15, &MatrixSetter15)
773 ;
774
775   value_array<Dali::Matrix3>("Matrix3")
776     .element(&Matrix3Getter0, &Matrix3Setter0)
777     .element(&Matrix3Getter1, &Matrix3Setter1)
778     .element(&Matrix3Getter2, &Matrix3Setter2)
779     .element(&Matrix3Getter3, &Matrix3Setter3)
780     .element(&Matrix3Getter4, &Matrix3Setter4)
781     .element(&Matrix3Getter5, &Matrix3Setter5)
782     .element(&Matrix3Getter6, &Matrix3Setter6)
783     .element(&Matrix3Getter7, &Matrix3Setter7)
784     .element(&Matrix3Getter8, &Matrix3Setter8)
785 ;
786
787   //
788   // enums
789   //
790   enum_<Dali::Property::Type>("PropertyType")
791     .value("NONE", Dali::Property::NONE)
792     .value("BOOLEAN", Dali::Property::BOOLEAN)
793     .value("FLOAT", Dali::Property::FLOAT)
794     .value("INTEGER", Dali::Property::INTEGER)
795     .value("VECTOR2", Dali::Property::VECTOR2)
796     .value("VECTOR3", Dali::Property::VECTOR3)
797     .value("VECTOR4", Dali::Property::VECTOR4)
798     .value("MATRIX3", Dali::Property::MATRIX3)
799     .value("MATRIX", Dali::Property::MATRIX)
800     .value("RECTANGLE", Dali::Property::RECTANGLE)
801     .value("ROTATION", Dali::Property::ROTATION)
802     .value("STRING", Dali::Property::STRING)
803     .value("ARRAY", Dali::Property::ARRAY)
804     .value("MAP", Dali::Property::MAP)
805 ;
806
807   enum_<Dali::ShaderEffect::GeometryHints>("GeometryHints")
808     .value("HINT_NONE", Dali::ShaderEffect::HINT_NONE)
809     .value("HINT_GRID_X", Dali::ShaderEffect::HINT_GRID_X)
810     .value("HINT_GRID_Y", Dali::ShaderEffect::HINT_GRID_Y)
811     .value("HINT_GRID", Dali::ShaderEffect::HINT_GRID)
812     .value("HINT_DEPTH_BUFFER", Dali::ShaderEffect::HINT_DEPTH_BUFFER)
813     .value("HINT_BLENDING", Dali::ShaderEffect::HINT_BLENDING)
814     .value("HINT_DOESNT_MODIFY_GEOMETRY", Dali::ShaderEffect::HINT_DOESNT_MODIFY_GEOMETRY)
815 ;
816
817   enum_<Dali::Shader::ShaderHints>("ShaderHints")
818     .value("HINT_NONE",                      Dali::Shader::HINT_NONE)
819     .value("HINT_OUTPUT_IS_TRANSPARENT",     Dali::Shader::HINT_OUTPUT_IS_TRANSPARENT)
820     .value("HINT_MODIFIES_GEOMETRY",         Dali::Shader::HINT_MODIFIES_GEOMETRY)
821 ;
822
823   enum_<Dali::Animation::EndAction>("EndAction")
824     .value("Bake",        Dali::Animation::Bake)
825     .value("Discard",     Dali::Animation::Discard)
826     .value("BakeFinal",   Dali::Animation::BakeFinal)
827 ;
828
829   enum_<Dali::Animation::Interpolation>("Interpolation")
830     .value("Linear", Dali::Animation::Interpolation::Linear)
831     .value("Cubic", Dali::Animation::Interpolation::Cubic)
832 ;
833
834   enum_<Dali::Geometry::GeometryType>("GeometryType")
835     .value("POINTS",          Dali::Geometry::POINTS)
836     .value("LINES",           Dali::Geometry::LINES)
837     .value("LINE_LOOP",       Dali::Geometry::LINE_LOOP)
838     .value("LINE_STRIP",      Dali::Geometry::LINE_STRIP)
839     .value("TRIANGLES",       Dali::Geometry::TRIANGLES)
840     .value("TRIANGLE_FAN",    Dali::Geometry::TRIANGLE_FAN)
841     .value("TRIANGLE_STRIP",  Dali::Geometry::TRIANGLE_STRIP)
842 ;
843
844   enum_<Dali::Image::ReleasePolicy>("ReleasePolicy")
845     .value("UNUSED",          Dali::Image::UNUSED)
846     .value("NEVER",           Dali::Image::NEVER)
847 ;
848
849   enum_<Dali::Pixel::Format>("PixelFormat")
850     .value("A8", Dali::Pixel::Format::A8)
851     .value("L8", Dali::Pixel::Format::L8)
852     .value("LA88", Dali::Pixel::Format::LA88)
853     .value("RGB565", Dali::Pixel::Format::RGB565)
854     .value("BGR565", Dali::Pixel::Format::BGR565)
855     .value("RGBA4444", Dali::Pixel::Format::RGBA4444)
856     .value("BGRA4444", Dali::Pixel::Format::BGRA4444)
857     .value("RGBA5551", Dali::Pixel::Format::RGBA5551)
858     .value("BGRA5551", Dali::Pixel::Format::BGRA5551)
859     .value("RGB888", Dali::Pixel::Format::RGB888)
860     .value("RGB8888", Dali::Pixel::Format::RGB8888)
861     .value("BGR8888", Dali::Pixel::Format::BGR8888)
862     .value("RGBA8888", Dali::Pixel::Format::RGBA8888)
863     .value("BGRA8888", Dali::Pixel::Format::BGRA8888)
864     // GLES 3 Standard compressed formats:
865     .value("COMPRESSED_R11_EAC", Dali::Pixel::Format::COMPRESSED_R11_EAC)
866     .value("COMPRESSED_SIGNED_R11_EAC", Dali::Pixel::Format::COMPRESSED_SIGNED_R11_EAC)
867     .value("COMPRESSED_RG11_EAC", Dali::Pixel::Format::COMPRESSED_RG11_EAC)
868     .value("COMPRESSED_SIGNED_RG11_EAC", Dali::Pixel::Format::COMPRESSED_SIGNED_RG11_EAC)
869     .value("COMPRESSED_RGB8_ETC2", Dali::Pixel::Format::COMPRESSED_RGB8_ETC2)
870     .value("COMPRESSED_SRGB8_ETC2", Dali::Pixel::Format::COMPRESSED_SRGB8_ETC2)
871     .value("COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Dali::Pixel::Format::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2)
872     .value("COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Dali::Pixel::Format::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2)
873     .value("COMPRESSED_RGBA8_ETC2_EAC", Dali::Pixel::Format::COMPRESSED_RGBA8_ETC2_EAC)
874     .value("COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Dali::Pixel::Format::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC)
875     // GLES 2 extension compressed formats:
876     .value("COMPRESSED_RGB8_ETC1", Dali::Pixel::Format::COMPRESSED_RGB8_ETC1)
877     .value("COMPRESSED_RGB_PVRTC_4BPPV1", Dali::Pixel::Format::COMPRESSED_RGB_PVRTC_4BPPV1)
878 ;
879
880   enum_<Dali::FaceCullingMode::Type>("FaceCullingMode")
881     .value("NONE", Dali::FaceCullingMode::NONE)
882     .value("FRONT", Dali::FaceCullingMode::FRONT)
883     .value("BACK", Dali::FaceCullingMode::BACK)
884     .value("FRONT_AND_BACK", Dali::FaceCullingMode::FRONT_AND_BACK)
885 ;
886
887   enum_<Dali::DepthWriteMode::Type>("DepthWriteMode")
888     .value("OFF", Dali::DepthWriteMode::OFF)
889     .value("AUTO", Dali::DepthWriteMode::AUTO)
890     .value("ON", Dali::DepthWriteMode::ON)
891 ;
892
893   enum_<Dali::BlendMode::Type>("BlendMode")
894     .value("OFF", Dali::BlendMode::OFF)
895     .value("AUTO", Dali::BlendMode::AUTO)
896     .value("ON", Dali::BlendMode::ON)
897 ;
898
899   enum_<Dali::AlphaFunction::BuiltinFunction>("AlphaFunction")
900     .value("DEFAULT", Dali::AlphaFunction::BuiltinFunction::DEFAULT)
901     .value("LINEAR", Dali::AlphaFunction::BuiltinFunction::LINEAR)
902     .value("REVERSE", Dali::AlphaFunction::BuiltinFunction::REVERSE)
903     .value("EASE_IN_SQUARE", Dali::AlphaFunction::BuiltinFunction::EASE_IN_SQUARE)
904     .value("EASE_OUT_SQUARE", Dali::AlphaFunction::BuiltinFunction::EASE_OUT_SQUARE)
905     .value("EASE_IN", Dali::AlphaFunction::BuiltinFunction::EASE_IN)
906     .value("EASE_OUT", Dali::AlphaFunction::BuiltinFunction::EASE_OUT)
907     .value("EASE_IN_OUT", Dali::AlphaFunction::BuiltinFunction::EASE_IN_OUT)
908     .value("EASE_IN_SINE", Dali::AlphaFunction::BuiltinFunction::EASE_IN_SINE)
909     .value("EASE_OUT_SINE", Dali::AlphaFunction::BuiltinFunction::EASE_OUT_SINE)
910     .value("EASE_IN_OUT_SINE", Dali::AlphaFunction::BuiltinFunction::EASE_IN_OUT_SINE)
911     .value("BOUNCE", Dali::AlphaFunction::BuiltinFunction::BOUNCE)
912     .value("SIN", Dali::AlphaFunction::BuiltinFunction::SIN)
913     .value("EASE_OUT_BACK", Dali::AlphaFunction::BuiltinFunction::EASE_OUT_BACK)
914 ;
915
916   //
917   // classes
918   //
919
920   // we need property map as an object rather than straight conversion to javascript 'object'
921   // because its ordered. And PropertyBuffer needs an order.
922   class_<Dali::Property::Map>("PropertyMap")
923     .constructor<>()
924     .function("count", &Dali::Property::Map::Count)
925     .function("empty", &Dali::Property::Map::Empty)
926     .function("__insert", select_overload< void(const std::string&, const Dali::Property::Value&) > (&Dali::Property::Map::Insert))
927     .function("__get", &PropertyMapGet)
928     .function("__getValue", &Dali::Property::Map::GetValue)
929     .function("getKey", &Dali::Property::Map::GetKey)
930     .function("clear", &Dali::Property::Map::Clear)
931     .function("merge", &Dali::Property::Map::Merge)
932 ;
933
934   class_<Dali::Property::Value>("PropertyValue")
935     .constructor<>()
936     .function("getType", &PropertyGetType)
937     .function("getTypeName", &PropertyGetTypeName)
938     .function("getBoolean", &PropertyGetBoolean)
939     .function("getFloat", &PropertyGetFloat)
940     .function("getInteger", &PropertyGetInteger)
941     .function("getVector2", &PropertyGetVector2)
942     .function("getVector3", &PropertyGetVector3)
943     .function("getVector4", &PropertyGetVector4)
944     .function("getString", &PropertyGetString)
945     .function("getMap", &PropertyGetMap)
946     .function("getArray", &PropertyGetArray)
947     .function("getMatrix", &PropertyGetMatrix)
948     .function("getMatrix3", &PropertyGetMatrix3)
949     .function("getEuler", &PropertyGetEuler)
950     .function("getRotation", &PropertyGetRotation)
951     .function("getIntRect", &PropertyGetIntRect)
952 ;
953
954   class_<Dali::BaseHandle>("BaseHandle")
955     .function("ok", &BaseHandleOk)
956     .function("getTypeName", &BaseHandle::GetTypeName)
957 ;
958
959   class_<Dali::TypeInfo, base<Dali::BaseHandle>>("TypeInfo")
960     .function("getName", &Dali::TypeInfo::GetName)
961     .function("getBaseName", &Dali::TypeInfo::GetBaseName)
962     .function("getProperties", &GetAllProperties)
963     .function("getActions", &GetActions)
964     .function("getSignals", &GetSignals)
965     .function("getPropertyIndices", &Dali::TypeInfo::GetPropertyIndices)
966 ;
967
968   class_<Dali::TypeRegistry>("TypeRegistry")
969     .constructor<>(&Dali::TypeRegistry::Get)
970     .function("getTypeNameCount", &Dali::TypeRegistry::GetTypeNameCount)
971     .function("getTypeName", &Dali::TypeRegistry::GetTypeName)
972     .function("getTypeInfo", select_overload< Dali::TypeInfo(const std::string&) > (&Dali::TypeRegistry::GetTypeInfo))
973 ;
974
975   class_<SignalHolder>("SignalHolder")
976     .constructor<>()
977 ;
978
979   class_<Dali::Handle, base<Dali::BaseHandle>>("Handle")
980     .function("__registerProperty", &RegisterProperty)
981     .function("__registerAnimatedProperty", &RegisterAnimatedProperty)
982     .function("setSelf", &SetSelf)
983     .function("setProperty", &SetProperty)
984     .function("getProperty", &GetProperty)
985     .function("getPropertyIndex", &GetPropertyIndex)
986     .function("getProperties", &GetProperties)
987     .function("getPropertyIndices", &Handle::GetPropertyIndices)
988     .function("getPropertyTypeFromName", &GetPropertyTypeFromName)
989     .function("getPropertyTypeName", &GetPropertyTypeName)
990     .function("registerProperty", &RegisterProperty)
991     .function("registerAnimatedProperty", &RegisterAnimatedProperty)
992     .function("getTypeInfo", &GetTypeInfo)
993     .function("isPropertyWritable", &Handle::IsPropertyWritable)
994     .function("isPropertyAnimatable", &Handle::IsPropertyAnimatable)
995     .function("isPropertyAConstraintInput", &Handle::IsPropertyAConstraintInput)
996 ;
997
998   class_<Dali::Path, base<Dali::Handle>>("Path")
999     .constructor<>(&Dali::Path::New)
1000     .function("addPoint", &Dali::Path::AddPoint)
1001     .function("addControlPoint", &Dali::Path::AddControlPoint)
1002     .function("generateControlPoints", &Dali::Path::GenerateControlPoints)
1003     .function("sample", &Dali::Path::Sample)
1004     .function("getPoint", &Dali::Path::GetPoint)
1005     .function("getControlPoint", &Dali::Path::GetControlPoint)
1006     .function("getPointCount", &Dali::Path::GetPointCount)
1007 ;
1008
1009   class_<Dali::KeyFrames>("KeyFrames")
1010     .constructor<>(&Dali::KeyFrames::New)
1011     .function("add", select_overload<void (float progress, Property::Value value)>(&Dali::KeyFrames::Add))
1012     .function("addWithAlpha", &KeyFramesAddWithAlpha)
1013 ;
1014
1015   class_<Dali::Animation>("Animation")
1016     .constructor<float>(&Dali::Animation::New)
1017     .function("__animateTo", &AnimateTo)
1018     .function("__animateBy", &AnimateBy)
1019     .function("__animateBetween", &AnimateBetween)
1020     .function("__animatePath", &AnimatePath)
1021     .function("setDuration", &Dali::Animation::SetDuration)
1022     .function("getDuration", &Dali::Animation::GetDuration)
1023     .function("setLooping", &Dali::Animation::SetLooping)
1024     .function("isLooping", &Dali::Animation::IsLooping)
1025     .function("setEndAction", &Dali::Animation::SetEndAction)
1026     .function("getEndAction", &Dali::Animation::GetEndAction)
1027     .function("setDisconnectAction", &Dali::Animation::SetDisconnectAction)
1028     .function("getDisconnectAction", &Dali::Animation::GetDisconnectAction)
1029     .function("setCurrentProgress", &Dali::Animation::SetCurrentProgress)
1030     .function("getCurrentProgress", &Dali::Animation::GetCurrentProgress)
1031     .function("setSpeedFactor", &Dali::Animation::SetSpeedFactor)
1032     .function("getSpeedFactor", &Dali::Animation::GetSpeedFactor)
1033     .function("setPlayRange", &Dali::Animation::SetPlayRange)
1034     .function("getPlayRange", &Dali::Animation::GetPlayRange)
1035     .function("play", &Dali::Animation::Play)
1036     .function("playFrom", &Dali::Animation::PlayFrom)
1037     .function("pause", &Dali::Animation::Pause)
1038     .function("stop", &Dali::Animation::Stop)
1039     .function("clear", &Dali::Animation::Clear)
1040 ;
1041
1042   class_<Dali::PropertyBuffer>("PropertyBuffer")
1043     .constructor<Dali::Property::Map&>(Dali::PropertyBuffer::New)
1044     .function("setData", &SetPropertyBufferDataRaw)
1045 ;
1046
1047   class_<Dali::Geometry>("Geometry")
1048     .constructor<>(&Dali::Geometry::New)
1049     .function("addVertexBuffer", &Dali::Geometry::AddVertexBuffer)
1050     .function("getNumberOfVertexBuffers", &Dali::Geometry::GetNumberOfVertexBuffers)
1051     .function("setIndexBuffer", &SetIndexBufferDataRaw)
1052     .function("setGeometryType", &Dali::Geometry::SetGeometryType)
1053     .function("getGeometryType", &Dali::Geometry::GetGeometryType)
1054 ;
1055
1056   class_<Dali::Image>("Image")
1057 ;
1058
1059   class_<Dali::BufferImage, base<Dali::Image> >("BufferImage")
1060     .constructor<const std::string&, unsigned int, unsigned int, Dali::Pixel::Format>(&BufferImageNew)
1061 ;
1062
1063   class_<Dali::EncodedBufferImage, base<Dali::Image> >("EncodedBufferImage")
1064     .constructor<const std::string&>(&EncodedBufferImageNew)
1065 ;
1066
1067   class_<Dali::Sampler>("Sampler")
1068     .constructor<>(&Dali::Sampler::New)
1069 ;
1070
1071   class_<Dali::Shader, base<Dali::Handle>>("Shader")
1072     .constructor<>(&Dali::Shader::New)
1073 ;
1074
1075   class_<Dali::TextureSet>("TextureSet")
1076     .constructor<>(&Dali::TextureSet::New)
1077     .function("setImage", &Dali::TextureSet::SetImage)
1078     .function("setSampler", &Dali::TextureSet::SetSampler)
1079     .function("getImage", &Dali::TextureSet::GetImage)
1080     .function("getSampler", &Dali::TextureSet::GetSampler)
1081     .function("getTextureCount", &Dali::TextureSet::GetTextureCount)
1082 ;
1083
1084   class_<Dali::Renderer, base<Dali::Handle>>("Renderer")
1085     .constructor<>(&Dali::Renderer::New)
1086     .function("setGeometry", &Dali::Renderer::SetGeometry)
1087     .function("getGeometry", &Dali::Renderer::GetGeometry)
1088     .function("SetTextures", &Dali::Renderer::SetTextures)
1089     .function("SetTextures", &Dali::Renderer::SetTextures)
1090 ;
1091
1092   class_<Dali::ShaderEffect, base<Dali::Handle>>("ShaderEffect")
1093     .constructor<const std::string&, const std::string&,
1094                  const std::string&, const std::string&,
1095                  int >(&CreateShaderEffect)
1096     .function("setEffectImage", &Dali::ShaderEffect::SetEffectImage)
1097     .function("__setUniform", &SetUniform)
1098 ;
1099
1100   class_<Dali::Actor, base<Dali::Handle>>("Actor")
1101     .constructor<>(&Dali::Actor::New)
1102     .function("add", &Dali::Actor::Add)
1103     .function("remove", &Dali::Actor::Remove)
1104     .function("getId", &Dali::Actor::GetId)
1105     .function("__getParent", &Dali::Actor::GetParent)
1106     .function("__findChildById", &Dali::Actor::FindChildById)
1107     .function("__findChildByName", &Dali::Actor::FindChildByName)
1108     .function("__getChildAt", &Dali::Actor::GetChildAt)
1109     .function("getChildCount", &Dali::Actor::GetChildCount)
1110     .function("__screenToLocal",
1111               select_overload<std::vector<float> (Dali::Actor, float, float)>(&ScreenToLocal))
1112     .function("addressOf", &AddressOf)
1113     .function("__connect", &ConnectSignal)
1114     .function("__setPropertyNotification", &SetPropertyNotification)
1115     .function("addRenderer", &Dali::Actor::AddRenderer)
1116     .function("getRendererCount", &Dali::Actor::GetRendererCount)
1117     .function("removeRenderer",
1118               select_overload<void(unsigned int)>(&Dali::Actor::RemoveRenderer))
1119     .function("__getRendererAt", &Dali::Actor::GetRendererAt)
1120 ;
1121
1122   class_<Dali::CameraActor, base<Dali::Actor>>("CameraActor")
1123     .constructor<>( select_overload<Dali::CameraActor()>(&Dali::CameraActor::New))
1124 ;
1125
1126   class_<Dali::Layer, base<Dali::Actor>>("Layer")
1127     .constructor<>(&Dali::Layer::New)
1128     .function("raise", &Dali::Layer::Raise)
1129     .function("lower", &Dali::Layer::Lower)
1130 ;
1131
1132   class_<Dali::Stage>("Stage")
1133     .constructor<>(&Dali::Stage::GetCurrent)
1134     .function("add", &Dali::Stage::Add)
1135     .function("remove", &Dali::Stage::Remove)
1136     .function("__getRootLayer", &Dali::Stage::GetRootLayer)
1137     .function("getLayer", &Dali::Stage::GetLayer)
1138     .function("getRenderTaskList", &Dali::Stage::GetRenderTaskList)
1139     .function("setBackgroundColor", &Dali::Stage::SetBackgroundColor)
1140 ;
1141
1142   class_<Dali::RenderTaskList>("RenderTaskList")
1143     .function("createTask", &Dali::RenderTaskList::CreateTask)
1144     .function("removeTask", &Dali::RenderTaskList::RemoveTask)
1145     .function("getTaskCount", &Dali::RenderTaskList::GetTaskCount)
1146     .function("getTask", &Dali::RenderTaskList::GetTask)
1147 ;
1148
1149   class_<Dali::RenderTask>("RenderTask")
1150     .function("__getCameraActor", &Dali::RenderTask::GetCameraActor)
1151     .function("setCameraActor", &Dali::RenderTask::SetCameraActor)
1152     .function("setSourceActor", &Dali::RenderTask::SetSourceActor)
1153     .function("setExclusive", &Dali::RenderTask::SetExclusive)
1154     .function("setInputEnabled", &Dali::RenderTask::SetInputEnabled)
1155     .function("setViewportPosition", &Dali::RenderTask::SetViewportPosition)
1156     .function("setViewportSize", &Dali::RenderTask::SetViewportSize)
1157     .function("getCurrentViewportPosition", &Dali::RenderTask::GetCurrentViewportPosition)
1158     .function("getCurrentViewportSize", &Dali::RenderTask::GetCurrentViewportSize)
1159     .function("setClearColor", &Dali::RenderTask::SetClearColor)
1160     .function("getClearColor", &Dali::RenderTask::GetClearColor)
1161     .function("setClearEnabled", &Dali::RenderTask::SetClearEnabled)
1162     .function("getClearEnabled", &Dali::RenderTask::GetClearEnabled)
1163     .function("screenToLocal",
1164               select_overload<Dali::Vector2(Dali::RenderTask, Dali::Actor, float, float)>(&ScreenToLocal))
1165     .function("worldToScreen", &WorldToScreen)
1166 ;
1167
1168 }
1169
1170 }; // namespace Emscripten
1171 }; // namespace Internal
1172 }; // namespace Dali