From: Richard Huang Date: Tue, 17 Nov 2015 17:36:10 +0000 (+0000) Subject: Remove JavaScript binding for NativeImage, NinePatchImage, ImageActor and ShaderEffect X-Git-Tag: dali_1.1.12~4^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=f4eece329a20b9b31e079ac3ebba57f50c24e5d0 Remove JavaScript binding for NativeImage, NinePatchImage, ImageActor and ShaderEffect Change-Id: Ic68322b4114459c11c4147c224ebf2eaafc055a4 --- diff --git a/node-addon/binding.gyp b/node-addon/binding.gyp index 0098678..dcef968 100644 --- a/node-addon/binding.gyp +++ b/node-addon/binding.gyp @@ -16,7 +16,6 @@ '<(DALI_JS_DIR)/actors/actor-wrapper.cpp', '<(DALI_JS_DIR)/actors/actor-api.cpp', '<(DALI_JS_DIR)/actors/layer-api.cpp', - '<(DALI_JS_DIR)/actors/image-actor-api.cpp', '<(DALI_JS_DIR)/actors/camera-actor-api.cpp', '<(DALI_JS_DIR)/constants/constants-wrapper.cpp', '<(DALI_JS_DIR)/animation/animation-api.cpp', @@ -31,15 +30,11 @@ '<(DALI_JS_DIR)/events/pan-gesture-detector-api.cpp', '<(DALI_JS_DIR)/events/pan-gesture-detector-wrapper.cpp', '<(DALI_JS_DIR)/stage/stage-api.cpp', - '<(DALI_JS_DIR)/shader-effects/shader-effect-api.cpp', - '<(DALI_JS_DIR)/shader-effects/shader-effect-wrapper.cpp', '<(DALI_JS_DIR)/image/image-wrapper.cpp', '<(DALI_JS_DIR)/image/image-api.cpp', '<(DALI_JS_DIR)/image/buffer-image-api.cpp', - '<(DALI_JS_DIR)/image/native-image-api.cpp', '<(DALI_JS_DIR)/image/frame-buffer-image-api.cpp', '<(DALI_JS_DIR)/image/resource-image-api.cpp', - '<(DALI_JS_DIR)/image/nine-patch-image-api.cpp', '<(DALI_JS_DIR)/object/handle-wrapper.cpp', '<(DALI_JS_DIR)/object/property-buffer-api.cpp', '<(DALI_JS_DIR)/object/property-buffer-wrapper.cpp', diff --git a/node-addon/test.js b/node-addon/test.js index b3abe08..25bbd48 100644 --- a/node-addon/test.js +++ b/node-addon/test.js @@ -88,16 +88,16 @@ daliApp.createActors = function() { for (x = 0; x < VIDEO_WALL_COLUMNS; ++x) { var actorIndex = daliApp.getWallActorIndex(x, y); - var imageActor = new dali.ImageActor(); + var imageView = new dali.Control("ImageView"); // wrap image index between 0 and NUMBER_OF_IMAGES var imageIndex = actorIndex % NUMBER_OF_IMAGES; - imageActor.setImage(DEMO_IMAGES[imageIndex]); + imageView.image = DEMO_IMAGES[imageIndex]; - imageActor.parentOrigin = dali.CENTER; - imageActor.anchorPoint = dali.CENTER; - imageActor.size = [VIDEO_WALL_ITEM_SIZE_NO_BORDER, VIDEO_WALL_ITEM_SIZE_NO_BORDER, 1.0]; // start with zero size so it zooms up + imageView.parentOrigin = dali.CENTER; + imageView.anchorPoint = dali.CENTER; + imageView.size = [VIDEO_WALL_ITEM_SIZE_NO_BORDER, VIDEO_WALL_ITEM_SIZE_NO_BORDER, 1.0]; // start with zero size so it zooms up var xPosition = x * VIDEO_WALL_ITEM_SIZE; // as the middle the wall is at zero (relative to wallRootActor), we need to subtract half the wall width. @@ -107,15 +107,15 @@ daliApp.createActors = function() { var yPosition = y * VIDEO_WALL_ITEM_SIZE; yPosition = yPosition - (VIDEO_WALL_HEIGHT / 2) + (VIDEO_WALL_ITEM_SIZE / 2); - imageActor.position = [0,0,0]; + imageView.position = [0,0,0]; animOptions.delay+=0.25; - anim.animateTo( imageActor,"position",[xPosition, yPosition, 0.0],animOptions); + anim.animateTo( imageView,"position",[xPosition, yPosition, 0.0],animOptions); // store the actor - VIDEO_WALL_ACTORS[actorIndex] = imageActor; + VIDEO_WALL_ACTORS[actorIndex] = imageView; // Add to the video wall root actor. - wallRootActor.add(imageActor); + wallRootActor.add(imageView); } } anim.play(); diff --git a/plugins/dali-script-v8/docs/content/actor.js b/plugins/dali-script-v8/docs/content/actor.js index 300ae3d..9f051fb 100644 --- a/plugins/dali-script-v8/docs/content/actor.js +++ b/plugins/dali-script-v8/docs/content/actor.js @@ -9,7 +9,6 @@ ``` var actor = new dali.Actor(); -var imageActor = new dali.ImageActor(); var textActor = new dali.TextActor("hello world"); var camera = new dali.CameraActor(); var layer = new dali.Layer(); diff --git a/plugins/dali-script-v8/docs/content/animation.js b/plugins/dali-script-v8/docs/content/animation.js index 43c258f..9d4dd48 100644 --- a/plugins/dali-script-v8/docs/content/animation.js +++ b/plugins/dali-script-v8/docs/content/animation.js @@ -115,7 +115,7 @@ anim.play(); The example below does the following with a single animation object: - - rotates the image actor + - rotates the image view - magnifies and color shifts the image using a fragment shader ![ ](../assets/img/shaders/shader-animation.png) @@ -123,15 +123,14 @@ The example below does the following with a single animation object: ``` -// create an image actor in the centre of the stage -createImageActor = function() { +// Creates an image view in the centre of the stage +createImageView = function() { - var image = new dali.ResourceImage({ url:getImageDirectory()+"gallery-medium-50.jpg"}); - var imageActor = new dali.ImageActor( image ); - imageActor.parentOrigin = dali.CENTER; - dali.stage.add( imageActor ); + var imageView = new dali.Control("ImageView"); + imageView.parentOrigin = dali.CENTER; + dali.stage.add( imageView ); - return imageActor; + return imageView; } // Creates a simple fragment shader that has 2 uniforms. @@ -140,77 +139,82 @@ createImageActor = function() { createColorShiftAndZoomEffect = function() { - var fragShader = - " uniform lowp vec4 uColorShift; \ - uniform lowp vec2 uScale; \ - \ - void main() \ - { \ - gl_FragColor = texture2D( sTexture, vTexCoord * uScale ) * uColor + uColorShift; \ - }" - - // Shader API - // geometryType = "image", "text", "mesh", "texturedMesh" - // fragmentPrefex ="" // prefix ( optional) - // fragmentShader = "" // fragment shader ( optional) - // geometryHints = [ "gridX", "gridY", "grid","depthBuffer","blending" ] ( optional) - // - var shaderOptions = { - geometryType: "image", - fragmentShader: fragShader, - geometryHints: ["blending"] + var fragShader = + "varying vec2 vTexCoord;\ + uniform sampler2D sTexture;\ + uniform vec4 uColor;\ + uniform lowp vec4 uColorShift;\ + uniform lowp vec2 uScale;\ + void main() \ + { \ + gl_FragColor = texture2D( sTexture, vTexCoord * uScale ) * uColor + uColorShift; \ + }"; + + // vertexShader = ""; // vertex shader ( optional) + // fragmentShader = ""; // fragment shader ( optional) + // hints = // shader hints ( optional) + // [ "requiresSelfDepthTest", // Expects depth testing enabled + // "outputIsTransparent", // Might generate transparent alpha from opaque inputs + // "outputIsOpaque", // Outputs opaque colors even if the inputs are transparent + // "modifiesGeometry" ]; // Might change position of vertices, this option disables any culling optimizations + + var shader = { + "fragmentShader": fragShader, + "hints" : "outputIsTransparent" }; - // create a new shader effect - var shader = new dali.ShaderEffect(shaderOptions); - - // add the color shift uniform so we can animate it - // default the color shift to zero, so it has no effect - shader.setUniform("uColorShift", [0, 0, 0, 0]); - - // add the zoom uniform so we can animate it - // default to 1,1 so no zoom is applied - var scale = new dali.Vector2([1, 1]); - shader.setUniform("uScale", scale); - return shader; } -createShaderAnimation = function( shader, color, zoom, duration, delay ) +createShaderAnimation = function( imageView, color, zoom, duration, delay ) { - var shaderAnim = new dali.Animation(duration+delay); + var shaderAnim = new dali.Animation(duration+delay); - var animOptions = { - alpha: "doubleEaseInOutSine60", - delay: delay, - duration: duration, - }; + var animOptions = { + alpha: "doubleEaseInOutSine60", + delay: delay, + duration: duration, + }; - // animate the color uniform - shaderAnim.animateTo( shader, "uColorShift", color, animOptions); + // animate the color uniform + shaderAnim.animateTo( imageView, "uColorShift", color, animOptions); - // zoom in and out of the image while applying the color shift - shaderAnim.animateTo( shader, "uScale", zoom, animOptions); + // zoom in and out of the image while applying the color shift + shaderAnim.animateTo( imageView, "uScale", zoom, animOptions); - return shaderAnim; + return shaderAnim; } -var imageActor = createImageActor(); -var shaderEffect = createColorShiftAndZoomEffect(); +var imageView = createImageView(); + +var shader = createColorShiftAndZoomEffect(); + +var image = { + "rendererType" : "imageRenderer", + "imageUrl" : getImageDirectory()+"gallery-medium-50.jpg", + "shader" : shader +}; + +imageView.image = image; // assign the shader to imageView + +// register the color shift property so we can animate it +// default the color shift to zero, so it has no effect +imageView.registerAnimatableProperty("uColorShift", [0, 0, 0, 0]); -// assign the shader effect to the actor ( it can be assigned to multiple actors). -imageActor.setShaderEffect( shaderEffect ); +// register the zoom property so we can animate it +// default to 1,1 so no zoom is applied +imageView.registerAnimatableProperty("uScale", [1, 1]); // create the shader animation var zoom = [0.5,0.5]; // zoom into the image by 2 var color = dali.COLOR_BLUE; // color shift the image to blue var duration = 5; // 5 seconds var delay = 5; // wait 1 second before starting -var shaderAnim = createShaderAnimation( shaderEffect, color,zoom, duration, delay); +var shaderAnim = createShaderAnimation( imageView, color,zoom, duration, delay); -// also rotate the imageActor 90 degrees at the same time. +// also rotate the imageView 90 degrees at the same time. var rotation = new dali.Rotation(90,0,0,1); -shaderAnim.animateTo(imageActor, "orientation", rotation, { alpha:"linear", duration:duration, delay:delay }); +shaderAnim.animateTo(imageView, "orientation", rotation, { alpha:"linear", duration:duration, delay:delay }); shaderAnim.play(); diff --git a/plugins/dali-script-v8/docs/content/constants.js b/plugins/dali-script-v8/docs/content/constants.js index f952e69..d321285 100644 --- a/plugins/dali-script-v8/docs/content/constants.js +++ b/plugins/dali-script-v8/docs/content/constants.js @@ -62,9 +62,6 @@ Constants accessible under the dali global object. |DRAW_MODE_STENCIL | integer value | |**Image load policy **| | -|IMAGE_LOAD_POLICY_IMMEDIATE | integer value | -|IMAGE_LOAD_POLICY_ON_DEMAND | integer value | - |**actor.SetBlendFunc() ** | | |BLEND_FACTOR_ZERO | integer value | |BLEND_FACTOR_ONE | integer value | diff --git a/plugins/dali-script-v8/docs/content/image-actor.js b/plugins/dali-script-v8/docs/content/image-actor.js deleted file mode 100644 index 40a6d5f..0000000 --- a/plugins/dali-script-v8/docs/content/image-actor.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -## Image Actor API ( extends Actor API) - -An actor for displaying images. - -Allows the developer to add an actor to stage which displays the content of an Image object. - -By default CullFaceMode is set to CullNone to enable the ImageActor to be viewed from all angles. - -If an ImageActor is created without setting size, then the actor takes the size of the image - -this is the natural size. -Setting a size on the ImageActor, e.g through the SetSize api or through an animation will -stop the natural size being used. - -Such a set size can be changed back to the image's size by calling {{#crossLink "ImageActor/setToNaturalSize:method"}}{{/crossLink}} . - -If a pixel area is set on an ImageActor with natural size, the actor size will change -to match the pixel area. If a pixel area is set on an ImageActor that has had it's size set, -then the size doesn't change, and the partial image will be stretched to fill the set size. - -Clearing the pixel area on an Image actor with natural size will cause the actor to show the -whole image again, and will change size back to that of the image. - -Clearing the pixel area on an Image actor with a set size will cause the actor to show the -whole image again, but will not change the image size. - -### Simple example -``` -var image = new dali.ResourceImage( {url:"background.png"} ); -var imageActor = new dali.ImageActor( image ); - -// by default an actor is anchored to the top-left of it's parent actor -// change it to the middle -imageActor.parentOrigin = dali.CENTER; - -// scale it up by 2 times in x,y -imageActor.scale = [ 2, 2, 1 ]; - -// add to the stage -dali.stage.add( imageActor ); -``` - -### Example using a pixel area ( needed for displaying images from a Texture Atlas ) - -``` -var imageAtlas = new dali.ResourceImage( {url:"atlas.png"} ) -``` -![ ](../assets/img/texture-atlas/example-javascript-code.jpg) - - -### Image Actor Specific Properties - - -|Name | Type | Writable | Animatable| -|-----------------------|------------|--------------|-----------| -| pixelArea | RECTANGE | ✔ | ✘ | -| fadeIn | BOOLEAN | ✔ | ✘ | -| fadeInDuration | FLOAT | ✔ | ✘ | -| style | dali.IMAGE_ACTOR_STYLE_QUAD, dali.IMAGE_ACTOR_STYLE_NINE_PATCH, dali.IMAGE_ACTOR_STYLE_NINE_PATCH_NO_CENTER | ✔ | ✘ | -| border | VECTOR4 | ✔ | ✘ | - - -@class ImageActor -@extends RenderableActor - */ \ No newline at end of file diff --git a/plugins/dali-script-v8/docs/content/image-view.js b/plugins/dali-script-v8/docs/content/image-view.js new file mode 100644 index 0000000..282f684 --- /dev/null +++ b/plugins/dali-script-v8/docs/content/image-view.js @@ -0,0 +1,63 @@ +/** + * +## ImageView API + + DALi ImageView can be used to display an image. + + It is preferable to set a valid size to the image for efficiency. However, do not set size + that is bigger than the actual image size, as the up-scaling is not available, the content + of the area not covered by actual image is undefined and it will not be cleared. + + +### Simple example of creating an ImageView + +``` +var imageView = new dali.Control("ImageView"); + +imageView.image = "myImage.jpg"; +imageView.parentOrigin = dali.CENTER; +imageView.anchorPoint = dali.CENTER; + +dali.stage.add( imageView ); +``` + +### Advanced example of creating an ImageView and applying a GL-ES shader to it + +``` +// vertexShader = ""; // vertex shader ( optional) +// fragmentShader = ""; // fragment shader ( optional) +// hints = // shader hints ( optional) +// [ "requiresSelfDepthTest", // Expects depth testing enabled +// "outputIsTransparent", // Might generate transparent alpha from opaque inputs +// "outputIsOpaque", // Outputs opaque colors even if the inputs are transparent +// "modifiesGeometry" ]; // Might change position of vertices, this option disables any culling optimizations + +var shader = { + "vertexShader": myVertexShader, + "fragmentShader": myFragmentShader, + "hints" : myHints +}; + +var imageView = new dali.Control("ImageView"); +imageView.parentOrigin = dali.CENTER; +imageView.anchorPoint = dali.CENTER; +imageView.size = imageViewSize; // If not set, it will use either the natural image size or the desired image size if any +dali.stage.add( imageView ); + +var image = { + "rendererType" : "imageRenderer", + "imageUrl" : "myImage.jpg", + "width" : desiredWidth, // The desired image width while loading (optional but preferable to set for efficiency) + "height" : desiredHeight, // The desired image height while loading (optional but preferable to set for efficiency) + "shader" : shader // Optional +}; + +imageView.image = image; // assign the image and shader to imageView + +``` + + + @class ImageView + @extends Actor + +*/ diff --git a/plugins/dali-script-v8/docs/content/image.js b/plugins/dali-script-v8/docs/content/image.js index f9ef313..e5810de 100644 --- a/plugins/dali-script-v8/docs/content/image.js +++ b/plugins/dali-script-v8/docs/content/image.js @@ -2,43 +2,34 @@ * ## Image API -An Image object represents a resource that can be added to ImageActors and ShaderEffects. +An Image object represents a resource that can be added to Material. -The image is discarded when all ImageActors using the Image object are discarded or in case they -were created with dali.IMAGE_RELEASE_POLICY_UNUSED, taken off stage. +The image is discarded when all Materials using the Image object are discarded. Note: if a resource was shared between Image objects it exists until its last reference is gone. Image objects are responsible for the underlying resource's lifetime. -### ReleasePolicies - - - dali.IMAGE_RELEASE_POLICY_UNUSED: release resource once ImageActor using it is taken off stage. - - dali.IMAGE_RELEASE_POLICY_NEVER: keep resource alive until Image object is thrown away ( default). - -#### Resolution of conflicting policies - - If the same image is created more than once with conflicting policies, ReleasePolicy "Never" overrides "Unused". - - ### The hierarchy of Image is: - {{#crossLink "image"}}Image base class {{/crossLink}} provides basic functionality - {{#crossLink "ResourceImage"}}ResourceImage {{/crossLink}} used for loading image files and nine-patch files - - {{#crossLink "NinePatchImage"}}NinePatch {{/crossLink}} used just for nine patch files - {{#crossLink "BufferImage"}}BufferImage {{/crossLink}} used for generating your own image - {{#crossLink "FrameBufferImage"}}FrameBufferImage {{/crossLink}} contains the result of an 'off screen' render pass of a RenderTask. - - {{#crossLink "NativeImage"}}NativeImage {{/crossLink}} Its data is provided by native resources, such as shared bitmap memory or pixmap from X11 or ECORE-X11, etc. ### Example: ``` +// Create a resource image with a given URL var image = new dali.ResourceImage( {url: "background.png"} ); -var imageActor1 = new dali.ImageActor( image ); -var imageActor2 = new dali.ImageActor( image ); +// Create materials that specifie the visual properties of the renderer. +var material1 = new dali.Material(); +var material2 = new dali.Material(); -shaderEffect.setEffectImage( image ); - +// Add images as texture to be used by the materials +material1.addTexture( image, "sTexture" ); +material2.addTexture( image, "sTexture" ); ``` The API supports functionality such as: @@ -52,10 +43,8 @@ The API supports functionality such as: The Image class also has support for loading 9 patch Images if the filename contains .9. e.g. ``` -var blackFrame = new dali.ResourceImage( url:"black-frame.9.png"}); +var blackFrame = new dali.ResourceImage( {url:"black-frame.9.png"} ); var borderNinePatch = new dali.ResourceImage( {url:"border.9.png"} ); -// or if the image doesn't have a .9 filename, you can use the NinePatchImage class -var image = new dali.NinePatchImage( {url:"my_image.png"}) ``` The nine patch image will scale automatically with the size of the actor. diff --git a/plugins/dali-script-v8/docs/content/path-animation.js b/plugins/dali-script-v8/docs/content/path-animation.js index 81aece0..7847fc1 100644 --- a/plugins/dali-script-v8/docs/content/path-animation.js +++ b/plugins/dali-script-v8/docs/content/path-animation.js @@ -23,17 +23,16 @@ myPath.generateControlPoints( 0.25 ); function begin() { - var image = new dali.ResourceImage( {url:"gallery-small-45.jpg"} ); + var imageView = new dali.Control("ImageView"); + imageView.image = "gallery-small-45.jpg"; - var actor = new dali.ImageActor(image); - - actor.position = [100,100,0]; - dali.stage.add( actor ); + imageView.position = [100,100,0]; + dali.stage.add( imageView ); var animation = new dali.Animation(2.0); var animOptions = { alpha:"easeInOutSine", delay:0.5, duration:1.5 }; var forward = new dali.Vector3(1,0,0); - animation.animate( actor, myPath, forward, animOptions ); + animation.animate( imageView, myPath, forward, animOptions ); animation.setLooping( true ); animation.play(); diff --git a/plugins/dali-script-v8/docs/content/resource-image.js b/plugins/dali-script-v8/docs/content/resource-image.js index ccdfe77..e14ad0f 100644 --- a/plugins/dali-script-v8/docs/content/resource-image.js +++ b/plugins/dali-script-v8/docs/content/resource-image.js @@ -5,18 +5,18 @@ A resource image extends the basic {{#crossLink "image"}}Image class{{/crossLink}} with the ability to load an image from a file. -ResourceImage supports two types of load policies - -- dali.IMAGE_LOAD_POLICY_IMMEDIATE // load image once it is created (default) -- dali.IMAGE_LOAD_POLICY_ON_DEMAND // delay loading until the image is being used (a related actor is added to Stage) - ### Simple example ``` -var image = new dali.ResourceImage( { url:"my_image.png" } ); - -var imageActor = new dali.ImageActor( image ); - +// Create a resource image with a given URL +var image = new dali.ResourceImage( {url: "my_image.png"} ); + +// Create a material that specifies the visual properties of the renderer. +var material = new dali.Material(); + +// Add the image as texture to be used by the material +material.addTexture( image, "sTexture" ); + ``` ### Advanced example ``` @@ -25,17 +25,14 @@ function imageLoaded( image ) { log("image loaded " +image.url + "\n"); } - -var options = { - url:"my_image.png", - loadPolicy:dali.IMAGE_LOAD_POLICY_IMMEDIATE, - releasePolicy: dali.IMAGE_RELEASE_POLICY_UNUSED -} -var image = new dali.ResourceImage( options ); - + +var image = new dali.ResourceImage( {url: "my_image.png"} ); + image.connect("imageLoadingFinished", finished ); - -var imageActor = new dali.ImageActor( image ); + +// Create a material and add the image as texture to be used by the material. +var material = new dali.Material(); +material.addTexture( image, "sTexture" ); ``` @class ResourceImage diff --git a/plugins/dali-script-v8/docs/content/shader-effect.js b/plugins/dali-script-v8/docs/content/shader-effect.js deleted file mode 100644 index 8c35f3d..0000000 --- a/plugins/dali-script-v8/docs/content/shader-effect.js +++ /dev/null @@ -1,268 +0,0 @@ -/** - * - -## Shader Effects API - -Shader effects provide a visual effect for actors. - -You can create a type-registered shader effect by its type name. -``` -// create a new shader effect -var shader = new dali.ShaderEffect("BlindEffect"); -``` - -Alternatively you can create a Custom shader by providing the vertex and fragment shader code as strings. -Each shader is provided with default uniforms and attributes. -For a vertex shader this part contains the following code: -``` -precision highp float; -attribute vec3 aPosition; -attribute vec2 aTexCoord; -uniform mat4 uMvpMatrix; -uniform mat4 uModelMatrix; -uniform mat4 uViewMatrix; -uniform mat4 uModelView; -uniform mat3 uNormalMatrix; -uniform mat4 uProjection; -uniform vec4 uColor; -varying vec2 vTexCoord; -``` -The custom shader part is expected to output the vertex position and texture coordinate. -A basic custom vertex shader would contain the following code: -``` -void main() -{ - gl_Position = uProjection * uModelView * vec4(aPosition, 1.0); - vTexCoord = aTexCoord; -} -``` -For an Image fragment shader the default attributes and uniforms are: -``` -precision mediump float; -uniform sampler2D sTexture; -uniform sampler2D sEffect; -uniform vec4 uColor; -varying vec2 vTexCoord; -``` -The custom shader is expected to output the fragment color. -The basic fragment shader for images would contain: -``` -void main() -{ - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor; -} -``` -The API supports functionality such as: - -+ new dali.{{#crossLink "ShaderEffect/ShaderEffect:method"}}{{/crossLink}} -+ {{#crossLink "ShaderEffect/setUniform:method"}}{{/crossLink}} - -### Example of using a custom uniform to brighten an Image (Fragment Shader) - -![ ](../assets/img/shaders/fragment-shader-color.png) - -``` -createColorEffect = function() -{ - - // add uColorShift to the pixel color - - var fragShader = - "uniform lowp vec4 uColorShift; \ - \ - void main() \ - { \ - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor + uColorShift; \ - }" - - var shaderOptions = { - geometryType: "image", - fragmentShader: fragShader - }; - - // create a new shader effect - var shader = new dali.ShaderEffect(shaderOptions); - - // add the color shift uniform so we can modify and animate it - shader.setUniform("uColorShift", [0.0, 0.0, 0.0, 0]); - return shader; -} -// create an image actor and add an image to it -var image = new dali.ResourceImage( { url: getImageDirectory() +"gallery-medium-50.jpg"}); -var imageActor = new dali.ImageActor( image ); -imageActor.parentOrigin = dali.CENTER; -dali.stage.add( imageActor ); - -var colorShift = createColorEffect(); - -colorShift.setUniform( "uColorShift", [0.5,0.5,0.5,0.0] ); // increase RGB by 50% - -imageActor.setShaderEffect( colorShift ); -``` - -For an example of animating we can just do: -``` -var shaderAnim = new dali.Animation(10); - -var animOptions = { - alpha: "doubleEaseInOutSine60", -}; - -// animate the color uniform to full white -shaderAnim.animateTo( colorShift, "uColorShift", dali.COLOR_WHITE, animOptions); - -shaderAnim.play(); -``` -Like all animatable properties we can also use keyframes to animate the value. -* * * - -### Example of animating a custom uniform to perform a mask operation (Fragment Shader) - -In this example we are using the OpenGL discard function to draw an image with a circular mask. - -![ ](../assets/img/shaders/fragment-shader-reveal.png) - -``` -createRevealEffect = function() -{ -// texture co-ordinate is from 0..1 -// we shift the texture co-ordinate to -0.5 to 0.5 to center it -// then work out the radius from the centre, using ( a^2 + b^2) = c^2 -// we use the dot product to perform the a^2 + b^2 -// then just perform uRadius * uRadius to workout c^2 - - var fragShader = - " uniform lowp float uRadius; \ - \ - void main() \ - { \ - lowp vec2 pos= vec2(vTexCoord.x-0.5,vTexCoord.y-0.5); \ - lowp float radius = dot(pos, pos ) ; \ - if( radius > (uRadius*uRadius) )\ - discard; \ - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor ; \ - }" - - var shaderOptions = { - geometryType: "image", - fragmentShader: fragShader - }; - - // create a new shader effect - var shader = new dali.ShaderEffect(shaderOptions); - - // set the uniform - shader.setUniform("uRadius",0.0); - return shader; -} -// create an image actor and add an image to it -var filename = getImageDirectory() +"gallery-medium-50.jpg; -var image = new dali.ResourceImage( {url: filename }); -var imageActor = new dali.ImageActor( image ); -imageActor.parentOrigin = dali.CENTER; -dali.stage.add( imageActor ); - -var revealEffect = createRevealEffect(); - -imageActor.setShaderEffect( revealEffect ); - -var shaderAnim = new dali.Animation(5); - -var animOptions = { - alpha: "easeInOutSine", - }; - -// animate up to radius = 0.5 ( a full circle ) -// if we go to 1.0 then it will go to a full box -shaderAnim.animateTo( revealEffect, "uRadius", 0.5,animOptions); -shaderAnim.play(); -``` -* * * -### Example of paper twisting in the wind with color (Vertex + Fragment Shader) - -![ ](../assets/img/shaders/vertex-shader.png) - - -The example does the following: - -+ Creates a varying variable called vColor in the vertex shader. - + The vColor is set to the position of the vertex, so the color changes depending on its position -+ Create a uniform called uOffset which modifies the xPosition of each vertex, creating a twist effect - -An ImageActor normally only has 4 vertices ( quad ). To allow the image to twist and bend we need it to have more -vertices. To do this we can break the image into a grid using the gridX and gridY geometry hints. - -![ ](../assets/img/shaders/shader-grid-hint.png) - -``` -createTwistEffect = function() -{ - - // do some maths on the x-position to move it based on y,z pos + uOffset - var vertexShader = - " \ - varying lowp vec4 vColor; \ - uniform lowp float uOffset; \ - \ - void main() \ - { \ - vec4 pos = uProjection * uModelView * vec4(aPosition, 1.0); \ - pos.x= 3*pos.z*(sin(1.57+uOffset+pos.y/1000.0)); \ - gl_Position =pos; \ - vColor = pos/500.0;\ - vTexCoord = aTexCoord; \ - }" - - // add the vColor to the pixel color to tint it - var fragShader = - " \ - varying lowp vec4 vColor; \ - void main() \ - { \ - gl_FragColor = texture2D( sTexture, vTexCoord ) *uColor + vColor*0.2; \ - }" - - var shaderOptions = { - geometryType: "image", - vertexShader: vertexShader, - fragmentShader: fragShader, - geometryHints: ["grid"] - }; - - // create a new shader effect - var shader = new dali.ShaderEffect(shaderOptions); - - // set the uniform - shader.setUniform("uOffset",0.0); - return shader; -} - - -dali.stage.setBackgroundColor( dali.COLOR_WHITE); - -var image = new dali.ResourceImage( { url:getImageDirectory() +"gallery-medium-50.jpg"}); -var imageActor = new dali.ImageActor( image ); -imageActor.parentOrigin = dali.CENTER; -imageActor.setCullFace( dali.CULL_FACE_DISABLE ); // disable face culling so we can see both sides -dali.stage.add( imageActor ); - -// start it of tilted around the y-axis -imageActor.orientation=new dali.Rotation(90, 0, 1, 0); - -var twistEffect = createTwistEffect(); -imageActor.setShaderEffect( twistEffect ); - -var shaderAnim = new dali.Animation(1); -var animOptions = { - alpha: "bounce", - duration:20 - }; -shaderAnim.animateTo( twistEffect, "uOffset",20,animOptions); - -shaderAnim.play(); -``` -Note: In order for fade and color animations to work, the fragment shader needs to multiply the fragment color -with the uniform color "uColor" of the node - -@class ShaderEffect -*/ \ No newline at end of file diff --git a/plugins/dali-script-v8/docs/content/stage.js b/plugins/dali-script-v8/docs/content/stage.js index f11a83d..c8b4cf3 100644 --- a/plugins/dali-script-v8/docs/content/stage.js +++ b/plugins/dali-script-v8/docs/content/stage.js @@ -14,12 +14,12 @@ dali.stage.setBackgroundColor( dali.COLOR_WHITE); var stageSize = dali.stage.getSize(); -var imageActor = new dali.ImageActor( ); +var actor = new dali.Actor( ); -dali.stage.add( imageActor ); +dali.stage.add( actor ); // when the actor is no longer required -dali.stage.remove( imageActor ); +dali.stage.remove( actor ); ``` ![ ](../assets/img/stage.png) diff --git a/plugins/dali-script-v8/file.list b/plugins/dali-script-v8/file.list index ead0a1f..e50d5cd 100644 --- a/plugins/dali-script-v8/file.list +++ b/plugins/dali-script-v8/file.list @@ -12,7 +12,6 @@ script_v8_plugin_src_files = \ $(v8_plugin_dir)/actors/actor-wrapper.cpp \ $(v8_plugin_dir)/actors/actor-api.cpp \ $(v8_plugin_dir)/actors/layer-api.cpp \ - $(v8_plugin_dir)/actors/image-actor-api.cpp \ $(v8_plugin_dir)/actors/camera-actor-api.cpp \ $(v8_plugin_dir)/constants/constants-wrapper.cpp \ $(v8_plugin_dir)/animation/animation-api.cpp \ @@ -27,15 +26,11 @@ script_v8_plugin_src_files = \ $(v8_plugin_dir)/events/pan-gesture-detector-api.cpp \ $(v8_plugin_dir)/events/pan-gesture-detector-wrapper.cpp \ $(v8_plugin_dir)/stage/stage-api.cpp \ - $(v8_plugin_dir)/shader-effects/shader-effect-api.cpp \ - $(v8_plugin_dir)/shader-effects/shader-effect-wrapper.cpp \ $(v8_plugin_dir)/image/image-wrapper.cpp \ $(v8_plugin_dir)/image/image-api.cpp \ $(v8_plugin_dir)/image/buffer-image-api.cpp \ - $(v8_plugin_dir)/image/native-image-api.cpp \ $(v8_plugin_dir)/image/frame-buffer-image-api.cpp \ $(v8_plugin_dir)/image/resource-image-api.cpp \ - $(v8_plugin_dir)/image/nine-patch-image-api.cpp \ $(v8_plugin_dir)/object/handle-wrapper.cpp \ $(v8_plugin_dir)/object/property-buffer-api.cpp \ $(v8_plugin_dir)/object/property-buffer-wrapper.cpp \ diff --git a/plugins/dali-script-v8/src/actors/actor-api.cpp b/plugins/dali-script-v8/src/actors/actor-api.cpp index 1ae60ec..5bac818 100644 --- a/plugins/dali-script-v8/src/actors/actor-api.cpp +++ b/plugins/dali-script-v8/src/actors/actor-api.cpp @@ -488,7 +488,7 @@ void ActorApi::IsKeyboardFocusable( const v8::FunctionCallbackInfo& a * * @for Actor * @method getActorType - * @return {String} Actor, ImageActor, MeshActor, Layer, CameraActor ... + * @return {String} Actor, Layer, CameraActor ... */ void ActorApi::GetActorType( const v8::FunctionCallbackInfo& args ) { diff --git a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp index a462723..c9a3536 100644 --- a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp +++ b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp @@ -25,7 +25,6 @@ // INTERNAL INCLUDES #include #include -#include #include #include #include @@ -37,7 +36,6 @@ namespace V8Plugin { v8::Persistent ActorWrapper::mActorTemplate; -v8::Persistent ActorWrapper::mImageActorTemplate; v8::Persistent ActorWrapper::mCameraActorTemplate; v8::Persistent ActorWrapper::mLayerActorTemplate; @@ -59,7 +57,6 @@ struct ActorTemplate const ActorTemplate ActorTemplateLookup[]= { { &ActorWrapper::mActorTemplate }, // ACTOR - { &ActorWrapper::mImageActorTemplate }, // IMAGE_ACTOR { &ActorWrapper::mLayerActorTemplate }, // LAYER_ACTOR { &ActorWrapper::mCameraActorTemplate} // CAMERA_ACTOR }; @@ -93,7 +90,6 @@ struct ActorApiStruct const ActorApiStruct ActorApiLookup[]= { {"Actor", ActorWrapper::ACTOR, ActorApi::New, ACTOR_API }, - {"ImageActor", ActorWrapper::IMAGE_ACTOR, ImageActorApi::New, ACTOR_API | IMAGE_ACTOR_API }, {"Layer", ActorWrapper::LAYER_ACTOR, LayerApi::New, ACTOR_API | LAYER_API }, {"CameraActor",ActorWrapper::CAMERA_ACTOR, CameraActorApi::New, ACTOR_API | CAMERA_ACTOR_API }, }; @@ -122,7 +118,7 @@ Actor CreateActor( const v8::FunctionCallbackInfo< v8::Value >& args, else { // run the constructor for this type of actor so it can pull out - // custom parameters, e.g. new ImageActor( MyImage ); + // custom parameters; actor = (ActorApiLookup[actorType].constructor)( args ); } return actor; @@ -215,8 +211,6 @@ const ActorFunctions ActorFunctionTable[]= // ignore SetColorMode() use Actor.colorMode // ignore GetColorMode() use Actor.colorMode // ignore GetCurrentWorldColor() use Actor.worldColor - // ignore SetInheritShaderEffect() use Actor.inheritShaderEffect - // ignore GetInheritShaderEffect() use Actor.inheritShaderEffect // ignore SetDrawMode() use Actor.drawMode // ignore GetDrawMode() use Actor.drawMode // ignore SetSensitive() use Actor.sensitve @@ -252,42 +246,6 @@ const ActorFunctions ActorFunctionTable[]= // @todo SetSortFunction /************************************** - * Image Actor API (in order of image-actor.h) - **************************************/ - - { "SetImage", ImageActorApi::SetImage, IMAGE_ACTOR_API }, - { "GetImage", ImageActorApi::GetImage, IMAGE_ACTOR_API }, - // ignore SetPixelArea, use imageActor.pixelArea - // ignore GetPixelArea, use imageActor.pixelArea - // ignore SetStyle, use imageActor.style - // ignore GetStyle, use imageActor.style - // ignore SetNinePatchBorder use imageActor.border - // ignore GetNinePatchBorder use imageActor.border - { "SetSortModifier", ImageActorApi::SetSortModifier, IMAGE_ACTOR_API }, - { "GetSortModifier", ImageActorApi::GetSortModifier, IMAGE_ACTOR_API }, - { "SetBlendMode", ImageActorApi::SetBlendMode, IMAGE_ACTOR_API }, - { "GetBlendMode", ImageActorApi::GetBlendMode, IMAGE_ACTOR_API }, - { "SetBlendFunc", ImageActorApi::SetBlendFunc, IMAGE_ACTOR_API }, - { "GetBlendFunc", ImageActorApi::GetBlendFunc, IMAGE_ACTOR_API }, - { "SetShaderEffect", ImageActorApi::SetShaderEffect, IMAGE_ACTOR_API }, - { "GetShaderEffect", ImageActorApi::GetShaderEffect, IMAGE_ACTOR_API }, - { "RemoveShaderEffect", ImageActorApi::RemoveShaderEffect,IMAGE_ACTOR_API }, - // ignore SetFadeIn use imageActor.fadeIn - // ignore GetFadeIn use imageActor.fadeIn - // ignore SetFadeInDuration use imageActor.fadeInDuration - // ignore GetFadeInDuration use imageActor.fadeInDuration - //{ "GetCurrentImageSize", ImageActorApi::GetCurrentImageSize, IMAGE_ACTOR_API }, - - /************************************** - * Mesh Actor API (in order of mesh-actor.h) - **************************************/ - // @todo a version of MeshActor::New( mesh ) - // @todo a version of MeshActor::New( AnimatableMesh ) - // @todo SetMaterial - // @todo GetMaterial - // @todo BindBonesToMesh - - /************************************** * Camera Actor API (in order of camera.h) **************************************/ // ignore SetType use camera.type @@ -394,7 +352,7 @@ v8::Handle ActorWrapper::MakeDaliActorTemplate( v8::Isolate* const ActorFunctions property = ActorFunctionTable[i]; // check to see if the actor supports a certain type of API - // e.g. ImageActor will support ACTOR_API, RENDERABLE_API and IMAGE_ACTOR_API + // e.g. Layer will support ACTOR_API and LAYER_API if( supportApis & property.api ) { std::string funcName = V8Utils::GetJavaScriptFunctionName( property.name); @@ -422,7 +380,7 @@ void ActorWrapper::NewActor( const v8::FunctionCallbackInfo< v8::Value >& args) return; } - // find out the callee function name...e.g. ImageActor, MeshActor + // find out the callee function name...e.g. CameraActor v8::Local callee = args.Callee(); v8::Local v8String = callee->GetName(); std::string typeName = V8Utils::v8StringToStdString( v8String ); @@ -472,7 +430,7 @@ void ActorWrapper::NewControl( const v8::FunctionCallbackInfo< v8::Value >& args /** - * given an actor type name, e.g. ImageActor returns the type, e.g. ActorWrapper::IMAGE_ACTOR + * given an actor type name, e.g. CameraActor returns the type, e.g. ActorWrapper::CAMERA_ACTOR */ ActorWrapper::ActorType ActorWrapper::GetActorType( const std::string& name ) { diff --git a/plugins/dali-script-v8/src/actors/actor-wrapper.h b/plugins/dali-script-v8/src/actors/actor-wrapper.h index 13cd811..e7899ee 100644 --- a/plugins/dali-script-v8/src/actors/actor-wrapper.h +++ b/plugins/dali-script-v8/src/actors/actor-wrapper.h @@ -71,7 +71,7 @@ public: /** * @brief Creates a new Actor wrapped inside a Javascript Object. - * @note: the actor type ie 'ImageActor' is expected to be the name of the callee function. + * @note: the actor type ie 'CameraActor' is expected to be the name of the callee function. * @param[in] args v8 function call arguments interpreted */ static void NewActor( const v8::FunctionCallbackInfo< v8::Value >& args); @@ -95,7 +95,6 @@ public: // The Actor ObjectTemplates. static v8::Persistent mActorTemplate; - static v8::Persistent mImageActorTemplate; static v8::Persistent mCameraActorTemplate; static v8::Persistent mLayerActorTemplate; diff --git a/plugins/dali-script-v8/src/actors/image-actor-api.cpp b/plugins/dali-script-v8/src/actors/image-actor-api.cpp deleted file mode 100644 index 252838e..0000000 --- a/plugins/dali-script-v8/src/actors/image-actor-api.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include "image-actor-api.h" - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace //unnamed name space -{ - -ImageActor GetImageActor( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - HandleWrapper* handleWrapper = HandleWrapper::Unwrap( isolate, args.This() ); - return ImageActor::DownCast( handleWrapper->mHandle ); -} - -} //unnamed name space - -/** - * Constructor - * - * @constructor - * @method ImageActor - * @for ImageActor - * @param {Object} [image] Image object - * @param {Object} [pixelArea] Vector4 - * @return {Object} ImageActor - * @example - * new DALI.imageActor( image, [10,23,35,56] ); - */ -Actor ImageActorApi::New( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - // Image actor has 3 different constructors - // New(); - // New( image); - // New( image, PixelArea pixelArea); - - if( args.Length() == 0 ) - { - return ImageActor::New(); - } - - // args.Length> 0, must have an Image parameter - bool found( false ); - Image image = V8Utils::GetImageParameter( PARAMETER_0, found, isolate, args ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "missing image from param 0" ); - return ImageActor(); - } - - // check for PixelArea, accept a DALI Vector4 object ( which can be a JavaScript array) - // e.g. new DALI.imageActor( image, [10,23,35,56] ); - // or new DALI.imageActor( image, Vector4 ); - - if( args.Length() > 1 ) - { - Vector4 rect = V8Utils::GetVector4Parameter( PARAMETER_1, found, isolate, args ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, " bad parameters" ); - return ImageActor(); - } - Rectrectangle( static_cast(rect.x), - static_cast(rect.y), - static_cast(rect.z), - static_cast(rect.w)); - - return ImageActor::New( image, rectangle ); - } - else - { - return ImageActor::New( image ); - } -} - -/** - * Set the image rendered by the actor. - * - * When the image is loaded the actor's size will be reset to the image size, - * unless a custom size was chosen, e.g. via actor.size or a pixel area - * was set. - * Note: The old image will continue to be displayed until the given image has loaded. - * @for ImageActor - * @method setImage - * @param {Object} image The image to display. - * - */ -void ImageActorApi::SetImage( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - bool found( false ); - Image image = V8Utils::GetImageParameter( PARAMETER_0, found, isolate, args ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "bad parameters" ); - return; - } - ImageActor imageActor = GetImageActor( isolate, args ); - imageActor.SetImage( image ); -} - -/** - * brief Retrieve the image rendered by the actor's attachment. - * @for ImageActor - * @method getImage - * @return {Object} the image. - */ -void ImageActorApi::GetImage( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - Image image = imageActor.GetImage(); - - // wrap the image - v8::Local localObject = ImageWrapper::WrapImage( isolate, image ); - args.GetReturnValue().Set( localObject ); -} - -/** - * Allows modification of an actors position in the depth sort algorithm. - * - * The offset can be altered for each coplanar actor hence allowing an order of painting. - * @param { Number } depthOffset the offset to be given to the actor. Positive values pushing it further back. - * @for ImageActor - * @method setSortModifier - */ -void ImageActorApi::SetSortModifier( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - bool found( false ); - float value = V8Utils::GetFloatParameter( PARAMETER_0, found, isolate, args, 0.f ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "bad parameter" ); - return; - } - imageActor.SetSortModifier( value ); -} - -/** - * Retrieves the offset used to modify an actors position in the depth sort algorithm. - * @for ImageActor - * @method getSortModifier . - * @return { Number} the offset that has been given to the actor. Positive values pushing it further back - */ -void ImageActorApi::GetSortModifier( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - args.GetReturnValue().Set( v8::Number::New( isolate, imageActor.GetSortModifier() ) ); - -} - -/** - * Sets the blending mode. - * - * If blending is disabled (BLENDING_OFF) fade in and fade out animations do not work. - * - * @example - * // blend mode is one of the following - * dali.BLENDING_OFF // Blending is disabled. - * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel. - * dali.BLENDING_ON // Blending is enabled. - * actor.SetBlendMode( dali.BLENDING_AUTO ); - * - * @for ImageActor - * @method setBlendMode - * @param { Number } blendMode - */ -void ImageActorApi::SetBlendMode( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - bool found( false ); - int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendMode parameter" ); - return; - } - imageActor.SetBlendMode( static_cast( mode ) ); - -} - -/** - * @for ImageActor - * @method getBlendMode - * @return { Number } blendMode - * @example returns one of the following: - * - * dali.BLENDING_OFF // Blending is disabled. - * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel. - * dali.BLENDING_ON // Blending is enabled. - * - */ -void ImageActorApi::GetBlendMode( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - args.GetReturnValue().Set( v8::Integer::New( isolate, imageActor.GetBlendMode() ) ); - -} - -/** - * @for ImageActor - * @method setBlendFunc - * @param {Number} SourceBlending RGB - * @param {Number} DestinationBlending RGB - * @param {Number} SourceBlending Alpha - * @param {Number} DestinatinoBlending Alpha - * @example - * //blending constants - dali.BLEND_FACTOR_ZERO - dali.BLEND_FACTOR_ONE - dali.BLEND_FACTOR_SRC_COLOR - dali.BLEND_FACTOR_ONE_MINUS_SRC_COLOR - dali.BLEND_FACTOR_SRC_ALPHA - dali.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA - dali.BLEND_FACTOR_DST_ALPHA - dali.BLEND_FACTOR_ONE_MINUS_DST_ALPHA - dali.BLEND_FACTOR_DST_COLOR - dali.BLEND_FACTOR_ONE_MINUS_DST_COLOR - dali.BLEND_FACTOR_SRC_ALPHA_SATURATE - dali.BLEND_FACTOR_CONSTANT_COLOR - dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR - dali.BLEND_FACTOR_CONSTANT_ALPHA - dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA - - actor.setBlendFunc( dali.BLEND_FACTOR_CONSTANT_COLOR, BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR, - dali.BLEND_FACTOR_CONSTANT_ALPHA, BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA); - - ); - */ -void ImageActorApi::SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - int params[4]; - bool foundAllParams(false); - V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 4, args,0 ); - if( foundAllParams ) - { - imageActor.SetBlendFunc( static_cast< Dali::BlendingFactor::Type>(params[0]), - static_cast< Dali::BlendingFactor::Type>(params[1]), - static_cast< Dali::BlendingFactor::Type>(params[2]), - static_cast< Dali::BlendingFactor::Type>(params[3])); - } - else - { - DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendMode parameter"); - return; - } -} - -/** - * @for ImageActor - * @method GetBlendFunc - * @return {Object} BlendProperties - * @example Blend properties object has 4 fields - * - * blendProperties.sourceRgb // source rgb enum - * blendProperties.destinationRgb // destination rgb enum - * blendProperties.sourceAlpha source // alpha enum - * blendProperties.destinationAlpha // destination alpha enum - */ -void ImageActorApi::GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - // @todo pass by reference doesn't work in Javascript so need to decide what to return - // for now just return a vector 4... - - BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha; - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - imageActor.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); - - v8::Local blendInfo = v8::Object::New( isolate ); - - blendInfo->Set( v8::String::NewFromUtf8( isolate, "sourceRgb" ), v8::Integer::New( isolate, srcFactorRgb) ); - blendInfo->Set( v8::String::NewFromUtf8( isolate, "destinationRgb" ), v8::Integer::New( isolate, destFactorRgb ) ); - blendInfo->Set( v8::String::NewFromUtf8( isolate, "sourceAlpha" ), v8::Integer::New( isolate, srcFactorAlpha ) ); - blendInfo->Set( v8::String::NewFromUtf8( isolate, "destinationAlpha" ), v8::Integer::New( isolate, destFactorAlpha ) ); - - args.GetReturnValue().Set( blendInfo ); - -} - -/** - * @for ImageActor - * @method getShaderEffect - * @return {Object} ShaderEffect object - * - * Retrieve the shader effect for the Actor. - * - * @example - * var shaderEffect = actor.getShaderEffect(); - * - */ -void ImageActorApi::GetShaderEffect( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - v8::Local < v8::Object > object = ShaderEffectWrapper::WrapShaderEffect( isolate, imageActor.GetShaderEffect() ); - args.GetReturnValue().Set( object ); - -} - -/** - * @for ImageActor - * @method setShaderEffect - * @param {Object} shaderEffect The shader effect. - * - * Sets the shader effect for the Actor. - * - * Shader effects provide special effects like rippling and bending. - * Setting a shader effect removes any shader effect previously set by SetShaderEffect. - * @example - * // first create the shaderOptions, then the shaderEffect - * var shader = new dali.ShaderEffect( shaderOptions ); - * actor.setShaderEffect( shader ); - * - */ -void ImageActorApi::SetShaderEffect( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - - bool found( false ); - ShaderEffect effect = ShaderEffectApi::GetShaderEffectFromParams( 0, found, isolate, args ); - if( found ) - { - imageActor.SetShaderEffect( effect ); - } - else - { - DALI_SCRIPT_EXCEPTION( isolate, "shader effect parameter missing" ); - } -} - -/** - * - * Removes the current shader effect - * - * @example - * actor.removeShaderEffect(); - * - * @for ImageActor - * @method removeShaderEffect - */ -void ImageActorApi::RemoveShaderEffect( const v8::FunctionCallbackInfo& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ImageActor imageActor = GetImageActor( isolate, args ); - imageActor.RemoveShaderEffect(); -} - -} // namespace V8Plugin - -} // namespace Dali diff --git a/plugins/dali-script-v8/src/actors/image-actor-api.h b/plugins/dali-script-v8/src/actors/image-actor-api.h deleted file mode 100644 index f5974e0..0000000 --- a/plugins/dali-script-v8/src/actors/image-actor-api.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __DALI_V8PLUGIN_IMAGE_ACTOR_API_H__ -#define __DALI_V8PLUGIN_IMAGE_ACTOR_API_H__ - -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace ImageActorApi -{ - - /** - * constructor - */ - Actor New( const v8::FunctionCallbackInfo< v8::Value >& args ); - - /** - * ImageActorApi API see image-actor.h for a description - * Most of the API is covered by the property system - */ - void SetImage( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetImage( const v8::FunctionCallbackInfo< v8::Value >& args ); - void SetSortModifier( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetSortModifier( const v8::FunctionCallbackInfo< v8::Value >& args ); - void SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args ); - void SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetShaderEffect( const v8::FunctionCallbackInfo< v8::Value >& args ); - void SetShaderEffect( const v8::FunctionCallbackInfo< v8::Value >& args ); - void RemoveShaderEffect( const v8::FunctionCallbackInfo< v8::Value >& args ); -}; // namespace ImageActorApi - -} // namespace V8Plugin - -} // namespace Dali - -#endif // header __DALI_V8PLUGIN_IMAGE_ACTOR_API_H__ diff --git a/plugins/dali-script-v8/src/animation/animation-api.cpp b/plugins/dali-script-v8/src/animation/animation-api.cpp index e3fc2d7..0db4482 100644 --- a/plugins/dali-script-v8/src/animation/animation-api.cpp +++ b/plugins/dali-script-v8/src/animation/animation-api.cpp @@ -245,7 +245,7 @@ bool GetAnimationParameters( v8::Isolate* isolate, AnimationParameters& animParams, AnimationApi::AnimationParameterType type) { - // used for things like anim.AnimateBy( myImageActor, property-name, property-value (or Javascript number array)); + // used for things like anim.AnimateBy( myImageView, property-name, property-value (or Javascript number array)); // 1 extract property handle from param1. // 2 extract property name from param2 ( in the format "uColor" ) // 3 extract PropertyValue from param3 diff --git a/plugins/dali-script-v8/src/constants/constants-wrapper.cpp b/plugins/dali-script-v8/src/constants/constants-wrapper.cpp index 162db9e..acaacb6 100644 --- a/plugins/dali-script-v8/src/constants/constants-wrapper.cpp +++ b/plugins/dali-script-v8/src/constants/constants-wrapper.cpp @@ -159,15 +159,9 @@ const IntegerPair EnumTable[] = { "DRAW_MODE_OVERLAY_2D", DrawMode::OVERLAY_2D }, { "DRAW_MODE_STENCIL", DrawMode::STENCIL }, - { "IMAGE_LOAD_POLICY_IMMEDIATE", ResourceImage::IMMEDIATE }, - { "IMAGE_LOAD_POLICY_ON_DEMAND", ResourceImage::ON_DEMAND }, - - { "IMAGE_RELEASE_POLICY_UNUSED", Image::UNUSED }, - { "IMAGE_RELEASE_POLICY_NEVER", Image::NEVER }, - { "RESOURCE_LOADING", Dali::ResourceLoading }, { "RESOURCE_LOADING_SUCCEEDED", Dali::ResourceLoadingSucceeded }, - { "RESOUCE_LOADING_FAILED", Dali::ResourceLoadingFailed }, + { "RESOURCE_LOADING_FAILED", Dali::ResourceLoadingFailed }, { "FITTING_MODE_SHRINK_TO_FIT", FittingMode::SHRINK_TO_FIT }, { "FITTING_MODE_SCALE_TO_FILL", FittingMode::SCALE_TO_FILL }, @@ -211,10 +205,6 @@ const IntegerPair EnumTable[] = { "CAMERA_PERSPECTIVE_PROJECTION" , Camera::PERSPECTIVE_PROJECTION }, { "CAMERA_ORTHOGRAPHIC_PROJECTION", Camera::ORTHOGRAPHIC_PROJECTION }, - {"IMAGE_ACTOR_STYLE_QUAD", ImageActor::STYLE_QUAD}, - {"IMAGE_ACTOR_STYLE_NINE_PATCH", ImageActor::STYLE_NINE_PATCH}, - {"IMAGE_ACTOR_STYLE_NINE_PATCH_NO_CENTER",ImageActor::STYLE_NINE_PATCH_NO_CENTER }, - { "FILTER_MODE_NONE", FilterMode::NONE }, { "FILTER_MODE_DEFAULT", FilterMode::DEFAULT }, { "FILTER_MODE_NEAREST", FilterMode::NEAREST }, diff --git a/plugins/dali-script-v8/src/dali-wrapper.cpp b/plugins/dali-script-v8/src/dali-wrapper.cpp index cc905a3..132dc5e 100644 --- a/plugins/dali-script-v8/src/dali-wrapper.cpp +++ b/plugins/dali-script-v8/src/dali-wrapper.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -69,16 +68,13 @@ const ApiFunction ConstructorFunctionTable[]= { "PathConstrainer", PathConstrainerWrapper::NewPathConstrainer}, { "LinearConstrainer", LinearConstrainerWrapper::NewLinearConstrainer}, { "Actor", ActorWrapper::NewActor }, - { "ImageActor", ActorWrapper::NewActor }, { "CameraActor", ActorWrapper::NewActor }, { "Layer", ActorWrapper::NewActor }, { "Control", ActorWrapper::NewControl }, { "ResourceImage", ImageWrapper::NewImage }, { "BufferImage", ImageWrapper::NewImage }, - { "NinePatchImage", ImageWrapper::NewImage }, { "FrameBufferImage", ImageWrapper::NewImage }, { "Animation", AnimationWrapper::NewAnimation}, - { "ShaderEffect", ShaderEffectWrapper::NewShaderEffect}, { "Shader", ShaderWrapper::NewShader}, { "Sampler", SamplerWrapper::NewSampler}, { "Material", MaterialWrapper::NewMaterial}, diff --git a/plugins/dali-script-v8/src/image/buffer-image-api.cpp b/plugins/dali-script-v8/src/image/buffer-image-api.cpp index ac07889..91075e9 100644 --- a/plugins/dali-script-v8/src/image/buffer-image-api.cpp +++ b/plugins/dali-script-v8/src/image/buffer-image-api.cpp @@ -31,7 +31,7 @@ namespace V8Plugin /** * ## BufferImage - * Bitmap represents an image resource that can be added to ImageActors. + * Bitmap represents an image resource that can be added to Material. * Its pixel buffer data is provided by the application developer. * * If the pixel format of the pixel buffer contains an alpha channel, diff --git a/plugins/dali-script-v8/src/image/frame-buffer-image-api.cpp b/plugins/dali-script-v8/src/image/frame-buffer-image-api.cpp index eb7f546..252bf0d 100644 --- a/plugins/dali-script-v8/src/image/frame-buffer-image-api.cpp +++ b/plugins/dali-script-v8/src/image/frame-buffer-image-api.cpp @@ -37,7 +37,7 @@ namespace FrameBufferImageApi /** * FrameBufferImage represents a GLES Frame Buffer Object and contains the result * of an 'off screen' render pass of a RenderTask. - * The FrameBufferImage can then be used with an ImageActor (with optional shader + * The FrameBufferImage can then be used with a Material (with optional shader * effects) and rendered to the screen. * @class FrameBufferImage * @extends Image diff --git a/plugins/dali-script-v8/src/image/image-api.cpp b/plugins/dali-script-v8/src/image/image-api.cpp index e57d3a3..04b60a0 100644 --- a/plugins/dali-script-v8/src/image/image-api.cpp +++ b/plugins/dali-script-v8/src/image/image-api.cpp @@ -55,22 +55,6 @@ Image ImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) } /** - * Return the image release policy - * @method getReleasePolicy - * @return dali.IMAGE_RELEASE_POLICY_UNUSED or dali.IMAGE_RELEASE_POLICY_NEVER - * @for Image - */ -void ImageApi::GetReleasePolicy( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - Image image = GetImage( isolate, args ); - - args.GetReturnValue().Set( v8::Integer::New( isolate, image.GetReleasePolicy() ) ); -} - -/** * Return the image width in pixels * @method getWidth * @for Image diff --git a/plugins/dali-script-v8/src/image/image-api.h b/plugins/dali-script-v8/src/image/image-api.h index 4f62c81..5985dd7 100644 --- a/plugins/dali-script-v8/src/image/image-api.h +++ b/plugins/dali-script-v8/src/image/image-api.h @@ -45,7 +45,6 @@ namespace ImageApi /** * Image API see image.h for a description */ - void GetReleasePolicy( const v8::FunctionCallbackInfo< v8::Value >& args ); void GetWidth( const v8::FunctionCallbackInfo< v8::Value >& args ); void GetHeight( const v8::FunctionCallbackInfo< v8::Value >& args ); diff --git a/plugins/dali-script-v8/src/image/image-wrapper.cpp b/plugins/dali-script-v8/src/image/image-wrapper.cpp index 6206fe4..2ada2c7 100644 --- a/plugins/dali-script-v8/src/image/image-wrapper.cpp +++ b/plugins/dali-script-v8/src/image/image-wrapper.cpp @@ -24,9 +24,7 @@ #include #include #include -#include #include -#include #include #include @@ -38,10 +36,8 @@ namespace V8Plugin v8::Persistent ImageWrapper::mImageTemplate; v8::Persistent ImageWrapper::mResourceImageTemplate; -v8::Persistent ImageWrapper::mNinePatchImageTemplate; v8::Persistent ImageWrapper::mBufferImageTemplate; v8::Persistent ImageWrapper::mFrameBufferImageTemplate; -v8::Persistent ImageWrapper::mNativeImageTemplate; /** * pointer to a persistent template handle @@ -58,10 +54,8 @@ const ImageTemplate ImageTemplateLookup[]= { { &ImageWrapper::mImageTemplate }, // IMAGE { &ImageWrapper::mResourceImageTemplate }, // RESOURCE_IMAGE - { &ImageWrapper::mNinePatchImageTemplate }, // NINE PATCH IMAGE { &ImageWrapper::mBufferImageTemplate }, // BITMAP_IMAGE { &ImageWrapper::mFrameBufferImageTemplate }, // FRAME_BUFFER_IMAGE - { &ImageWrapper::mNativeImageTemplate }, // NATIVE_IMAGE }; @@ -77,9 +71,7 @@ enum ImageApiBitMask IMAGE_API = 1 << 0, BITMAP_IMAGE_API = 1 << 1, RESOURCE_IMAGE_API = 1 << 2, - NINE_PATCH_IMAGE_API = 1 << 3, - FRAME_BUFFER_IMAGE_API = 1 << 4, - NATIVE_IMAGE_API = 1 << 5, + FRAME_BUFFER_IMAGE_API = 1 << 3, }; @@ -101,11 +93,8 @@ const ImageApiStruct ImageApiLookup[]= { {"Image", ImageWrapper::IMAGE, ImageApi::New, IMAGE_API }, {"ResourceImage", ImageWrapper::RESOURCE_IMAGE, ResourceImageApi::New, IMAGE_API | RESOURCE_IMAGE_API }, - {"NinePatchImage", ImageWrapper::NINE_PATCH_IMAGE, NinePatchImageApi::New, IMAGE_API | RESOURCE_IMAGE_API | NINE_PATCH_IMAGE_API }, {"BufferImage", ImageWrapper::BITMAP_IMAGE, BufferImageApi::New, IMAGE_API | BITMAP_IMAGE_API }, {"FrameBufferImage",ImageWrapper::FRAME_BUFFER_IMAGE, FrameBufferImageApi::New, IMAGE_API | FRAME_BUFFER_IMAGE_API }, - {"NativeImage", ImageWrapper::NATIVE_IMAGE, NativeImageApi::New, IMAGE_API | NATIVE_IMAGE_API }, - }; const unsigned int ImageApiLookupCount = sizeof(ImageApiLookup)/sizeof(ImageApiLookup[0]); @@ -140,18 +129,12 @@ const ImageFunctions ImageFunctionTable[]= **************************************/ { "GetWidth", ImageApi::GetWidth , IMAGE_API }, { "GetHeight", ImageApi::GetHeight, IMAGE_API }, - { "GetReleasePolicy", ImageApi::GetReleasePolicy, IMAGE_API }, // resource-image API { "GetLoadingState", ResourceImageApi::GetLoadingState, RESOURCE_IMAGE_API }, { "GetUrl", ResourceImageApi::GetUrl, RESOURCE_IMAGE_API }, - { "GetLoadPolicy", ResourceImageApi::GetLoadPolicy, RESOURCE_IMAGE_API }, { "Reload", ResourceImageApi::Reload, RESOURCE_IMAGE_API }, - // nine-patch API - { "GetChildRectangle", NinePatchImageApi::GetChildRectangle, NINE_PATCH_IMAGE_API }, - { "CreateCroppedBufferImage",NinePatchImageApi::CreateCroppedBufferImage, NINE_PATCH_IMAGE_API }, - // buffer image API { "GetBuffer", BufferImageApi::GetBuffer, BITMAP_IMAGE_API }, { "GetBufferSize", BufferImageApi::GetBufferSize, BITMAP_IMAGE_API }, @@ -232,8 +215,7 @@ v8::Handle ImageWrapper::MakeImageTemplate( v8::Isolate* iso // add intercepts for Signals on ResourceImage, we can't use HandleWrapper::AddIntercepts because Image doesn't inherit // from Handle ( just baseHandle) - if (( imageType == RESOURCE_IMAGE ) || - ( imageType == NINE_PATCH_IMAGE )) + if ( imageType == RESOURCE_IMAGE ) { ObjectTemplateHelper::AddSignalConnectAndDisconnect( isolate, objTemplate ); } diff --git a/plugins/dali-script-v8/src/image/image-wrapper.h b/plugins/dali-script-v8/src/image/image-wrapper.h index 7644b00..d6d461d 100644 --- a/plugins/dali-script-v8/src/image/image-wrapper.h +++ b/plugins/dali-script-v8/src/image/image-wrapper.h @@ -52,10 +52,8 @@ public: UNKNOWN_IMAGE_TYPE = -1, IMAGE = 0, RESOURCE_IMAGE = 1, - NINE_PATCH_IMAGE = 2, - BITMAP_IMAGE = 3, - FRAME_BUFFER_IMAGE = 4, - NATIVE_IMAGE = 5 + BITMAP_IMAGE = 2, + FRAME_BUFFER_IMAGE = 3 }; /** @@ -102,10 +100,8 @@ public: // keep generating them everytime we want to create an Image static v8::Persistent mImageTemplate; static v8::Persistent mResourceImageTemplate; - static v8::Persistent mNinePatchImageTemplate; static v8::Persistent mBufferImageTemplate; static v8::Persistent mFrameBufferImageTemplate; - static v8::Persistent mNativeImageTemplate; private: diff --git a/plugins/dali-script-v8/src/image/native-image-api.cpp b/plugins/dali-script-v8/src/image/native-image-api.cpp deleted file mode 100644 index a09ebca..0000000 --- a/plugins/dali-script-v8/src/image/native-image-api.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include "frame-buffer-image-api.h" - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include -#include - - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace NativeImageApi -{ - -/** - * ## NativeImage **Not Supported** - * NativeImage represents an image resource that can be added to ImageActors. - * Its data is provided by native resources, such as shared bitmap memory or pixmap from X11 or ECORE-X11, etc. - * @class NativeImage - * @extends Image - */ - -/** - * **Currently not supported. This is a Place holder** - * @constructor - * @method NativeImage - * @for NativeImage - * @return {Object} Image - */ -Image New( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - // return empty image handle - return NativeImage(); -} - -} // NativeImageApi - -} // namespace V8Plugin - -} // namespace Dali diff --git a/plugins/dali-script-v8/src/image/native-image-api.h b/plugins/dali-script-v8/src/image/native-image-api.h deleted file mode 100644 index 609cc39..0000000 --- a/plugins/dali-script-v8/src/image/native-image-api.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __DALI_V8PLUGIN_NATIVE_IMAGE_API_H__ -#define __DALI_V8PLUGIN_NATIVE_IMAGE_API_H__ - -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace NativeImageApi -{ - - /** - * Constructor - */ - Image New( const v8::FunctionCallbackInfo< v8::Value >& args ); - - -}; // namespace NativeImageApi - -} // namespace V8Plugin - -} // namespace Dali - -#endif // header __DALI_V8PLUGIN_NATIVE_IMAGE_API_H__ diff --git a/plugins/dali-script-v8/src/image/nine-patch-image-api.cpp b/plugins/dali-script-v8/src/image/nine-patch-image-api.cpp deleted file mode 100644 index ad4a51b..0000000 --- a/plugins/dali-script-v8/src/image/nine-patch-image-api.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include "nine-patch-image-api.h" - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -/** - * - * NinePatchImage represents an image resource that can be added to ImageActors. - * It contains a bitmap that is synchronously loaded from the file system that contains - * a 9 patch border - a 1 pixel border that describes the stretch borders and the child - * area. - * - * The class offers an API to read the stretch area and child area, but it does not - * remove the border from it's bitmap. An API can be used to obtain a BufferImage with - * the border removed. - * - * Adding this image to an ImageActor using an Image handle will automatically convert - * to use the cropped BufferImage - if you don't retain a handle to this object, it will - * be automatically destroyed. - * @class NinePatchImage - * @extends ResourceImage - */ - -NinePatchImage NinePatchImageApi::GetNinePatchImage( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::HandleScope handleScope( isolate ); - - v8::Local object = args.This(); - v8::Local field = v8::Local::Cast( object->GetInternalField(0) ); - void* ptr = field->Value(); - - ImageWrapper* wrapper = static_cast< ImageWrapper *>(ptr); - return NinePatchImage ::DownCast( wrapper->GetImage() ); -} - - -/** - * Create a new nine patch image object. - * - * @constructor - * @method NinePatchImage - * @for NinePatchImage - * @param {Object} options - * @param {String} options.url The URL of the nine patch image file to use. - * @return {Object} Image - */ -Image NinePatchImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - std::string url; - v8::Local options( args[0] ); - - if( !options->IsObject() ) - { - DALI_SCRIPT_EXCEPTION( isolate, "Missing params"); - return NinePatchImage(); - } - - v8::Local optionsObject = options->ToObject(); - - v8::Local urlValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "url" ) ); - if( urlValue->IsString() ) - { - url = V8Utils::v8StringToStdString( urlValue ); - } - else - { - DALI_SCRIPT_EXCEPTION( isolate, "Missing url"); - return NinePatchImage(); - } - - return NinePatchImage::New( url ); -} - -/** - * Get the child rectangle - * @method getChildRectangle - * @for NinePatchImage - * @return {Object} position/size of of the child rectangle with x,y,w,h properties - * - */ -void NinePatchImageApi::GetChildRectangle( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - NinePatchImage image = GetNinePatchImage( isolate, args ); - - v8::Local rectObject = v8::Object::New( isolate ); - Rect childRect = image.GetChildRectangle(); - - rectObject->Set( v8::String::NewFromUtf8( isolate, "x" ), v8::Integer::New( isolate,childRect.x ) ); - rectObject->Set( v8::String::NewFromUtf8( isolate, "y" ), v8::Integer::New( isolate,childRect.y ) ); - rectObject->Set( v8::String::NewFromUtf8( isolate, "w" ), v8::Integer::New( isolate,childRect.width ) ); - rectObject->Set( v8::String::NewFromUtf8( isolate, "h" ), v8::Integer::New( isolate,childRect.height ) ); - - args.GetReturnValue().Set( rectObject ); -} - -/** - * Creates a buffer image from the bitmap with the 1 pixel border cropped off. - * This does not change the internal bitmap. - * @method createCroppedBufferImage - * @for NinePatchImage - */ -void NinePatchImageApi::CreateCroppedBufferImage( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - Image image = GetNinePatchImage( isolate, args ); - - args.GetReturnValue().Set( v8::Integer::New( isolate, image.GetWidth() ) ); -} - - -} // namespace V8Plugin - -} // namespace Dali diff --git a/plugins/dali-script-v8/src/image/nine-patch-image-api.h b/plugins/dali-script-v8/src/image/nine-patch-image-api.h deleted file mode 100644 index 1a51d8c..0000000 --- a/plugins/dali-script-v8/src/image/nine-patch-image-api.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __DALI_V8PLUGIN_NINE_PATCH_IMAGE_API_H__ -#define __DALI_V8PLUGIN_NINE_PATCH_IMAGE_API_H__ - -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace NinePatchImageApi -{ - /** - * Helper - */ - NinePatchImage GetNinePatchImage( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ); - - - /** - * Constructor - */ - Image New( const v8::FunctionCallbackInfo< v8::Value >& args ); - - - /** - * Ninepatch Image API see nine-patch-image.h for a description - */ - void GetChildRectangle( const v8::FunctionCallbackInfo< v8::Value >& args ); - void CreateCroppedBufferImage( const v8::FunctionCallbackInfo< v8::Value >& args ); - -}; // namespace NinePatchImageApi - -} // namespace V8Plugin - -} // namespace Dali - -#endif // header __DALI_V8PLUGIN_NINE_PATCH_IMAGE_API_H__ diff --git a/plugins/dali-script-v8/src/image/resource-image-api.cpp b/plugins/dali-script-v8/src/image/resource-image-api.cpp index 8e7df33..c119b53 100644 --- a/plugins/dali-script-v8/src/image/resource-image-api.cpp +++ b/plugins/dali-script-v8/src/image/resource-image-api.cpp @@ -51,8 +51,8 @@ ResourceImage ResourceImageApi::GetResourceImage( v8::Isolate* isolate, const v8 * @for ResourceImage * @param {Object} options * @param {String} options.url The URL of the image file to use. - * @param {Integer} [options.loadPolicy] The LoadPolicy to apply when loading the image resource. - * @param {Integer} [options.releasePolicy] optionally release memory when image is not visible on screen. + * @param {Float} options.width The width to fit the loaded image to + * @param {Float} options.height The height to fit the loaded image to * @return {Object} Image */ Image ResourceImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) @@ -62,12 +62,6 @@ Image ResourceImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) std::string url; ImageDimensions dimensions; - FittingMode::Type fittingMode = FittingMode::DEFAULT; - SamplingMode::Type samplingMode = SamplingMode::DEFAULT; - bool orientationCorrection = true; - ResourceImage::LoadPolicy loadPolicy( ResourceImage::IMMEDIATE ); - Image::ReleasePolicy releasePolicy( Image::NEVER); - v8::Local options( args[0] ); if( !options->IsObject() ) @@ -103,54 +97,7 @@ Image ResourceImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) dimensions = ImageDimensions( dimensions.GetWidth(), height ); } - v8::Local fittingModeValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "fittingMode" ) ); - if( fittingModeValue->IsUint32() ) - { - fittingMode = static_cast( fittingModeValue->ToUint32()->Value() ); - } - - v8::Local samplingModeValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "samplingMode" ) ); - if( samplingModeValue->IsUint32() ) - { - samplingMode = static_cast( samplingModeValue->ToUint32()->Value() ); - } - - v8::Local orientationCorrectionValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "orientationCorrection" ) ); - if( orientationCorrectionValue->IsBoolean() ) - { - orientationCorrection = orientationCorrectionValue->ToBoolean()->Value(); - } - - v8::Local releasePolicyValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "releasePolicy" ) ); - if( releasePolicyValue->IsUint32() ) - { - releasePolicy = static_cast( releasePolicyValue->ToUint32()->Value() ); - } - - v8::Local loadPolicyValue = optionsObject->Get( v8::String::NewFromUtf8( isolate, "loadPolicy" ) ); - if( loadPolicyValue->IsUint32() ) - { - loadPolicy = static_cast< ResourceImage::LoadPolicy >( loadPolicyValue->ToUint32()->Value()); - } - - return ResourceImage::New( url, loadPolicy, releasePolicy, dimensions, fittingMode, samplingMode, orientationCorrection ); -} - -/** - * Get the load policy - * - * @method getLoadPolicy - * @for ResourceImage - * @return {Integer} load policy either dali.IMAGE_LOAD_POLICY_ON_DEMAND or dali.IMAGE_LOAD_POLICY_IMMEDIATE - */ -void ResourceImageApi::GetLoadPolicy( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - ResourceImage image = GetResourceImage( isolate, args ); - - args.GetReturnValue().Set( v8::Integer::New( isolate, image.GetLoadPolicy() ) ); + return ResourceImage::New( url, dimensions ); } /** diff --git a/plugins/dali-script-v8/src/image/resource-image-api.h b/plugins/dali-script-v8/src/image/resource-image-api.h index a9af141..5912975 100644 --- a/plugins/dali-script-v8/src/image/resource-image-api.h +++ b/plugins/dali-script-v8/src/image/resource-image-api.h @@ -45,7 +45,6 @@ namespace ResourceImageApi /** * Resource Image API see resource-image.h for a description */ - void GetLoadPolicy( const v8::FunctionCallbackInfo< v8::Value >& args ); void GetLoadingState( const v8::FunctionCallbackInfo< v8::Value >& args ); void GetUrl( const v8::FunctionCallbackInfo< v8::Value >& args ); void Reload( const v8::FunctionCallbackInfo< v8::Value >& args ); diff --git a/plugins/dali-script-v8/src/module-loader/module-loader.cpp b/plugins/dali-script-v8/src/module-loader/module-loader.cpp index 6623374..0c993d4 100644 --- a/plugins/dali-script-v8/src/module-loader/module-loader.cpp +++ b/plugins/dali-script-v8/src/module-loader/module-loader.cpp @@ -173,23 +173,24 @@ bool ModuleLoader::ExecuteScriptFromFile( v8::Isolate* isolate, * #### Exporting as a constructor * * - * // ImageActor.js - * function ImageActor( position, orientation, image, name ) + * // ImageView.js + * function ImageView( position, orientation, image, name ) * { - * this = new dali.ImageActor( image ); + * this = new dali.Control("ImageView"); + * this.image = image; * this.position = position; * this.orientation = orientation; * this.name = name; * } - * module.exports = ImageActor; + * module.exports = ImageView; * *
* * // main.js * - * var ImageActor = require(" ImageActor.js"); + * var ImageView = require(" ImageView.js"); * - * var imageActor = new ImageActor( position, orientation, image, "my first image actor"); + * var imageView = new ImageView( position, orientation, image, "my first image actor"); * * #### Exporting as a singleton * diff --git a/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp b/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp deleted file mode 100644 index ea2df91..0000000 --- a/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -// CLASS HEADER -#include "shader-effect-api.h" - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace // un named namespace -{ - -typedef std::vector< std::string > HintsArray; - -struct GeometryHintPair -{ - const char* name; - ShaderEffect::GeometryHints hint; -}; - -const GeometryHintPair GeometryHintTable[]= -{ - {"gridX", ShaderEffect::HINT_GRID_X }, - {"gridY", ShaderEffect::HINT_GRID_Y }, - {"grid", ShaderEffect::HINT_GRID }, - {"depthBuffer", ShaderEffect::HINT_DEPTH_BUFFER }, - {"blending", ShaderEffect::HINT_BLENDING }, - {"doesntModifyGeometry", ShaderEffect::HINT_DOESNT_MODIFY_GEOMETRY } -}; - -const unsigned int GeometryHintTableCount = sizeof(GeometryHintTable)/sizeof(GeometryHintTable[0]); - - - - -struct ShaderParameters -{ - ShaderParameters() - : mHints( ShaderEffect::HINT_NONE ) - { - } - - ShaderEffect::GeometryHints GetGeometryHint( const std::string& hint ) - { - for( unsigned int i = 0 ; i < GeometryHintTableCount; ++i ) - { - if( hint == GeometryHintTable[i].name ) - { - return GeometryHintTable[i].hint; - } - } - return ShaderEffect::HINT_NONE; - } - - void ProcessHintsArray( const HintsArray& hintsArray ) - { - for( HintsArray::const_iterator iter = hintsArray.begin(); iter != hintsArray.end() ; ++iter ) - { - mHints= static_cast( mHints | GetGeometryHint( *iter ) ); - } - } - - ShaderEffect NewShader() - { - return ShaderEffect::NewWithPrefix( mVertexPrefix , - mVertex, - mFragmentPrefix, - mFragment, - mHints); - } - std::string mVertexPrefix; - std::string mVertex; - std::string mFragmentPrefix; - std::string mFragment; - ShaderEffect::GeometryHints mHints; -}; - -ShaderEffect GetShaderEffect( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::HandleScope handleScope( isolate ); - - v8::Local object = args.This(); - v8::Local field = v8::Local::Cast( object->GetInternalField(0) ); - void* ptr = field->Value(); - - ShaderEffectWrapper* wrapper = static_cast< ShaderEffectWrapper *>(ptr); - return wrapper->GetShaderEffect(); -} - -} // unnamed space - -/** - * Create a new ShaderEffect - * @constructor - * @for ShaderEffect - * @method ShaderEffect - * @param {Object} shaderOptions - * @param {String} [shaderOptions.geometryType] Type of geometry to be rendered with the effect. "image", "text", "mesh", "texturedMesh", default is image. - * @param {String} [shaderOptions.vertexShaderPrefix] This string will be inserted before the default uniforms for the vertex shader(ideal for #defines) - * @param {String} [shaderOptions.vertexShader] VertexShader code for the effect. If not defined, the default version will be used - * @param {String} [shaderOptions.fragmentShaderPrefix] This string will be inserted before the default uniforms for the fragment shader(ideal for #defines) - * @param {String} [shaderOptions.fragmentShader] FragmentShader code for the effect. If not defined, the default version will be used - * @param {Array} [shaderOptions.geometryHints] Hints for rendering the geometry, e.g. [ "gridX", "gridY", "grid","depthBuffer","blending","doesntModifyGeometry" ] - * @return {Object} ShaderEffect - * @example - - // this will match the default shaders for image - var vertexShader = " void main() \ - { \ - gl_Position = uProjection * uModelView * vec4(aPosition, 1.0); \ - vTexCoord = aTexCoord; \ - }; " - var fragShader = " void main() \ - { \ - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\ - }; " - var shaderOptions = { - geometryType: "image", - vertexShader: vertexShader, - fragmentShader: fragShader - }; - - var shader = new dali.ShaderEffect(shaderOptions); - - imageActor.setShaderEffect( shader ); - - * - * - * - */ -ShaderEffect ShaderEffectApi::New( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::HandleScope handleScope( isolate ); - - if( args[0]->IsObject() ) - { - ShaderParameters shaderParams; - - v8::Local obj = args[0]->ToObject(); - - v8::Local vertexPrefixValue = obj->Get(v8::String::NewFromUtf8( isolate, "vertexShaderPrefix")); - if( vertexPrefixValue->IsString() ) - { - shaderParams.mVertexPrefix = V8Utils::v8StringToStdString( vertexPrefixValue ); - } - - v8::Local fragmentPrefixValue = obj->Get(v8::String::NewFromUtf8( isolate, "fragmentShaderPrefix")); - if( fragmentPrefixValue->IsString() ) - { - shaderParams.mFragmentPrefix = V8Utils::v8StringToStdString( fragmentPrefixValue ); - } - - v8::Local vertexValue = obj->Get(v8::String::NewFromUtf8( isolate, "vertexShader")); - if( vertexValue->IsString() ) - { - shaderParams.mVertex = V8Utils::v8StringToStdString( vertexValue ); - } - - v8::Local fragmentValue = obj->Get(v8::String::NewFromUtf8( isolate, "fragmentShader")); - if( fragmentValue->IsString() ) - { - shaderParams.mFragment = V8Utils::v8StringToStdString( fragmentValue ); - } - // Get any hints - v8::Local hints = obj->Get(v8::String::NewFromUtf8( isolate, "geometryHints")); - if( hints->IsArray() ) - { - HintsArray hintsArray; - v8::Local array = v8::Local::Cast( hints ); - for( uint32_t i=0; i < array->Length(); ++i) - { - v8::Handle entry = array->Get( v8::Integer::New( isolate, i) ); - if( entry->IsString() ) - { - std::string entryString = V8Utils::v8StringToStdString( entry ); - hintsArray.push_back( entryString ); - } - } - shaderParams.ProcessHintsArray( hintsArray ); - } - - return shaderParams.NewShader(); - } - else - { - ShaderEffect effect; - - bool found( false ); - std::string typeName = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "string parameter missing" ); - } - else - { - // create a new shader effect based on type, using the type registry. - Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( typeName ); - if( typeInfo ) // handle, check if it has a value - { - Dali::BaseHandle handle = typeInfo.CreateInstance(); - if( handle ) - { - effect = ShaderEffect::DownCast( handle ); - } - } - else - { - DALI_SCRIPT_EXCEPTION(isolate,"Unknown shader effect type"); - } - } - - return effect; - } -} - -ShaderEffect ShaderEffectApi::GetShaderEffectFromParams( int paramIndex, - bool& found, - v8::Isolate* isolate, - const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - found = false; - - v8::HandleScope handleScope( isolate ); - BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::SHADER_EFFECT, isolate, args ); - if( wrappedObject ) - { - found = true; - ShaderEffectWrapper* wrapper = static_cast< ShaderEffectWrapper *>(wrappedObject); - return wrapper->GetShaderEffect(); - } - else - { - return ShaderEffect(); - } -} - -/** - * Set a shader effect image. - * This image texture will be bound to the "sEffect" sampler - * so it can be used in fragment shader for effects - * @method setEffectImage - * @for ShaderEffect - * @param {Object} image - * @example - * - * shader.setEffectImage( image ); - * - * // example of a fragment shader than can use the effect image (sEffect and main texture sTexture) - * - * "void main() \ - * { \ - * vec4 v4Color = (texture2D(sTexture, vTexCoord) * uColor); \ - * v4Color = v4Color* texture2D(sEffect, vTexCoord);\ - * gl_FragColor = v4Color; \" - * }"; - */ -void ShaderEffectApi::SetEffectImage( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - bool found( false ); - Image image = V8Utils::GetImageParameter( PARAMETER_0, found, isolate, args ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, " Image::SetEffectImage invalid params"); - return; - } - ShaderEffect effect = GetShaderEffect( isolate, args ); - effect.SetEffectImage( image ); -} - - -/** - * Sets and registers a uniform property. - * If name matches a uniform in the shader source, this value will be uploaded when rendering. - * This uniform can then be animated / modified and the change will be made to the shader. - * @method setUniform - * @for ShaderEffect - * @param {String} name - * @param {Object} value must be a: float, vector2 vector3, vector4, matrix - * @param {String} [uniformCoordinateType] The coordinate type of the uniform. - * either "viewPortPosition" or "viewPortDirection" - * @example - - var fragShader = - " uniform lowp vec4 uColorShift; \ - \ - void main() \ - { \ - - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor + uColorShift; \ - }" - - var shaderOptions = { - geometryType: "image", - fragmentShader: fragShader - }; - - // create a new shader effect - var shader = new dali.ShaderEffect(shaderOptions); - - // add the color shift uniform so we can animate it - // default the color shift to zero, so it has no effect - shader.setUniform("uColorShift", [0.0, 0.0, 0.0, 0]); - */ -void ShaderEffectApi::SetUniform( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - ShaderEffect effect = GetShaderEffect( isolate, args ); - - bool found(false); - std::string uniformName = V8Utils::GetStringParameter( PARAMETER_0 , found, isolate, args ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "SetUniform: uniform name not found\n"); - return; - } - - Property::Value propValue = V8Utils::GetPropertyValueParameter( PARAMETER_1 , found, isolate, args ); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "SetUniform: value not found\n"); - return; - } - - std::string coordinateType = V8Utils::GetStringParameter( PARAMETER_2, found, isolate, args ); - ShaderEffect::UniformCoordinateType uniformCoordinateType( ShaderEffect::COORDINATE_TYPE_DEFAULT ); - if( found ) - { - if( coordinateType == "viewPortPosition") - { - uniformCoordinateType = ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION; - } - else if ( coordinateType == "viewPortDirection ") - { - uniformCoordinateType = ShaderEffect::COORDINATE_TYPE_VIEWPORT_DIRECTION; - } - } - - switch( propValue.GetType() ) - { - case Property::FLOAT: - { - effect.SetUniform( uniformName, propValue.Get(), uniformCoordinateType ); - break; - } - case Property::VECTOR2: - { - effect.SetUniform( uniformName, propValue.Get(), uniformCoordinateType ); - break; - } - case Property::VECTOR3: - { - effect.SetUniform( uniformName, propValue.Get(), uniformCoordinateType ); - break; - } - case Property::VECTOR4: - { - effect.SetUniform( uniformName, propValue.Get(), uniformCoordinateType ); - break; - } - case Property::MATRIX: - { - effect.SetUniform( uniformName, propValue.Get(), uniformCoordinateType ); - break; - } - case Property::MATRIX3: - { - effect.SetUniform( uniformName, propValue.Get(), uniformCoordinateType ); - break; - } - default: - { - DALI_SCRIPT_EXCEPTION( isolate, "value type not recognised \n"); - break; - } - } -} - - -} // namespace V8Plugin - -} // namespace Dali diff --git a/plugins/dali-script-v8/src/shader-effects/shader-effect-api.h b/plugins/dali-script-v8/src/shader-effects/shader-effect-api.h deleted file mode 100644 index 3b2534a..0000000 --- a/plugins/dali-script-v8/src/shader-effects/shader-effect-api.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __DALI_V8PLUGIN_SHADER_EFFECT_API_H__ -#define __DALI_V8PLUGIN_SHADER_EFFECT_API_H__ - -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - - -namespace Dali -{ - -namespace V8Plugin -{ - -namespace ShaderEffectApi -{ - - /** - * Constructor - */ - ShaderEffect New( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ); - - ShaderEffect GetShaderEffectFromParams( int paramIndex, - bool& found, - v8::Isolate* isolate, - const v8::FunctionCallbackInfo< v8::Value >& args ); - - /** - * ShaderEffect API see shader-effect.h for a description - */ - void SetEffectImage( const v8::FunctionCallbackInfo< v8::Value >& args ); - void SetUniform( const v8::FunctionCallbackInfo< v8::Value >& args ); - -}; // namespace ShaderEffectApi - -} // namespace V8Plugin - -} // namespace Dali - -#endif // header __DALI_V8PLUGIN_SHADER_EFFECT_API_H__ diff --git a/plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.cpp b/plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.cpp deleted file mode 100644 index 89f4ebe..0000000 --- a/plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include "shader-effect-wrapper.h" - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace V8Plugin -{ - -v8::Persistent ShaderEffectWrapper::mShaderEffectTemplate; - -namespace // un-named name space -{ - -/** - * Contains a list of all functions that can be called - */ -const ApiFunction ShaderEffectFunctionTable[]= -{ - /************************************** - * ShaderEffect API (in order of shaderEffect.h) - **************************************/ - - { "SetEffectImage" , ShaderEffectApi::SetEffectImage }, - { "SetUniform" , ShaderEffectApi::SetUniform }, -}; - -const unsigned int ShaderEffectFunctionTableCount = sizeof(ShaderEffectFunctionTable)/sizeof(ShaderEffectFunctionTable[0]); -} //un-named space - - -ShaderEffectWrapper::ShaderEffectWrapper( const Dali::ShaderEffect& shaderEffect, GarbageCollectorInterface& gc ) -: HandleWrapper( BaseWrappedObject::SHADER_EFFECT , shaderEffect, gc ) -{ - mShaderEffect = shaderEffect; -} - -v8::Handle ShaderEffectWrapper::WrapShaderEffect(v8::Isolate* isolate, const Dali::ShaderEffect& shaderEffect ) -{ - v8::EscapableHandleScope handleScope( isolate ); - v8::Local objectTemplate; - - objectTemplate = GetShaderEffectTemplate( isolate); - - // create an instance of the template - v8::Local localObject = objectTemplate->NewInstance(); - - // create the ShaderEffect wrapper - ShaderEffectWrapper* pointer = new ShaderEffectWrapper( shaderEffect, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() ); - - // assign the JavaScript object to the wrapper. - pointer->SetJavascriptObject( isolate, localObject ); - - return handleScope.Escape( localObject ); -} - -v8::Local ShaderEffectWrapper::GetShaderEffectTemplate( v8::Isolate* isolate) -{ - v8::EscapableHandleScope handleScope( isolate ); - v8::Local objectTemplate; - - if( mShaderEffectTemplate.IsEmpty() ) - { - objectTemplate = MakeShaderEffectTemplate( isolate ); - mShaderEffectTemplate.Reset( isolate, objectTemplate ); - } - else - { - // get the object template - objectTemplate = v8::Local::New( isolate, mShaderEffectTemplate ); - } - return handleScope.Escape( objectTemplate ); -} - -v8::Handle ShaderEffectWrapper::MakeShaderEffectTemplate( v8::Isolate* isolate ) -{ - v8::EscapableHandleScope handleScope( isolate ); - - v8::Local objTemplate = v8::ObjectTemplate::New(); - - // property handle intercepts property getters and setters and signals - HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate ); - - objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT ); - - // add our function properties - ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, ShaderEffectFunctionTable, ShaderEffectFunctionTableCount ); - - return handleScope.Escape( objTemplate ); -} - -void ShaderEffectWrapper::NewShaderEffect( const v8::FunctionCallbackInfo< v8::Value >& args) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate); - - if(!args.IsConstructCall()) - { - DALI_SCRIPT_EXCEPTION( isolate, "ShaderEffect constructor called without 'new'"); - return; - } - Dali::ShaderEffect shaderEffect = ShaderEffectApi::New( isolate, args ); - - if(shaderEffect) - { - v8::Local localObject = WrapShaderEffect( isolate, shaderEffect ); - args.GetReturnValue().Set( localObject ); - } -} - - -ShaderEffect ShaderEffectWrapper::GetShaderEffect() -{ - return mShaderEffect; -} - - -} // namespace V8Plugin - -} // namespace Dali diff --git a/plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.h b/plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.h deleted file mode 100644 index 0a4f5f7..0000000 --- a/plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef __DALI_V8PLUGIN_SHADER_EFFECT_WRAPPER_H__ -#define __DALI_V8PLUGIN_SHADER_EFFECT_WRAPPER_H__ - -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace V8Plugin -{ - - -/** - * An ShaderEffect wrapper. - * Provides access to ShaderEffect specific functionality and V8 memory handling. - */ -class ShaderEffectWrapper : public HandleWrapper -{ - -public: - - ShaderEffectWrapper( const ShaderEffect& shaderEffect, - GarbageCollectorInterface& gc ); - - virtual ~ShaderEffectWrapper() - { - }; - - /** - * @brief Creates a new ShaderEffect wrapped inside a Javascript Object. - * @param[in] args v8 function call arguments interpreted - */ - static void NewShaderEffect( const v8::FunctionCallbackInfo< v8::Value >& args); - - /** - * Wraps a shaderEffect - */ - static v8::Handle WrapShaderEffect(v8::Isolate* isolate, const Dali::ShaderEffect& ); - - - // The ShaderEffectAttribute ObjectTemplate, we cache templates so we don't have - // keep generating them everytime we want to create an ShaderEffect - static v8::Persistent mShaderEffectTemplate; - - ShaderEffect GetShaderEffect(); - - -private: - - // ShaderEffect - ShaderEffect mShaderEffect; - - static v8::Handle MakeShaderEffectTemplate( v8::Isolate* isolate ); - static v8::Local GetShaderEffectTemplate( v8::Isolate* isolate ); - -}; - -} // namespace V8Plugin - -} // namespace Dali - -#endif // __DALI_V8PLUGIN_SHADER_EFFECT_WRAPPER_H__ diff --git a/plugins/dali-script-v8/src/shared/base-wrapped-object.h b/plugins/dali-script-v8/src/shared/base-wrapped-object.h index 3a0e9d9..db1c8a8 100644 --- a/plugins/dali-script-v8/src/shared/base-wrapped-object.h +++ b/plugins/dali-script-v8/src/shared/base-wrapped-object.h @@ -142,7 +142,7 @@ public: void SetJavascriptObject( v8::Isolate* isolate, v8::Local& object ); /** - * @return true if the object is of a certain wrapped type (e.g. ImageActor ) + * @return true if the object is of a certain wrapped type (e.g. Animation ) */ static bool IsWrappedType( v8::Isolate* isolate, const v8::Local& object, BaseWrappedObject::Type type); diff --git a/plugins/dali-script-v8/src/toolkit/builder/builder-api.cpp b/plugins/dali-script-v8/src/toolkit/builder/builder-api.cpp index 7af23dc..c5154ba 100644 --- a/plugins/dali-script-v8/src/toolkit/builder/builder-api.cpp +++ b/plugins/dali-script-v8/src/toolkit/builder/builder-api.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include @@ -293,11 +292,6 @@ void BuilderApi::Create( const v8::FunctionCallbackInfo< v8::Value >& args ) v8::Local image = ImageWrapper::WrapImage(isolate, Image::DownCast(handle) ); args.GetReturnValue().Set( image ); } - if( typeName == "ShaderEffect") - { - v8::Local shaderEffect = ShaderEffectWrapper::WrapShaderEffect(isolate, ShaderEffect::DownCast( handle )); - args.GetReturnValue().Set( shaderEffect ); - } if( typeName == "Shader") { v8::Local shader = ShaderWrapper::WrapShader(isolate, Shader::DownCast( handle )); @@ -426,26 +420,6 @@ void BuilderApi::CreateRenderTask( const v8::FunctionCallbackInfo< v8::Value >& } } -void BuilderApi::GetShaderEffect( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - Dali::Toolkit::Builder builder = GetBuilder( isolate, args ); - - bool found(false); - std::string str = V8Utils::GetStringParameter( 0, found, isolate, args ); - if( found ) - { - ShaderEffect handle = builder.GetShaderEffect( str ); - v8::Local shader = ShaderEffectWrapper::WrapShaderEffect(isolate, handle); - args.GetReturnValue().Set( shader ); - } - else - { - DALI_SCRIPT_EXCEPTION( isolate, "missing shader name"); - } -} - void BuilderApi::GetFrameBufferImage( const v8::FunctionCallbackInfo< v8::Value >& args ) { v8::Isolate* isolate = args.GetIsolate(); diff --git a/plugins/dali-script-v8/src/toolkit/builder/builder-api.h b/plugins/dali-script-v8/src/toolkit/builder/builder-api.h index 7a682f4..a53f4b1 100644 --- a/plugins/dali-script-v8/src/toolkit/builder/builder-api.h +++ b/plugins/dali-script-v8/src/toolkit/builder/builder-api.h @@ -52,7 +52,6 @@ namespace BuilderApi void ApplyFromJson(const v8::FunctionCallbackInfo< v8::Value >& args); void AddActors( const v8::FunctionCallbackInfo< v8::Value >& args ); void CreateRenderTask( const v8::FunctionCallbackInfo< v8::Value >& args ); - void GetShaderEffect( const v8::FunctionCallbackInfo< v8::Value >& args ); void GetFrameBufferImage( const v8::FunctionCallbackInfo< v8::Value >& args ); }; // namespace BuilderApi diff --git a/plugins/dali-script-v8/src/toolkit/builder/builder-wrapper.cpp b/plugins/dali-script-v8/src/toolkit/builder/builder-wrapper.cpp index 04617e3..d8c0f7f 100644 --- a/plugins/dali-script-v8/src/toolkit/builder/builder-wrapper.cpp +++ b/plugins/dali-script-v8/src/toolkit/builder/builder-wrapper.cpp @@ -51,7 +51,6 @@ const ApiFunction BuilderFunctionTable[]= { "ApplyFromJson" , BuilderApi::ApplyFromJson }, { "AddActors" , BuilderApi::AddActors }, { "CreateRenderTask" , BuilderApi::CreateRenderTask }, - { "GetShaderEffect" , BuilderApi::GetShaderEffect }, { "GetFrameBufferImage" , BuilderApi::GetFrameBufferImage } };