Remove JavaScript binding for NativeImage, NinePatchImage, ImageActor and ShaderEffect
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / src / image / image-wrapper.h
1 #ifndef __DALI_V8PLUGIN_IMAGE_WRAPPER_H__
2 #define __DALI_V8PLUGIN_IMAGE_WRAPPER_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <v8.h>
23 #include <dali/public-api/images/image.h>
24
25 // INTERNAL INCLUDES
26 #include <shared/base-wrapped-object.h>
27 #include <signals/signal-manager.h>
28
29
30 namespace Dali
31 {
32
33 namespace V8Plugin
34 {
35
36
37 /**
38  * An Image  wrapper.
39  * Provides access to Image specific functionality and V8 memory handling.
40  */
41 class ImageWrapper : public BaseWrappedObject
42 {
43
44 public:
45
46   /**
47    * Image type used an index,
48    * please update the table in ImageApiLookup if this list changes ( the enum is used as an index)
49    */
50   enum ImageType
51   {
52     UNKNOWN_IMAGE_TYPE = -1,
53     IMAGE               = 0,
54     RESOURCE_IMAGE      = 1,
55     BITMAP_IMAGE        = 2,
56     FRAME_BUFFER_IMAGE  = 3
57    };
58
59   /**
60    * Constructor
61    */
62   ImageWrapper( const Image& image,
63                 GarbageCollectorInterface& gc );
64
65   /**
66    * Destructor
67    */
68   virtual ~ImageWrapper()
69   {
70   };
71
72   /**
73    * @brief Creates a new Image wrapped inside a Javascript Object.
74    * @note: the actor type ie 'ImageImage' is expected to be the name of the callee function.
75    * @param[in] args v8 function call arguments interpreted
76    */
77   static void NewImage( const v8::FunctionCallbackInfo< v8::Value >& args);
78
79   /**
80    * Wraps an image of a given type
81    */
82   static v8::Handle<v8::Object> WrapImage(v8::Isolate* isolate, const Dali::Image& image, ImageType imageType );
83
84   /**
85    * Wraps an image, the type is looked up from the image
86    */
87   static v8::Handle<v8::Object> WrapImage(v8::Isolate* isolate, const Dali::Image& image );
88
89   /**
90    * @return Image
91    */
92   Image GetImage();
93
94   /**
95    * @return signal manager pointer
96    */
97   virtual SignalManager* GetSignalManager() { return &mSignalManager;}
98
99   // The Image ObjectTemplate, we cache templates so we don't have
100   // keep generating them everytime we want to create an Image
101   static v8::Persistent<v8::ObjectTemplate> mImageTemplate;
102   static v8::Persistent<v8::ObjectTemplate> mResourceImageTemplate;
103   static v8::Persistent<v8::ObjectTemplate> mBufferImageTemplate;
104   static v8::Persistent<v8::ObjectTemplate> mFrameBufferImageTemplate;
105
106 private:
107
108   /**
109    * Helper
110    */
111   static ImageType GetImageType( const std::string& name );
112
113   static v8::Handle<v8::ObjectTemplate> MakeImageTemplate( v8::Isolate* isolate, ImageType imageType );
114   static v8::Local<v8::ObjectTemplate> GetImageTemplate( v8::Isolate* isolate , ImageType imageType );
115
116
117   Image mImage;                     ///< Image handle
118   SignalManager mSignalManager;     ///< Signal Manager
119
120 };
121
122 } // namespace V8Plugin
123
124 } // namespace Dali
125
126 #endif // __DALI_V8PLUGIN_IMAGE_WRAPPER_H__