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