--- /dev/null
+g cube
+
+v 0.0 0.0 0.0
+v 0.0 0.0 1.0
+v 0.0 1.0 0.0
+v 0.0 1.0 1.0
+v 1.0 0.0 0.0
+v 1.0 0.0 1.0
+v 1.0 1.0 0.0
+v 1.0 1.0 1.0
+
+f 1 7 5
+f 1 3 7
+f 1 4 3
+f 1 2 4
+f 3 8 7
+f 3 4 8
+f 5 7 8
+f 5 8 6
+f 1 5 6
+f 1 6 2
+f 2 6 8
+f 2 8 4
utc-Dali-SuperBlurView.cpp
utc-Dali-Toolkit.cpp
utc-Dali-Model3dView.cpp
- utc-Dali-ControlRenderer.cpp
- utc-Dali-RendererFactory.cpp
- utc-Dali-DebugRenderer.cpp
+ utc-Dali-Visual.cpp
+ utc-Dali-VisualFactory.cpp
+ utc-Dali-DebugVisual.cpp
utc-Dali-ImageAtlas.cpp
utc-Dali-VideoView.cpp
)
inline void ClearStencil(GLint s)
{
+ std::stringstream out;
+ out << s;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["s"] = ToString( s );
+
+ mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams );
}
inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
{
+ mColorMaskParams.red = red;
+ mColorMaskParams.green = green;
+ mColorMaskParams.blue = blue;
+ mColorMaskParams.alpha = alpha;
}
inline void CompileShader(GLuint shader)
inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
{
+ std::stringstream out;
+ out << func << ", " << ref << ", " << mask;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["func"] = ToString( func );
+ namedParams["ref"] = ToString( ref );
+ namedParams["mask"] = ToString( mask );
+
+ mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
}
inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
{
+ std::stringstream out;
+ out << face << ", " << func << ", " << ref << ", " << mask;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["face"] = ToString( face );
+ namedParams["func"] = ToString( func );
+ namedParams["ref"] = ToString( ref );
+ namedParams["mask"] = ToString( mask );
+
+ mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
}
inline void StencilMask(GLuint mask)
{
+ std::stringstream out;
+ out << mask;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["mask"] = ToString( mask );
+
+ mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
}
inline void StencilMaskSeparate(GLenum face, GLuint mask)
{
+ std::stringstream out;
+ out << face << ", " << mask;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["face"] = ToString( face );
+ namedParams["mask"] = ToString( mask );
+
+ mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
}
inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
{
+ std::stringstream out;
+ out << fail << ", " << zfail << ", " << zpass;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["fail"] = ToString( fail );
+ namedParams["zfail"] = ToString( zfail );
+ namedParams["zpass"] = ToString( zpass );
+
+ mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
}
inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
{
+ std::stringstream out;
+ out << face << ", " << fail << ", " << zfail << "," << zpass;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["face"] = ToString( face );
+ namedParams["fail"] = ToString( fail );
+ namedParams["zfail"] = ToString( zfail );
+ namedParams["zpass"] = ToString( zpass );
+
+ mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
}
inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
+ //Methods for Stencil function verification
+ inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
+ inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
+ inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
+
template <typename T>
inline bool GetUniformValue( const char* name, T& value ) const
{
// Methods to check scissor tests
inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
+ struct ColorMaskParams
+ {
+ GLboolean red;
+ GLboolean green;
+ GLboolean blue;
+ GLboolean alpha;
+
+ ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
+ };
+
inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
inline unsigned int GetClearCountCalled() const { return mClearCount; }
+ inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
+
typedef std::vector<size_t> BufferDataCalls;
inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
TraceCallStack mTexParamaterTrace;
TraceCallStack mDrawTrace;
TraceCallStack mDepthFunctionTrace;
+ TraceCallStack mStencilFunctionTrace;
// Shaders & Uniforms
GLuint mLastShaderIdUsed;
}
ScissorParams mScissorParams;
+ ColorMaskParams mColorMaskParams;
};
template <>
-#ifndef __TEST_TRACE_CALL_STACK_H__
-#define __TEST_TRACE_CALL_STACK_H__
+#ifndef TEST_TRACE_CALL_STACK_H
+#define TEST_TRACE_CALL_STACK_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
#include <string>
#include <vector>
#include <map>
+#include <sstream>
namespace Dali
{
class TraceCallStack
{
public:
+
/// Typedef for passing and storing named parameters
typedef std::map< std::string, std::string > NamedParams;
*/
void Reset();
+ /**
+ * Method to display contents of the TraceCallStack.
+ * @return A string containing a list of function calls and parameters (may contain newline characters)
+ */
+ std::string GetTraceString()
+ {
+ std::stringstream traceStream;
+ int functionCount = mCallStack.size();
+ for( int i = 0; i < functionCount; ++i )
+ {
+ Dali::TraceCallStack::FunctionCall functionCall = mCallStack[ i ];
+ traceStream << "StackTrace: Index:" << i << ", Function:" << functionCall.method << ", ParamList:" << functionCall.paramList << std::endl;
+ }
+
+ return traceStream.str();
+ }
+
private:
bool mTraceActive; ///< True if the trace is active
} // namespace dali
-#endif //__TEST_TRACE_CALL_STACK_H__
+#endif // TEST_TRACE_CALL_STACK_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
Property::Map* resultMap = propValue.GetMap();
- DALI_TEST_CHECK( resultMap->Find( "rendererType" ) );
- DALI_TEST_CHECK( resultMap->Find( "rendererType" )->Get<std::string>() == "COLOR" );
- DALI_TEST_CHECK( resultMap->Find( "mixColor" ) );
- DALI_TEST_CHECK( resultMap->Find( "mixColor" )->Get<Vector4>() == Color::RED );
+ DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
+ DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
+ DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
+ DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::RED );
DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
propValue = control.GetProperty( Control::Property::BACKGROUND );
resultMap = propValue.GetMap();
- DALI_TEST_CHECK( resultMap->Find( "mixColor" ) );
- DALI_TEST_CHECK( resultMap->Find( "mixColor" )->Get<Vector4>() == Color::YELLOW );
+ DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
+ DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::YELLOW );
DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
Property::Map* resultMap = propValue.GetMap();
- DALI_TEST_CHECK( resultMap->Find( "rendererType" ) );
- DALI_TEST_CHECK( resultMap->Find( "rendererType" )->Get<std::string>() == "IMAGE" );
- DALI_TEST_CHECK( resultMap->Find( "url" ) );
- DALI_TEST_CHECK( resultMap->Find( "url" )->Get<std::string>() == "TestImage" );
+ DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
+ DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
+ DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
+ DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
image = ResourceImage::New("TestImage2");
control.SetBackgroundImage( image );
propValue = control.GetProperty( Control::Property::BACKGROUND );
resultMap = propValue.GetMap();
- DALI_TEST_CHECK( resultMap->Find( "url" ) );
- DALI_TEST_CHECK( resultMap->Find( "url" )->Get<std::string>() == "TestImage2" );
+ DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
+ DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage2" );
END_TEST;
}
DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
Property::Map imageMap;
- imageMap[ "rendererType" ] = "IMAGE";
- imageMap[ "url" ] = "TestImage";
+ imageMap[ Visual::Property::TYPE ] = Visual::IMAGE;
+ imageMap[ ImageVisual::Property::URL ] = "TestImage";
control.SetProperty( Control::Property::BACKGROUND, imageMap );
Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
Property::Map* resultMap = propValue.GetMap();
- DALI_TEST_CHECK( resultMap->Find( "rendererType" ) );
- DALI_TEST_CHECK( resultMap->Find( "rendererType" )->Get<std::string>() == "IMAGE" );
- DALI_TEST_CHECK( resultMap->Find( "url" ) );
- DALI_TEST_CHECK( resultMap->Find( "url" )->Get<std::string>() == "TestImage" );
+ DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
+ DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
+ DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
+ DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
Property::Map rendererMap;
- rendererMap["rendererType"] = "COLOR";
- rendererMap["mixColor"] = Color::CYAN;
+ rendererMap[Visual::Property::TYPE] = Visual::COLOR;
+ rendererMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
control.SetProperty( Control::Property::BACKGROUND, rendererMap );
propValue = control.GetProperty( Control::Property::BACKGROUND );
resultMap = propValue.GetMap();
- DALI_TEST_CHECK( resultMap->Find( "rendererType" ) );
- DALI_TEST_CHECK( resultMap->Find( "rendererType" )->Get<std::string>() == "COLOR" );
- DALI_TEST_CHECK( resultMap->Find( "mixColor" ) );
- DALI_TEST_CHECK( resultMap->Find( "mixColor" )->Get<Vector4>() == Color::CYAN );
+ DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
+ DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
+ DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
+ DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::CYAN );
Property::Map emptyMap;
control.SetProperty( Control::Property::BACKGROUND, emptyMap );
control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap );
propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
resultMap = propValue.GetMap();
- DALI_TEST_CHECK( resultMap->Find( "url" )->Get< std::string >() == "TestImage" );
+ DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >() == "TestImage" );
control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
+++ /dev/null
-/*
- * Copyright (c) 2016 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.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali/public-api/rendering/renderer.h>
-#include <dali/public-api/rendering/texture-set.h>
-#include <dali/public-api/rendering/shader.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace
-{
-const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
-const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg";
-const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
-const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
-const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
-const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
-}
-
-void dali_control_renderer_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_control_renderer_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliControlRendererCopyAndAssignment(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererCopyAndAssignment" );
-
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "COLOR");
- propertyMap.Insert("mixColor", Color::BLUE);
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
-
- ControlRenderer controlRendererCopy( controlRenderer );
- DALI_TEST_CHECK(controlRenderer == controlRendererCopy);
-
- ControlRenderer emptyControlRenderer;
- ControlRenderer emptyControlRendererCopy( emptyControlRenderer );
- DALI_TEST_CHECK(emptyControlRenderer == emptyControlRendererCopy);
-
- ControlRenderer controlRendererEquals;
- controlRendererEquals = controlRenderer;
- DALI_TEST_CHECK(controlRenderer == controlRendererEquals);
-
- ControlRenderer emptyControlRendererEquals;
- emptyControlRendererEquals = emptyControlRenderer;
- DALI_TEST_CHECK( emptyControlRenderer == emptyControlRendererEquals );
-
- //self assignment
- controlRenderer = controlRenderer;
- DALI_TEST_CHECK( controlRenderer = controlRendererCopy );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererSetGetDepthIndex(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererSetDepthIndex" );
-
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "COLOR");
- propertyMap.Insert("mixColor", Color::BLUE);
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
-
- controlRenderer.SetDepthIndex( 1.f );
-
- Actor actor = Actor::New();
- actor.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor );
- controlRenderer.SetOnStage( actor );
-
- int depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
- DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION );
- DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), 1.f, TEST_LOCATION );
-
- controlRenderer.SetDepthIndex( -1.f );
- depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
- DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION );
- DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), -1.f, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererSize(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetNaturalSize" );
-
- RendererFactory factory = RendererFactory::Get();
- Vector2 rendererSize( 20.f, 30.f );
- Vector2 naturalSize;
-
- // color renderer
- Dali::Property::Map map;
- map[ "rendererType" ] = "COLOR";
- map[ "mixColor" ] = Color::MAGENTA;
- ControlRenderer colorRenderer = factory.CreateControlRenderer( map );
- colorRenderer.SetSize( rendererSize );
- DALI_TEST_EQUALS( colorRenderer.GetSize(), rendererSize, TEST_LOCATION );
- colorRenderer.GetNaturalSize(naturalSize);
- DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
-
- // image renderer
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
- ControlRenderer imageRenderer = factory.CreateControlRenderer( image );
- imageRenderer.SetSize( rendererSize );
- DALI_TEST_EQUALS( imageRenderer.GetSize(), rendererSize, TEST_LOCATION );
- imageRenderer.GetNaturalSize(naturalSize);
- DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
-
- // n patch renderer
- TestPlatformAbstraction& platform = application.GetPlatform();
- Vector2 testSize(80.f, 160.f);
- platform.SetClosestImageSize(testSize);
- image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
- ControlRenderer nPatchRenderer = factory.CreateControlRenderer( image );
- nPatchRenderer.SetSize( rendererSize );
- DALI_TEST_EQUALS( nPatchRenderer.GetSize(), rendererSize, TEST_LOCATION );
- nPatchRenderer.GetNaturalSize(naturalSize);
- DALI_TEST_EQUALS( naturalSize, testSize, TEST_LOCATION );
-
- // border renderer
- float borderSize = 5.f;
- map.Clear();
- map[ "rendererType" ] = "BORDER";
- map[ "borderColor" ] = Color::RED;
- map[ "borderSize" ] = borderSize;
- ControlRenderer borderRenderer = factory.CreateControlRenderer( map );
- borderRenderer.SetSize( rendererSize );
- DALI_TEST_EQUALS( borderRenderer.GetSize(), rendererSize, TEST_LOCATION );
- borderRenderer.GetNaturalSize(naturalSize);
- DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
-
- // gradient renderer
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "GRADIENT");
- Vector2 start(-1.f, -1.f);
- Vector2 end(1.f, 1.f);
- propertyMap.Insert("startPosition", start);
- propertyMap.Insert("endPosition", end);
- propertyMap.Insert("stopOffset", Vector2(0.f, 1.f));
- Property::Array stopColors;
- stopColors.PushBack( Color::RED );
- stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("stopColor", stopColors);
- ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap);
- gradientRenderer.SetSize( rendererSize );
- DALI_TEST_EQUALS( gradientRenderer.GetSize(), rendererSize, TEST_LOCATION );
- gradientRenderer.GetNaturalSize(naturalSize);
- DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
-
- //svg renderer
- ControlRenderer svgRenderer = factory.CreateControlRenderer( TEST_SVG_FILE_NAME, ImageDimensions() );
- svgRenderer.SetSize( rendererSize );
- DALI_TEST_EQUALS( svgRenderer.GetSize(), rendererSize, TEST_LOCATION );
- svgRenderer.GetNaturalSize(naturalSize);
- // TEST_SVG_FILE:
- // <svg width="100" height="100">
- // <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
- // </svg>
- DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliControlRendererSetOnOffStage(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererSetDepthIndex" );
-
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "COLOR");
- propertyMap.Insert("mixColor", Color::BLUE);
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
-
- Actor actor = Actor::New();
- actor.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
- controlRenderer.SetOnStage( actor );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- controlRenderer.SetOffStage( actor );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererRemoveAndReset(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "intUtcDaliControlRendererRemoveAndReset" );
-
- RendererFactory factory = RendererFactory::Get();
-
- Actor actor = Actor::New();
- actor.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor );
-
- ControlRenderer imageRenderer;
- // test calling RemoveAndReset with an empty handle
- try
- {
- imageRenderer.RemoveAndReset( actor );
- tet_result(TET_PASS);
- }
- catch (DaliException& exception)
- {
- tet_result(TET_FAIL);
- }
-
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
- imageRenderer = factory.CreateControlRenderer(image);
- DALI_TEST_CHECK( imageRenderer );
-
- imageRenderer.SetOnStage( actor );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- imageRenderer.RemoveAndReset( actor );
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); // renderer is removed from actor
- DALI_TEST_CHECK( !imageRenderer ); // control renderer is reset
-
- END_TEST;
-}
-
-int UtcDaliControlRendererGetPropertyMap1(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap1: ColorRenderer" );
-
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "COLOR");
- propertyMap.Insert("mixColor", Color::BLUE);
- ControlRenderer colorRenderer = factory.CreateControlRenderer( propertyMap );
-
- Property::Map resultMap;
- colorRenderer.CreatePropertyMap( resultMap );
-
- Property::Value* typeValue = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( typeValue );
- DALI_TEST_CHECK( typeValue->Get<std::string>() == "COLOR" );
-
- Property::Value* colorValue = resultMap.Find( "mixColor", Property::VECTOR4 );
- DALI_TEST_CHECK( colorValue );
- DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
-
- // change the blend color
- Actor actor;
- colorRenderer.RemoveAndReset( actor );
- propertyMap["mixColor"] = Color::CYAN;
- colorRenderer = factory.CreateControlRenderer( propertyMap );
- colorRenderer.CreatePropertyMap( resultMap );
-
- colorValue = resultMap.Find( "mixColor", Property::VECTOR4 );
- DALI_TEST_CHECK( colorValue );
- DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererGetPropertyMap2(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap2: BorderRenderer" );
-
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "BORDER");
- propertyMap.Insert("borderColor", Color::BLUE);
- propertyMap.Insert("borderSize", 5.f);
- ControlRenderer borderRenderer = factory.CreateControlRenderer( propertyMap );
-
- Property::Map resultMap;
- borderRenderer.CreatePropertyMap( resultMap );
-
- // check the property values from the returned map from control renderer
- Property::Value* typeValue = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( typeValue );
- DALI_TEST_CHECK( typeValue->Get<std::string>() == "BORDER" );
-
- Property::Value* colorValue = resultMap.Find( "borderColor", Property::VECTOR4 );
- DALI_TEST_CHECK( colorValue );
- DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
-
- Property::Value* sizeValue = resultMap.Find( "borderSize", Property::FLOAT );
- DALI_TEST_CHECK( sizeValue );
- DALI_TEST_CHECK( sizeValue->Get<float>() == 5.f );
-
- Property::Map propertyMap1;
- propertyMap1[ "rendererType" ] = "BORDER";
- propertyMap1[ "borderColor" ] = Color::CYAN;
- propertyMap1[ "borderSize" ] = 10.0f;
- borderRenderer = factory.CreateControlRenderer( propertyMap1 );
- borderRenderer.CreatePropertyMap( resultMap );
-
- typeValue = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( typeValue );
- DALI_TEST_CHECK( typeValue->Get<std::string>() == "BORDER" );
-
- colorValue = resultMap.Find( "borderColor", Property::VECTOR4 );
- DALI_TEST_CHECK( colorValue );
- DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
-
- colorValue = resultMap.Find( "borderSize", Property::FLOAT );
- DALI_TEST_CHECK( colorValue );
- DALI_TEST_CHECK( colorValue->Get<float>() == 10.f );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererGetPropertyMap3(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap3: linear GradientRenderer" );
-
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "GRADIENT");
-
- Vector2 start(-1.f, -1.f);
- Vector2 end(1.f, 1.f);
- propertyMap.Insert("startPosition", start);
- propertyMap.Insert("endPosition", end);
- propertyMap.Insert("spreadMethod", "REPEAT");
-
- propertyMap.Insert("stopOffset", Vector2(0.2f, 0.8f));
-
- Property::Array stopColors;
- stopColors.PushBack( Color::RED );
- stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("stopColor", stopColors);
-
- ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap);
-
- Property::Map resultMap;
- gradientRenderer.CreatePropertyMap( resultMap );
-
- // check the property values from the returned map from control renderer
- Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "GRADIENT" );
-
- value = resultMap.Find( "units", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "OBJECT_BOUNDING_BOX" );
-
- value = resultMap.Find( "spreadMethod", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "REPEAT" );
-
- value = resultMap.Find( "startPosition", Property::VECTOR2 );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "endPosition", Property::VECTOR2 );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "stopOffset", Property::ARRAY );
- DALI_TEST_CHECK( value );
- Property::Array* offsetArray = value->GetArray();
- DALI_TEST_CHECK( offsetArray->Count() == 2 );
- DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.2f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.8f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "stopColor", Property::ARRAY );
- DALI_TEST_CHECK( value );
- Property::Array* colorArray = value->GetArray();
- DALI_TEST_CHECK( colorArray->Count() == 2 );
- DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererGetPropertyMap4(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap4: radial GradientRenderer" );
-
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Property::Map propertyMap;
- propertyMap.Insert("rendererType", "GRADIENT");
-
- Vector2 center(100.f, 100.f);
- float radius = 100.f;
- propertyMap.Insert("units", "USER_SPACE");
- propertyMap.Insert("center", center);
- propertyMap.Insert("radius", radius);
- propertyMap.Insert("stopOffset", Vector3(0.1f, 0.3f, 1.1f));
-
- Property::Array stopColors;
- stopColors.PushBack( Color::RED );
- stopColors.PushBack( Color::BLACK );
- stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("stopColor", stopColors);
-
- ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap);
- DALI_TEST_CHECK( gradientRenderer );
-
- Property::Map resultMap;
- gradientRenderer.CreatePropertyMap( resultMap );
-
- // check the property values from the returned map from control renderer
- Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "GRADIENT" );
-
- value = resultMap.Find( "units", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "USER_SPACE" );
-
- value = resultMap.Find( "spreadMethod", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "PAD" );
-
- value = resultMap.Find( "center", Property::VECTOR2 );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<Vector2>(), center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "radius", Property::FLOAT );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), radius , Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "stopOffset", Property::ARRAY );
- DALI_TEST_CHECK( value );
- Property::Array* offsetArray = value->GetArray();
- DALI_TEST_CHECK( offsetArray->Count() == 3 );
- DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.1f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.3f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- // any stop value will be clamped to [0.0, 1.0];
- DALI_TEST_EQUALS( offsetArray->GetElementAt(2).Get<float>(), 1.0f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "stopColor", Property::ARRAY );
- DALI_TEST_CHECK( value );
- Property::Array* colorArray = value->GetArray();
- DALI_TEST_CHECK( colorArray->Count() == 3 );
- DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::BLACK , Math::MACHINE_EPSILON_100, TEST_LOCATION );
- DALI_TEST_EQUALS( colorArray->GetElementAt(2).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererGetPropertyMap5(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap5: ImageRenderer" );
-
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "IMAGE" );
- propertyMap.Insert( "url", TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( "desiredWidth", 20 );
- propertyMap.Insert( "desiredHeight", 30 );
- propertyMap.Insert( "fittingMode", "FIT_HEIGHT" );
- propertyMap.Insert( "samplingMode", "BOX_THEN_NEAREST" );
- propertyMap.Insert( "synchronousLoading", true );
-
- ControlRenderer imageRenderer = factory.CreateControlRenderer(propertyMap);
- DALI_TEST_CHECK( imageRenderer );
-
- Property::Map resultMap;
- imageRenderer.CreatePropertyMap( resultMap );
-
- // check the property values from the returned map from control renderer
- Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "IMAGE" );
-
- value = resultMap.Find( "url", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
-
- value = resultMap.Find( "fittingMode", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "FIT_HEIGHT" );
-
- value = resultMap.Find( "samplingMode", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "BOX_THEN_NEAREST" );
-
- value = resultMap.Find( "desiredWidth", Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 20 );
-
- value = resultMap.Find( "desiredHeight", Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 30 );
-
- value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<bool>() == true );
-
- // Get an image renderer with an image handle, and test the default property values
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
- imageRenderer = factory.CreateControlRenderer(image);
- imageRenderer.CreatePropertyMap( resultMap );
-
- value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "IMAGE" );
-
- value = resultMap.Find( "url", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
-
- value = resultMap.Find( "fittingMode", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "SHRINK_TO_FIT" );
-
- value = resultMap.Find( "samplingMode", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "BOX" );
-
- value = resultMap.Find( "desiredWidth", Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 100 );
-
- value = resultMap.Find( "desiredHeight", Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 200 );
-
- value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<bool>() == false );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererGetPropertyMap6(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap6: NPatchRenderer" );
-
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "IMAGE" );
- propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME );
- propertyMap.Insert( "borderOnly", true );
- ControlRenderer nPatchRenderer = factory.CreateControlRenderer( propertyMap );
-
- Property::Map resultMap;
- nPatchRenderer.CreatePropertyMap( resultMap );
-
- // check the property values from the returned map from control renderer
- Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "IMAGE" );
-
- value = resultMap.Find( "url", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
-
- value = resultMap.Find( "borderOnly", Property::BOOLEAN );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<bool>() );
-
- END_TEST;
-}
-
-int UtcDaliControlRendererGetPropertyMap7(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap7: SvgRenderer" );
-
- // request SvgRenderer with a property map
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "IMAGE" );
- propertyMap.Insert( "url", TEST_SVG_FILE_NAME );
- ControlRenderer svgRenderer = factory.CreateControlRenderer( propertyMap );
-
- Property::Map resultMap;
- svgRenderer.CreatePropertyMap( resultMap );
- // check the property values from the returned map from control renderer
- Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "IMAGE" );
-
- value = resultMap.Find( "url", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
-
- // request SvgRenderer with an URL
- ControlRenderer svgRenderer2 = factory.CreateControlRenderer( TEST_SVG_FILE_NAME, ImageDimensions() );
- resultMap.Clear();
- svgRenderer2.CreatePropertyMap( resultMap );
- // check the property values from the returned map from control renderer
- value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == "IMAGE" );
-
- value = resultMap.Find( "url", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
-
- END_TEST;
-}
-
-//Mesh renderer
-int UtcDaliControlRendererGetPropertyMap8(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap8: MeshRenderer" );
-
- //Request MeshRenderer using a property map.
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "MESH" );
- propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
- propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
- propertyMap.Insert( "texturesPath", TEST_RESOURCE_LOCATION );
- propertyMap.Insert( "shaderType", "TEXTURELESS" );
- ControlRenderer meshRenderer = factory.CreateControlRenderer( propertyMap );
-
- Property::Map resultMap;
- meshRenderer.CreatePropertyMap( resultMap );
-
- //Check values in the result map are identical to the initial map's values.
- Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<std::string>(), "MESH", TEST_LOCATION );
-
- value = resultMap.Find( "objectUrl", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<std::string>(), TEST_OBJ_FILE_NAME, TEST_LOCATION );
-
- value = resultMap.Find( "materialUrl", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<std::string>(), TEST_MTL_FILE_NAME, TEST_LOCATION );
-
- value = resultMap.Find( "texturesPath", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<std::string>(), TEST_RESOURCE_LOCATION, TEST_LOCATION );
-
- value = resultMap.Find( "shaderType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<std::string>(), "TEXTURELESS", TEST_LOCATION );
-
- END_TEST;
-}
-
-//Primitive shape renderer
-int UtcDaliControlRendererGetPropertyMap9(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliControlRendererGetPropertyMap9: PrimitiveRenderer" );
-
- Vector4 color = Vector4( 1.0, 0.8, 0.6, 1.0);
- Vector3 dimensions = Vector3( 1.0, 2.0, 3.0 );
-
- //Request PrimitiveRenderer using a property map.
- RendererFactory factory = RendererFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "CUBE" );
- propertyMap.Insert( "color", color );
- propertyMap.Insert( "slices", 10 );
- propertyMap.Insert( "stacks", 20 );
- propertyMap.Insert( "scaleTopRadius", 30.0f );
- propertyMap.Insert( "scaleBottomRadius", 40.0f );
- propertyMap.Insert( "scaleHeight", 50.0f );
- propertyMap.Insert( "scaleRadius", 60.0f );
- propertyMap.Insert( "scaleDimensions", dimensions );
- propertyMap.Insert( "bevelPercentage", 0.3f );
- propertyMap.Insert( "bevelSmoothness", 0.6f );
- propertyMap.Insert( "uLightPosition", Vector3( 5.0f, 10.0f, 15.0f) );
- ControlRenderer primitiveRenderer = factory.CreateControlRenderer( propertyMap );
-
- Property::Map resultMap;
- primitiveRenderer.CreatePropertyMap( resultMap );
-
- //Check values in the result map are identical to the initial map's values.
- Property::Value* value = resultMap.Find( "rendererType", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<std::string>(), "PRIMITIVE", TEST_LOCATION );
-
- value = resultMap.Find( "shape", Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<std::string>(), "CUBE", TEST_LOCATION );
-
- value = resultMap.Find( "color", Property::VECTOR4 );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<Vector4>() == color );
- DALI_TEST_EQUALS( value->Get<Vector4>(), color, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "slices", Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
-
- value = resultMap.Find( "stacks", Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<int>(), 20, TEST_LOCATION );
-
- value = resultMap.Find( "scaleTopRadius", Property::FLOAT );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 30.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "scaleBottomRadius", Property::FLOAT );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 40.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "scaleHeight", Property::FLOAT );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 50.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "scaleRadius", Property::FLOAT );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 60.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "scaleDimensions", Property::VECTOR3 );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<Vector3>(), dimensions, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "bevelPercentage", Property::FLOAT );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 0.3f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "bevelSmoothness", Property::FLOAT );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<float>(), 0.6f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( "uLightPosition", Property::VECTOR3 );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
-#include <dali/public-api/rendering/renderer.h>
-#include <dali/public-api/rendering/geometry.h>
-
-#include <toolkit-environment-variable.h> // for setting environment variable: DALI_DEBUG_RENDERING
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace
-{
-const char* TEST_IMAGE_FILE_NAME = "image_01.jpg";
-const char* TEST_NPATCH_FILE_NAME = "image_01.9.jpg";
-
-bool IsDebugRenderer( ControlRenderer& renderer )
-{
- bool isDebugRendererType = false;
- bool isGeometryLineType = false;
-
- Property::Map propertyMap;
- renderer.CreatePropertyMap( propertyMap );
- Property::Value* typeValue = propertyMap.Find( "rendererType", Property::STRING );
- if ( typeValue )
- {
- isDebugRendererType = ( typeValue->Get<std::string>() == "DEBUG" );
- }
-
- Actor actor = Actor::New();
- renderer.SetOnStage( actor );
- Geometry geometry = actor.GetRendererAt( 0 ).GetGeometry();
- isGeometryLineType = ( geometry.GetGeometryType() == Geometry::LINES );
-
- return isDebugRendererType && isGeometryLineType;
-}
-}
-
-void dali_debug_renderer_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_debug_renderer_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliDebugRendererGetRenderer1(void)
-{
- EnvironmentVariable::SetTestingEnvironmentVariable(true);
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliDebugRendererGetRenderer1: Request renderer with a Property::Map" );
-
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- // Test that color renderer is replaced with debug renderer
- Property::Map propertyMap1;
- propertyMap1.Insert("rendererType", "COLOR");
- propertyMap1.Insert("mixColor", Color::BLUE);
- ControlRenderer colorRenderer = factory.CreateControlRenderer(propertyMap1);
- DALI_TEST_CHECK( colorRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( colorRenderer ) );
-
- // Test that border renderer is replaced with debug renderer
- Property::Map propertyMap2;
- propertyMap2.Insert("rendererType", "BORDER");
- propertyMap2.Insert("borderColor", Color::BLUE);
- propertyMap2.Insert("borderSize", 2.f);
- ControlRenderer borderRenderer = factory.CreateControlRenderer(propertyMap2);
- DALI_TEST_CHECK( borderRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( borderRenderer ) );
-
- // Test that gradient renderer is replaced with debug renderer
- Property::Map propertyMap3;
- propertyMap3.Insert("rendererType", "GRADIENT");
- Vector2 start(-1.f, -1.f);
- Vector2 end(1.f, 1.f);
- propertyMap3.Insert("startPosition", start);
- propertyMap3.Insert("endPosition", end);
- propertyMap3.Insert("spreadMethod", "REPEAT");
- Property::Array stopOffsets;
- stopOffsets.PushBack( 0.2f );
- stopOffsets.PushBack( 0.8f );
- propertyMap3.Insert("stopOffset", stopOffsets);
- Property::Array stopColors;
- stopColors.PushBack( Color::RED );
- stopColors.PushBack( Color::GREEN );
- propertyMap3.Insert("stopColor", stopColors);
- ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap3);
- DALI_TEST_CHECK( gradientRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( gradientRenderer ) );
-
- // Test that image renderer is replaced with debug renderer
- Property::Map propertyMap4;
- propertyMap4.Insert( "rendererType", "IMAGE" );
- propertyMap4.Insert( "url", TEST_IMAGE_FILE_NAME );
- ControlRenderer imageRenderer = factory.CreateControlRenderer( propertyMap4 );
- DALI_TEST_CHECK( imageRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( imageRenderer ) );
-
- // Test that n patch renderer is replaced with debug renderer
- Property::Map propertyMap5;
- propertyMap5.Insert( "rendererType", "IMAGE" );
- propertyMap5.Insert( "url", TEST_NPATCH_FILE_NAME );
- ControlRenderer nPatchRenderer = factory.CreateControlRenderer( propertyMap4 );
- DALI_TEST_CHECK( nPatchRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( nPatchRenderer ) );
-
- EnvironmentVariable::SetTestingEnvironmentVariable(false);
- END_TEST;
-}
-
-int UtcDaliDebugRendererGetRenderer2(void)
-{
- EnvironmentVariable::SetTestingEnvironmentVariable(true);
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliDebugRendererGetRenderer2: Request renderer with various parameters" );
-
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
-
- // Test that color renderer is replaced with debug renderer
- Dali::Property::Map map;
- map[ "rendererType" ] = "COLOR";
- map[ "mixColor" ] = Color::CYAN;
-
- ControlRenderer colorRenderer = factory.CreateControlRenderer( map);
- DALI_TEST_CHECK( colorRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( colorRenderer ) );
-
- // Test that border renderer is replaced with debug renderer
- map.Clear();
- map[ "rendererType" ] = "BORDER";
- map[ "borderColor" ] = Color::GREEN;
- map[ "borderSize" ] = 2.f;
- ControlRenderer borderRenderer = factory.CreateControlRenderer( map );
- DALI_TEST_CHECK( borderRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( borderRenderer ) );
-
- // Test that image renderer is replaced with debug renderer
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- ControlRenderer imageRenderer = factory.CreateControlRenderer( image );
- DALI_TEST_CHECK( imageRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( imageRenderer ) );
-
- // Test that n patch renderer is replaced with debug renderer
- ControlRenderer nPatchRenderer = factory.CreateControlRenderer( TEST_NPATCH_FILE_NAME, ImageDimensions() );
- DALI_TEST_CHECK( nPatchRenderer );
- DALI_TEST_CHECK( IsDebugRenderer( nPatchRenderer ) );
-
- EnvironmentVariable::SetTestingEnvironmentVariable(false);
- END_TEST;
-}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali/public-api/rendering/renderer.h>
+#include <dali/public-api/rendering/geometry.h>
+
+#include <dali-toolkit/dali-toolkit.h>
+
+#include <toolkit-environment-variable.h> // for setting environment variable: DALI_DEBUG_RENDERING
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+const char* TEST_IMAGE_FILE_NAME = "image_01.jpg";
+const char* TEST_NPATCH_FILE_NAME = "image_01.9.jpg";
+
+bool IsDebugVisual( Visual::Base& visual )
+{
+ bool isDebugVisualType = false;
+ bool isGeometryLineType = false;
+
+ Property::Map propertyMap;
+ visual.CreatePropertyMap( propertyMap );
+ Property::Value* typeValue = propertyMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ if ( typeValue )
+ {
+ isDebugVisualType = ( typeValue->Get<int>() == Visual::DEBUG );
+ }
+
+ Actor actor = Actor::New();
+ visual.SetOnStage( actor );
+ Geometry geometry = actor.GetRendererAt( 0 ).GetGeometry();
+ isGeometryLineType = ( geometry.GetType() == Geometry::LINES );
+
+ return isDebugVisualType && isGeometryLineType;
+}
+}
+
+void dali_debug_renderer_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_debug_renderer_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliDebugVisualGetVisual1(void)
+{
+ EnvironmentVariable::SetTestingEnvironmentVariable(true);
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliDebugVisualGetVisual1: Request visual with a Property::Map" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ // Test that color visual is replaced with debug visual
+ Property::Map propertyMap1;
+ propertyMap1.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap1.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base colorVisual = factory.CreateVisual(propertyMap1);
+ DALI_TEST_CHECK( colorVisual );
+ DALI_TEST_CHECK( IsDebugVisual( colorVisual ) );
+
+ // Test that border visual is replaced with debug visual
+ Property::Map propertyMap2;
+ propertyMap2.Insert(Visual::Property::TYPE, Visual::BORDER);
+ propertyMap2.Insert(BorderVisual::Property::COLOR, Color::BLUE);
+ propertyMap2.Insert(BorderVisual::Property::SIZE, 2.f);
+ Visual::Base borderVisual = factory.CreateVisual(propertyMap2);
+ DALI_TEST_CHECK( borderVisual );
+ DALI_TEST_CHECK( IsDebugVisual( borderVisual ) );
+
+ // Test that gradient visual is replaced with debug visual
+ Property::Map propertyMap3;
+ propertyMap3.Insert(Visual::Property::TYPE, Visual::GRADIENT);
+ Vector2 start(-1.f, -1.f);
+ Vector2 end(1.f, 1.f);
+ propertyMap3.Insert(GradientVisual::Property::START_POSITION, start);
+ propertyMap3.Insert(GradientVisual::Property::END_POSITION, end);
+ propertyMap3.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
+ Property::Array stopOffsets;
+ stopOffsets.PushBack( 0.2f );
+ stopOffsets.PushBack( 0.8f );
+ propertyMap3.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
+ Property::Array stopColors;
+ stopColors.PushBack( Color::RED );
+ stopColors.PushBack( Color::GREEN );
+ propertyMap3.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
+ Visual::Base gradientVisual = factory.CreateVisual(propertyMap3);
+ DALI_TEST_CHECK( gradientVisual );
+ DALI_TEST_CHECK( IsDebugVisual( gradientVisual ) );
+
+ // Test that image visual is replaced with debug visual
+ Property::Map propertyMap4;
+ propertyMap4.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap4.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ Visual::Base imageVisual = factory.CreateVisual( propertyMap4 );
+ DALI_TEST_CHECK( imageVisual );
+ DALI_TEST_CHECK( IsDebugVisual( imageVisual ) );
+
+ // Test that n patch visual is replaced with debug visual
+ Property::Map propertyMap5;
+ propertyMap5.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap5.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
+ Visual::Base nPatchVisual = factory.CreateVisual( propertyMap4 );
+ DALI_TEST_CHECK( nPatchVisual );
+ DALI_TEST_CHECK( IsDebugVisual( nPatchVisual ) );
+
+ EnvironmentVariable::SetTestingEnvironmentVariable(false);
+ END_TEST;
+}
+
+int UtcDaliDebugVisualGetVisual2(void)
+{
+ EnvironmentVariable::SetTestingEnvironmentVariable(true);
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliDebugVisualGetVisual2: Request visual with various parameters" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ // Test that color visual is replaced with debug visual
+ Dali::Property::Map map;
+ map[ Visual::Property::TYPE ] = Visual::COLOR;
+ map[ ColorVisual::Property::MIX_COLOR ] = Color::CYAN;
+
+ Visual::Base colorVisual = factory.CreateVisual( map);
+ DALI_TEST_CHECK( colorVisual );
+ DALI_TEST_CHECK( IsDebugVisual( colorVisual ) );
+
+ // Test that border visual is replaced with debug visual
+ map.Clear();
+ map[ Visual::Property::TYPE ] = Visual::BORDER;
+ map[ BorderVisual::Property::COLOR ] = Color::GREEN;
+ map[ BorderVisual::Property::SIZE ] = 2.f;
+ Visual::Base borderVisual = factory.CreateVisual( map );
+ DALI_TEST_CHECK( borderVisual );
+ DALI_TEST_CHECK( IsDebugVisual( borderVisual ) );
+
+ // Test that image visual is replaced with debug visual
+ Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
+ Visual::Base imageVisual = factory.CreateVisual( image );
+ DALI_TEST_CHECK( imageVisual );
+ DALI_TEST_CHECK( IsDebugVisual( imageVisual ) );
+
+ // Test that n patch visual is replaced with debug visual
+ Visual::Base nPatchVisual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
+ DALI_TEST_CHECK( nPatchVisual );
+ DALI_TEST_CHECK( IsDebugVisual( nPatchVisual ) );
+
+ EnvironmentVariable::SetTestingEnvironmentVariable(false);
+ END_TEST;
+}
ImageView imageView = ImageView::New();
// Sync loading is used
- syncLoadingMap[ "url" ] = gImage_600_RGB;
+ syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
// BitmapLoader is used, and the loading is started immediately even the actor is not on stage.
ImageView imageView = ImageView::New( );
// Sync loading is used
- syncLoadingMap[ "url" ] = gImage_34_RGBA;
- syncLoadingMap[ "desiredHeight" ] = 34;
- syncLoadingMap[ "desiredWidth" ] = 34;
+ syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
+ syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
+ syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
// loading is started even if the actor is offStage
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
#include <dali-toolkit/devel-api/shader-effects/swirl-effect.h>
using namespace Dali;
+using namespace Dali::Toolkit;
int UtcDaliCreateAlphaDiscardEffect(void)
{
Property::Map effect = Toolkit::CreateAlphaDiscardEffect();
DALI_TEST_CHECK( !effect.Empty() );
- Property::Value* customShaderValue = effect.Find( "shader" );
+ Property::Value* customShaderValue = effect.Find( Visual::Property::SHADER );
DALI_TEST_CHECK( customShaderValue );
Property::Map customShader;
DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
- Property::Value* vertexShaderValue = customShader.Find( "vertexShader" );
+ Property::Value* vertexShaderValue = customShader.Find( Visual::Shader::Property::VERTEX_SHADER );
DALI_TEST_CHECK( !vertexShaderValue );
- Property::Value* fragmentShaderValue = customShader.Find( "fragmentShader" );
+ Property::Value* fragmentShaderValue = customShader.Find( Visual::Shader::Property::FRAGMENT_SHADER );
DALI_TEST_CHECK( fragmentShaderValue );
std::string fragmentShader;
DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
DALI_TEST_CHECK( !fragmentShader.empty() );
- Property::Value* gridXValue = customShader.Find( "subdivideGridX" );
+ Property::Value* gridXValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_X );
DALI_TEST_CHECK( !gridXValue );
- Property::Value* gridYValue = customShader.Find( "subdivideGridY" );
+ Property::Value* gridYValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_Y );
DALI_TEST_CHECK( !gridYValue );
- Property::Value* hintsValue = customShader.Find( "hints" );
+ Property::Value* hintsValue = customShader.Find( Visual::Shader::Property::HINTS );
DALI_TEST_CHECK( !hintsValue );
END_TEST;
Property::Map effect = Toolkit::CreateDissolveEffect( highPrecision );
DALI_TEST_CHECK( !effect.Empty() );
- Property::Value* customShaderValue = effect.Find( "shader" );
+ Property::Value* customShaderValue = effect.Find( Visual::Property::SHADER );
DALI_TEST_CHECK( customShaderValue );
Property::Map customShader;
DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
- Property::Value* vertexShaderValue = customShader.Find( "vertexShader" );
+ Property::Value* vertexShaderValue = customShader.Find( Visual::Shader::Property::VERTEX_SHADER );
DALI_TEST_CHECK( vertexShaderValue );
std::string vertexShader;
DALI_TEST_CHECK( vertexShaderValue->Get( vertexShader ) );
DALI_TEST_CHECK( !vertexShader.empty() );
- Property::Value* fragmentShaderValue = customShader.Find( "fragmentShader" );
+ Property::Value* fragmentShaderValue = customShader.Find( Visual::Shader::Property::FRAGMENT_SHADER );
DALI_TEST_CHECK( fragmentShaderValue );
std::string fragmentShader;
DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
DALI_TEST_CHECK( !fragmentShader.empty() );
- Property::Value* gridXValue = customShader.Find( "subdivideGridX" );
+ Property::Value* gridXValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_X );
DALI_TEST_CHECK( gridXValue );
int gridX = 0;
DALI_TEST_CHECK( gridXValue->Get( gridX ) );
DALI_TEST_CHECK( gridX > 1 );
- Property::Value* gridYValue = customShader.Find( "subdivideGridY" );
+ Property::Value* gridYValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_Y );
DALI_TEST_CHECK( gridYValue );
int gridY = 0;
DALI_TEST_CHECK( gridYValue->Get( gridY ) );
DALI_TEST_CHECK( gridY > 1 );
- Property::Value* hintsValue = customShader.Find( "hints" );
+ Property::Value* hintsValue = customShader.Find( Visual::Shader::Property::HINTS );
DALI_TEST_CHECK( hintsValue );
- std::string hints;
+ int hints;;
DALI_TEST_CHECK( hintsValue->Get( hints ) );
- DALI_TEST_CHECK( hints == "outputIsTransparent" );
+ DALI_TEST_CHECK( hints == Shader::Hint::OUTPUT_IS_TRANSPARENT );
Actor actor = Actor::New();
Toolkit::DissolveEffectSetCentralLine( actor, Vector2::ONE, Vector2::ONE, 0.0f );
Property::Map effect = Toolkit::CreateDistanceFieldEffect();
DALI_TEST_CHECK( !effect.Empty() );
- Property::Value* customShaderValue = effect.Find( "shader" );
+ Property::Value* customShaderValue = effect.Find( Visual::Property::SHADER );
DALI_TEST_CHECK( customShaderValue );
Property::Map customShader;
DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
- Property::Value* vertexShaderValue = customShader.Find( "vertexShader" );
+ Property::Value* vertexShaderValue = customShader.Find( Visual::Shader::Property::VERTEX_SHADER );
DALI_TEST_CHECK( !vertexShaderValue );
- Property::Value* fragmentShaderValue = customShader.Find( "fragmentShader" );
+ Property::Value* fragmentShaderValue = customShader.Find( Visual::Shader::Property::FRAGMENT_SHADER );
DALI_TEST_CHECK( fragmentShaderValue );
std::string fragmentShader;
DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
DALI_TEST_CHECK( !fragmentShader.empty() );
- Property::Value* gridXValue = customShader.Find( "subdivideGridX" );
+ Property::Value* gridXValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_X );
DALI_TEST_CHECK( !gridXValue );
- Property::Value* hintsValue = customShader.Find( "hints" );
+ Property::Value* hintsValue = customShader.Find( Visual::Shader::Property::HINTS );
DALI_TEST_CHECK( hintsValue );
- std::string hints;
+ int hints;;
DALI_TEST_CHECK( hintsValue->Get( hints ) );
- DALI_TEST_CHECK( hints == "outputIsTransparent" );
+ DALI_TEST_CHECK( hints == Shader::Hint::OUTPUT_IS_TRANSPARENT );
END_TEST;
}
Property::Map effect = Toolkit::CreateImageRegionEffect();
DALI_TEST_CHECK( !effect.Empty() );
- Property::Value* customShaderValue = effect.Find( "shader" );
+ Property::Value* customShaderValue = effect.Find( Visual::Property::SHADER );
DALI_TEST_CHECK( customShaderValue );
Property::Map customShader;
DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
- Property::Value* vertexShaderValue = customShader.Find( "vertexShader" );
+ Property::Value* vertexShaderValue = customShader.Find( Visual::Shader::Property::VERTEX_SHADER );
DALI_TEST_CHECK( vertexShaderValue );
std::string vertexShader;
DALI_TEST_CHECK( vertexShaderValue->Get( vertexShader ) );
DALI_TEST_CHECK( !vertexShader.empty() );
- Property::Value* fragmentShaderValue = customShader.Find( "fragmentShader" );
+ Property::Value* fragmentShaderValue = customShader.Find( Visual::Shader::Property::FRAGMENT_SHADER );
DALI_TEST_CHECK( !fragmentShaderValue );
- Property::Value* gridXValue = customShader.Find( "subdivideGridX" );
+ Property::Value* gridXValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_X );
DALI_TEST_CHECK( !gridXValue );
- Property::Value* gridYValue = customShader.Find( "subdivideGridY" );
+ Property::Value* gridYValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_Y );
DALI_TEST_CHECK( !gridYValue );
- Property::Value* hintsValue = customShader.Find( "hints" );
+ Property::Value* hintsValue = customShader.Find( Visual::Shader::Property::HINTS );
DALI_TEST_CHECK( !hintsValue );
END_TEST;
Property::Map effect = Toolkit::CreateMotionBlurEffect();
DALI_TEST_CHECK( !effect.Empty() );
- Property::Value* customShaderValue = effect.Find( "shader" );
+ Property::Value* customShaderValue = effect.Find( Visual::Property::SHADER );
DALI_TEST_CHECK( customShaderValue );
Property::Map customShader;
DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
- Property::Value* vertexShaderValue = customShader.Find( "vertexShader" );
+ Property::Value* vertexShaderValue = customShader.Find( Visual::Shader::Property::VERTEX_SHADER );
DALI_TEST_CHECK( vertexShaderValue );
std::string vertexShader;
DALI_TEST_CHECK( vertexShaderValue->Get( vertexShader ) );
DALI_TEST_CHECK( !vertexShader.empty() );
- Property::Value* fragmentShaderValue = customShader.Find( "fragmentShader" );
+ Property::Value* fragmentShaderValue = customShader.Find( Visual::Shader::Property::FRAGMENT_SHADER );
DALI_TEST_CHECK( fragmentShaderValue );
std::string fragmentShader;
DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
DALI_TEST_CHECK( !fragmentShader.empty() );
- Property::Value* gridXValue = customShader.Find( "subdivideGridX" );
+ Property::Value* gridXValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_X );
DALI_TEST_CHECK( gridXValue );
int gridX = 0;
DALI_TEST_CHECK( gridXValue->Get( gridX ) );
DALI_TEST_CHECK( gridX > 1 );
- Property::Value* gridYValue = customShader.Find( "subdivideGridY" );
+ Property::Value* gridYValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_Y );
DALI_TEST_CHECK( gridYValue );
int gridY = 0;
DALI_TEST_CHECK( gridYValue->Get( gridY ) );
DALI_TEST_CHECK( gridY > 1 );
- Property::Value* hintsValue = customShader.Find( "hints" );
+ Property::Value* hintsValue = customShader.Find( Visual::Shader::Property::HINTS );
DALI_TEST_CHECK( hintsValue );
- std::string hints;
+ int hints;;
DALI_TEST_CHECK( hintsValue->Get( hints ) );
- DALI_TEST_CHECK( hints == "outputIsTransparent" );
+ DALI_TEST_CHECK( hints == Shader::Hint::OUTPUT_IS_TRANSPARENT );
unsigned int sampleCount( 4 );
Actor actor = Actor::New();
Property::Map effect = Toolkit::CreateMotionStretchEffect();
DALI_TEST_CHECK( !effect.Empty() );
- Property::Value* customShaderValue = effect.Find( "shader" );
+ Property::Value* customShaderValue = effect.Find( Visual::Property::SHADER );
DALI_TEST_CHECK( customShaderValue );
Property::Map customShader;
DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
- Property::Value* vertexShaderValue = customShader.Find( "vertexShader" );
+ Property::Value* vertexShaderValue = customShader.Find( Visual::Shader::Property::VERTEX_SHADER );
DALI_TEST_CHECK( vertexShaderValue );
std::string vertexShader;
DALI_TEST_CHECK( vertexShaderValue->Get( vertexShader ) );
DALI_TEST_CHECK( !vertexShader.empty() );
- Property::Value* fragmentShaderValue = customShader.Find( "fragmentShader" );
+ Property::Value* fragmentShaderValue = customShader.Find( Visual::Shader::Property::FRAGMENT_SHADER );
DALI_TEST_CHECK( fragmentShaderValue );
std::string fragmentShader;
DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
DALI_TEST_CHECK( !fragmentShader.empty() );
- Property::Value* gridXValue = customShader.Find( "subdivideGridX" );
+ Property::Value* gridXValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_X );
DALI_TEST_CHECK( gridXValue );
int gridX = 0;
DALI_TEST_CHECK( gridXValue->Get( gridX ) );
DALI_TEST_CHECK( gridX > 1 );
- Property::Value* gridYValue = customShader.Find( "subdivideGridY" );
+ Property::Value* gridYValue = customShader.Find( Visual::Shader::Property::SUBDIVIDE_GRID_Y );
DALI_TEST_CHECK( gridYValue );
int gridY = 0;
DALI_TEST_CHECK( gridYValue->Get( gridY ) );
DALI_TEST_CHECK( gridY > 1 );
- Property::Value* hintsValue = customShader.Find( "hints" );
+ Property::Value* hintsValue = customShader.Find( Visual::Shader::Property::HINTS );
DALI_TEST_CHECK( hintsValue );
- std::string hints;
+ int hints;;
DALI_TEST_CHECK( hintsValue->Get( hints ) );
- DALI_TEST_CHECK( hints == "outputIsTransparent" );
+ DALI_TEST_CHECK( hints == Shader::Hint::OUTPUT_IS_TRANSPARENT );
Actor actor = Actor::New();
Toolkit::SetMotionStretchProperties( actor );
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
{
Property::Map map;
- map["rendererType"] = "IMAGE";
+ map["visualType"] = "IMAGE";
map["size"] = Vector2(200, 200);
map["url"] = "track2.png";
slider.SetProperty(Slider::Property::TRACK_VISUAL, map);
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali-toolkit/devel-api/controls/tool-bar/tool-bar.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
using namespace Dali;
using namespace Toolkit;
{
Actor solidColorActor = Actor::New();
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
Dali::Property::Map map;
- map[ "rendererType" ] = "COLOR";
- map[ "mixColor" ] = color;
- ControlRenderer colorRenderer = factory.CreateControlRenderer( map );
- colorRenderer.SetOnStage( solidColorActor );
+ map[ Visual::Property::TYPE ] = Visual::COLOR;
+ map[ ColorVisual::Property::MIX_COLOR ] = color;
+ Visual::Base colorVisual = factory.CreateVisual( map );
+ colorVisual.SetOnStage( solidColorActor );
return solidColorActor;
}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali/public-api/rendering/renderer.h>
+#include <dali/public-api/rendering/texture-set.h>
+#include <dali/public-api/rendering/shader.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
+const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.jpg";
+const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
+const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
+const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
+const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
+}
+
+void dali_visual_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_visual_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliVisualCopyAndAssignment(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualCopyAndAssignment" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ Visual::Base visualCopy( visual );
+ DALI_TEST_CHECK(visual == visualCopy);
+
+ Visual::Base emptyVisual;
+ Visual::Base emptyVisualCopy( emptyVisual );
+ DALI_TEST_CHECK(emptyVisual == emptyVisualCopy);
+
+ Visual::Base visualEquals;
+ visualEquals = visual;
+ DALI_TEST_CHECK(visual == visualEquals);
+
+ Visual::Base emptyVisualEquals;
+ emptyVisualEquals = emptyVisual;
+ DALI_TEST_CHECK( emptyVisual == emptyVisualEquals );
+
+ //self assignment
+ visual = visual;
+ DALI_TEST_CHECK( visual = visualCopy );
+
+ END_TEST;
+}
+
+int UtcDaliVisualSetGetDepthIndex(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualSetDepthIndex" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ visual.SetDepthIndex( 1.f );
+
+ Actor actor = Actor::New();
+ actor.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor );
+ visual.SetOnStage( actor );
+
+ int depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
+ DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( visual.GetDepthIndex(), 1.f, TEST_LOCATION );
+
+ visual.SetDepthIndex( -1.f );
+ depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
+ DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION );
+ DALI_TEST_EQUALS( visual.GetDepthIndex(), -1.f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliVisualSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetNaturalSize" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Vector2 visualSize( 20.f, 30.f );
+ Vector2 naturalSize;
+
+ // color colorVisual
+ Dali::Property::Map map;
+ map[ Visual::Property::TYPE ] = Visual::COLOR;
+ map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA;
+ Visual::Base colorVisual = factory.CreateVisual( map );
+ colorVisual.SetSize( visualSize );
+ DALI_TEST_EQUALS( colorVisual.GetSize(), visualSize, TEST_LOCATION );
+ colorVisual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
+
+ // image visual
+ Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
+ Visual::Base imageVisual = factory.CreateVisual( image );
+ imageVisual.SetSize( visualSize );
+ DALI_TEST_EQUALS( imageVisual.GetSize(), visualSize, TEST_LOCATION );
+ imageVisual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
+
+ // n patch visual
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ Vector2 testSize(80.f, 160.f);
+ platform.SetClosestImageSize(testSize);
+ image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
+ Visual::Base nPatchVisual = factory.CreateVisual( image );
+ nPatchVisual.SetSize( visualSize );
+ DALI_TEST_EQUALS( nPatchVisual.GetSize(), visualSize, TEST_LOCATION );
+ nPatchVisual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, testSize, TEST_LOCATION );
+
+ // border visual
+ float borderSize = 5.f;
+ map.Clear();
+ map[ Visual::Property::TYPE ] = Visual::BORDER;
+ map[ BorderVisual::Property::COLOR ] = Color::RED;
+ map[ BorderVisual::Property::SIZE ] = borderSize;
+ Visual::Base borderVisual = factory.CreateVisual( map );
+ borderVisual.SetSize( visualSize );
+ DALI_TEST_EQUALS( borderVisual.GetSize(), visualSize, TEST_LOCATION );
+ borderVisual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
+
+ // gradient gradientVisual
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
+ Vector2 start(-1.f, -1.f);
+ Vector2 end(1.f, 1.f);
+ propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
+ propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
+ propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector2(0.f, 1.f));
+ Property::Array stopColors;
+ stopColors.PushBack( Color::RED );
+ stopColors.PushBack( Color::GREEN );
+ propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
+ Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
+ gradientVisual.SetSize( visualSize );
+ DALI_TEST_EQUALS( gradientVisual.GetSize(), visualSize, TEST_LOCATION );
+ gradientVisual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
+
+ //svg visual
+ Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
+ svgVisual.SetSize( visualSize );
+ DALI_TEST_EQUALS( svgVisual.GetSize(), visualSize, TEST_LOCATION );
+ svgVisual.GetNaturalSize(naturalSize);
+ // TEST_SVG_FILE:
+ // <svg width="100" height="100">
+ // <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
+ // </svg>
+ DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliVisualSetOnOffStage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualSetDepthIndex" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ Actor actor = Actor::New();
+ actor.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ visual.SetOnStage( actor );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ visual.SetOffStage( actor );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+int UtcDaliVisualRemoveAndReset(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "intUtcDaliVisualRemoveAndReset" );
+
+ VisualFactory factory = VisualFactory::Get();
+
+ Actor actor = Actor::New();
+ actor.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor );
+
+ Visual::Base imageVisual;
+ // test calling RemoveAndReset with an empty handle
+ try
+ {
+ imageVisual.RemoveAndReset( actor );
+ tet_result(TET_PASS);
+ }
+ catch (DaliException& exception)
+ {
+ tet_result(TET_FAIL);
+ }
+
+ Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
+ imageVisual = factory.CreateVisual(image);
+ DALI_TEST_CHECK( imageVisual );
+
+ imageVisual.SetOnStage( actor );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ imageVisual.RemoveAndReset( actor );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); // visual is removed from actor
+ DALI_TEST_CHECK( !imageVisual ); // visual is reset
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetPropertyMap1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap1: ColorVisual" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base colorVisual = factory.CreateVisual( propertyMap );
+
+ Property::Map resultMap;
+ colorVisual.CreatePropertyMap( resultMap );
+
+ Property::Value* typeValue = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_CHECK( typeValue->Get<int>() == Visual::COLOR );
+
+ Property::Value* colorValue = resultMap.Find( ColorVisual::Property::MIX_COLOR, Property::VECTOR4 );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
+
+ // change the blend color
+ Actor actor;
+ colorVisual.RemoveAndReset( actor );
+ propertyMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
+ colorVisual = factory.CreateVisual( propertyMap );
+ colorVisual.CreatePropertyMap( resultMap );
+
+ colorValue = resultMap.Find( ColorVisual::Property::MIX_COLOR, Property::VECTOR4 );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetPropertyMap2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap2: BorderVisual" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
+ propertyMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
+ propertyMap.Insert(BorderVisual::Property::SIZE, 5.f);
+ Visual::Base borderVisual = factory.CreateVisual( propertyMap );
+
+ Property::Map resultMap;
+ borderVisual.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from visual
+ Property::Value* typeValue = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_CHECK( typeValue->Get<int>() == Visual::BORDER );
+
+ Property::Value* colorValue = resultMap.Find( BorderVisual::Property::COLOR, Property::VECTOR4 );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
+
+ Property::Value* sizeValue = resultMap.Find( BorderVisual::Property::SIZE, Property::FLOAT );
+ DALI_TEST_CHECK( sizeValue );
+ DALI_TEST_CHECK( sizeValue->Get<float>() == 5.f );
+
+ Property::Map propertyMap1;
+ propertyMap1[ Visual::Property::TYPE ] = Visual::BORDER;
+ propertyMap1[ BorderVisual::Property::COLOR ] = Color::CYAN;
+ propertyMap1[ BorderVisual::Property::SIZE ] = 10.0f;
+ borderVisual = factory.CreateVisual( propertyMap1 );
+ borderVisual.CreatePropertyMap( resultMap );
+
+ typeValue = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_CHECK( typeValue->Get<int>() == Visual::BORDER );
+
+ colorValue = resultMap.Find( BorderVisual::Property::COLOR, Property::VECTOR4 );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
+
+ colorValue = resultMap.Find( BorderVisual::Property::SIZE, Property::FLOAT );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_CHECK( colorValue->Get<float>() == 10.f );
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetPropertyMap3(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap3: linear GradientVisual" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
+
+ Vector2 start(-1.f, -1.f);
+ Vector2 end(1.f, 1.f);
+ propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
+ propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
+ propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
+
+ propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector2(0.2f, 0.8f));
+
+ Property::Array stopColors;
+ stopColors.PushBack( Color::RED );
+ stopColors.PushBack( Color::GREEN );
+ propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
+
+ Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
+
+ Property::Map resultMap;
+ gradientVisual.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from visual
+ Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::GRADIENT );
+
+ value = resultMap.Find( GradientVisual::Property::UNITS, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == GradientVisual::Units::OBJECT_BOUNDING_BOX );
+
+ value = resultMap.Find( GradientVisual::Property::SPREAD_METHOD, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == GradientVisual::SpreadMethod::REPEAT );
+
+ value = resultMap.Find( GradientVisual::Property::START_POSITION, Property::VECTOR2 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( GradientVisual::Property::END_POSITION, Property::VECTOR2 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( GradientVisual::Property::STOP_OFFSET, Property::ARRAY );
+ DALI_TEST_CHECK( value );
+ Property::Array* offsetArray = value->GetArray();
+ DALI_TEST_CHECK( offsetArray->Count() == 2 );
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.2f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.8f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( GradientVisual::Property::STOP_COLOR, Property::ARRAY );
+ DALI_TEST_CHECK( value );
+ Property::Array* colorArray = value->GetArray();
+ DALI_TEST_CHECK( colorArray->Count() == 2 );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetPropertyMap4(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap4: radial GradientVisual" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
+
+ Vector2 center(100.f, 100.f);
+ float radius = 100.f;
+ propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
+ propertyMap.Insert(GradientVisual::Property::CENTER, center);
+ propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
+ propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector3(0.1f, 0.3f, 1.1f));
+
+ Property::Array stopColors;
+ stopColors.PushBack( Color::RED );
+ stopColors.PushBack( Color::BLACK );
+ stopColors.PushBack( Color::GREEN );
+ propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
+
+ Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK( gradientVisual );
+
+ Property::Map resultMap;
+ gradientVisual.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from visual
+ Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::GRADIENT );
+
+ value = resultMap.Find( GradientVisual::Property::UNITS, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == GradientVisual::Units::USER_SPACE );
+
+ value = resultMap.Find( GradientVisual::Property::SPREAD_METHOD, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == GradientVisual::SpreadMethod::PAD );
+
+ value = resultMap.Find( GradientVisual::Property::CENTER, Property::VECTOR2 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector2>(), center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( GradientVisual::Property::RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), radius , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( GradientVisual::Property::STOP_OFFSET, Property::ARRAY );
+ DALI_TEST_CHECK( value );
+ Property::Array* offsetArray = value->GetArray();
+ DALI_TEST_CHECK( offsetArray->Count() == 3 );
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.1f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.3f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ // any stop value will be clamped to [0.0, 1.0];
+ DALI_TEST_EQUALS( offsetArray->GetElementAt(2).Get<float>(), 1.0f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( GradientVisual::Property::STOP_COLOR, Property::ARRAY );
+ DALI_TEST_CHECK( value );
+ Property::Array* colorArray = value->GetArray();
+ DALI_TEST_CHECK( colorArray->Count() == 3 );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::BLACK , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_EQUALS( colorArray->GetElementAt(2).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetPropertyMap5(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap5: ImageVisual" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
+ propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
+ propertyMap.Insert( ImageVisual::Property::FITTING_MODE, FittingMode::FIT_HEIGHT );
+ propertyMap.Insert( ImageVisual::Property::SAMPLING_MODE, SamplingMode::BOX_THEN_NEAREST );
+ propertyMap.Insert( "synchronousLoading", true );
+
+ Visual::Base imageVisual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK( imageVisual );
+
+ Property::Map resultMap;
+ imageVisual.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from visual
+ Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
+
+ value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
+
+ value = resultMap.Find( ImageVisual::Property::FITTING_MODE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == FittingMode::FIT_HEIGHT );
+
+ value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX_THEN_NEAREST );
+
+ value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == 20 );
+
+ value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == 30 );
+
+ value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<bool>() == true );
+
+ // Get an image visual with an image handle, and test the default property values
+ Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
+ imageVisual = factory.CreateVisual(image);
+ imageVisual.CreatePropertyMap( resultMap );
+
+ value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
+
+ value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
+
+ value = resultMap.Find( ImageVisual::Property::FITTING_MODE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == FittingMode::SHRINK_TO_FIT );
+
+ value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX );
+
+ value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == 100 );
+
+ value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == 200 );
+
+ value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<bool>() == false );
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetPropertyMap6(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap6: NPatchVisual" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
+ Visual::Base nPatchVisual = factory.CreateVisual( propertyMap );
+
+ Property::Map resultMap;
+ nPatchVisual.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from visual
+ Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
+
+ value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
+
+ value = resultMap.Find( ImageVisual::Property::BORDER_ONLY, Property::BOOLEAN );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<bool>() );
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetPropertyMap7(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap7: SvgVisual" );
+
+ // request SvgVisual with a property map
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
+ Visual::Base svgVisual = factory.CreateVisual( propertyMap );
+
+ Property::Map resultMap;
+ svgVisual.CreatePropertyMap( resultMap );
+ // check the property values from the returned map from a visual
+ Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
+
+ value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
+
+ // request SvgVisual with an URL
+ Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
+ resultMap.Clear();
+ svgVisual2.CreatePropertyMap( resultMap );
+ // check the property values from the returned map from a visual
+ value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
+
+ value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
+
+ END_TEST;
+}
+
+//Mesh visual
+int UtcDaliVisualGetPropertyMap8(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap8: MeshVisual" );
+
+ //Request MeshVisual using a property map.
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_LOCATION );
+ propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
+ propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 5.0f, 10.0f, 15.0f) );
+ Visual::Base meshVisual = factory.CreateVisual( propertyMap );
+
+ Property::Map resultMap;
+ meshVisual.CreatePropertyMap( resultMap );
+
+ //Check values in the result map are identical to the initial map's values.
+ Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::MESH, TEST_LOCATION );
+
+ value = resultMap.Find( MeshVisual::Property::OBJECT_URL, Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<std::string>(), TEST_OBJ_FILE_NAME, TEST_LOCATION );
+
+ value = resultMap.Find( MeshVisual::Property::MATERIAL_URL, Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<std::string>(), TEST_MTL_FILE_NAME, TEST_LOCATION );
+
+ value = resultMap.Find( MeshVisual::Property::TEXTURES_PATH, Property::STRING );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<std::string>(), TEST_RESOURCE_LOCATION, TEST_LOCATION );
+
+ value = resultMap.Find( MeshVisual::Property::SHADING_MODE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), (int)MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING, TEST_LOCATION );
+
+ value = resultMap.Find( MeshVisual::Property::LIGHT_POSITION, Property::VECTOR3 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ END_TEST;
+}
+
+//Primitive shape visual
+int UtcDaliVisualGetPropertyMap9(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetPropertyMap9: PrimitiveVisual" );
+
+ Vector4 color = Vector4( 1.0, 0.8, 0.6, 1.0);
+ Vector3 dimensions = Vector3( 1.0, 2.0, 3.0 );
+
+ //Request PrimitiveVisual using a property map.
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
+ propertyMap.Insert( PrimitiveVisual::Property::COLOR, color );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
+ propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, dimensions );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.3f );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.6f );
+ propertyMap.Insert( PrimitiveVisual::Property::LIGHT_POSITION, Vector3( 5.0f, 10.0f, 15.0f) );
+ Visual::Base primitiveVisual = factory.CreateVisual( propertyMap );
+
+ Property::Map resultMap;
+ primitiveVisual.CreatePropertyMap( resultMap );
+
+ //Check values in the result map are identical to the initial map's values.
+ Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::PRIMITIVE, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::SHAPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), (int)PrimitiveVisual::Shape::CUBE, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::COLOR, Property::VECTOR4 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<Vector4>() == color );
+ DALI_TEST_EQUALS( value->Get<Vector4>(), color, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::SLICES, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::STACKS, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 20, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::SCALE_TOP_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 30.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 40.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::SCALE_HEIGHT, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 50.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::SCALE_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 60.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::SCALE_DIMENSIONS, Property::VECTOR3 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector3>(), dimensions, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 0.3f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 0.6f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ value = resultMap.Find( PrimitiveVisual::Property::LIGHT_POSITION, Property::VECTOR3 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ END_TEST;
+}
#include <dali/public-api/rendering/renderer.h>
#include <dali/public-api/rendering/texture-set.h>
#include <dali/public-api/rendering/shader.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/dali-toolkit.h>
using namespace Dali;
using namespace Dali::Toolkit;
const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
+const char* TEST_SIMPLE_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube-Points-Only.obj";
const char* TEST_SIMPLE_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal-Simple.mtl";
Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
return resourcePtr;
}
-void TestControlRendererRender( ToolkitTestApplication& application,
+void TestVisualRender( ToolkitTestApplication& application,
Actor& actor,
- ControlRenderer& controlRenderer,
+ Visual::Base& visual,
std::size_t expectedSamplers = 0,
ImageDimensions imageDimensions = ImageDimensions(),
Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
actor.SetSize( 200.f, 200.f );
Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2(200.f, 200.f) );
- controlRenderer.SetOnStage( actor );
+ visual.SetSize( Vector2(200.f, 200.f) );
+ visual.SetOnStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
} // namespace
-void dali_renderer_factory_startup(void)
+void dali_visual_factory_startup(void)
{
test_return_value = TET_UNDEF;
}
-void dali_renderer_factory_cleanup(void)
+void dali_visual_factory_cleanup(void)
{
test_return_value = TET_PASS;
}
-int UtcDaliRendererFactoryGet(void)
+int UtcDaliVisualFactoryGet(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactory" );
+ tet_infoline( "UtcDaliVisualFactory" );
//Register type
TypeInfo type;
- type = TypeRegistry::Get().GetTypeInfo( "RendererFactory" );
+ type = TypeRegistry::Get().GetTypeInfo( "VisualFactory" );
DALI_TEST_CHECK( type );
BaseHandle handle = type.CreateInstance();
DALI_TEST_CHECK( handle );
- RendererFactory factory;
- factory = RendererFactory::Get();
+ VisualFactory factory;
+ factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
- RendererFactory newFactory = RendererFactory::Get();
+ VisualFactory newFactory = VisualFactory::Get();
DALI_TEST_CHECK( newFactory );
// Check that renderer factory is a singleton
END_TEST;
}
-int UtcDaliRendererFactoryCopyAndAssignment(void)
+int UtcDaliVisualFactoryCopyAndAssignment(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryCopyAndAssignment" );
- RendererFactory factory = RendererFactory::Get();
+ tet_infoline( "UtcDaliVisualFactoryCopyAndAssignment" );
+ VisualFactory factory = VisualFactory::Get();
- RendererFactory factoryCopy( factory );
+ VisualFactory factoryCopy( factory );
DALI_TEST_CHECK(factory == factoryCopy);
- RendererFactory emptyFactory;
- RendererFactory emptyFactoryCopy( emptyFactory );
+ VisualFactory emptyFactory;
+ VisualFactory emptyFactoryCopy( emptyFactory );
DALI_TEST_CHECK(emptyFactory == emptyFactoryCopy);
- RendererFactory factoryEquals;
+ VisualFactory factoryEquals;
factoryEquals = factory;
DALI_TEST_CHECK(factory == factoryEquals);
- RendererFactory emptyFactoryEquals;
+ VisualFactory emptyFactoryEquals;
emptyFactoryEquals = emptyFactory;
DALI_TEST_CHECK( emptyFactory == emptyFactoryEquals );
END_TEST;
}
-int UtcDaliRendererFactoryGetColorRenderer1(void)
+int UtcDaliVisualFactoryGetColorVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetColorRenderer1: Request color renderer with a Property::Map" );
+ tet_infoline( "UtcDaliVisualFactoryGetColorVisual1: Request color visual with a Property::Map" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
- propertyMap.Insert("rendererType", "COLOR");
- propertyMap.Insert("mixColor", testColor);
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, testColor);
- ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer );
+ TestVisualRender( application, actor, visual );
Vector4 actualValue(Vector4::ZERO);
TestGlAbstraction& gl = application.GetGlAbstraction();
END_TEST;
}
-int UtcDaliRendererFactoryGetColorRenderer2(void)
+int UtcDaliVisualFactoryGetColorVisual2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetColorRenderer2: Request color renderer with a Vector4" );
+ tet_infoline( "UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
Dali::Property::Map map;
- map[ "rendererType" ] = "COLOR";
- map[ "mixColor" ] = testColor;
- ControlRenderer controlRenderer = factory.CreateControlRenderer( map );
- DALI_TEST_CHECK( controlRenderer );
+ map[ Visual::Property::TYPE ] = Visual::COLOR;
+ map[ ColorVisual::Property::MIX_COLOR ] = testColor;
+ Visual::Base visual = factory.CreateVisual( map );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer );
+ TestVisualRender( application, actor, visual );
Vector4 actualValue(Vector4::ZERO);
TestGlAbstraction& gl = application.GetGlAbstraction();
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
}
-int UtcDaliRendererFactoryGetBorderRenderer1(void)
+int UtcDaliVisualFactoryGetBorderVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetBorderRenderer1: Request border renderer with a Property::Map" );
+ tet_infoline( "UtcDaliVisualFactoryGetBorderVisual1: Request border visual with a Property::Map" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
float testSize = 5.f;
- propertyMap.Insert("rendererType", "BORDER");
- propertyMap.Insert("borderColor", testColor);
- propertyMap.Insert("borderSize", testSize);
+ propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
+ propertyMap.Insert(BorderVisual::Property::COLOR, testColor);
+ propertyMap.Insert(BorderVisual::Property::SIZE, testSize);
- ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
actor.SetSize(200.f, 200.f);
Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize(Vector2(200.f, 200.f));
- controlRenderer.SetOnStage( actor );
+ visual.SetSize(Vector2(200.f, 200.f));
+ visual.SetOnStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
}
-int UtcDaliRendererFactoryGetBorderRenderer2(void)
+int UtcDaliVisualFactoryGetBorderVisual2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetBorderRenderer2: Request border renderer with a borderSize and a borderColor" );
+ tet_infoline( "UtcDaliVisualFactoryGetBorderVisual2: Request border visual with a borderSize and a borderColor" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
float testSize = 5.f;
Dali::Property::Map propertyMap;
- propertyMap[ "rendererType" ] = "BORDER";
- propertyMap[ "borderColor" ] = testColor;
- propertyMap[ "borderSize" ] = testSize;
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ propertyMap[ Visual::Property::TYPE ] = Visual::BORDER;
+ propertyMap[ BorderVisual::Property::COLOR ] = testColor;
+ propertyMap[ BorderVisual::Property::SIZE ] = testSize;
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
actor.SetSize(200.f, 200.f);
Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize(Vector2(200.f, 200.f));
- controlRenderer.SetOnStage( actor );
+ visual.SetSize(Vector2(200.f, 200.f));
+ visual.SetOnStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
// enable the anti-aliasing
Dali::Property::Map map;
- map[ "rendererType" ] = "BORDER";
- map[ "borderColor" ] = testColor;
- map[ "borderSize" ] = testSize;
- map[ "antiAliasing" ] = true;
- controlRenderer = factory.CreateControlRenderer( map );
- controlRenderer.SetOnStage( actor );
+ map[ Visual::Property::TYPE ] = Visual::BORDER;
+ map[ BorderVisual::Property::COLOR ] = testColor;
+ map[ BorderVisual::Property::SIZE ] = testSize;
+ map[ BorderVisual::Property::ANTI_ALIASING ] = true;
+ visual = factory.CreateVisual( map );
+ visual.SetOnStage( actor );
application.SendNotification();
application.Render(0);
END_TEST;
}
-int UtcDaliRendererFactoryGetLinearGradientRenderer(void)
+int UtcDaliVisualFactoryGetLinearGradientVisual(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliRendererFactoryGetRadialGradientRenderer");
+ tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "GRADIENT");
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
Vector2 start(-1.f, -1.f);
Vector2 end(1.f, 1.f);
- propertyMap.Insert("startPosition", start);
- propertyMap.Insert("endPosition", end);
- propertyMap.Insert("spreadMethod", "REPEAT");
+ propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
+ propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
+ propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
Property::Array stopOffsets;
stopOffsets.PushBack( 0.2f );
stopOffsets.PushBack( 0.8f );
- propertyMap.Insert("stopOffset", stopOffsets);
+ propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
Property::Array stopColors;
stopColors.PushBack( Color::RED );
stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("stopColor", stopColors);
+ propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
- ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK( visual );
// A lookup texture is generated and pass to shader as sampler
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, 1u );
+ TestVisualRender( application, actor, visual, 1u );
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
}
-int UtcDaliRendererFactoryGetRadialGradientRenderer(void)
+int UtcDaliVisualFactoryGetRadialGradientVisual(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliRendererFactoryGetRadialGradientRenderer");
+ tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "GRADIENT");
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
Vector2 center(100.f, 100.f);
float radius = 100.f;
- propertyMap.Insert("units", "USER_SPACE");
- propertyMap.Insert("center", center);
- propertyMap.Insert("radius", radius);
+ propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
+ propertyMap.Insert(GradientVisual::Property::CENTER, center);
+ propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
Property::Array stopOffsets;
stopOffsets.PushBack( 0.0f );
stopOffsets.PushBack( 1.f );
- propertyMap.Insert("stopOffset", stopOffsets);
+ propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
Property::Array stopColors;
stopColors.PushBack( Color::RED );
stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("stopColor", stopColors);
+ propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
- ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK( visual );
// A lookup texture is generated and pass to shader as sampler
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, 1u );
+ TestVisualRender( application, actor, visual, 1u );
Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
alignMatrix.Invert();
END_TEST;
}
-int UtcDaliRendererFactoryDefaultOffsetsGradientRenderer(void)
+int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliRendererFactoryGetRadialGradientRenderer");
+ tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
- propertyMap.Insert("rendererType", "GRADIENT");
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
Vector2 start(-1.f, -1.f);
Vector2 end(1.f, 1.f);
- propertyMap.Insert("startPosition", start);
- propertyMap.Insert("endPosition", end);
- propertyMap.Insert("spreadMethod", "REPEAT");
+ propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
+ propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
+ propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
Property::Array stopColors;
stopColors.PushBack( Color::RED );
stopColors.PushBack( Color::GREEN );
- propertyMap.Insert("stopColor", stopColors);
+ propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
- ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap);
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK( visual );
// A lookup texture is generated and pass to shader as sampler
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, 1u );
+ TestVisualRender( application, actor, visual, 1u );
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
}
-int UtcDaliRendererFactoryGetImageRenderer1(void)
+int UtcDaliVisualFactoryGetImageVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetImageRenderer1: Request image renderer with a Property::Map" );
+ tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image renderer with a Property::Map" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "IMAGE" );
- propertyMap.Insert( "url", TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
// For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(width, height),
Integration::ResourcePointer( bitmap ) );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
}
-int UtcDaliRendererFactoryGetImageRenderer2(void)
+int UtcDaliVisualFactoryGetImageVisual2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetImageRenderer2: Request image renderer with an image handle" );
+ tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image renderer with an image handle" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- ControlRenderer controlRenderer = factory.CreateControlRenderer( image );
+ Visual::Base visual = factory.CreateVisual( image );
Actor actor = Actor::New();
// For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(width, height),
Integration::ResourcePointer(bitmap) );
END_TEST;
}
-int UtcDaliRendererFactoryGetNPatchRenderer1(void)
+int UtcDaliVisualFactoryGetNPatchVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetNPatchRenderer1: Request 9-patch renderer with a Property::Map" );
+ tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch renderer with a Property::Map" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
const unsigned int ninePatchImageHeight = 18;
Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "IMAGE" );
- propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
{
tet_infoline( "whole grid" );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
ninePatchResource );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
}
- propertyMap.Insert( "borderOnly", true );
+ propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
{
tet_infoline( "border only" );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
ninePatchResource );
END_TEST;
}
-int UtcDaliRendererFactoryGetNPatchRenderer2(void)
+int UtcDaliVisualFactoryGetNPatchVisual2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetNPatchRenderer2: Request n-patch renderer with a Property::Map" );
+ tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch renderer with a Property::Map" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
const unsigned int ninePatchImageWidth = 18;
Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "IMAGE" );
- propertyMap.Insert( "url", TEST_NPATCH_FILE_NAME );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
{
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
TestGlAbstraction& gl = application.GetGlAbstraction();
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
ninePatchResource );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
}
- propertyMap.Insert( "borderOnly", true );
+ propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
{
tet_infoline( "border only" );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
TestGlAbstraction& gl = application.GetGlAbstraction();
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
Actor actor = Actor::New();
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
ninePatchResource );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
}
END_TEST;
}
-int UtcDaliRendererFactoryGetNPatchRenderer3(void)
+int UtcDaliVisualFactoryGetNPatchVisual3(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetNPatchRenderer3: Request 9-patch renderer with an image url" );
+ tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch renderer with an image url" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
const unsigned int ninePatchImageHeight = 18;
stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( TEST_NPATCH_FILE_NAME, ImageDimensions() );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
ninePatchResource );
END_TEST;
}
-int UtcDaliRendererFactoryGetNPatchRenderer4(void)
+int UtcDaliVisualFactoryGetNPatchVisual4(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetNPatchRenderer4: Request n-patch renderer with an image url" );
+ tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual4: Request n-patch visual with an image url" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
const unsigned int ninePatchImageHeight = 18;
stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( TEST_NPATCH_FILE_NAME, ImageDimensions() );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
ninePatchResource );
END_TEST;
}
-int UtcDaliRendererFactoryGetNPatchRendererN1(void)
+int UtcDaliVisualFactoryGetNPatchVisualN1(void)
{
//This should still load but display an error image
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetNPatchRendererN: Request n-patch renderer with an invalid image url" );
+ tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( "ERROR.9.jpg", ImageDimensions() );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(),
Integration::ResourcePointer(bitmap) );
END_TEST;
}
-int UtcDaliRendererFactoryGetNPatchRendererN2(void)
+int UtcDaliVisualFactoryGetNPatchVisualN2(void)
{
//This should still load but display an error image
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetNPatchRendererN: Request n-patch renderer with an invalid Property::Map" );
+ tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid Property::Map" );
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", 111 );
- propertyMap.Insert( "url", "ERROR.9.jpg" );
+ propertyMap.Insert( Visual::Property::TYPE, 111 );
+ propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
Actor actor = Actor::New();
TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestControlRendererRender( application, actor, controlRenderer, 1u,
+ TestVisualRender( application, actor, visual, 1u,
ImageDimensions(),
Integration::ResourcePointer(bitmap) );
END_TEST;
}
-int UtcDaliRendererFactoryGetSvgRenderer(void)
+int UtcDaliVisualFactoryGetSvgVisual(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetSvgRenderer: Request svg renderer with a svg url" );
+ tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
- RendererFactory factory = RendererFactory::Get();
- ControlRenderer controlRenderer = factory.CreateControlRenderer( TEST_SVG_FILE_NAME, ImageDimensions() );
- DALI_TEST_CHECK( controlRenderer );
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
+ DALI_TEST_CHECK( visual );
TestGlAbstraction& gl = application.GetGlAbstraction();
TraceCallStack& textureTrace = gl.GetTextureTrace();
Actor actor = Actor::New();
actor.SetSize( 200.f, 200.f );
Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2(200.f, 200.f) );
- controlRenderer.SetOnStage( actor );
+ visual.SetSize( Vector2(200.f, 200.f) );
+ visual.SetOnStage( actor );
application.SendNotification();
application.Render();
END_TEST;
}
-//Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
-int UtcDaliRendererFactoryGetMeshRenderer1(void)
+//Creates a mesh renderer from the given propertyMap and tries to load it on stage in the given application.
+//This is expected to succeed, which will then pass the test.
+void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetMeshRenderer1: Request mesh renderer with a valid object file only" );
-
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
- //Set up renderer properties.
- Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "MESH" );
- propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
-
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ //Create a mesh visual.
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+ //Create an actor on stage to house the visual.
Actor actor = Actor::New();
actor.SetSize( 200.f, 200.f );
Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
- controlRenderer.SetOnStage( actor );
+ visual.SetSize( Vector2( 200.f, 200.f ) );
+ visual.SetOnStage( actor );
+ //Ensure set on stage.
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+
+ //Attempt to render to queue resource load requests.
application.SendNotification();
application.Render( 0 );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
//Tell the platform abstraction that the required resources have been loaded.
TestPlatformAbstraction& platform = application.GetPlatform();
platform.SetAllResourceRequestsAsLoaded();
application.SendNotification();
application.Render( 0 );
- TestGlAbstraction& gl = application.GetGlAbstraction();
-
Matrix testScaleMatrix;
testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
Matrix actualScaleMatrix;
//Test to see if the object has been successfully loaded.
- DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
+ DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
- controlRenderer.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
- END_TEST;
+ //Finish by setting off stage, and ensuring this was successful.
+ visual.SetOffStage( actor );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
}
-//Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
-int UtcDaliRendererFactoryGetMeshRenderer2(void)
+//Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
+//This is expected to fail, which will then pass the test.
+void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetMeshRenderer2: Request mesh renderer with blank material file and images directory" );
-
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
- //Set up renderer properties.
- Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "MESH" );
- propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
- propertyMap.Insert( "materialUrl", "" );
- propertyMap.Insert( "texturesPath", "" );
-
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ //Create a mesh visual.
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
- //Add renderer to an actor on stage.
+ //Create an actor on stage to house the visual.
Actor actor = Actor::New();
actor.SetSize( 200.f, 200.f );
Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
- controlRenderer.SetOnStage( actor );
+ visual.SetSize( Vector2( 200.f, 200.f ) );
+ visual.SetOnStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ //Ensure set on stage.
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
//Attempt to render to queue resource load requests.
application.SendNotification();
application.SendNotification();
application.Render( 0 );
- TestGlAbstraction& gl = application.GetGlAbstraction();
-
- Matrix testScaleMatrix;
- testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
- Matrix actualScaleMatrix;
-
- //Test to see if the object has been successfully loaded.
- DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
- DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- controlRenderer.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ //Test to see if the object has not been loaded, as expected.
+ Matrix scaleMatrix;
+ DALI_TEST_CHECK( !application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
- END_TEST;
+ //Finish by setting off stage, and ensuring this was successful.
+ visual.SetOffStage( actor );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
}
-//Test if mesh loads correctly when supplied with all parameters, an object file, a material file and a directory location.
-int UtcDaliRendererFactoryGetMeshRenderer3(void)
+//Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
+int UtcDaliVisualFactoryGetMeshVisual1(void)
{
+ //Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetMeshRenderer3: Request mesh renderer with all parameters correct" );
-
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
- //Set up renderer properties.
- Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "MESH" );
- propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
- propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
- propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisual1: Request mesh visual with a valid object file only" );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
- //Add renderer to an actor on stage.
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
- controlRenderer.SetOnStage( actor );
-
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
- //Attempt to render to queue resource load requests.
- application.SendNotification();
- application.Render( 0 );
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest( propertyMap, application );
- //Tell the platform abstraction that the required resources have been loaded.
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetAllResourceRequestsAsLoaded();
+ END_TEST;
+}
- //Render again to upload the now-loaded textures.
- application.SendNotification();
- application.Render( 0 );
- TestGlAbstraction& gl = application.GetGlAbstraction();
+//Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
+int UtcDaliVisualFactoryGetMeshVisual2(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
- Matrix testScaleMatrix;
- testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
- Matrix actualScaleMatrix;
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisual2: Request mesh visual with blank material file and images directory" );
- //Test to see if the object has been successfully loaded.
- DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
- DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" );
- controlRenderer.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest( propertyMap, application );
END_TEST;
}
-//Test if mesh renderer can load a correctly supplied mesh without a normal map or gloss map in the material file.
-int UtcDaliRendererFactoryGetMeshRenderer4(void)
+//Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
+int UtcDaliVisualFactoryGetMeshVisual3(void)
{
+ //Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetMeshRenderer4: Request mesh renderer with diffuse texture but not normal or gloss." );
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "MESH" );
- propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
- propertyMap.Insert( "materialUrl", TEST_SIMPLE_MTL_FILE_NAME );
- propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
-
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
- //Add renderer to an actor on stage.
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
- controlRenderer.SetOnStage( actor );
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest( propertyMap, application );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- //Attempt to render to queue resource load requests.
- application.SendNotification();
- application.Render( 0 );
+ END_TEST;
+}
- //Tell the platform abstraction that the required resources have been loaded.
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetAllResourceRequestsAsLoaded();
+//Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
+int UtcDaliVisualFactoryGetMeshVisual4(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
- //Render again to upload the now-loaded textures.
- application.SendNotification();
- application.Render( 0 );
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisual4: Request mesh visual with diffuse texture but not normal or gloss." );
- TestGlAbstraction& gl = application.GetGlAbstraction();
- Matrix testScaleMatrix;
- testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
- Matrix actualScaleMatrix;
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
- //Test to see if the object has been successfully loaded.
- DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
- DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest( propertyMap, application );
- controlRenderer.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
}
-//Test if mesh renderer handles the case of lacking an object file.
-int UtcDaliRendererFactoryGetMeshRendererN1(void)
+//Test if mesh visual can load when made to use diffuse textures only.
+int UtcDaliVisualFactoryGetMeshVisual5(void)
{
+ //Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetMeshRendererN1: Request mesh renderer without object file" );
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual and make it only use diffuse textures." );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "MESH" );
- propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
- propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
+ propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING );
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest( propertyMap, application );
- //Add renderer to an actor on stage.
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
- controlRenderer.SetOnStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ END_TEST;
+}
- //Attempt to render to queue resource load requests.
- application.SendNotification();
- application.Render( 0 );
+//Test if mesh visual can load when made to not use the supplied textures.
+int UtcDaliVisualFactoryGetMeshVisual6(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
- //Tell the platform abstraction that the required resources have been loaded.
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetAllResourceRequestsAsLoaded();
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisual6: Request mesh visual and make it not use any textures." );
- //Render again to upload the now-loaded textures.
- application.SendNotification();
- application.Render( 0 );
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
+ propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
- TestGlAbstraction& gl = application.GetGlAbstraction();
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest( propertyMap, application );
- //Test to see if the object has not been loaded, as expected.
- Matrix scaleMatrix;
- DALI_TEST_CHECK( ! gl.GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
+ END_TEST;
+}
+//Test if mesh visual loads correctly when light position is manually set.
+int UtcDaliVisualFactoryGetMeshVisual7(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
- controlRenderer.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisual7: Request mesh visual with custom light position." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
+ propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest( propertyMap, application );
END_TEST;
}
-//Test if mesh renderer handles the case of being passed invalid material and images urls.
-int UtcDaliRendererFactoryGetMeshRendererN2(void)
+//Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
+//Note that this notably tests object loader functionality.
+int UtcDaliVisualFactoryGetMeshVisual8(void)
{
+ //Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetMeshRendererN2: Request mesh renderer with invalid material and images urls" );
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual with normal-less object file." );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "MESH" );
- propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
- propertyMap.Insert( "materialUrl", "invalid" );
- propertyMap.Insert( "texturesPath", "also invalid" );
-
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
- //Add renderer to an actor on stage.
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
- controlRenderer.SetOnStage( actor );
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest( propertyMap, application );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- //Attempt to render to queue resource load requests.
- application.SendNotification();
- application.Render( 0 );
+ END_TEST;
+}
- //Tell the platform abstraction that the required resources have been loaded.
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetAllResourceRequestsAsLoaded();
+//Test if mesh visual handles the case of lacking an object file.
+int UtcDaliVisualFactoryGetMeshVisualN1(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
- //Render again to upload the now-loaded textures.
- application.SendNotification();
- application.Render( 0 );
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file" );
- TestGlAbstraction& gl = application.GetGlAbstraction();
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
- //Test to see if the object has not been loaded, as expected.
- Matrix scaleMatrix;
- DALI_TEST_CHECK( ! gl.GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
- controlRenderer.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
}
-//Test if mesh renderer handles the case of being passed an invalid object url
-int UtcDaliRendererFactoryGetMeshRendererN3(void)
+//Test if mesh visual handles the case of being passed invalid material and images urls.
+int UtcDaliVisualFactoryGetMeshVisualN2(void)
{
+ //Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetMeshRendererN3: Request mesh renderer with invalid object url" );
- RendererFactory factory = RendererFactory::Get();
- DALI_TEST_CHECK( factory );
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "MESH" );
- propertyMap.Insert( "objectUrl", "invalid" );
- propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
- propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
-
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
- //Add renderer to an actor on stage.
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
- controlRenderer.SetOnStage( actor );
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- //Attempt to render to queue resource load requests.
- application.SendNotification();
- application.Render( 0 );
- //Tell the platform abstraction that the required resources have been loaded.
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetAllResourceRequestsAsLoaded();
+ END_TEST;
+}
- //Render again to upload the now-loaded textures.
- application.SendNotification();
- application.Render( 0 );
+//Test if mesh visual handles the case of being passed an invalid object url
+int UtcDaliVisualFactoryGetMeshVisualN3(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url" );
- TestGlAbstraction& gl = application.GetGlAbstraction();
- //Test to see if the object has not been loaded, as expected.
- Matrix scaleMatrix;
- DALI_TEST_CHECK( ! gl.GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
- controlRenderer.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
END_TEST;
}
-//Creates a primitive renderer with the given property map and tests to see if it correctly loads in the given application.
-void TestPrimitiveRendererWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
+//Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
+void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
{
- RendererFactory factory = RendererFactory::Get();
+ VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
- //Create a primitive renderer.
- ControlRenderer controlRenderer = factory.CreateControlRenderer( propertyMap );
- DALI_TEST_CHECK( controlRenderer );
+ //Create a primitive visual.
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
- //Create an actor on stage to house the renderer.
+ //Create an actor on stage to house the visual.
Actor actor = Actor::New();
actor.SetSize( 200.f, 200.f );
Stage::GetCurrent().Add( actor );
- controlRenderer.SetSize( Vector2( 200.f, 200.f ) );
- controlRenderer.SetOnStage( actor );
+ visual.SetSize( Vector2( 200.f, 200.f ) );
+ visual.SetOnStage( actor );
//Ensure set on stage.
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
- //Tell test application to load the renderer.
+ //Tell test application to load the visual.
application.SendNotification();
application.Render(0);
DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
//Finish by setting off stage, and ensuring this was successful.
- controlRenderer.SetOffStage( actor );
+ visual.SetOffStage( actor );
DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
}
//Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
-int UtcDaliRendererFactoryGetPrimitiveRenderer1(void)
+int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRenderer1: Request primitive renderer with a shape only" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "CUBE" );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
//Test to see if shape loads correctly.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
//Test if primitive shape loads correctly when supplied with all possible parameters
-int UtcDaliRendererFactoryGetPrimitiveRenderer2(void)
+int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRenderer2: Request primitive renderer with everything" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "CUBE" );
- propertyMap.Insert( "color", Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( "slices", 10 );
- propertyMap.Insert( "stacks", 20 );
- propertyMap.Insert( "scaleTopRadius", 30.0f );
- propertyMap.Insert( "scaleBottomRadius", 40.0f );
- propertyMap.Insert( "scaleHeight", 50.0f );
- propertyMap.Insert( "scaleRadius", 60.0f );
- propertyMap.Insert( "bevelPercentage", 0.7f );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
+ propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
+ propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
+ propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
//Test to see if shape loads correctly.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
//Test if primitive shape loads a sphere correctly.
-int UtcDaliRendererFactoryGetPrimitiveRenderer3(void)
+int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRenderer3: Request primitive renderer to display a sphere" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "SPHERE" );
- propertyMap.Insert( "color", Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( "slices", 10 );
- propertyMap.Insert( "stacks", 20 );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
+ propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
//Test to see if shape loads correctly.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
//Test if primitive shape loads a conic section correctly.
-int UtcDaliRendererFactoryGetPrimitiveRenderer4(void)
+int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRenderer4: Request primitive renderer to display a conic section" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "CONICAL_FRUSTRUM" );
- propertyMap.Insert( "color", Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( "slices", 10 );
- propertyMap.Insert( "scaleTopRadius", 30.0f );
- propertyMap.Insert( "scaleBottomRadius", 40.0f );
- propertyMap.Insert( "scaleHeight", 50.0f );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
+ propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
//Test to see if shape loads correctly.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
//Test if primitive shape loads a bevelled cube correctly.
-int UtcDaliRendererFactoryGetPrimitiveRenderer5(void)
+int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRenderer5: Request primitive renderer to display a bevelled cube" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "BEVELLED_CUBE" );
- propertyMap.Insert( "color", Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( "bevelPercentage", 0.7f );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
+ propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
//Test to see if shape loads correctly.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
//Test if primitive shape loads an octahedron correctly.
-int UtcDaliRendererFactoryGetPrimitiveRenderer6(void)
+int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRenderer6: Request primitive renderer to display an octahedron" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "OCTAHEDRON" );
- propertyMap.Insert( "color", Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
+ propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
//Test to see if shape loads correctly.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
//Test if primitive shape loads a cone correctly.
-int UtcDaliRendererFactoryGetPrimitiveRenderer7(void)
+int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRenderer7: Request primitive renderer to display a cone" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual7: Request primitive visual to display a cone" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "CONE" );
- propertyMap.Insert( "color", Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( "slices", 10 );
- propertyMap.Insert( "scaleTopRadius", 30.0f );
- propertyMap.Insert( "scaleHeight", 50.0f );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
+ propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
//Test to see if shape loads correctly.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
//Test if primitive shape loads correctly when light position is manually set.
-int UtcDaliRendererFactoryGetPrimitiveRenderer8(void)
+int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRenderer8: Request primitive renderer with set light position" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual8: Request primitive visual with set light position" );
- //Set up renderer properties.
+ //Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
- propertyMap.Insert( "shape", "SPHERE" );
- propertyMap.Insert( "color", Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( "uLightPosition", Vector3( 0.0, 1.0, 2.0 ) );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
//Test to see if shape loads correctly.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
//Test if primitive shape renderer handles the case of not being passed a specific shape to use.
-int UtcDaliRendererFactoryGetPrimitiveRendererN1(void)
+int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliRendererFactoryGetPrimitiveRendererN1: Request primitive renderer without shape" );
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisualN1: Request primitive visual without shape" );
- //Set up renderer properties, without supplying shape.
+ //Set up visual properties, without supplying shape.
Property::Map propertyMap;
- propertyMap.Insert( "rendererType", "PRIMITIVE" );
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
//Test to see if shape loads regardless of missing input.
- TestPrimitiveRendererWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties( propertyMap, application );
END_TEST;
}
#
-# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+# Copyright (c) 2016 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.
develapibubbleemitterdir = $(develapicontrolsdir)/bubble-effect
develapieffectsviewdir = $(develapicontrolsdir)/effects-view
develapimagnifierdir = $(develapicontrolsdir)/magnifier
-develapirendererfactorydir = $(develapicontrolsdir)/renderer-factory
develapipopupdir = $(develapicontrolsdir)/popup
develapishadowviewdir = $(develapicontrolsdir)/shadow-view
develapisuperblurviewdir = $(develapicontrolsdir)/super-blur-view
develapitransitioneffectsdir = $(develapidir)/transition-effects
develapitoolbardir = $(develapicontrolsdir)/tool-bar
develapitextselectionpopupdir = $(develapicontrolsdir)/text-controls
+develapivisualfactorydir = $(develapidir)/visual-factory
# devel headers
+develapi_HEADERS = $(devel_api_header_files)
develapicontrols_HEADERS = $(devel_api_controls_header_files)
develapibloomview_HEADERS = $(devel_api_bloom_view_header_files)
develapibubbleemitter_HEADERS = $(devel_api_bubble_emitter_header_files)
develapiimageatlas_HEADERS = $(devel_api_image_atlas_header_files)
develapimagnifier_HEADERS = $(devel_api_magnifier_header_files)
develapipopup_HEADERS = $(devel_api_popup_header_files)
-develapirendererfactory_HEADERS = $(devel_api_renderer_factory_header_files)
+develapivisualfactory_HEADERS = $(devel_api_visual_factory_header_files)
develapiscripting_HEADERS = $(devel_api_scripting_header_files)
develapishadowview_HEADERS = $(devel_api_shadow_view_header_files)
develapishadereffects_HEADERS = $(devel_api_shader_effects_header_files)
publicapifocusmanagerdir = $(publicapidir)/focus-manager
publicapirenderingbackenddir = $(publicapidir)/text
publicapisliderdir = $(publicapicontrolsdir)/slider
+publicapivisualsdir = $(publicapidir)/visuals
# public api headers
publicapi_HEADERS = $(public_api_header_files)
publicapifocusmanager_HEADERS = $(public_api_focus_manager_header_files)
publicapirenderingbackend_HEADERS = $(public_api_rendering_backend_header_files)
publicapislider_HEADERS = $(public_api_slider_header_files)
+publicapivisuals_HEADERS = $(public_api_visuals_header_files)
# package doxygen file (contains doxygen grouping information)
packagedoxydir = $(topleveldir)/doc
#define __DALI_TOOLKIT_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
#include <dali/dali.h>
-// Toolkit
#include <dali-toolkit/public-api/controls/alignment/alignment.h>
#include <dali-toolkit/public-api/controls/buttons/button.h>
#include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
#include <dali-toolkit/public-api/controls/text-controls/text-field.h>
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/public-api/controls/video-view/video-view.h>
+
#include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
+
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+
#include <dali-toolkit/public-api/styling/style-manager.h>
+
#include <dali-toolkit/public-api/text/rendering-backend.h>
+
+#include <dali-toolkit/public-api/visuals/border-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/gradient-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/mesh-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/primitive-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
#include <dali-toolkit/public-api/dali-toolkit-version.h>
#include <dali-toolkit/public-api/enums.h>
+#include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
#endif // __DALI_TOOLKIT_H__
+++ /dev/null
-#ifndef __DALI_TOOLKIT_RENDERER_FACTORY_H__
-#define __DALI_TOOLKIT_RENDERER_FACTORY_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 <dali/public-api/object/base-handle.h>
-#include <dali/public-api/images/image-operations.h>
-#include <dali/public-api/object/property-map.h>
-
-// INTERNAK INCLUDES
-#include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
-
-namespace Dali
-{
-class Image;
-class Vector4;
-
-namespace Toolkit
-{
-
-namespace Internal DALI_INTERNAL
-{
-class RendererFactory;
-}
-
-/**
- * @brief RendererFactory is a singleton object that provides and shares renderers for controls
- *
- * By setting environment variable 'DALI_DEBUG_RENDERING', all concrete renderer is replaced with the debug renderer which renders a quad wireframe.
- *
- * The renderer type is required in the property map for requesting a control renderer.
- *
- * | %Property Name | Type |
- * |--------------------------|------------------|
- * | rendererType | STRING |
- */
-class DALI_IMPORT_API RendererFactory : public BaseHandle
-{
-public:
-
- /**
- * @brief Create or retrieve RendererFactory singleton.
- *
- * @return A handle to the RendererFactory control.
- */
- static RendererFactory Get();
-
- /**
- * @brief Create a RendererFactory handle.
- *
- * Calling member functions with an uninitialised handle is not allowed.
- */
- RendererFactory();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~RendererFactory();
-
- /**
- * @brief This copy constructor is required for (smart) pointer semantics.
- *
- * @param[in] handle A reference to the copied handle.
- */
- RendererFactory( const RendererFactory& handle );
-
- /**
- * @brief This assignment operator is required for (smart) pointer semantics.
- *
- * @param [in] handle A reference to the copied handle.
- * @return A reference to this.
- */
- RendererFactory& operator=( const RendererFactory& handle );
-
- /**
- * @brief Request the control renderer
- *
- * @param[in] propertyMap The map contains the properties required by the control renderer
- * Depends on the content of the map, different kind of renderer would be returned.
- * @return The pointer pointing to control renderer
- */
- ControlRenderer CreateControlRenderer( const Property::Map& propertyMap );
-
- /**
- * @brief Request the control renderer to render the image.
- *
- * @param[in] image The image to be rendered.
- * @return The pointer pointing to the control renderer
- */
- ControlRenderer CreateControlRenderer( const Image& image );
-
- /**
- * @brief Request the control renderer to render the given resource at the url.
- *
- * @param[in] url The URL to the resource to be rendered.
- * @param[in] size The width and height to fit the loaded image to.
- * @return The pointer pointing to the control renderer
- */
- ControlRenderer CreateControlRenderer( const std::string& url, ImageDimensions size );
-
-private:
-
- explicit DALI_INTERNAL RendererFactory(Internal::RendererFactory *impl);
-
-};
-
-
-/**
- * @brief Template to allow discard old renderer, get new one and set it on stage if possible
- *
- * @tparam ParameterType0 The type of first argument passed to the CreateControlRenderer()
- * @tparam ParameterType1 The type of second argument passed to the CreateControlRenderer()
- * @SINCE_1_0.39
- * @param[in] actor Actor for which the renderer will be replaced
- * @param[in,out] renderer The renderer object to be replaced
- * @param[in] param0 First template based argument passed to the renderer factory
- * @param[in] param1 Second template based argument passed to the renderer factory
- */
-template< class ParameterType0, class ParameterType1 >
-void InitializeControlRenderer( Actor& actor, ControlRenderer& renderer, ParameterType0& param0, ParameterType1& param1 )
-{
- renderer.RemoveAndReset( actor );
- renderer = Toolkit::RendererFactory::Get().CreateControlRenderer( param0, param1 );
- if( renderer && actor && actor.OnStage() )
- {
- renderer.SetOnStage( actor );
- }
-}
-
-/**
- * @brief Template to allow discard old renderer, get new one and set it on stage if possible
- *
- * @tparam ParameterType The type of argument passed to the CreateControlRenderer()
- * @SINCE_1_0.39
- * @param[in] actor Actor for which the renderer will be replaced
- * @param[in,out] renderer The renderer object to be replaced
- * @param[in] param Template based argument passed to the renderer factory
- */
-template< class ParameterType >
-void InitializeControlRenderer( Actor& actor, ControlRenderer& renderer, ParameterType& param )
-{
- renderer.RemoveAndReset( actor );
- renderer = Toolkit::RendererFactory::Get().CreateControlRenderer( param );
- if( renderer && actor && actor.OnStage() )
- {
- renderer.SetOnStage( actor );
- }
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-
-#endif /* __DALI_TOOLKIT_RENDERER_FACTORY_H__ */
$(devel_api_src_dir)/controls/magnifier/magnifier.cpp \
$(devel_api_src_dir)/controls/popup/confirmation-popup.cpp \
$(devel_api_src_dir)/controls/popup/popup.cpp \
- $(devel_api_src_dir)/controls/renderer-factory/renderer-factory.cpp \
- $(devel_api_src_dir)/controls/renderer-factory/control-renderer.cpp \
$(devel_api_src_dir)/controls/shadow-view/shadow-view.cpp \
$(devel_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \
$(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-cross-effect.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-effect.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-fold-effect.cpp \
- $(devel_api_src_dir)/transition-effects/cube-transition-wave-effect.cpp
+ $(devel_api_src_dir)/transition-effects/cube-transition-wave-effect.cpp \
+ $(devel_api_src_dir)/visual-factory/visual-factory.cpp \
+ $(devel_api_src_dir)/visual-factory/visual-base.cpp
# Add devel header files here
$(devel_api_src_dir)/controls/popup/confirmation-popup.h \
$(devel_api_src_dir)/controls/popup/popup.h
-devel_api_renderer_factory_header_files = \
- $(devel_api_src_dir)/controls/renderer-factory/renderer-factory.h \
- $(devel_api_src_dir)/controls/renderer-factory/control-renderer.h
+devel_api_visual_factory_header_files = \
+ $(devel_api_src_dir)/visual-factory/visual-factory.h \
+ $(devel_api_src_dir)/visual-factory/visual-base.h
devel_api_shadow_view_header_files = \
$(devel_api_src_dir)/controls/shadow-view/shadow-view.h
#define __DALI_TOOLKIT_ALPHA_DISCARD_EFFECT_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/object/property-map.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
namespace Dali
{
Property::Map map;
Property::Map customShader;
- customShader[ "fragmentShader" ] = ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE;
+ customShader[ Visual::Shader::Property::FRAGMENT_SHADER ] = ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE;
- map[ "shader" ] = customShader;
- return map;}
+ map[ Visual::Property::SHADER ] = customShader;
+ return map;
+}
} // namespace Toolkit
#include <string.h>
#include <dali/public-api/rendering/shader.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
namespace Dali
{
vertexShaderString.append( vertexShader );
fragmentShaderString.append( fragmentShader );
- customShader[ "vertexShader" ] = vertexShaderString;
- customShader[ "fragmentShader" ] = fragmentShaderString;
+ customShader[ Visual::Shader::Property::VERTEX_SHADER ] = vertexShaderString;
+ customShader[ Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShaderString;
- customShader[ "subdivideGridX" ] = 20;
- customShader[ "subdivideGridY" ] = 20;
+ customShader[ Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 20;
+ customShader[ Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 20;
- customShader[ "hints" ] = "outputIsTransparent";
+ customShader[ Visual::Shader::Property::HINTS ] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
- map[ "shader" ] = customShader;
+ map[ Visual::Property::SHADER ] = customShader;
return map;
}
#define __DALI_TOOLKIT_SHADER_EFFECT_DISTANCEFIELD_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
// EXTERNAL INCLUDES
#include <string.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/object/property-map.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
namespace Dali
{
fragmentShaderString.append( fragmentShaderPrefix );
fragmentShaderString.append( fragmentShader );
- customShader[ "fragmentShader" ] = fragmentShaderString;
- customShader[ "hints" ] = "outputIsTransparent";
+ customShader[ Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShaderString;
+ customShader[ Visual::Shader::Property::HINTS ] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
- map[ "shader" ] = customShader;
+ map[ Visual::Property::SHADER ] = customShader;
return map;
}
#define __DALI_TOOLKIT_IMAGE_REGION_EFFECT_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
// EXTERNAL INCLUDES
#include <dali/public-api/object/property-map.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
namespace Dali
{
Property::Map map;
Property::Map customShader;
- customShader[ "vertexShader" ] = vertexShader;
+ customShader[ Visual::Shader::Property::VERTEX_SHADER ] = vertexShader;
- map[ "shader" ] = customShader;
+ map[ Visual::Property::SHADER ] = customShader;
return map;
}
#define __DALI_TOOLKIT_SHADER_EFFECT_MOTION_BLUR_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
namespace Dali
{
* "uObjectFadeStart" - The displacement from the centre of the actor that the actor will start to fade towards its
* edges. This is used to prevent an unsightly hard edge between the blurred actor and the scene.
* Depends on the values of the vertices in the vertex stream. When the actor is at rest this is
- * not applied. Default 0.25, which is half way towards the edge for an ImageRenderer::QUAD.
+ * not applied. Default 0.25, which is half way towards the edge for an ImageVisual::QUAD.
* "uObjectFadeEnd" - The displacement from the centre of the actor that the actor will finish fading towards its
* edges. This is used to prevent an unsightly hard edge between the blurred actor and the scene.
* Depends on the values of the vertices in the vertex stream. When the actor is at rest this is
- * not applied.Default 0.5, which is all the way towards the edge for an ImageRenderer::QUAD.
+ * not applied.Default 0.5, which is all the way towards the edge for an ImageVisual::QUAD.
* "uAlphaScale" - Global scaler applied to the alpha of the actor. Used to make the blurred actor a bit more subtle
* (helps to hide discontinuities due to limited number of texture samples) and reveal a bit of the
* background behind it as it moves. When the actor is at rest this is not applied. Default 0.75.
Property::Map map;
Property::Map customShader;
- customShader[ "vertexShader" ] = vertexSource;
- customShader[ "fragmentShader" ] = fragmentSource;
+ customShader[ Visual::Shader::Property::VERTEX_SHADER ] = vertexSource;
+ customShader[ Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource;
- customShader[ "subdivideGridX" ] = 10;
- customShader[ "subdivideGridY" ] = 10;
+ customShader[ Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 10;
+ customShader[ Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 10;
- // NOTE: we must turn on alpha blending for the actor (HINT_BLENDING)
- customShader[ "hints" ] = "outputIsTransparent";
+ customShader[ Visual::Shader::Property::HINTS ] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
- map[ "shader" ] = customShader;
+ map[ Visual::Property::SHADER ] = customShader;
return map;
}
#define __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
namespace Dali
{
* its edges. This is used to prevent an unsightly hard edge between the stretched actor and
* the scene. Depends on the values of the vertices in the vertex stream. When the actor is at
* rest this is not applied. Default Vector2(0.25, 0.25), which is half way towards the edge for
- * an ImageRenderer::QUAD.
+ * an ImageVisual::QUAD.
* "uObjectFadeEnd" - The displacement from the centre of the actor that the actor will finish fading towards its edges.
* This is used to prevent an unsightly hard edge between the stretched actor and the scene. Depends
* on the values of the vertices in the vertex stream. When the actor is at rest this is not applied.
- * Default 0.5, which is all the way towards the edge for an ImageRenderer::QUAD.
+ * Default 0.5, which is all the way towards the edge for an ImageVisual::QUAD.
* "uAlphaScale" - Global scaler applied to the alpha of the actor. Used to make the stretched actor a bit more subtle
* and reveal a bit of the background behind it as it moves. When the actor is at rest this is not
* applied. Default 0.75.
Property::Map map;
Property::Map customShader;
- customShader[ "vertexShader" ] = vertexSource;
- customShader[ "fragmentShader" ] = fragmentSource;
+ customShader[ Visual::Shader::Property::VERTEX_SHADER ] = vertexSource;
+ customShader[ Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource;
- customShader[ "subdivideGridX" ] = 10;
- customShader[ "subdivideGridY" ] = 10;
+ customShader[ Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 10;
+ customShader[ Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 10;
- // NOTE: we must turn on alpha blending for the actor (HINT_BLENDING)
- customShader[ "hints" ] = "outputIsTransparent";
+ customShader[ Visual::Shader::Property::HINTS ] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
- map[ "shader" ] = customShader;
+ map[ Visual::Property::SHADER ] = customShader;
return map;
}
*/
// CLASS HEADER
-#include "control-renderer.h"
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+// INTERAL INCLUDES
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
namespace Toolkit
{
-ControlRenderer::ControlRenderer()
+namespace Visual
+{
+
+Base::Base()
{
}
-ControlRenderer::~ControlRenderer()
+Base::~Base()
{
}
-ControlRenderer::ControlRenderer( const ControlRenderer& handle )
+Base::Base( const Base& handle )
: BaseHandle( handle )
{
}
-ControlRenderer& ControlRenderer::operator=( const ControlRenderer& handle )
+Base& Base::operator=( const Base& handle )
{
BaseHandle::operator=( handle );
return *this;
}
-ControlRenderer::ControlRenderer(Internal::ControlRenderer *impl)
+Base::Base(Internal::Visual::Base *impl)
: BaseHandle( impl )
{
}
-void ControlRenderer::SetSize( const Vector2& size )
+void Base::SetSize( const Vector2& size )
{
GetImplementation( *this ).SetSize( size );
}
-const Vector2& ControlRenderer::GetSize() const
+const Vector2& Base::GetSize() const
{
return GetImplementation( *this ).GetSize();
}
-void ControlRenderer::GetNaturalSize(Vector2& naturalSize ) const
+void Base::GetNaturalSize(Vector2& naturalSize ) const
{
GetImplementation( *this ).GetNaturalSize( naturalSize );
}
-void ControlRenderer::SetDepthIndex( float index )
+void Base::SetDepthIndex( float index )
{
GetImplementation( *this ).SetDepthIndex( index );
}
-float ControlRenderer::GetDepthIndex() const
+float Base::GetDepthIndex() const
{
return GetImplementation( *this ).GetDepthIndex();
}
-void ControlRenderer::SetOnStage( Actor& actor )
+void Base::SetOnStage( Actor& actor )
{
GetImplementation( *this ).SetOnStage( actor );
}
-void ControlRenderer::SetOffStage( Actor& actor )
+void Base::SetOffStage( Actor& actor )
{
GetImplementation( *this ).SetOffStage( actor );
}
-void ControlRenderer::RemoveAndReset( Actor& actor )
+void Base::RemoveAndReset( Actor& actor )
{
if( actor && *this )
{
Reset();
}
-void ControlRenderer::CreatePropertyMap( Property::Map& map ) const
+void Base::CreatePropertyMap( Property::Map& map ) const
{
GetImplementation( *this ).CreatePropertyMap( map );
}
+} // namespace Visual
+
} // namespace Toolkit
} // namespace Dali
-#ifndef __DALI_TOOLKIT_CONTROL_RENDERER_H__
-#define __DALI_TOOLKIT_CONTROL_RENDERER_H__
+#ifndef DALI_TOOLKIT_VISUAL_BASE_H
+#define DALI_TOOLKIT_VISUAL_BASE_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
namespace Internal DALI_INTERNAL
{
-class ControlRenderer;
+namespace Visual
+{
+class Base;
+}
}
+namespace Visual
+{
/**
- * @brief ControlRenderer provides renderer for rendering the controls. A control may have multiple ControlRenders.
+ * @brief Visual provides a renderer for rendering the controls. A control may have multiple visuals.
*
- * ControlRenderers reuses geometry, shader etc. across controls and manages the renderer and texture sets to exist only when control is on-stage.
+ * Visuals reuses geometry, shader etc. across controls and manages the renderer and texture sets to exist only when control is on-stage.
* It also responds to actor size and color change, and provides the clipping at the renderer level.
- * Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
+ * Note: The visual responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
*/
-class DALI_IMPORT_API ControlRenderer : public BaseHandle
+class DALI_IMPORT_API Base : public BaseHandle
{
public:
/**
- * @brief Create an empty ControlRenderer Handle
+ * @brief Create an empty Visual Handle
*/
- ControlRenderer();
+ Base();
/**
* @brief Destructor
*
* This is non-virtual since derived Handle types must not contain data or virtual methods.
*/
- ~ControlRenderer();
+ ~Base();
/**
* @brief This copy constructor is required for (smart) pointer semantics.
*
* @param[in] handle A reference to the copied handle.
*/
- ControlRenderer( const ControlRenderer& handle );
+ Base( const Base& handle );
/**
* @brief This assignment operator is required for (smart) pointer semantics.
* @param [in] handle A reference to the copied handle.
* @return A reference to this.
*/
- ControlRenderer& operator=( const ControlRenderer& handle );
+ Base& operator=( const Base& handle );
/**
* @brief Set the size of the painting area.
/**
* @brief Get the size of the painting area.
*
- * @return The size of the renderer's painting area.
+ * @return The size of the visual's painting area.
*/
const Vector2& GetSize() const;
/**
- * @brief Return the natural size of the renderer.
+ * @brief Return the natural size of the visual.
*
- * Deriving classes stipulate the natural size and by default a renderer has a ZERO natural size.
+ * Deriving classes stipulate the natural size and by default a visual has a ZERO natural size.
*
- * @param[out] naturalSize The renderer's natural size
+ * @param[out] naturalSize The visual's natural size
*/
void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @brief Set the depth index of this renderer.
+ * @brief Set the depth index of this visual.
*
- * Depth-index controls draw-order for overlapping renderers.
- * Renderer with higher depth indices are rendered in front of other renderer with smaller values
+ * Depth-index controls draw-order for overlapping visuals.
+ * Visuals with higher depth indices are rendered in front of other visual with smaller values
*
- * @param[in] index The depth index of this renderer.
+ * @param[in] index The depth index of this visual.
*/
void SetDepthIndex( float index );
/**
- * @brief Get the depth index of this renderer
+ * @brief Get the depth index of this visual
*
- * @return The depth index of this renderer.
+ * @return The depth index of this visual.
*/
float GetDepthIndex() const;
/**
- * @brief Renderer only exists when control is on stage.
+ * @brief Visual needs to know when when the control is put on to the stage to add the renderer.
*
- * This function should be called when the control put on stage.
+ * This function should be called when the control is put on to the stage.
*
- * @param[in] actor The actor applying this renderer.
+ * @param[in] actor The actor using this visual.
* @post SetOffStage should be called with the same actor when the control is put off stage otherwise memory will be leaked
*/
void SetOnStage( Actor& actor );
/**
- * @brief Renderer is destroyed when control is off stage.
+ * @brief Visual needs to know when when the control is removed from the stage to remove the renderer.
*
- * This function should be called when the control removes from stage
+ * This function should be called when the control is removed from the stage
*
- * @param[in] actor The actor applying this renderer.
+ * @param[in] actor The actor using this visual.
*/
void SetOffStage( Actor& actor );
/**
- * @brief Remove the renderer from actor and reset the control renderer self.
+ * @brief Remove the renderer from the actor and reset the visual self.
*
- * This function can be called with an empty handle. If the control renderer is empty, do nothing.
+ * This function can be called with an empty handle. If the visual is empty, this is a no-op.
*
* @param[in] actor The actor to be set off stage.
*/
void RemoveAndReset( Actor& actor );
/**
- * @brief Create the property map representing this renderer.
+ * @brief Create the property map representing this visual.
*
- * @param[out] map The renderer property map.
+ * @param[out] map The visual property map.
*/
- void CreatePropertyMap( Property::Map& map ) const;
+ void CreatePropertyMap( Dali::Property::Map& map ) const;
public: // Not intended for application developers
- explicit DALI_INTERNAL ControlRenderer(Internal::ControlRenderer *impl);
+ explicit DALI_INTERNAL Base(Internal::Visual::Base *impl);
};
+} // namespace Visual
+
} // namespace Toolkit
} // namespace Dali
-#endif /*__DALI_TOOLKIT_CONTROL_RENDERER_H__*/
+#endif /*DALI_TOOLKIT_VISUAL_BASE_H*/
*/
// CLASS HEADER
-#include "renderer-factory.h"
+#include "visual-factory.h"
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/singleton-service.h>
#include <dali/devel-api/adaptor-framework/environment-variable.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
namespace Dali
{
const char * const DALI_DEBUG_RENDERING("DALI_DEBUG_RENDERING");
}
-RendererFactory RendererFactory::Get()
+VisualFactory VisualFactory::Get()
{
- RendererFactory factory;
+ VisualFactory factory;
- // Check whether the RendererFactory is already created
+ // Check whether the VisualFactory is already created
SingletonService singletonService( SingletonService::Get() );
if( singletonService )
{
- BaseHandle handle = singletonService.GetSingleton( typeid(RendererFactory) );
+ BaseHandle handle = singletonService.GetSingleton( typeid(VisualFactory) );
if( handle )
{
- //If so, downcast the handle of singleton to RendererFactory
- factory = RendererFactory( dynamic_cast<Internal::RendererFactory*>(handle.GetObjectPtr()) );
+ //If so, downcast the handle of singleton to VisualFactory
+ factory = VisualFactory( dynamic_cast<Internal::VisualFactory*>(handle.GetObjectPtr()) );
}
- if( !factory )// If not, create the RendererFactory and register it as a singleton
+ if( !factory )// If not, create the VisualFactory and register it as a singleton
{
// Check whether debug rendering is required
if( EnvironmentVariable::GetEnvironmentVariable( DALI_DEBUG_RENDERING ) )
{
- factory = RendererFactory( new Internal::RendererFactory(true) );
+ factory = VisualFactory( new Internal::VisualFactory(true) );
}
else
{
- factory = RendererFactory( new Internal::RendererFactory(false) );
+ factory = VisualFactory( new Internal::VisualFactory(false) );
}
- singletonService.Register( typeid(RendererFactory), factory );
+ singletonService.Register( typeid(VisualFactory), factory );
}
}
return factory;
}
-RendererFactory::RendererFactory()
+VisualFactory::VisualFactory()
{
}
-RendererFactory::~RendererFactory()
+VisualFactory::~VisualFactory()
{
}
-RendererFactory::RendererFactory( const RendererFactory& handle )
+VisualFactory::VisualFactory( const VisualFactory& handle )
: BaseHandle( handle )
{
}
-RendererFactory& RendererFactory::operator=( const RendererFactory& handle )
+VisualFactory& VisualFactory::operator=( const VisualFactory& handle )
{
BaseHandle::operator=( handle );
return *this;
}
-RendererFactory::RendererFactory(Internal::RendererFactory *impl)
+VisualFactory::VisualFactory(Internal::VisualFactory *impl)
: BaseHandle(impl)
{
}
-ControlRenderer RendererFactory::CreateControlRenderer( const Property::Map& propertyMap )
+Visual::Base VisualFactory::CreateVisual( const Property::Map& propertyMap )
{
- return GetImplementation( *this ).CreateControlRenderer( propertyMap );
+ return GetImplementation( *this ).CreateVisual( propertyMap );
}
-ControlRenderer RendererFactory::CreateControlRenderer( const Image& image )
+Visual::Base VisualFactory::CreateVisual( const Image& image )
{
- return GetImplementation( *this ).CreateControlRenderer( image );
+ return GetImplementation( *this ).CreateVisual( image );
}
-ControlRenderer RendererFactory::CreateControlRenderer( const std::string& url, ImageDimensions size )
+Visual::Base VisualFactory::CreateVisual( const std::string& url, ImageDimensions size )
{
- return GetImplementation( *this ).CreateControlRenderer( url, size );
+ return GetImplementation( *this ).CreateVisual( url, size );
}
} // namespace Toolkit
--- /dev/null
+#ifndef DALI_TOOLKIT_VISUAL_FACTORY_H
+#define DALI_TOOLKIT_VISUAL_FACTORY_H
+
+/*
+ * Copyright (c) 2016 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 <dali/public-api/object/base-handle.h>
+#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/object/property-map.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+
+namespace Dali
+{
+class Image;
+class Vector4;
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class VisualFactory;
+}
+
+/**
+ * @brief VisualFactory is a singleton object that provides and shares visuals between controls
+ *
+ * By setting environment variable 'DALI_DEBUG_RENDERING', a debug visual is used which renders a quad wireframe.
+ *
+ * The visual type is required in the property map for requesting a visual.
+ *
+ * | %Property Name | Type |
+ * |--------------------------|-------------------|
+ * | visualType | INTEGER or STRING |
+ * | shader | MAP |
+ */
+class DALI_IMPORT_API VisualFactory : public BaseHandle
+{
+public:
+
+ /**
+ * @brief Create or retrieve VisualFactory singleton.
+ *
+ * @return A handle to the VisualFactory control.
+ */
+ static VisualFactory Get();
+
+ /**
+ * @brief Create a VisualFactory handle.
+ *
+ * Calling member functions with an uninitialised handle is not allowed.
+ */
+ VisualFactory();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~VisualFactory();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle.
+ */
+ VisualFactory( const VisualFactory& handle );
+
+ /**
+ * @brief This assignment operator is required for (smart) pointer semantics.
+ *
+ * @param [in] handle A reference to the copied handle.
+ * @return A reference to this.
+ */
+ VisualFactory& operator=( const VisualFactory& handle );
+
+ /**
+ * @brief Request the visual
+ *
+ * @param[in] propertyMap The map contains the properties required by the visual.
+ * The content of the map determines the type of visual that will be returned.
+ * @return The handle to the created visual
+ */
+ Visual::Base CreateVisual( const Property::Map& propertyMap );
+
+ /**
+ * @brief Request the visual to render the image.
+ *
+ * @param[in] image The image to be rendered.
+ * @return The pointer pointing to the visual
+ */
+ Visual::Base CreateVisual( const Image& image );
+
+ /**
+ * @brief Request the visual to render the given resource at the url.
+ *
+ * @param[in] url The URL to the resource to be rendered.
+ * @param[in] size The width and height to fit the loaded image to.
+ * @return The pointer pointing to the visual
+ */
+ Visual::Base CreateVisual( const std::string& url, ImageDimensions size );
+
+private:
+
+ explicit DALI_INTERNAL VisualFactory(Internal::VisualFactory *impl);
+
+};
+
+
+/**
+ * @brief Template to allow discard old visual, get new one and set it on stage if possible
+ *
+ * @tparam ParameterType0 The type of first argument passed to the CreateVisual()
+ * @tparam ParameterType1 The type of second argument passed to the CreateVisual()
+ * @SINCE_1_0.39
+ * @param[in] actor Actor for which the visual will be replaced
+ * @param[in,out] visual The visual to be replaced
+ * @param[in] param0 First template based argument passed to the visual factory
+ * @param[in] param1 Second template based argument passed to the visual factory
+ */
+template< class ParameterType0, class ParameterType1 >
+void InitializeVisual( Actor& actor, Visual::Base& visual, ParameterType0& param0, ParameterType1& param1 )
+{
+ visual.RemoveAndReset( actor );
+ visual = Toolkit::VisualFactory::Get().CreateVisual( param0, param1 );
+ if( visual && actor && actor.OnStage() )
+ {
+ visual.SetOnStage( actor );
+ }
+}
+
+/**
+ * @brief Template to allow discard old visual, get new one and set it on stage if possible
+ *
+ * @tparam ParameterType The type of argument passed to the CreateVisual()
+ * @SINCE_1_0.39
+ * @param[in] actor Actor for which the visual will be replaced
+ * @param[in,out] visual The visual to be replaced
+ * @param[in] param Template based argument passed to the visual factory
+ */
+template< class ParameterType >
+void InitializeVisual( Actor& actor, Visual::Base& visual, ParameterType& param )
+{
+ visual.RemoveAndReset( actor );
+ visual = Toolkit::VisualFactory::Get().CreateVisual( param );
+ if( visual && actor && actor.OnStage() )
+ {
+ visual.SetOnStage( actor );
+ }
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_VISUAL_FACTORY_H
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
-#include "../gaussian-blur-view/gaussian-blur-view-impl.h"
+#include <dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h>
namespace Dali
{
mBloomExtractImageView.SetSize(mDownsampledWidth, mDownsampledHeight); // size needs to match render target
// Create shader used for extracting the bright parts of an image
Property::Map customShader;
- customShader[ "fragmentShader" ] = BLOOM_EXTRACT_FRAGMENT_SOURCE;
- Property::Map rendererMap;
- rendererMap.Insert( "shader", customShader );
- mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = BLOOM_EXTRACT_FRAGMENT_SOURCE;
+ Property::Map visualMap;
+ visualMap.Insert( Toolkit::Visual::Property::SHADER, customShader );
+ mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
// set GaussianBlurView to blur our extracted bloom
mGaussianBlurView.SetUserImageAndOutputRenderTarget(mBloomExtractTarget, mBlurExtractTarget);
// use the completed blur in the first buffer and composite with the original child actors render
mCompositeImageView.SetImage( mRenderTargetForRenderingChildren );
// Create shader used to composite bloom and original image to output render target
- customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE;
- rendererMap[ "shader" ] = customShader;
- mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = COMPOSITE_FRAGMENT_SOURCE;
+ visualMap[ Toolkit::Visual::Property::SHADER ] = customShader;
+ mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
TextureSet textureSet = mCompositeImageView.GetRendererAt(0).GetTextures();
TextureSetImage( textureSet, 1u, mBlurExtractTarget );
-#ifndef __DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H_
-#define __DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H_
+#ifndef DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H
+#define DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
* limitations under the License.
*
*/
+
+// EXTERNAL INCLUDES
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/object/property-map.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
#define DALI_COMPOSE_SHADER(STR) #STR
namespace Dali
);
Property::Map customShader;
- customShader[ "fragmentShader" ] = fragmentShader;
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShader;
Property::Map map;
- map[ "shader" ] = customShader;
+ map[ Toolkit::Visual::Property::SHADER ] = customShader;
return map;
}
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H_ */
+#endif // DALI_TOOLKIT_INTERNAL_COLOR_ADJUSTER_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+
/**
* Button states and contents
{
// If there is no existing content, create a new actor to use for flat color.
Actor placementActor = Actor::New();
- Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
- Toolkit::ControlRenderer colorRenderer;
+ Toolkit::VisualFactory rendererFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base colorRenderer;
Property::Map map;
- map["rendererType"] = "COLOR";
- map["mixColor"] = color;
+ map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
+ map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
- colorRenderer = rendererFactory.CreateControlRenderer( map );
+ colorRenderer = rendererFactory.CreateVisual( map );
colorRenderer.SetOnStage( placementActor );
SetupContent( *contentActor, placementActor ); //
#include <dali/devel-api/images/texture-set-image.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
#include <dali-toolkit/internal/filters/emboss-filter.h>
#include <dali-toolkit/internal/filters/spread-filter.h>
RemoveFilters();
Actor self = Self();
- Property::Map rendererMap;
- rendererMap.Insert( "rendererType", "IMAGE" );
+ Property::Map visualMap;
+ visualMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
switch( type )
{
}
Property::Map customShader;
- customShader[ "vertexShader" ] = EFFECTS_VIEW_VERTEX_SOURCE;
- customShader[ "fragmentShader" ] = EFFECTS_VIEW_FRAGMENT_SOURCE;
- rendererMap[ "shader" ] = customShader;
- InitializeControlRenderer( self, mRendererPostFilter, rendererMap );
+ customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = EFFECTS_VIEW_VERTEX_SOURCE;
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = EFFECTS_VIEW_FRAGMENT_SOURCE;
+ visualMap[ Toolkit::Visual::Property::SHADER ] = customShader;
+ InitializeVisual( self, mVisualPostFilter, visualMap );
mEffectType = type;
}
Enable();
Actor self = Self();
- if( mRendererPostFilter )
+ if( mVisualPostFilter )
{
- mRendererPostFilter.SetOnStage( self );
+ mVisualPostFilter.SetOnStage( self );
}
- if( mRendererForChildren )
+ if( mVisualForChildren )
{
- mRendererForChildren.SetOnStage( self );
+ mVisualForChildren.SetOnStage( self );
}
}
}
Actor self = Self();
- if( mRendererPostFilter )
+ if( mVisualPostFilter )
{
- mRendererPostFilter.SetOffStage( self );
+ mVisualPostFilter.SetOffStage( self );
}
- if( mRendererForChildren )
+ if( mVisualForChildren )
{
- mRendererForChildren.SetOffStage( self );
+ mVisualForChildren.SetOffStage( self );
}
Control::OnStageDisconnection();
Actor self( Self() );
mImageForChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED );
- InitializeControlRenderer( self, mRendererForChildren, mImageForChildren );
- mRendererForChildren.SetDepthIndex( DepthIndex::CONTENT+1 );
+ InitializeVisual( self, mVisualForChildren, mImageForChildren );
+ mVisualForChildren.SetDepthIndex( DepthIndex::CONTENT+1 );
mImagePostFilter = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED );
TextureSet textureSet = TextureSet::New();
TextureSetImage( textureSet, 0u, mImagePostFilter );
self.GetRendererAt( 0 ).SetTextures( textureSet );
- mRendererPostFilter.SetDepthIndex( DepthIndex::CONTENT );
+ mVisualPostFilter.SetDepthIndex( DepthIndex::CONTENT );
SetupFilters();
}
#include <dali-toolkit/devel-api/controls/effects-view/effects-view.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
namespace Dali
{
/////////////////////////////////////////////////////////////
// for rendering all user added children to offscreen target
- FrameBufferImage mImageForChildren;
- Toolkit::ControlRenderer mRendererForChildren;
- RenderTask mRenderTaskForChildren;
- CameraActor mCameraForChildren;
- Actor mChildrenRoot; // for creating a subtree for all user added child actors
+ FrameBufferImage mImageForChildren;
+ Toolkit::Visual::Base mVisualForChildren;
+ RenderTask mRenderTaskForChildren;
+ CameraActor mCameraForChildren;
+ Actor mChildrenRoot; // for creating a subtree for all user added child actors
/////////////////////////////////////////////////////////////
// background fill color
Vector2 mLastSize;
/////////////////////////////////////////////////////////////
// post blur image
- FrameBufferImage mImagePostFilter;
- Toolkit::ControlRenderer mRendererPostFilter;
+ FrameBufferImage mImagePostFilter;
+ Toolkit::Visual::Base mVisualPostFilter;
Vector<ImageFilter*> mFilters;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
// TODO:
// pixel format / size - set from JSON
horizFragmentShaderStringStream << "#define NUM_SAMPLES " << mNumSamples << "\n";
horizFragmentShaderStringStream << GAUSSIAN_BLUR_FRAGMENT_SOURCE;
Property::Map source;
- source[ "fragmentShader" ] = horizFragmentShaderStringStream.str();
- mCustomShader["shader"] = source;
+ source[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = horizFragmentShaderStringStream.str();
+ mCustomShader[ Toolkit::Visual::Property::SHADER ] = source;
//////////////////////////////////////////////////////
// Create actors
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+// Copyright (c) 2016 Samsung Electronics Co., Ltd.
// CLASS HEADER
#include "image-view-impl.h"
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
mImage = image;
Actor self( Self() );
- InitializeControlRenderer( self, mRenderer, image );
+ InitializeVisual( self, mVisual, image );
mImageSize = image ? ImageDimensions( image.GetWidth(), image.GetHeight() ) : ImageDimensions( 0, 0 );
RelayoutRequest();
mPropertyMap = map;
Actor self( Self() );
- InitializeControlRenderer( self, mRenderer, mPropertyMap );
+ InitializeVisual( self, mVisual, mPropertyMap );
Property::Value* widthValue = mPropertyMap.Find( "width" );
if( widthValue )
}
Actor self( Self() );
- InitializeControlRenderer( self, mRenderer, url, size );
+ InitializeVisual( self, mVisual, url, size );
- mRenderer.SetSize( mSizeSet );
+ mVisual.SetSize( mSizeSet );
RelayoutRequest();
}
void ImageView::EnablePreMultipliedAlpha( bool preMultipled )
{
- if( mRenderer )
+ if( mVisual )
{
- GetImplementation( mRenderer ).EnablePreMultipliedAlpha( preMultipled );
+ Toolkit::GetImplementation( mVisual ).EnablePreMultipliedAlpha( preMultipled );
}
}
bool ImageView::IsPreMultipliedAlphaEnabled() const
{
- if( mRenderer )
+ if( mVisual )
{
- return GetImplementation( mRenderer ).IsPreMultipliedAlphaEnabled();
+ return Toolkit::GetImplementation( mVisual ).IsPreMultipliedAlphaEnabled();
}
return false;
}
void ImageView::SetDepthIndex( int depthIndex )
{
- if( mRenderer )
+ if( mVisual )
{
- mRenderer.SetDepthIndex( depthIndex );
+ mVisual.SetDepthIndex( depthIndex );
}
}
Vector3 ImageView::GetNaturalSize()
{
- if( mRenderer )
+ if( mVisual )
{
Vector2 rendererNaturalSize;
- mRenderer.GetNaturalSize( rendererNaturalSize );
+ mVisual.GetNaturalSize( rendererNaturalSize );
return Vector3( rendererNaturalSize );
}
{
Control::OnStageConnection( depth );
- if( mRenderer )
+ if( mVisual )
{
CustomActor self = Self();
- mRenderer.SetOnStage( self );
+ mVisual.SetOnStage( self );
}
}
void ImageView::OnStageDisconnection()
{
- if( mRenderer )
+ if( mVisual )
{
CustomActor self = Self();
- mRenderer.SetOffStage( self );
+ mVisual.SetOffStage( self );
}
Control::OnStageDisconnection();
Control::OnSizeSet( targetSize );
mSizeSet = targetSize;
- if( mRenderer )
+ if( mVisual )
{
Vector2 size( targetSize );
- mRenderer.SetSize( size );
+ mVisual.SetSize( size );
}
}
// if its not a string then get a Property::Map from the property if possible.
else if( value.Get( map ) )
{
- Property::Value* shaderValue = map.Find( "shader" );
+ Property::Value* shaderValue = map.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
// set image only if property map contains image information other than custom shader
if( map.Count() > 1u || !shaderValue )
{
impl.SetImage( map );
}
// the property map contains only the custom shader
- else if( impl.mRenderer && map.Count() == 1u && shaderValue )
+ else if( impl.mVisual && map.Count() == 1u && shaderValue )
{
Property::Map shaderMap;
if( shaderValue->Get( shaderMap ) )
{
- Internal::ControlRenderer& renderer = GetImplementation( impl.mRenderer );
- renderer.SetCustomShader( shaderMap );
+ Internal::Visual::Base& visual = Toolkit::GetImplementation( impl.mVisual );
+ visual.SetCustomShader( shaderMap );
if( imageView.OnStage() )
{
// force to create new core renderer to use the newly set shader
- renderer.SetOffStage( imageView );
- renderer.SetOnStage( imageView );
+ visual.SetOffStage( imageView );
+ visual.SetOnStage( imageView );
}
}
}
#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
+#include <dali-toolkit/internal/visuals/image/image-visual.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
/**
* @brief Set the depth index of this image renderer
*
- * Renderer with higher depth indices are rendered in front of other renderers with smaller values
+ * Renderer with higher depth indices are rendered in front of other visuals with smaller values
*
* @param[in] depthIndex The depth index of this renderer
*/
ImageView& operator=( const ImageView& );
private:
- Toolkit::ControlRenderer mRenderer;
- ImageDimensions mImageSize;
- Vector2 mSizeSet;
+ Toolkit::Visual::Base mVisual;
+ ImageDimensions mImageSize;
+ Vector2 mSizeSet;
std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
Image mImage; ///< the Image if the image came from a Image, null otherwise
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
+#include <dali-toolkit/public-api/visuals/border-visual-properties.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
namespace Dali
{
Vector3 sizeOffset(IMAGE_BORDER_INDENT*2.f - 2.f, IMAGE_BORDER_INDENT*2.f - 2.f, 0.0f);
mFrame.SetSizeModeFactor( sizeOffset );
- Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
Property::Map map;
- map[ RENDERER_TYPE ] = BORDER_RENDERER;
- map[ "borderColor" ] = Color::WHITE;
- map[ "borderSize" ] = IMAGE_BORDER_INDENT;
- Toolkit::ControlRenderer borderRenderer = rendererFactory.CreateControlRenderer( map );
- borderRenderer.SetOnStage( mFrame );
+ map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::BORDER;
+ map[ Toolkit::BorderVisual::Property::COLOR ] = Color::WHITE;
+ map[ Toolkit::BorderVisual::Property::SIZE ] = IMAGE_BORDER_INDENT;
+ Toolkit::Visual::Base borderVisual = visualFactory.CreateVisual( map );
+ borderVisual.SetOnStage( mFrame );
Constraint constraint = Constraint::New<Vector3>( mFrame, Actor::Property::POSITION, EqualToConstraint() );
constraint.AddSource( ParentSource( Actor::Property::WORLD_POSITION ) );
{
impl.LoadMaterial();
impl.CreateMaterial();
+ impl.LoadTextures();
}
break;
}
if( mObjLoader.IsSceneLoaded() )
{
- mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ) );
+ mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ), true );
CreateMaterial();
LoadTextures();
{
if( mObjLoader.IsSceneLoaded() )
{
- mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ) );
+ mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ), true );
if( mRenderer )
{
return mMaterialLoaded;
}
-//TODO: Use a function that can generate more than one normal/tangent per vertex (using angle)
-void ObjLoader::CalculateTangentArray(const Dali::Vector<Vector3>& vertex,
- const Dali::Vector<Vector2>& texcoord,
- Dali::Vector<TriIndex>& triangle,
- Dali::Vector<Vector3>& normal,
- Dali::Vector<Vector3>& tangent)
+void ObjLoader::CalculateHardFaceNormals( const Dali::Vector<Vector3>& vertices, Dali::Vector<TriIndex>& triangles,
+ Dali::Vector<Vector3>& normals )
{
- Dali::Vector<Vector3> tangents;
- tangents.Resize( vertex.Size() );
+ int numFaceVertices = 3 * triangles.Size(); //Vertex per face, as each point has different normals for each face.
+ int normalIndex = 0; //Tracks progress through the array of normals.
- // Resize of a vector of Vector3 will initialise with the default constructor, setting to all zeros.
+ normals.Clear();
+ normals.Resize( numFaceVertices );
- for ( unsigned long a = 0; a < triangle.Size(); a++ )
+ //For each triangle, calculate the normal by crossing two vectors on the triangle's plane.
+ for( unsigned long i = 0; i < triangles.Size(); i++ )
{
- Vector3 tangentVector, normalVector;
+ //Triangle vertices.
+ const Vector3& v0 = vertices[triangles[i].pointIndex[0]];
+ const Vector3& v1 = vertices[triangles[i].pointIndex[1]];
+ const Vector3& v2 = vertices[triangles[i].pointIndex[2]];
+
+ //Triangle edges.
+ Vector3 edge1 = v1 - v0;
+ Vector3 edge2 = v2 - v0;
+
+ //Using edges as vectors on the plane, cross to get the normal.
+ Vector3 normalVector = edge1.Cross(edge2);
+ normalVector.Normalize();
+
+ //Assign normals to points.
+ for( unsigned long j = 0; j < 3; j++, normalIndex++ )
+ {
+ triangles[i].normalIndex[j] = normalIndex;
+ normals[normalIndex] = normalVector;
+ }
+ }
+}
- const Vector3& v0 = vertex[triangle[a].pntIndex[0]];
- const Vector3& v1 = vertex[triangle[a].pntIndex[1]];
- const Vector3& v2 = vertex[triangle[a].pntIndex[2]];
+void ObjLoader::CalculateSoftFaceNormals( const Dali::Vector<Vector3>& vertices, Dali::Vector<TriIndex>& triangles,
+ Dali::Vector<Vector3>& normals )
+{
+ int normalIndex = 0; //Tracks progress through the array of normals.
+
+ normals.Clear();
+ normals.Resize( vertices.Size() ); //One (averaged) normal per point.
+
+ //For each triangle, calculate the normal by crossing two vectors on the triangle's plane
+ //We then add the triangle's normal to the cumulative normals at each point of it
+ for( unsigned long i = 0; i < triangles.Size(); i++ )
+ {
+ //Triangle vertices.
+ const Vector3& v0 = vertices[triangles[i].pointIndex[0]];
+ const Vector3& v1 = vertices[triangles[i].pointIndex[1]];
+ const Vector3& v2 = vertices[triangles[i].pointIndex[2]];
+ //Triangle edges.
Vector3 edge1 = v1 - v0;
Vector3 edge2 = v2 - v0;
- normalVector = edge1.Cross(edge2);
+ //Using edges as vectors on the plane, cross to get the normal.
+ Vector3 normalVector = edge1.Cross(edge2);
+
+ //Add this triangle's normal to the cumulative normal of each constituent point and set the index of the normal accordingly.
+ for( unsigned long j = 0; j < 3; j++, normalIndex++ )
+ {
+ triangles[i].normalIndex[j] = triangles[i].pointIndex[j]; //Normal index matches up to vertex index, as one normal per vertex.
+ normals[triangles[i].normalIndex[j]] += normalVector;
+ }
+ }
+
+ //Normalise the normals.
+ for( unsigned long i = 0; i < normals.Size(); i++ )
+ {
+ normals[i].Normalize();
+ }
+}
+
+//TODO: Use a function that can generate more than one normal/tangent per vertex (using angle)
+void ObjLoader::CalculateTangentFrame()
+{
+ //Reset tangent and bitangent vectors to hold new values.
+ mTangents.Clear();
+ mBiTangents.Clear();
+ mTangents.Resize( mPoints.Size() );
+ mBiTangents.Resize( mPoints.Size() );
+
+ //For each triangle, calculate the tangent vector and then add it to the total tangent vector of each point.
+ for ( unsigned long a = 0; a < mTriangles.Size(); a++ )
+ {
+ Vector3 tangentVector;
- const Vector2& w0 = texcoord[triangle[a].texIndex[0]];
- const Vector2& w1 = texcoord[triangle[a].texIndex[1]];
- const Vector2& w2 = texcoord[triangle[a].texIndex[2]];
+ const Vector3& v0 = mPoints[mTriangles[a].pointIndex[0]];
+ const Vector3& v1 = mPoints[mTriangles[a].pointIndex[1]];
+ const Vector3& v2 = mPoints[mTriangles[a].pointIndex[2]];
+
+ Vector3 edge1 = v1 - v0;
+ Vector3 edge2 = v2 - v0;
+
+ const Vector2& w0 = mTextures[mTriangles[a].textureIndex[0]];
+ const Vector2& w1 = mTextures[mTriangles[a].textureIndex[1]];
+ const Vector2& w2 = mTextures[mTriangles[a].textureIndex[2]];
float deltaU1 = w1.x - w0.x;
float deltaV1 = w1.y - w0.y;
tangentVector.y = f * ( deltaV2 * edge1.y - deltaV1 * edge2.y );
tangentVector.z = f * ( deltaV2 * edge1.z - deltaV1 * edge2.z );
- tangents[triangle[a].pntIndex[0]] += tangentVector;
- tangents[triangle[a].pntIndex[1]] += tangentVector;
- tangents[triangle[a].pntIndex[2]] += tangentVector;
-
- normal[triangle[a].pntIndex[0]] += normalVector;
- normal[triangle[a].pntIndex[1]] += normalVector;
- normal[triangle[a].pntIndex[2]] += normalVector;
+ mTangents[mTriangles[a].pointIndex[0]] += tangentVector;
+ mTangents[mTriangles[a].pointIndex[1]] += tangentVector;
+ mTangents[mTriangles[a].pointIndex[2]] += tangentVector;
}
- for ( unsigned long a = 0; a < triangle.Size(); a++ )
+ //Orthogonalize tangents and set binormals.
+ for ( unsigned long a = 0; a < mTangents.Size(); a++ )
{
- for ( unsigned long j = 0; j < 3; j++ )
- {
- triangle[a].nrmIndex[j] = triangle[a].pntIndex[j];
- }
- }
-
- for ( unsigned long a = 0; a < normal.Size(); a++ )
- {
- normal[a].Normalize();
-
- const Vector3& n = normal[a];
- const Vector3& t = tangents[a];
+ const Vector3& n = mNormals[a];
+ const Vector3& t = mTangents[a];
// Gram-Schmidt orthogonalize
- Vector3 calc = t - n * n.Dot(t);
- calc.Normalize();
- tangent[a] = Vector3( calc.x,calc.y,calc.z );
+ mTangents[a] = t - n * n.Dot(t);
+ mTangents[a].Normalize();
+
+ mBiTangents[a] = mNormals[a].Cross( mTangents[a] );
}
}
-
void ObjLoader::CenterAndScale( bool center, Dali::Vector<Vector3>& points )
{
BoundingVolume newAABB;
biggestDimension = sceneSize.z;
}
-
newAABB.Init();
for( unsigned int ui = 0; ui < points.Size(); ++ui )
{
mSceneAABB = newAABB;
}
-void ObjLoader::CreateGeometryArray(Dali::Vector<Vertex> & vertices,
- Dali::Vector<Vector2> & textures,
- Dali::Vector<VertexExt> & verticesExt,
- Dali::Vector<unsigned short> & indices)
+void ObjLoader::CreateGeometryArray( Dali::Vector<Vertex> & vertices,
+ Dali::Vector<Vector2> & textures,
+ Dali::Vector<VertexExt> & verticesExt,
+ Dali::Vector<unsigned short> & indices,
+ bool useSoftNormals )
{
- //If we don't have tangents, calculate them
- //we need to recalculate the normals too, because we need just one normal,tangent, bitangent per vertex
- //In the case of a textureless object, we don't need tangents for our shader and so we skip this step
- //TODO: Use a better function to calculate tangents
- if( mTangents.Size() == 0 && mHasTexturePoints )
+ //We must calculate the tangents and bitangents if they weren't supplied, or if they don't match up.
+ bool mustCalculateTangents = mTangents.Size() == 0 || mBiTangents.Size() == 0 ||
+ mTangents.Size() != mBiTangents.Size() || mTangents.Size() != mNormals.Size() ||
+ mBiTangents.Size() != mNormals.Size();
+
+ //However, we don't need to do this if the object doesn't use textures to begin with.
+ mustCalculateTangents &= mHasTexturePoints;
+
+ //We also have to recalculate the normals if we need to calculate tangents,
+ // as we need just one normal, tangent and bitangent per vertex, rather than the supplied per-face vertices.
+ //Alternatively, we need to calculate the normals if there weren't any to begin with.
+ if( mNormals.Size() == 0 || mustCalculateTangents )
{
- mNormals.Clear();
-
- mNormals.Resize( mPoints.Size() );
- mTangents.Resize( mPoints.Size() );
- mBiTangents.Resize( mPoints.Size() );
-
- CalculateTangentArray( mPoints, mTextures, mTriangles, mNormals, mTangents );
-
- for ( unsigned int ui = 0 ; ui < mNormals.Size() ; ++ui )
+ if( useSoftNormals || mustCalculateTangents )
{
- mBiTangents[ui] = mNormals[ui].Cross(mTangents[ui]);
+ CalculateSoftFaceNormals( mPoints, mTriangles, mNormals );
}
+ else
+ {
+ CalculateHardFaceNormals( mPoints, mTriangles, mNormals );
+ }
+ }
+
+ //TODO: Use a better function to calculate tangents
+ if( mHasTexturePoints && mustCalculateTangents )
+ {
+ CalculateTangentFrame();
}
bool mapsCorrespond; //True if the sizes of the arrays necessary for the object agree.
{
for ( int j = 0 ; j < 3 ; ++j )
{
- indices[indiceIndex] = mTriangles[ui].pntIndex[j];
+ indices[indiceIndex] = mTriangles[ui].pointIndex[j];
indiceIndex++;
- vertices[mTriangles[ui].pntIndex[j]].normal = mNormals[mTriangles[ui].nrmIndex[j]];
+ vertices[mTriangles[ui].pointIndex[j]].normal = mNormals[mTriangles[ui].normalIndex[j]];
if ( mHasTexturePoints )
{
- textures[mTriangles[ui].pntIndex[j]] = mTextures[mTriangles[ui].texIndex[j]];
- verticesExt[mTriangles[ui].pntIndex[j]].tangent = mTangents[mTriangles[ui].nrmIndex[j]];
- verticesExt[mTriangles[ui].pntIndex[j]].bitangent = mBiTangents[mTriangles[ui].nrmIndex[j]];
+ textures[mTriangles[ui].pointIndex[j]] = mTextures[mTriangles[ui].textureIndex[j]];
+ verticesExt[mTriangles[ui].pointIndex[j]].tangent = mTangents[mTriangles[ui].normalIndex[j]];
+ verticesExt[mTriangles[ui].pointIndex[j]].bitangent = mBiTangents[mTriangles[ui].normalIndex[j]];
}
}
}
for ( int j = 0 ; j < 3 ; ++j )
{
Vertex vertex;
- vertex.position = mPoints[mTriangles[ui].pntIndex[j]];
- vertex.normal = mNormals[mTriangles[ui].nrmIndex[j]];
+ vertex.position = mPoints[mTriangles[ui].pointIndex[j]];
+ vertex.normal = mNormals[mTriangles[ui].normalIndex[j]];
vertices[index] = vertex;
if ( mHasTexturePoints )
{
- textures[index] = mTextures[mTriangles[ui].texIndex[j]];
+ textures[index] = mTextures[mTriangles[ui].textureIndex[j]];
VertexExt vertexExt;
- vertexExt.tangent = mTangents[mTriangles[ui].nrmIndex[j]];
- vertexExt.bitangent = mBiTangents[mTriangles[ui].nrmIndex[j]];
+ vertexExt.tangent = mTangents[mTriangles[ui].normalIndex[j]];
+ vertexExt.bitangent = mBiTangents[mTriangles[ui].normalIndex[j]];
verticesExt[index] = vertexExt;
-
}
index++;
{
for( int i = 0 ; i < 3; i++ )
{
- triangle.pntIndex[i] = ptIdx[i] - 1 - pntAcum;
- triangle.nrmIndex[i] = nrmIdx[i] - 1 - nrmAcum;
- triangle.texIndex[i] = texIdx[i] - 1 - texAcum;
+ triangle.pointIndex[i] = ptIdx[i] - 1 - pntAcum;
+ triangle.normalIndex[i] = nrmIdx[i] - 1 - nrmAcum;
+ triangle.textureIndex[i] = texIdx[i] - 1 - texAcum;
}
mTriangles.PushBack( triangle );
face++;
{
for( int i = 0 ; i < 3; i++ )
{
- triangle.pntIndex[i] = ptIdx[i] - 1 - pntAcum;
- triangle.nrmIndex[i] = nrmIdx[i] - 1 - nrmAcum;
- triangle.texIndex[i] = texIdx[i] - 1 - texAcum;
+ triangle.pointIndex[i] = ptIdx[i] - 1 - pntAcum;
+ triangle.normalIndex[i] = nrmIdx[i] - 1 - nrmAcum;
+ triangle.textureIndex[i] = texIdx[i] - 1 - texAcum;
}
mTriangles.PushBack( triangle );
face++;
for( int i = 0 ; i < 3; i++ )
{
int idx = ( i + 2 ) % numIndices;
- triangle2.pntIndex[i] = ptIdx[idx] - 1 - pntAcum;
- triangle2.nrmIndex[i] = nrmIdx[idx] - 1 - nrmAcum;
- triangle2.texIndex[i] = texIdx[idx] - 1 - texAcum;
+ triangle2.pointIndex[i] = ptIdx[idx] - 1 - pntAcum;
+ triangle2.normalIndex[i] = nrmIdx[idx] - 1 - nrmAcum;
+ triangle2.textureIndex[i] = texIdx[idx] - 1 - texAcum;
}
mTriangles.PushBack( triangle2 );
face++;
mMaterialLoaded = true;
}
-Geometry ObjLoader::CreateGeometry( int objectProperties )
+Geometry ObjLoader::CreateGeometry( int objectProperties, bool useSoftNormals )
{
Geometry surface = Geometry::New();
Dali::Vector<VertexExt> verticesExt;
Dali::Vector<unsigned short> indices;
- CreateGeometryArray( vertices, textures, verticesExt, indices );
+ CreateGeometryArray( vertices, textures, verticesExt, indices, useSoftNormals );
//All vertices need at least Position and Normal
Property::Map vertexFormat;
struct TriIndex
{
- int pntIndex[3];
- int nrmIndex[3];
- int texIndex[3];
+ int pointIndex[3];
+ int normalIndex[3];
+ int textureIndex[3];
};
struct Vertex
void LoadMaterial( char* objBuffer, std::streampos fileSize, std::string& diffuseTextureUrl,
std::string& normalTextureUrl, std::string& glossTextureUrl );
- Geometry CreateGeometry( int objectProperties );
+ Geometry CreateGeometry( int objectProperties, bool useSoftNormals );
Vector3 GetCenter();
Vector3 GetSize();
bool mHasNormalMap;
bool mHasSpecularMap;
- Dali::Vector<Vector3> mPoints;
- Dali::Vector<Vector2> mTextures;
- Dali::Vector<Vector2> mTextures2;
- Dali::Vector<Vector3> mNormals;
- Dali::Vector<Vector3> mTangents;
- Dali::Vector<Vector3> mBiTangents;
+ Dali::Vector<Vector3> mPoints;
+ Dali::Vector<Vector2> mTextures;
+ Dali::Vector<Vector2> mTextures2;
+ Dali::Vector<Vector3> mNormals;
+ Dali::Vector<Vector3> mTangents;
+ Dali::Vector<Vector3> mBiTangents;
Dali::Vector<TriIndex> mTriangles;
- void CalculateTangentArray( const Dali::Vector<Vector3>& vertex,
- const Dali::Vector<Vector2>& texcoord,
- Dali::Vector<TriIndex>& triangle,
- Dali::Vector<Vector3>& normal,
- Dali::Vector<Vector3>& tangent );
+ /**
+ * @brief Calculates normals for each point on a per-face basis.
+ *
+ * There are multiple normals per point, each corresponding to the normal of a face connecting to the point.
+ *
+ * @param[in] vertices The vertices of the object.
+ * @param[in, out] triangles The triangles that form the faces. The normals of each triangle will be updated.
+ * @param[in, out] normals The normals to be calculated.
+ */
+ void CalculateHardFaceNormals( const Dali::Vector<Vector3>& vertices,
+ Dali::Vector<TriIndex>& triangles,
+ Dali::Vector<Vector3>& normals );
+
+ /**
+ * @brief Calculates smoothed normals for each point.
+ *
+ * There is one normal per point, an average of the connecting faces.
+ *
+ * @param[in] vertices The vertices of the object.
+ * @param[in, out] triangles The triangles that form the faces. The normals of each triangle will be updated.
+ * @param[in, out] normals The normals to be calculated.
+ */
+ void CalculateSoftFaceNormals( const Dali::Vector<Vector3>& vertices,
+ Dali::Vector<TriIndex>& triangles,
+ Dali::Vector<Vector3>& normals );
+
+ /**
+ * @brief Calculates tangents and bitangents for each point of the object.
+ *
+ * These are calculated using the object's points, texture coordinates and normals, so these must be initialised first.
+ */
+ void CalculateTangentFrame();
void CenterAndScale( bool center, Dali::Vector<Vector3>& points );
-
+ /**
+ * @brief Using the data loaded from the file, create arrays of data to be used in creating the geometry.
+ *
+ * @param[in] vertices The vertices of the object.
+ * @param[in] textures The texture coordinates of the object.
+ * @param[in] verticesExt Extension to vertices, storing tangents and bitangents.
+ * @param[in] indices Indices of corresponding values to match triangles to their respective data.
+ * @param[in] useSoftNormals Indicates whether we should average the normals at each point to smooth the surface or not.
+ */
void CreateGeometryArray( Dali::Vector<Vertex> & vertices,
Dali::Vector<Vector2> & textures,
Dali::Vector<VertexExt> & verticesExt,
- Dali::Vector<unsigned short> & indices );
+ Dali::Vector<unsigned short> & indices,
+ bool useSoftNormals );
};
-#ifndef __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__
-#define __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__
+#ifndef DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H
+#define DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*
*/
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
#define DALI_COMPOSE_SHADER(STR) #STR
namespace Dali
Property::Map customShader;
- customShader[ "vertexShader" ] = vertexSource;
- customShader[ "fragmentShader" ] = fragmentSource;
+ customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = vertexSource;
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource;
- map[ "shader" ] = customShader;
+ map[ Toolkit::Visual::Property::SHADER ] = customShader;
return map;
}
} // namespace Dali
-#endif /* __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__ */
+#endif // DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*
*/
-//EXTERNAL INCLUDES
+// EXTERNAL INCLUDES
#include <string.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/object/property-map.h>
-//INTERNAL INCLUDES
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
using namespace Dali;
Property::Map customShader;
- customShader[ "vertexShader" ] = vertexShader;
- customShader[ "fragmentShader" ] = fragmentShader;
- customShader[ "subdivideGridX" ] = 20;
- customShader[ "subdivideGridY" ] = 20;
+ customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = vertexShader;
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShader;
+ customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 20;
+ customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 20;
- map[ "shader" ] = customShader;
+ map[ Toolkit::Visual::Property::SHADER ] = customShader;
return map;
}
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
using namespace Dali;
// broken image is loaded if there is no valid image provided for the page
const char * const BROKEN_IMAGE_URL( DALI_IMAGE_DIR "broken.png");
-// names of shader property map
-const char * const CUSTOM_SHADER( "shader" );
-const char * const CUSTOM_VERTEX_SHADER( "vertexShader" );
-const char * const CUSTOM_FRAGMENT_SHADER( "fragmentShader" );
-
// properties set on shader, these properties have the constant value in regardless of the page status
const char * const PROPERTY_SPINE_SHADOW ( "uSpineShadowParameter" ); // uniform for both spine and turn effect
// create the grid geometry for pages
uint16_t width = static_cast<uint16_t>(mPageSize.width / DEFAULT_GRID_DENSITY + 0.5f);
uint16_t height = static_cast<uint16_t>(mPageSize.height / DEFAULT_GRID_DENSITY + 0.5f);
- mGeometry = RendererFactoryCache::CreateGridGeometry( Uint16Pair( width, height ) );
+ mGeometry = VisualFactoryCache::CreateGridGeometry( Uint16Pair( width, height ) );
mPages.reserve( NUMBER_OF_CACHED_PAGES );
for( int i = 0; i < NUMBER_OF_CACHED_PAGES; i++ )
Shader PageTurnView::CreateShader( const Property::Map& shaderMap )
{
Shader shader;
- Property::Value* shaderValue = shaderMap.Find( CUSTOM_SHADER );
+ Property::Value* shaderValue = shaderMap.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
Property::Map shaderSource;
if( shaderValue && shaderValue->Get( shaderSource ) )
{
std::string vertexShader;
- Property::Value* vertexShaderValue = shaderSource.Find( CUSTOM_VERTEX_SHADER );
+ Property::Value* vertexShaderValue = shaderSource.Find( Toolkit::Visual::Shader::Property::VERTEX_SHADER, CUSTOM_VERTEX_SHADER );
if( !vertexShaderValue || !vertexShaderValue->Get( vertexShader ) )
{
DALI_LOG_ERROR("PageTurnView::CreateShader failed: vertex shader source is not available.\n");
}
std::string fragmentShader;
- Property::Value* fragmentShaderValue = shaderSource.Find( CUSTOM_FRAGMENT_SHADER );
+ Property::Value* fragmentShaderValue = shaderSource.Find( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, CUSTOM_FRAGMENT_SHADER );
if( !fragmentShaderValue || !fragmentShaderValue->Get( fragmentShader ) )
{
DALI_LOG_ERROR("PageTurnView::CreateShader failed: fragment shader source is not available.\n");
+++ /dev/null
-/*
- * 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 "control-renderer-data-impl.h"
-
-// EXTERNAL HEADER
-#include <dali/public-api/common/dali-common.h>
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/object/property-array.h>
-
-// EXTERNAL HEADER
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-//custom shader
-const char * const CUSTOM_SHADER( "shader" );
-const char * const CUSTOM_VERTEX_SHADER( "vertexShader" );
-const char * const CUSTOM_FRAGMENT_SHADER( "fragmentShader" );
-const char * const CUSTOM_SUBDIVIDE_GRID_X( "subdivideGridX" );
-const char * const CUSTOM_SUBDIVIDE_GRID_Y( "subdivideGridY" );
-const char * const CUSTOM_SHADER_HINTS( "hints" ); ///< type STRING for a hint from the below hint strings or an ARRAY of of hint strings
-
-/**
- * where hints should be contain strings of the following shader hints:
- * "none" | corresponds to HINT_NONE
- * "outputIsTransparent" | corresponds to HINT_OUTPUT_IS_TRANSPARENT
- * "modifiesGeometry" | corresponds to HINT_MODIFIES_GEOMETRY
- */
-
-Shader::ShaderHints HintFromString( std::string hintString )
-{
- if( hintString == "none" )
- {
- return Shader::HINT_NONE;
- }
- else if( hintString == "outputIsTransparent" )
- {
- return Shader::HINT_OUTPUT_IS_TRANSPARENT;
- }
- else if( hintString == "modifiesGeometry" )
- {
- return Shader::HINT_MODIFIES_GEOMETRY;
- }
- else
- {
- DALI_LOG_ERROR( "'%s' hint string is not recognised", hintString.c_str() );
- }
-
- return Shader::HINT_NONE;
-}
-
-}// unnamed namespace
-
-Internal::ControlRenderer::Impl::Impl()
-: mCustomShader(NULL),
- mDepthIndex( 0.0f ),
- mFlags( 0 )
-{
-}
-
-Internal::ControlRenderer::Impl::~Impl()
-{
- delete mCustomShader;
-}
-
-Internal::ControlRenderer::Impl::CustomShader::CustomShader( const Property::Map& map )
-: mGridSize( 1, 1 ),
- mHints( Shader::HINT_NONE )
-{
- SetPropertyMap( map );
-}
-
-void Internal::ControlRenderer::Impl::CustomShader::SetPropertyMap( const Property::Map& shaderMap )
-{
- mVertexShader.clear();
- mFragmentShader.clear();
- mGridSize = ImageDimensions( 1, 1 );
- mHints = Shader::HINT_NONE;
-
- Property::Value* vertexShaderValue = shaderMap.Find( CUSTOM_VERTEX_SHADER );
- if( vertexShaderValue )
- {
- if( !vertexShaderValue->Get( mVertexShader ) )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_VERTEX_SHADER );
- }
- }
-
- Property::Value* fragmentShaderValue = shaderMap.Find( CUSTOM_FRAGMENT_SHADER );
- if( fragmentShaderValue )
- {
- if( !fragmentShaderValue->Get( mFragmentShader ) )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_FRAGMENT_SHADER );
- }
- }
-
- Property::Value* subdivideXValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_X );
- if( subdivideXValue )
- {
- int subdivideX;
- if( !subdivideXValue->Get( subdivideX ) || subdivideX < 1 )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_X );
- }
- else
- {
- mGridSize = ImageDimensions( subdivideX, mGridSize.GetY() );
- }
- }
-
- Property::Value* subdivideYValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_Y );
- if( subdivideYValue )
- {
- int subdivideY;
- if( !subdivideYValue->Get( subdivideY ) || subdivideY < 1 )
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_Y );
- }
- else
- {
- mGridSize = ImageDimensions( mGridSize.GetX(), subdivideY );
- }
- }
-
- Property::Value* hintsValue = shaderMap.Find( CUSTOM_SHADER_HINTS );
- if( hintsValue )
- {
- std::string hintString;
- Property::Array hintsArray;
-
- if( hintsValue->Get( hintString ) )
- {
- mHints = HintFromString( hintString );
- }
- else if( hintsValue->Get( hintsArray ) )
- {
- int hints = Shader::HINT_NONE;
- for( Property::Array::SizeType i = 0; i < hintsArray.Count(); ++i)
- {
- Property::Value hintValue = hintsArray[ i ];
- if( hintValue.Get( hintString ) )
- {
- hints |= static_cast< int >( HintFromString( hintString ) );
- }
- else
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify an hint string at index %d", CUSTOM_SHADER_HINTS, i );
- }
-
- mHints = static_cast< Shader::ShaderHints >( hints );
- }
- }
- else
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint string or an array of hint strings", CUSTOM_SHADER_HINTS );
- }
- }
-}
-
-void Internal::ControlRenderer::Impl::CustomShader::CreatePropertyMap( Property::Map& map ) const
-{
- if( !mVertexShader.empty() || !mFragmentShader.empty() )
- {
- Property::Map customShader;
- if( !mVertexShader.empty() )
- {
- customShader.Insert(CUSTOM_VERTEX_SHADER, mVertexShader );
- }
- if( !mFragmentShader.empty() )
- {
- customShader.Insert(CUSTOM_FRAGMENT_SHADER, mFragmentShader );
- }
-
- if( mGridSize.GetWidth() != 1 )
- {
- customShader.Insert(CUSTOM_SUBDIVIDE_GRID_X, mGridSize.GetWidth() );
- }
- if( mGridSize.GetHeight() != 1 )
- {
- customShader.Insert(CUSTOM_SUBDIVIDE_GRID_Y, mGridSize.GetHeight() );
- }
-
- if( mHints != Dali::Shader::HINT_NONE )
- {
- customShader.Insert(CUSTOM_SHADER_HINTS, static_cast< int >(mHints) );
- }
-
- map.Insert( CUSTOM_SHADER, customShader );
- }
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
- /*
- * 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 <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/object/property-array.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/type-registry-helper.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/border/border-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/debug/debug-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/gradient/gradient-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/npatch/npatch-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/svg/svg-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/primitive/primitive-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/image-atlas-manager.h>
-
-namespace
-{
-const char * const BROKEN_RENDERER_IMAGE_URL( DALI_IMAGE_DIR "broken.png");
-}
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-
-BaseHandle Create()
-{
- BaseHandle handle = Toolkit::RendererFactory::Get();
-
- return handle;
-}
-
-DALI_TYPE_REGISTRATION_BEGIN_CREATE( Toolkit::RendererFactory, Dali::BaseHandle, Create, true )
-DALI_TYPE_REGISTRATION_END()
-
-} // namespace
-
-RendererFactory::RendererFactory( bool debugEnabled )
-:mDebugEnabled( debugEnabled )
-{
-}
-
-RendererFactory::~RendererFactory()
-{
-}
-
-RendererFactory::RendererType RendererFactory::GetRendererType( const Property::Map& propertyMap )
-{
- RendererType rendererType = UNDEFINED;
-
- Property::Value* type = propertyMap.Find( RENDERER_TYPE );
- std::string typeValue ;
- if( type && type->Get( typeValue ))
- {
- if( typeValue == COLOR_RENDERER )
- {
- rendererType = COLOR;
- }
- else if( typeValue == BORDER_RENDERER )
- {
- rendererType = BORDER;
- }
- else if( typeValue == GRADIENT_RENDERER )
- {
- rendererType = GRADIENT;
- }
- else if( typeValue == IMAGE_RENDERER )
- {
- rendererType = IMAGE;
- }
- else if( typeValue == MESH_RENDERER )
- {
- rendererType = MESH;
- }
- else if( typeValue == PRIMITIVE_RENDERER )
- {
- rendererType = PRIMITIVE;
- }
- }
-
- // check the url if exist, to decide the renderer type
- if( rendererType == IMAGE || rendererType == UNDEFINED )
- {
- Property::Value* imageURLValue = propertyMap.Find( IMAGE_URL_NAME );
- std::string imageUrl;
- if( imageURLValue && imageURLValue->Get( imageUrl ))
- {
- if( NinePatchImage::IsNinePatchUrl( imageUrl ) )
- {
- rendererType = N_PATCH;
- }
- else if( SvgRenderer::IsSvgUrl( imageUrl ) )
- {
- rendererType = SVG;
- }
- else
- {
- rendererType = IMAGE;
- }
- }
- }
-
- return rendererType;
-}
-
-Toolkit::ControlRenderer RendererFactory::CreateControlRenderer( const Property::Map& propertyMap )
-{
- ControlRenderer* rendererPtr = NULL;
-
- RendererType type = GetRendererType( propertyMap );
- if( type != UNDEFINED)
- {
- if( !mFactoryCache )
- {
- mFactoryCache = new RendererFactoryCache();
- }
-
- if( mDebugEnabled )
- {
- return Toolkit::ControlRenderer( new DebugRenderer( *( mFactoryCache.Get() ) ) );
- }
- }
-
- switch( type )
- {
- case COLOR:
- {
- rendererPtr = new ColorRenderer( *( mFactoryCache.Get() ) );
- break;
- }
- case GRADIENT:
- {
- rendererPtr = new GradientRenderer( *( mFactoryCache.Get() ) );
- break;
- }
- case BORDER:
- {
- rendererPtr = new BorderRenderer( *( mFactoryCache.Get() ) );
- break;
- }
- case IMAGE:
- {
- CreateAtlasManager();
- rendererPtr = new ImageRenderer( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
- break;
- }
- case N_PATCH:
- {
- rendererPtr = new NPatchRenderer( *( mFactoryCache.Get() ) );
- break;
- }
- case SVG:
- {
- CreateAtlasManager();
- rendererPtr = new SvgRenderer( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
- break;
- }
- case MESH:
- {
- rendererPtr = new MeshRenderer( *( mFactoryCache.Get() ) );
- break;
- }
- case PRIMITIVE:
- {
- rendererPtr = new PrimitiveRenderer( *( mFactoryCache.Get() ) );
- break;
- }
- case UNDEFINED:
- default:
- {
- break;
- }
- }
-
- if( rendererPtr )
- {
- Actor actor;
- rendererPtr->Initialize( actor, propertyMap );
- }
- else
- {
- DALI_LOG_ERROR( "Renderer type unknown" );
- }
-
- return Toolkit::ControlRenderer( rendererPtr );
-}
-
-Toolkit::ControlRenderer RendererFactory::CreateControlRenderer( const Image& image )
-{
- if( !mFactoryCache )
- {
- mFactoryCache = new RendererFactoryCache();
- }
-
- if( mDebugEnabled )
- {
- return Toolkit::ControlRenderer( new DebugRenderer( *( mFactoryCache.Get() ) ) );
- }
-
- NinePatchImage npatchImage = NinePatchImage::DownCast( image );
- if( npatchImage )
- {
- NPatchRenderer* rendererPtr = new NPatchRenderer( *( mFactoryCache.Get() ) );
- rendererPtr->SetImage( npatchImage );
-
- return Toolkit::ControlRenderer( rendererPtr );
- }
- else
- {
- CreateAtlasManager();
- ImageRenderer* rendererPtr = new ImageRenderer( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
- Actor actor;
- rendererPtr->SetImage( actor, image );
-
- return Toolkit::ControlRenderer( rendererPtr );
- }
-}
-
-Toolkit::ControlRenderer RendererFactory::CreateControlRenderer( const std::string& url, ImageDimensions size )
-{
- if( !mFactoryCache )
- {
- mFactoryCache = new RendererFactoryCache();
- }
-
- if( mDebugEnabled )
- {
- return Toolkit::ControlRenderer( new DebugRenderer( *( mFactoryCache.Get() ) ) );
- }
-
- if( NinePatchImage::IsNinePatchUrl( url ) )
- {
- NPatchRenderer* rendererPtr = new NPatchRenderer( *( mFactoryCache.Get() ) );
- rendererPtr->SetImage( url );
-
- return Toolkit::ControlRenderer( rendererPtr );
- }
- else if( SvgRenderer::IsSvgUrl( url ) )
- {
- CreateAtlasManager();
- SvgRenderer* rendererPtr = new SvgRenderer( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
- rendererPtr->SetImage( url, size );
- return Toolkit::ControlRenderer( rendererPtr );
- }
- else
- {
- CreateAtlasManager();
- ImageRenderer* rendererPtr = new ImageRenderer( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
- Actor actor;
- rendererPtr->SetImage( actor, url, size );
-
- return Toolkit::ControlRenderer( rendererPtr );
- }
-}
-
-Image RendererFactory::GetBrokenRendererImage()
-{
- return ResourceImage::New( BROKEN_RENDERER_IMAGE_URL );
-}
-
-void RendererFactory::CreateAtlasManager()
-{
- if( !mAtlasManager )
- {
- Shader shader = ImageRenderer::GetImageShader( *( mFactoryCache.Get() ) );
- mAtlasManager = new ImageAtlasManager();
- mAtlasManager->SetBrokenImage( BROKEN_RENDERER_IMAGE_URL );
- }
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_RENDERER_FACTORY_IMPL_H__
-#define __DALI_TOOLKIT_RENDERER_FACTORY_IMPL_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 <dali/public-api/object/base-object.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-class RendererFactoryCache;
-typedef IntrusivePtr<RendererFactoryCache> RendererFactoryCachePtr;
-
-class ImageAtlasManager;
-typedef IntrusivePtr<ImageAtlasManager> ImageAtlasManagerPtr;
-
-/**
- * @copydoc Toolkit::RendererFactory
- */
-class RendererFactory : public BaseObject
-{
-public:
-
- enum RendererType
- {
- COLOR,
- BORDER,
- GRADIENT,
- IMAGE,
- N_PATCH,
- SVG,
- MESH,
- PRIMITIVE,
- UNDEFINED
- };
-
- /**
- * @brief Constructor
- *
- * @param[in] debugEnabled If true, use debug renderer to replace all the concrete renderer.
- */
- RendererFactory( bool debugEnabled );
-
- /**
- * @copydoc Toolkit::RenderFactory::CreateControlRenderer( const Property::Map& )
- */
- Toolkit::ControlRenderer CreateControlRenderer( const Property::Map& propertyMap );
-
- /**
- * @copydoc Toolkit::RenderFactory::CreateControlRenderer( const Image& )
- */
- Toolkit::ControlRenderer CreateControlRenderer( const Image& image );
-
- /**
- * @copydoc Toolkit::RenderFactory::CreateControlRenderer( const std::string&, ImageDimensions )
- */
- Toolkit::ControlRenderer CreateControlRenderer( const std::string& image, ImageDimensions size );
-
-public:
- /**
- * @brief Returns an image to be used when a renderer has failed to correctly render
- */
- static Image GetBrokenRendererImage();
-
-protected:
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~RendererFactory();
-
-private:
-
- /**
- * Get the renderer type from the property map.
- *
- * @param[in] propertyMap The map contains the properties of the control renderer
- * @return The rendererType
- */
- RendererType GetRendererType( const Property::Map& propertyMap );
-
- /**
- * Prepare the atlas manager
- */
- void CreateAtlasManager();
-
- /**
- * Undefined copy constructor.
- */
- RendererFactory(const RendererFactory&);
-
- /**
- * Undefined assignment operator.
- */
- RendererFactory& operator=(const RendererFactory& rhs);
-
-private:
-
- RendererFactoryCachePtr mFactoryCache;
- ImageAtlasManagerPtr mAtlasManager;
- bool mDebugEnabled;
-};
-
-} // namespace Internal
-
-inline const Internal::RendererFactory& GetImplementation(const Toolkit::RendererFactory& factory)
-{
- DALI_ASSERT_ALWAYS( factory && "RendererFactory handle is empty" );
-
- const BaseObject& handle = factory.GetBaseObject();
-
- return static_cast<const Internal::RendererFactory&>(handle);
-}
-
-inline Internal::RendererFactory& GetImplementation(Toolkit::RendererFactory& factory)
-{
- DALI_ASSERT_ALWAYS( factory && "RendererFactory handle is empty" );
-
- BaseObject& handle = factory.GetBaseObject();
-
- return static_cast<Internal::RendererFactory&>(handle);
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif /* __DALI_TOOLKIT_RENDERER_FACTORY_IMPL_H__ */
+++ /dev/null
- /*
- * 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 "renderer-string-constants.h"
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-const char * const RENDERER_TYPE("rendererType");
-const char * const COLOR_RENDERER("COLOR");
-const char * const BORDER_RENDERER("BORDER");
-const char * const GRADIENT_RENDERER("GRADIENT");
-const char * const IMAGE_RENDERER("IMAGE");
-const char * const MESH_RENDERER("MESH");
-const char * const PRIMITIVE_RENDERER( "PRIMITIVE" );
-const char * const DEBUG_RENDERER("DEBUG");
-
-const char * const IMAGE_URL_NAME("url");
-const char * const ATLAS_RECT_UNIFORM_NAME ( "uAtlasRect" );
-const char * const LIGHT_POSITION_UNIFORM_NAME( "uLightPosition" );
-
-//Mesh properties
-const char * const OBJECT_URL( "objectUrl" );
-const char * const MATERIAL_URL( "materialUrl" );
-const char * const TEXTURES_PATH( "texturesPath" );
-const char * const SHADER_TYPE( "shaderType" );
-const char * const USE_MIPMAPPING( "useMipmapping" );
-
-//Primitive shape properties
-const char * const PRIMITIVE_SHAPE( "shape" );
-const char * const SHAPE_COLOR( "color" );
-const char * const SLICES( "slices" );
-const char * const STACKS( "stacks" );
-const char * const SCALE_TOP_RADIUS( "scaleTopRadius" );
-const char * const SCALE_BOTTOM_RADIUS( "scaleBottomRadius" );
-const char * const SCALE_HEIGHT( "scaleHeight" );
-const char * const SCALE_RADIUS( "scaleRadius" );
-const char * const SCALE_DIMENSIONS( "scaleDimensions" );
-const char * const BEVEL_PERCENTAGE( "bevelPercentage" );
-const char * const BEVEL_SMOOTHNESS( "bevelSmoothness" );
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_RENDERER_STRING_CONSTANTS_H__
-#define __DALI_TOOLKIT_INTERNAL_RENDERER_STRING_CONSTANTS_H__
-
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-extern const char * const RENDERER_TYPE;
-extern const char * const COLOR_RENDERER;
-extern const char * const BORDER_RENDERER;
-extern const char * const GRADIENT_RENDERER;
-extern const char * const IMAGE_RENDERER;
-extern const char * const MESH_RENDERER;
-extern const char * const PRIMITIVE_RENDERER;
-extern const char * const DEBUG_RENDERER;
-
-extern const char * const IMAGE_URL_NAME;
-extern const char * const ATLAS_RECT_UNIFORM_NAME;
-extern const char * const LIGHT_POSITION_UNIFORM_NAME;
-
-//Mesh properties
-extern const char * const OBJECT_URL;
-extern const char * const MATERIAL_URL;
-extern const char * const TEXTURES_PATH;
-extern const char * const SHADER_TYPE;
-extern const char * const USE_MIPMAPPING;
-
-//Primitive shape properties
-extern const char * const PRIMITIVE_SHAPE;
-extern const char * const SHAPE_COLOR;
-extern const char * const SLICES;
-extern const char * const STACKS;
-extern const char * const SCALE_TOP_RADIUS;
-extern const char * const SCALE_BOTTOM_RADIUS;
-extern const char * const SCALE_HEIGHT;
-extern const char * const SCALE_RADIUS;
-extern const char * const SCALE_DIMENSIONS;
-extern const char * const BEVEL_PERCENTAGE;
-extern const char * const BEVEL_SMOOTHNESS;
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif /* __DALI_TOOLKIT_INTERNAL_RENDERER_STRING_CONSTANTS_H__ */
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/rendering/shader.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/controls/shadow-view/shadow-view-impl.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
mShadowPlane.SetParentOrigin(ParentOrigin::CENTER);
mShadowPlane.SetAnchorPoint(AnchorPoint::CENTER);
- mShadowPlane.SetProperty( Toolkit::ImageView::Property::IMAGE, mShadowRenderShader );
+ mShadowPlane.SetProperty( Toolkit::ImageView::Property::IMAGE, mShadowVisualMap );
SetShaderConstants();
// Rather than parent the shadow plane drawable and have constraints to move it to the same
Property::Map customShader;
- customShader[ "vertexShader" ] = RENDER_SHADOW_VERTEX_SOURCE;
- customShader[ "fragmentShader" ] = RENDER_SHADOW_FRAGMENT_SOURCE;
+ customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = RENDER_SHADOW_VERTEX_SOURCE;
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = RENDER_SHADOW_FRAGMENT_SOURCE;
- customShader[ "subdivideGridX" ] = 20;
- customShader[ "subdivideGridY" ] = 20;
+ customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 20;
+ customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 20;
- customShader[ "hints" ] = "outputIsTransparent";
+ customShader[ Toolkit::Visual::Shader::Property::HINTS ] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
- mShadowRenderShader[ "shader" ] = customShader;
+ mShadowVisualMap[ Toolkit::Visual::Property::SHADER ] = customShader;
// Create render targets needed for rendering from light's point of view
mSceneFromLightRenderTarget = FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 );
#define __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
- Property::Map mShadowRenderShader;
+ Property::Map mShadowVisualMap;
BlurTwoPassFilter mBlurFilter;
Vector4 mCachedShadowColor; ///< Cached Shadow color.
#include <dali/integration-api/debug.h>
// INTERNAL_INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace //Unnamed namespace
{
DALI_ASSERT_ALWAYS( mBlurLevels > 0 && " Minimal blur level is one, otherwise no blur is needed" );
mGaussianBlurView.assign( blurLevels, Toolkit::GaussianBlurView() );
mBlurredImage.assign( blurLevels, FrameBufferImage() );
- mRenderers.assign( blurLevels+1, Toolkit::ControlRenderer() );
+ mVisuals.assign( blurLevels+1, Toolkit::Visual::Base() );
}
SuperBlurView::~SuperBlurView()
mInputImage = inputImage;
Actor self( Self() );
- InitializeControlRenderer( self, mRenderers[0], mInputImage );
- mRenderers[0].SetDepthIndex(0);
- SetShaderEffect( mRenderers[0] );
+ InitializeVisual( self, mVisuals[0], mInputImage );
+ mVisuals[0].SetDepthIndex(0);
+ SetShaderEffect( mVisuals[0] );
if( self.OnStage() )
{
- mRenderers[0].SetOnStage( self );
+ mVisuals[0].SetOnStage( self );
}
BlurImage( 0, inputImage);
mResourcesCleared = true;
}
}
-void SuperBlurView::SetShaderEffect( Toolkit::ControlRenderer& renderer )
+void SuperBlurView::SetShaderEffect( Toolkit::Visual::Base& visual )
{
Property::Map shaderMap;
std::stringstream verterShaderString;
shaderMap[ "fragmentShader" ] = FRAGMENT_SHADER;
- Internal::ControlRenderer& rendererImpl = GetImplementation( renderer );
+ Internal::Visual::Base& rendererImpl = Toolkit::GetImplementation( visual );
rendererImpl.SetCustomShader( shaderMap );
}
{
mTargetSize = Vector2(targetSize);
- Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
Actor self = Self();
for( unsigned int i = 1; i <= mBlurLevels; i++ )
{
float exponent = static_cast<float>(i);
mBlurredImage[i-1] = FrameBufferImage::New( mTargetSize.width/std::pow(2.f,exponent) , mTargetSize.height/std::pow(2.f,exponent),
GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT, Dali::Image::NEVER );
- InitializeControlRenderer( self, mRenderers[i], mBlurredImage[i - 1] );
- mRenderers[ i ].SetDepthIndex( i );
- SetShaderEffect( mRenderers[ i ] );
+ InitializeVisual( self, mVisuals[i], mBlurredImage[i - 1] );
+ mVisuals[ i ].SetDepthIndex( i );
+ SetShaderEffect( mVisuals[ i ] );
}
if( mInputImage )
{
for( unsigned int i = 1; i <= mBlurLevels; i++ )
{
- mRenderers[i].SetOnStage( self );
+ mVisuals[i].SetOnStage( self );
}
}
}
}
Actor self = Self();
- if( mRenderers[0] )
+ if( mVisuals[0] )
{
- mRenderers[0].SetOnStage( self );
+ mVisuals[0].SetOnStage( self );
}
for(unsigned int i=1; i<=mBlurLevels;i++)
{
- if( mRenderers[i] )
+ if( mVisuals[i] )
{
- mRenderers[i].SetOnStage( self );
+ mVisuals[i].SetOnStage( self );
}
Renderer renderer = self.GetRendererAt( i );
Actor self = Self();
for(unsigned int i=0; i<mBlurLevels+1;i++)
{
- mRenderers[i].SetOffStage( self );
+ mVisuals[i].SetOffStage( self );
}
Control::OnStageDisconnection();
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h>
#include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
namespace Dali
{
/**
* Sets shader effect on the control renderer
- * @param[in,out] Sets custom shader effect on the given renderer
+ * @param[in,out] Sets custom shader effect on the given visual
*/
- void SetShaderEffect( Toolkit::ControlRenderer& renderer );
+ void SetShaderEffect( Toolkit::Visual::Base& visual );
private:
std::vector<Toolkit::GaussianBlurView> mGaussianBlurView;
std::vector<FrameBufferImage> mBlurredImage;
- std::vector<Toolkit::ControlRenderer> mRenderers;
+ std::vector<Toolkit::Visual::Base> mVisuals;
Image mInputImage;
Vector2 mTargetSize;
// Call the Control::OnStageConnection() to set the depth of the background.
Control::OnStageConnection( depth );
- // Sets the depth to the renderers inside the text's decorator.
+ // Sets the depth to the visuals inside the text's decorator.
mDecorator->SetTextDepth( depth );
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
// Call the Control::OnStageConnection() to set the depth of the background.
Control::OnStageConnection( depth );
- // Sets the depth to the renderers inside the text's decorator.
+ // Sets the depth to the visuals inside the text's decorator.
mDecorator->SetTextDepth( depth );
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
mPropertyMap = map;
Actor self( Self() );
- InitializeControlRenderer( self, mRenderer, mPropertyMap );
+ InitializeVisual( self, mVisual, mPropertyMap );
Property::Value* widthValue = mPropertyMap.Find( "width" );
if( widthValue )
void VideoView::SetDepthIndex( int depthIndex )
{
- if( mRenderer )
+ if( mVisual )
{
- mRenderer.SetDepthIndex( depthIndex );
+ mVisual.SetDepthIndex( depthIndex );
}
}
{
Control::OnStageConnection( depth );
- if( mRenderer )
+ if( mVisual )
{
CustomActor self = Self();
- mRenderer.SetOnStage( self );
+ mVisual.SetOnStage( self );
}
}
void VideoView::OnStageDisconnection()
{
- if( mRenderer )
+ if( mVisual )
{
CustomActor self = Self();
- mRenderer.SetOffStage( self );
+ mVisual.SetOffStage( self );
}
Control::OnStageDisconnection();
int curPos = mVideoPlayer.GetPlayPosition();
mSetRenderingTarget = true;
- mRenderer.RemoveAndReset( self );
+ mVisual.RemoveAndReset( self );
mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
mVideoPlayer.SetUrl( mUrl );
mVideoPlayer.SetUrl( mUrl );
mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
- InitializeControlRenderer( self, mRenderer, mNativeImage );
+ InitializeVisual( self, mVisual, mNativeImage );
if( mIsPlay )
{
-#ifndef __DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H__
-#define __DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H__
+#ifndef DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
+#define DALI_TOOLKIT_INTERNAL_VIDEO_VIEW_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
#include <dali/devel-api/adaptor-framework/video-player.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
+#include <dali-toolkit/internal/visuals/image/image-visual.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/video-view/video-view.h>
/**
* @brief Set the depth index of this image renderer
*
- * Renderer with higher depth indices are rendered in front of other renderers with smaller values
+ * Renderer with higher depth indices are rendered in front of other visuals with smaller values
* @SINCE_1_1.38
* @param[in] depthIndex The depth index of this renderer
*/
Dali::VideoPlayer mVideoPlayer;
Dali::ImageDimensions mVideoSize;
- Toolkit::ControlRenderer mRenderer;
+ Toolkit::Visual::Base mVisual;
Dali::Property::Map mPropertyMap;
Dali::NativeImage mNativeImage; ///< Native image handle for video rendering by texture streaming
Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
} // namespace Dali
-#endif // __DALI_TOOLKIT_VIDEO_VIEW_H__
+#endif // DALI_TOOLKIT_VIDEO_VIEW_H
$(toolkit_src_dir)/builder/json-parser-impl.cpp \
$(toolkit_src_dir)/builder/tree-node-manipulator.cpp \
$(toolkit_src_dir)/builder/replacement.cpp \
- $(toolkit_src_dir)/controls/renderers/control-renderer-impl.cpp \
- $(toolkit_src_dir)/controls/renderers/control-renderer-data-impl.cpp \
- $(toolkit_src_dir)/controls/renderers/image-atlas-manager.cpp \
- $(toolkit_src_dir)/controls/renderers/renderer-factory-cache.cpp \
- $(toolkit_src_dir)/controls/renderers/renderer-factory-impl.cpp \
- $(toolkit_src_dir)/controls/renderers/renderer-string-constants.cpp \
- $(toolkit_src_dir)/controls/renderers/border/border-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/color/color-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/debug/debug-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/image/image-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/npatch/npatch-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/gradient/gradient.cpp \
- $(toolkit_src_dir)/controls/renderers/gradient/linear-gradient.cpp \
- $(toolkit_src_dir)/controls/renderers/gradient/radial-gradient.cpp \
- $(toolkit_src_dir)/controls/renderers/gradient/gradient-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/svg/svg-rasterize-thread.cpp \
- $(toolkit_src_dir)/controls/renderers/svg/svg-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/mesh/mesh-renderer.cpp \
- $(toolkit_src_dir)/controls/renderers/primitive/primitive-renderer.cpp \
+ $(toolkit_src_dir)/visuals/visual-base-impl.cpp \
+ $(toolkit_src_dir)/visuals/visual-base-data-impl.cpp \
+ $(toolkit_src_dir)/visuals/image-atlas-manager.cpp \
+ $(toolkit_src_dir)/visuals/visual-factory-cache.cpp \
+ $(toolkit_src_dir)/visuals/visual-factory-impl.cpp \
+ $(toolkit_src_dir)/visuals/visual-string-constants.cpp \
+ $(toolkit_src_dir)/visuals/border/border-visual.cpp \
+ $(toolkit_src_dir)/visuals/color/color-visual.cpp \
+ $(toolkit_src_dir)/visuals/debug/debug-visual.cpp \
+ $(toolkit_src_dir)/visuals/image/image-visual.cpp \
+ $(toolkit_src_dir)/visuals/npatch/npatch-visual.cpp \
+ $(toolkit_src_dir)/visuals/gradient/gradient.cpp \
+ $(toolkit_src_dir)/visuals/gradient/linear-gradient.cpp \
+ $(toolkit_src_dir)/visuals/gradient/radial-gradient.cpp \
+ $(toolkit_src_dir)/visuals/gradient/gradient-visual.cpp \
+ $(toolkit_src_dir)/visuals/svg/svg-rasterize-thread.cpp \
+ $(toolkit_src_dir)/visuals/svg/svg-visual.cpp \
+ $(toolkit_src_dir)/visuals/mesh/mesh-visual.cpp \
+ $(toolkit_src_dir)/visuals/primitive/primitive-visual.cpp \
$(toolkit_src_dir)/controls/alignment/alignment-impl.cpp \
$(toolkit_src_dir)/controls/bloom-view/bloom-view-impl.cpp \
$(toolkit_src_dir)/controls/bubble-effect/bubble-emitter-impl.cpp \
#include <dali/public-api/rendering/renderer.h>
#include <dali/devel-api/images/texture-set-image.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
namespace Dali
{
fragmentSource << BLUR_TWO_PASS_FRAGMENT_SOURCE;
Property::Map customShader;
- customShader[ "fragmentShader" ] = fragmentSource.str();
- Property::Map rendererMap;
- rendererMap.Insert( "shader", customShader );
- mActorForInput.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
- mActorForHorz.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource.str();
+ Property::Map visualMap;
+ visualMap.Insert( Toolkit::Visual::Property::SHADER, customShader );
+ mActorForInput.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
+ mActorForHorz.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
// Set up blend-two-image custom shader
- customShader[ "fragmentShader" ] = BLEND_TWO_IMAGES_FRAGMENT_SOURCE;
- rendererMap[ "shader"] = customShader;
- mActorForBlending.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = BLEND_TWO_IMAGES_FRAGMENT_SOURCE;
+ visualMap[ Toolkit::Visual::Property::SHADER ] = customShader;
+ mActorForBlending.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
mRootActor.Add( mActorForInput );
mRootActor.Add( mActorForHorz );
#include <dali/devel-api/images/texture-set-image.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
namespace Dali
{
mImageForEmboss2 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::UNUSED );
Property::Map customShader;
- customShader[ "fragmentShader" ] = EMBOSS_FRAGMENT_SOURCE;
- Property::Map rendererMap;
- rendererMap.Insert( "shader", customShader );
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = EMBOSS_FRAGMENT_SOURCE;
+ Property::Map visualMap;
+ visualMap.Insert( Toolkit::Visual::Property::SHADER, customShader );
// create actor to render input with applied emboss effect
mActorForInput1 = Toolkit::ImageView::New(mInputImage);
mActorForInput1.RegisterProperty( TEX_SCALE_UNIFORM_NAME, textureScale );
mActorForInput1.RegisterProperty( COEFFICIENT_UNIFORM_NAME, Vector3( 2.f, -1.f, -1.f ) );
// set EMBOSS custom shader
- mActorForInput1.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
+ mActorForInput1.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
mRootActor.Add( mActorForInput1 );
mActorForInput2 = Toolkit::ImageView::New(mInputImage);
mActorForInput2.RegisterProperty( TEX_SCALE_UNIFORM_NAME, textureScale );
mActorForInput2.RegisterProperty( COEFFICIENT_UNIFORM_NAME, Vector3( -1.f, -1.f, 2.f ) );
// set EMBOSS custom shader
- mActorForInput2.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
+ mActorForInput2.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
mRootActor.Add( mActorForInput2 );
mActorForComposite = Actor::New();
mActorForComposite.SetSize(mTargetSize);
mActorForComposite.SetColor( Color::BLACK );
- customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE;
- rendererMap[ "shader"] = customShader;
- rendererMap[ "rendererType"] = "IMAGE";
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = COMPOSITE_FRAGMENT_SOURCE;
+ visualMap[ Toolkit::Visual::Property::SHADER ] = customShader;
+ visualMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
mRootActor.Add( mActorForComposite );
- InitializeControlRenderer( mActorForComposite, mRendererForEmboss1, rendererMap );
- InitializeControlRenderer( mActorForComposite, mRendererForEmboss2, rendererMap );
+ InitializeVisual( mActorForComposite, mVisualForEmboss1, visualMap );
+ InitializeVisual( mActorForComposite, mVisualForEmboss2, visualMap );
TextureSet textureSet1 = TextureSet::New();
TextureSetImage( textureSet1, 0, mImageForEmboss1 );
if( mActorForComposite )
{
- mRendererForEmboss1.SetOffStage( mActorForComposite );
- mRendererForEmboss2.SetOffStage( mActorForComposite );
- mRendererForEmboss1.Reset();
- mRendererForEmboss2.Reset();
+ mVisualForEmboss1.SetOffStage( mActorForComposite );
+ mVisualForEmboss2.SetOffStage( mActorForComposite );
+ mVisualForEmboss1.Reset();
+ mVisualForEmboss2.Reset();
mRootActor.Remove( mActorForComposite );
mActorForComposite.Reset();
}
// EXTERNAL INCLUDES
#include <dali/public-api/render-tasks/render-task.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
-
-// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include "image-filter.h"
namespace Dali
private: // Attributes
- RenderTask mRenderTaskForEmboss1;
- RenderTask mRenderTaskForEmboss2;
- RenderTask mRenderTaskForOutput;
- FrameBufferImage mImageForEmboss1;
- FrameBufferImage mImageForEmboss2;
- Toolkit::ImageView mActorForInput1;
- Toolkit::ImageView mActorForInput2;
- Toolkit::ControlRenderer mRendererForEmboss1;
- Toolkit::ControlRenderer mRendererForEmboss2;
- Actor mActorForComposite;
+ RenderTask mRenderTaskForEmboss1;
+ RenderTask mRenderTaskForEmboss2;
+ RenderTask mRenderTaskForOutput;
+ FrameBufferImage mImageForEmboss1;
+ FrameBufferImage mImageForEmboss2;
+ Toolkit::ImageView mActorForInput1;
+ Toolkit::ImageView mActorForInput2;
+ Toolkit::Visual::Base mVisualForEmboss1;
+ Toolkit::Visual::Base mVisualForEmboss2;
+ Actor mActorForComposite;
}; // class EmbossFilter
} // namespace Internal
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
#include <dali/public-api/render-tasks/render-task-list.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
namespace Dali
{
mActorForHorz.RegisterProperty( TEX_SCALE_UNIFORM_NAME, Vector2( 0.0f, 1.0f / mTargetSize.height ) );
Property::Map customShader;
- customShader[ "fragmentShader" ] = SPREAD_FRAGMENT_SOURCE;
- Property::Map rendererMap;
- rendererMap.Insert( "shader", customShader );
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SPREAD_FRAGMENT_SOURCE;
+ Property::Map visualMap;
+ visualMap.Insert( Toolkit::Visual::Property::SHADER, customShader );
// set SPREAD custom shader
- mActorForInput.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
- mActorForHorz.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
+ mActorForInput.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
+ mActorForHorz.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
mRootActor.Add( mActorForInput );
mRootActor.Add( mActorForHorz );
Shader shaderEffectCustom = Shader::New( vertexShaderStringStream.str(),
fragmentShaderStringStream.str(),
- Shader::ShaderHints( Shader::HINT_OUTPUT_IS_TRANSPARENT ) );
+ Shader::Hint::OUTPUT_IS_TRANSPARENT );
GlyphyShader handle( shaderEffectCustom );
*/
void CreateRenderer( FrameBufferImage frameBufferImage, Dali::Renderer& renderer )
{
- Shader shader = Shader::New( VERTEX_SHADER_SCROLL , FRAGMENT_SHADER, Shader::HINT_NONE );
+ Shader shader = Shader::New( VERTEX_SHADER_SCROLL , FRAGMENT_SHADER, Shader::Hint::NONE );
Sampler sampler = Sampler::New();
sampler.SetFilterMode(FilterMode::NEAREST, FilterMode::NEAREST );
#include <cstring> // for strcmp
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
namespace Dali
{
{
Control::OnStageConnection( depth );
- Geometry geometry = RendererFactoryCache::CreateQuadGeometry();
+ Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
TextureSet textureSet = TextureSet::New();
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*/
// CLASS HEADER
-#include "border-renderer.h"
+#include "border-visual.h"
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-//INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/border-visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace Dali
{
);
}
-BorderRenderer::BorderRenderer( RendererFactoryCache& factoryCache )
-: ControlRenderer( factoryCache ),
+BorderVisual::BorderVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache ),
mBorderColor( Color::TRANSPARENT ),
mBorderSize( 0.f ),
mBorderColorIndex( Property::INVALID_INDEX ),
{
}
-BorderRenderer::~BorderRenderer()
+BorderVisual::~BorderVisual()
{
}
-void BorderRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void BorderVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
- Property::Value* color = propertyMap.Find( COLOR_NAME );
+ Property::Value* color = propertyMap.Find( Toolkit::BorderVisual::Property::COLOR, COLOR_NAME );
if( !( color && color->Get(mBorderColor) ) )
{
- DALI_LOG_ERROR( "Fail to provide a border color to the BorderRenderer object" );
+ DALI_LOG_ERROR( "Fail to provide a border color to the BorderVisual object" );
}
- Property::Value* size = propertyMap.Find( SIZE_NAME );
+ Property::Value* size = propertyMap.Find( Toolkit::BorderVisual::Property::SIZE, SIZE_NAME );
if( !( size && size->Get(mBorderSize) ) )
{
- DALI_LOG_ERROR( "Fail to provide a border size to the BorderRenderer object" );
+ DALI_LOG_ERROR( "Fail to provide a border size to the BorderVisual object" );
}
- Property::Value* antiAliasing = propertyMap.Find( ANTI_ALIASING );
+ Property::Value* antiAliasing = propertyMap.Find( Toolkit::BorderVisual::Property::ANTI_ALIASING, ANTI_ALIASING );
if( antiAliasing )
{
antiAliasing->Get( mAntiAliasing );
}
}
-void BorderRenderer::SetClipRect( const Rect<int>& clipRect )
+void BorderVisual::SetClipRect( const Rect<int>& clipRect )
{
- ControlRenderer::SetClipRect( clipRect );
+ Visual::Base::SetClipRect( clipRect );
//ToDo: renderer responds to the clipRect change
}
-void BorderRenderer::DoSetOnStage( Actor& actor )
+void BorderVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
mBorderSizeIndex = (mImpl->mRenderer).RegisterProperty( SIZE_NAME, mBorderSize );
}
-void BorderRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void BorderVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, BORDER_RENDERER );
- map.Insert( COLOR_NAME, mBorderColor );
- map.Insert( SIZE_NAME, mBorderSize );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::BORDER );
+ map.Insert( Toolkit::BorderVisual::Property::COLOR, mBorderColor );
+ map.Insert( Toolkit::BorderVisual::Property::SIZE, mBorderSize );
+ map.Insert( Toolkit::BorderVisual::Property::ANTI_ALIASING, mAntiAliasing );
}
-void BorderRenderer::InitializeRenderer()
+void BorderVisual::InitializeRenderer()
{
- Geometry geometry = mFactoryCache.GetGeometry( RendererFactoryCache::BORDER_GEOMETRY );
+ Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::BORDER_GEOMETRY );
if( !geometry )
{
geometry = CreateBorderGeometry();
- mFactoryCache.SaveGeometry( RendererFactoryCache::BORDER_GEOMETRY, geometry );
+ mFactoryCache.SaveGeometry( VisualFactoryCache::BORDER_GEOMETRY, geometry );
}
}
-void BorderRenderer::SetBorderColor(const Vector4& color)
+void BorderVisual::SetBorderColor(const Vector4& color)
{
mBorderColor = color;
}
}
-void BorderRenderer::SetBorderSize( float size )
+void BorderVisual::SetBorderSize( float size )
{
mBorderSize = size;
}
}
-void BorderRenderer::RequireAntiAliasing( bool antiAliasing )
+void BorderVisual::RequireAntiAliasing( bool antiAliasing )
{
if( mAntiAliasing != antiAliasing )
{
}
}
-Shader BorderRenderer::GetBorderShader()
+Shader BorderVisual::GetBorderShader()
{
Shader shader;
if( mAntiAliasing )
{
- shader = mFactoryCache.GetShader( RendererFactoryCache::BORDER_SHADER_ANTI_ALIASING );
+ shader = mFactoryCache.GetShader( VisualFactoryCache::BORDER_SHADER_ANTI_ALIASING );
if( !shader )
{
shader = Shader::New( VERTEX_SHADER_ANTI_ALIASING, FRAGMENT_SHADER_ANTI_ALIASING );
- mFactoryCache.SaveShader( RendererFactoryCache::BORDER_SHADER_ANTI_ALIASING, shader );
+ mFactoryCache.SaveShader( VisualFactoryCache::BORDER_SHADER_ANTI_ALIASING, shader );
}
}
else
{
- shader = mFactoryCache.GetShader( RendererFactoryCache::BORDER_SHADER );
+ shader = mFactoryCache.GetShader( VisualFactoryCache::BORDER_SHADER );
if( !shader )
{
shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- mFactoryCache.SaveShader( RendererFactoryCache::BORDER_SHADER, shader );
+ mFactoryCache.SaveShader( VisualFactoryCache::BORDER_SHADER, shader );
}
}
* |/ |/ | \|
* 12-13-14-15
*/
-Geometry BorderRenderer::CreateBorderGeometry()
+Geometry BorderVisual::CreateBorderGeometry()
{
const float halfWidth = 0.5f;
const float halfHeight = 0.5f;
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( borderVertices );
geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) );
- geometry.SetGeometryType( Geometry::TRIANGLE_STRIP );
+ geometry.SetType( Geometry::TRIANGLE_STRIP );
return geometry;
}
-#ifndef DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H
-#define DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H
+#ifndef DALI_TOOLKIT_INTERNAL_BORDER_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_BORDER_VISUAL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
#include <dali/public-api/rendering/geometry.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
{
/**
- * The renderer which renders a solid color to the control's quad border fixed to a specified size.
+ * The visual which renders a solid color to the control's quad border fixed to a specified size.
*
* The following properties are required for create a BorderRender
*
* | antiAliasing | BOOLEAN |
*/
-class BorderRenderer : public ControlRenderer
+class BorderVisual : public Visual::Base
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- BorderRenderer( RendererFactoryCache& factoryCache );
+ BorderVisual( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- virtual ~BorderRenderer();
+ virtual ~BorderVisual();
-public: // from ControlRenderer
+public: // from Visual
/**
- * @copydoc ControlRenderer::SetClipRect
+ * @copydoc Visual::SetClipRect
*/
virtual void SetClipRect( const Rect<int>& clipRect );
protected:
/**
- * @copydoc ControlRenderer::DoInitialize
+ * @copydoc Visual::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
Geometry CreateBorderGeometry();
// Undefined
- BorderRenderer( const BorderRenderer& borderRenderer );
+ BorderVisual( const BorderVisual& borderRenderer );
// Undefined
- BorderRenderer& operator=( const BorderRenderer& borderRenderer );
+ BorderVisual& operator=( const BorderVisual& borderRenderer );
private:
} // namespace Dali
-#endif // DALI_TOOLKIT_INTERNAL_BORDER_RENDERER_H
+#endif // DALI_TOOLKIT_INTERNAL_BORDER_VISUAL_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*/
// CLASS HEADER
-#include "color-renderer.h"
+#include "color-visual.h"
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
//INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace Dali
{
);
}
-ColorRenderer::ColorRenderer( RendererFactoryCache& factoryCache )
-: ControlRenderer( factoryCache ),
+ColorVisual::ColorVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache ),
mMixColorIndex( Property::INVALID_INDEX )
{
}
-ColorRenderer::~ColorRenderer()
+ColorVisual::~ColorVisual()
{
}
-void ColorRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void ColorVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
- Property::Value* color = propertyMap.Find( COLOR_NAME );
+ Property::Value* color = propertyMap.Find( Toolkit::ColorVisual::Property::MIX_COLOR, COLOR_NAME );
if( !( color && color->Get(mMixColor) ) )
{
- DALI_LOG_ERROR( "Fail to provide a color to the ColorRenderer object" );
+ DALI_LOG_ERROR( "Fail to provide a color to the ColorVisual object" );
}
}
-void ColorRenderer::SetSize( const Vector2& size )
+void ColorVisual::SetSize( const Vector2& size )
{
- ControlRenderer::SetSize( size );
+ Visual::Base::SetSize( size );
// ToDo: renderer responds to the size change
}
-void ColorRenderer::SetClipRect( const Rect<int>& clipRect )
+void ColorVisual::SetClipRect( const Rect<int>& clipRect )
{
- ControlRenderer::SetClipRect( clipRect );
+ Visual::Base::SetClipRect( clipRect );
//ToDo: renderer responds to the clipRect change
}
-void ColorRenderer::SetOffset( const Vector2& offset )
+void ColorVisual::SetOffset( const Vector2& offset )
{
//ToDo: renderer applies the offset
}
-void ColorRenderer::DoSetOnStage( Actor& actor )
+void ColorVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
}
-void ColorRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void ColorVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, COLOR_RENDERER );
- map.Insert( COLOR_NAME, mMixColor );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR );
+ map.Insert( Toolkit::ColorVisual::Property::MIX_COLOR, mMixColor );
}
-void ColorRenderer::InitializeRenderer()
+void ColorVisual::InitializeRenderer()
{
- Geometry geometry = mFactoryCache.GetGeometry( RendererFactoryCache::QUAD_GEOMETRY );
+ Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
if( !geometry )
{
- geometry = RendererFactoryCache::CreateQuadGeometry();
- mFactoryCache.SaveGeometry( RendererFactoryCache::QUAD_GEOMETRY, geometry );
+ geometry = VisualFactoryCache::CreateQuadGeometry();
+ mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry );
}
- Shader shader = mFactoryCache.GetShader( RendererFactoryCache::COLOR_SHADER );
+ Shader shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER );
if( !shader )
{
shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- mFactoryCache.SaveShader( RendererFactoryCache::COLOR_SHADER, shader );
+ mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER, shader );
}
mImpl->mRenderer = Renderer::New( geometry, shader );
}
}
-void ColorRenderer::SetColor(const Vector4& color)
+void ColorVisual::SetColor(const Vector4& color)
{
mMixColor = color;
-#ifndef __DALI_TOOLKIT_INTERNAL_COLOR_RENDERER_H__
-#define __DALI_TOOLKIT_INTERNAL_COLOR_RENDERER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*/
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
{
/**
- * The renderer which renders a solid color to the control's quad
+ * The visual which renders a solid color to the control's quad
*
* The following properties are required for create a ColorRender
*
* |-----------------|-------------|
* | mixColor | VECTOR4 |
*/
-class ColorRenderer: public ControlRenderer
+class ColorVisual: public Visual::Base
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- ColorRenderer( RendererFactoryCache& factoryCache );
+ ColorVisual( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- virtual ~ColorRenderer();
+ virtual ~ColorVisual();
-public: // from ControlRenderer
+public: // from Visual
/**
- * @copydoc ControlRenderer::SetSize
+ * @copydoc Visual::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc ControlRenderer::SetClipRect
+ * @copydoc Visual::SetClipRect
*/
virtual void SetClipRect( const Rect<int>& clipRect );
/**
- * @copydoc ControlRenderer::SetOffset
+ * @copydoc Visual::SetOffset
*/
virtual void SetOffset( const Vector2& offset );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc ControlRenderer::DoInitialize
+ * @copydoc Visual::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
private:
// Undefined
- ColorRenderer( const ColorRenderer& colorRenderer );
+ ColorVisual( const ColorVisual& colorRenderer );
// Undefined
- ColorRenderer& operator=( const ColorRenderer& colorRenderer );
+ ColorVisual& operator=( const ColorVisual& colorRenderer );
private:
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_COLOR_RENDERER_H__ */
+#endif /* DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H */
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
// CLASS HEADER
-#include "debug-renderer.h"
+#include "debug-visual.h"
-//INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace Dali
{
}
-DebugRenderer::DebugRenderer( RendererFactoryCache& factoryCache )
-: ControlRenderer( factoryCache )
+DebugVisual::DebugVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache )
{
}
-DebugRenderer::~DebugRenderer()
+DebugVisual::~DebugVisual()
{}
-void DebugRenderer::DoSetOnStage( Actor& actor )
+void DebugVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
}
-void DebugRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void DebugVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, DEBUG_RENDERER );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::DEBUG );
}
-void DebugRenderer::InitializeRenderer()
+void DebugVisual::InitializeRenderer()
{
mImpl->mRenderer = mFactoryCache.GetDebugRenderer();
if( !mImpl->mRenderer )
}
}
-Geometry DebugRenderer::CreateQuadWireframeGeometry()
+Geometry DebugVisual::CreateQuadWireframeGeometry()
{
const float halfWidth = 0.5f;
const float halfHeight = 0.5f;
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( quadVertices );
geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) );
- geometry.SetGeometryType( Geometry::LINES );
+ geometry.SetType( Geometry::LINES );
return geometry;
}
-#ifndef __DALI_TOOLKIT_INTERNAL_DEBUG_RENDERER_H__
-#define __DALI_TOOLKIT_INTERNAL_DEBUG_RENDERER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_DEBUG_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_DEBUG_VISUAL_H
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*/
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
{
/**
- * The renderer which renders a wireframe outline to the control's quad for debugging
+ * The visual which renders a wireframe outline to the control's quad for debugging
*
*/
-class DebugRenderer: public ControlRenderer
+class DebugVisual: public Visual::Base
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- DebugRenderer( RendererFactoryCache& factoryCache );
+ DebugVisual( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- virtual ~DebugRenderer();
+ virtual ~DebugVisual();
protected:
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
private:
// Undefined
- DebugRenderer( const DebugRenderer& debugRenderer );
+ DebugVisual( const DebugVisual& debugVisual);
// Undefined
- DebugRenderer& operator=( const DebugRenderer& debugRenderer );
+ DebugVisual& operator=( const DebugVisual& debugVisual );
};
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_DEBUG_RENDERER_H__ */
+#endif /* DALI_TOOLKIT_INTERNAL_DEBUG_VISUAL_H */
*/
// CLASS HEADER
-#include "gradient-renderer.h"
+#include "gradient-visual.h"
// EXTERNAL INCLUDES
#include <typeinfo>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/object/property-array.h>
-
-//INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/gradient/linear-gradient.h>
-#include <dali-toolkit/internal/controls/renderers/gradient/radial-gradient.h>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/gradient-visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/gradient/linear-gradient.h>
+#include <dali-toolkit/internal/visuals/gradient/radial-gradient.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace Dali
{
const char * const UNITS_NAME("units"); // Property::String "userSpaceOnUse | objectBoundingBox"
const char * const SPREAD_METHOD_NAME("spreadMethod"); // Property::String "pad | reflect | repeat"
-// string values
-const char * const UNIT_USER_SPACE("USER_SPACE");
-const char * const UNIT_BOUNDING_BOX("OBJECT_BOUNDING_BOX");
-const char * const SPREAD_PAD("PAD");
-const char * const SPREAD_REFLECT("REFLECT");
-const char * const SPREAD_REPEAT("REPEAT");
+DALI_ENUM_TO_STRING_TABLE_BEGIN( UNITS )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::GradientVisual::Units, OBJECT_BOUNDING_BOX )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::GradientVisual::Units, USER_SPACE )
+DALI_ENUM_TO_STRING_TABLE_END( UNITS )
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( SPREAD_METHOD )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::GradientVisual::SpreadMethod, PAD )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::GradientVisual::SpreadMethod, REFLECT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::GradientVisual::SpreadMethod, REPEAT )
+DALI_ENUM_TO_STRING_TABLE_END( SPREAD_METHOD )
// uniform names
const char * const UNIFORM_ALIGNMENT_MATRIX_NAME( "uAlignmentMatrix" );
const unsigned int DEFAULT_OFFSET_MINIMUM = 0.0f;
const unsigned int DEFAULT_OFFSET_MAXIMUM = 1.0f;
-RendererFactoryCache::ShaderType GetShaderType( GradientRenderer::Type type, Gradient::GradientUnits units)
+VisualFactoryCache::ShaderType GetShaderType( GradientVisual::Type type, Toolkit::GradientVisual::Units::Type units )
{
- if( type==GradientRenderer::LINEAR )
+ if( type == GradientVisual::LINEAR )
{
- if( units == Gradient::USER_SPACE_ON_USE )
+ if( units == Toolkit::GradientVisual::Units::USER_SPACE )
{
- return RendererFactoryCache::GRADIENT_SHADER_LINEAR_USER_SPACE;
+ return VisualFactoryCache::GRADIENT_SHADER_LINEAR_USER_SPACE;
}
- return RendererFactoryCache::GRADIENT_SHADER_LINEAR_BOUNDING_BOX;
+ return VisualFactoryCache::GRADIENT_SHADER_LINEAR_BOUNDING_BOX;
}
- else if( units == Gradient::USER_SPACE_ON_USE )
+ else if( units == Toolkit::GradientVisual::Units::USER_SPACE )
{
- return RendererFactoryCache::GRADIENT_SHADER_RADIAL_USER_SPACE;
+ return VisualFactoryCache::GRADIENT_SHADER_RADIAL_USER_SPACE;
}
- return RendererFactoryCache::GRADIENT_SHADER_RADIAL_BOUNDING_BOX;
+ return VisualFactoryCache::GRADIENT_SHADER_RADIAL_BOUNDING_BOX;
}
const char* VERTEX_SHADER[] =
{
-// vertex shader for gradient units as USER_SPACE_ON_USE
-DALI_COMPOSE_SHADER(
+// vertex shader for gradient units as OBJECT_BOUNDING_BOX
+ DALI_COMPOSE_SHADER(
attribute mediump vec2 aPosition;\n
uniform mediump mat4 uMvpMatrix;\n
uniform mediump vec3 uSize;\n
void main()\n
{\n
mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
+ vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
+ \n
vertexPosition.xyz *= uSize;\n
gl_Position = uMvpMatrix * vertexPosition;\n
- \n
- vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
}\n
),
-// vertex shader for gradient units as OBJECT_BOUNDING_BOX
- DALI_COMPOSE_SHADER(
+// vertex shader for gradient units as USER_SPACE
+DALI_COMPOSE_SHADER(
attribute mediump vec2 aPosition;\n
uniform mediump mat4 uMvpMatrix;\n
uniform mediump vec3 uSize;\n
void main()\n
{\n
mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
- vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
- \n
vertexPosition.xyz *= uSize;\n
gl_Position = uMvpMatrix * vertexPosition;\n
+ \n
+ vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
}\n
)
};
)
};
-Dali::WrapMode::Type GetWrapMode( Gradient::SpreadMethod spread )
+Dali::WrapMode::Type GetWrapMode( Toolkit::GradientVisual::SpreadMethod::Type spread )
{
switch(spread)
{
- case Gradient::REPEAT:
+ case Toolkit::GradientVisual::SpreadMethod::REPEAT:
{
return Dali::WrapMode::REPEAT;
}
- case Gradient::REFLECT:
+ case Toolkit::GradientVisual::SpreadMethod::REFLECT:
{
return Dali::WrapMode::MIRRORED_REPEAT;
}
- case Gradient::PAD:
+ case Toolkit::GradientVisual::SpreadMethod::PAD:
default:
{
return Dali::WrapMode::CLAMP_TO_EDGE;
}
}
-}
+} // unnamed namespace
-GradientRenderer::GradientRenderer( RendererFactoryCache& factoryCache )
-: ControlRenderer( factoryCache ),
+GradientVisual::GradientVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache ),
mGradientType( LINEAR )
{
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
}
-GradientRenderer::~GradientRenderer()
+GradientVisual::~GradientVisual()
{
}
-void GradientRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void GradientVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
- Gradient::GradientUnits gradientUnits = Gradient::OBJECT_BOUNDING_BOX;
- Property::Value* unitsValue = propertyMap.Find( UNITS_NAME );
- std::string units;
- // The default unit is OBJECT_BOUNDING_BOX.
- // Only need to set new units if 'USER_SPACE'
- if( unitsValue && unitsValue->Get( units ) && units == UNIT_USER_SPACE )
+ Toolkit::GradientVisual::Units::Type gradientUnits = Toolkit::GradientVisual::Units::OBJECT_BOUNDING_BOX;
+
+ Property::Value* unitsValue = propertyMap.Find( Toolkit::GradientVisual::Property::UNITS, UNITS_NAME );
+ if( unitsValue )
{
- gradientUnits = Gradient::USER_SPACE_ON_USE;
+ Scripting::GetEnumerationProperty( *unitsValue, UNITS_TABLE, UNITS_TABLE_COUNT, gradientUnits );
}
mGradientType = LINEAR;
- if( propertyMap.Find( RADIUS_NAME ))
+ if( propertyMap.Find( Toolkit::GradientVisual::Property::RADIUS, RADIUS_NAME ) )
{
mGradientType = RADIAL;
}
}
else
{
- DALI_LOG_ERROR( "Fail to provide valid properties to create a GradientRenderer object" );
+ DALI_LOG_ERROR( "Fail to provide valid properties to create a GradientVisual object" );
}
}
-void GradientRenderer::SetSize( const Vector2& size )
+void GradientVisual::SetSize( const Vector2& size )
{
- ControlRenderer::SetSize( size );
+ Visual::Base::SetSize( size );
}
-void GradientRenderer::SetClipRect( const Rect<int>& clipRect )
+void GradientVisual::SetClipRect( const Rect<int>& clipRect )
{
- ControlRenderer::SetClipRect( clipRect );
+ Visual::Base::SetClipRect( clipRect );
//ToDo: renderer responds to the clipRect change
}
-void GradientRenderer::SetOffset( const Vector2& offset )
+void GradientVisual::SetOffset( const Vector2& offset )
{
//ToDo: renderer applies the offset
}
-void GradientRenderer::DoSetOnStage( Actor& actor )
+void GradientVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
}
-void GradientRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void GradientVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, GRADIENT_RENDERER );
-
- Gradient::GradientUnits units = mGradient->GetGradientUnits();
- if( units == Gradient::USER_SPACE_ON_USE )
- {
- map.Insert( UNITS_NAME, UNIT_USER_SPACE );
- }
- else // if( units == Gradient::OBJECT_BOUNDING_BOX )
- {
- map.Insert( UNITS_NAME, UNIT_BOUNDING_BOX );
- }
-
- Gradient::SpreadMethod spread = mGradient->GetSpreadMethod();
- if( spread == Gradient::PAD )
- {
- map.Insert( SPREAD_METHOD_NAME, SPREAD_PAD );
- }
- else if( spread == Gradient::REFLECT )
- {
- map.Insert( SPREAD_METHOD_NAME, SPREAD_REFLECT );
- }
- else // if( units == Gradient::REPEAT )
- {
- map.Insert( SPREAD_METHOD_NAME, SPREAD_REPEAT );
- }
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::GRADIENT );
+ map.Insert( Toolkit::GradientVisual::Property::UNITS, mGradient->GetGradientUnits() );
+ map.Insert( Toolkit::GradientVisual::Property::SPREAD_METHOD, mGradient->GetSpreadMethod() );
const Vector<Gradient::GradientStop>& stops( mGradient->GetStops() );
Property::Array offsets;
}
}
- map.Insert( STOP_OFFSET_NAME, offsets );
- map.Insert( STOP_COLOR_NAME, colors );
+ map.Insert( Toolkit::GradientVisual::Property::STOP_OFFSET, offsets );
+ map.Insert( Toolkit::GradientVisual::Property::STOP_COLOR, colors );
if( &typeid( *mGradient ) == &typeid(LinearGradient) )
{
LinearGradient* gradient = static_cast<LinearGradient*>( mGradient.Get() );
- map.Insert( START_POSITION_NAME, gradient->GetStartPosition() );
- map.Insert( END_POSITION_NAME, gradient->GetEndPosition() );
+ map.Insert( Toolkit::GradientVisual::Property::START_POSITION, gradient->GetStartPosition() );
+ map.Insert( Toolkit::GradientVisual::Property::END_POSITION, gradient->GetEndPosition() );
}
else // if( &typeid( *mGradient ) == &typeid(RadialGradient) )
{
RadialGradient* gradient = static_cast<RadialGradient*>( mGradient.Get() );
- map.Insert( CENTER_NAME, gradient->GetCenter() );
- map.Insert( RADIUS_NAME, gradient->GetRadius() );
+ map.Insert( Toolkit::GradientVisual::Property::CENTER, gradient->GetCenter() );
+ map.Insert( Toolkit::GradientVisual::Property::RADIUS, gradient->GetRadius() );
}
}
-void GradientRenderer::InitializeRenderer()
+void GradientVisual::InitializeRenderer()
{
- Geometry geometry = mFactoryCache.GetGeometry( RendererFactoryCache::QUAD_GEOMETRY );
+ Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
if( !geometry )
{
- geometry = RendererFactoryCache::CreateQuadGeometry();
- mFactoryCache.SaveGeometry( RendererFactoryCache::QUAD_GEOMETRY, geometry );
+ geometry = VisualFactoryCache::CreateQuadGeometry();
+ mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry );
}
- Gradient::GradientUnits gradientUnits = mGradient->GetGradientUnits();
- RendererFactoryCache::ShaderType shaderType = GetShaderType( mGradientType, gradientUnits );
+ Toolkit::GradientVisual::Units::Type gradientUnits = mGradient->GetGradientUnits();
+ VisualFactoryCache::ShaderType shaderType = GetShaderType( mGradientType, gradientUnits );
Shader shader = mFactoryCache.GetShader( shaderType );
if( !shader )
{
mImpl->mRenderer.RegisterProperty( UNIFORM_ALIGNMENT_MATRIX_NAME, mGradientTransform );
}
-bool GradientRenderer::NewGradient(Type gradientType, const Property::Map& propertyMap)
+bool GradientVisual::NewGradient(Type gradientType, const Property::Map& propertyMap)
{
- if( gradientType==LINEAR )
+ if( gradientType == LINEAR )
{
- Property::Value* startPositionValue = propertyMap.Find( START_POSITION_NAME );
- Property::Value* endPositionValue = propertyMap.Find( END_POSITION_NAME );
+ Property::Value* startPositionValue = propertyMap.Find( Toolkit::GradientVisual::Property::START_POSITION, START_POSITION_NAME );
+ Property::Value* endPositionValue = propertyMap.Find( Toolkit::GradientVisual::Property::END_POSITION, END_POSITION_NAME );
Vector2 startPosition;
Vector2 endPosition;
}
else // type==RADIAL
{
- Property::Value* centerValue = propertyMap.Find( CENTER_NAME );
- Property::Value* radiusValue = propertyMap.Find( RADIUS_NAME );
+ Property::Value* centerValue = propertyMap.Find( Toolkit::GradientVisual::Property::CENTER, CENTER_NAME );
+ Property::Value* radiusValue = propertyMap.Find( Toolkit::GradientVisual::Property::RADIUS, RADIUS_NAME );
Vector2 center;
float radius;
if( centerValue && centerValue->Get(center)
}
unsigned int numValidStop = 0u;
- Property::Value* stopOffsetValue = propertyMap.Find( STOP_OFFSET_NAME );
- Property::Value* stopColorValue = propertyMap.Find( STOP_COLOR_NAME );
+ Property::Value* stopOffsetValue = propertyMap.Find( Toolkit::GradientVisual::Property::STOP_OFFSET, STOP_OFFSET_NAME );
+ Property::Value* stopColorValue = propertyMap.Find( Toolkit::GradientVisual::Property::STOP_COLOR, STOP_COLOR_NAME );
if( stopColorValue )
{
Vector<float> offsetArray;
return false;
}
- Property::Value* spread = propertyMap.Find( SPREAD_METHOD_NAME );
- std::string stringValue ;
- // The default spread method is PAD.
- // Only need to set new spread if 'reflect' or 'repeat"
- if( spread && spread->Get( stringValue ))
+ Property::Value* spread = propertyMap.Find( Toolkit::GradientVisual::Property::SPREAD_METHOD, SPREAD_METHOD_NAME );
+ // The default spread method is PAD. Only need to set new spread if it's anything else.
+ if( spread )
{
- if( stringValue == SPREAD_REFLECT )
- {
- mGradient->SetSpreadMethod( Gradient::REFLECT );
- }
- else if( stringValue == SPREAD_REPEAT )
+ Toolkit::GradientVisual::SpreadMethod::Type spreadMethod = Toolkit::GradientVisual::SpreadMethod::PAD;
+ if( Scripting::GetEnumerationProperty( *spread, SPREAD_METHOD_TABLE, SPREAD_METHOD_TABLE_COUNT, spreadMethod ) );
{
- mGradient->SetSpreadMethod( Gradient::REPEAT );
+ mGradient->SetSpreadMethod( spreadMethod );
}
}
return true;
}
-void GradientRenderer::GetStopOffsets(const Property::Value* value, Vector<float>& stopOffsets)
+void GradientVisual::GetStopOffsets(const Property::Value* value, Vector<float>& stopOffsets)
{
if ( value ) // Only check valve type if a valid Property has been passed in
-#ifndef __DALI_TOOLKIT_INTERNAL_GRADIENT_RENDERER_H__
-#define __DALI_TOOLKIT_INTERNAL_GRADIENT_RENDERER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_GRADIENT_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_GRADIENT_VISUAL_H
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*/
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
-#include <dali-toolkit/internal/controls/renderers/gradient/gradient.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/internal/visuals/gradient/gradient.h>
namespace Dali
{
class Gradient;
/**
- * The renderer which renders smooth transition of colors to the control's quad.
+ * The visual which renders smooth transition of colors to the control's quad.
* It supports two types of gradients: linear and radial.
*
* The following properties are essential for create a LINEAR GradientRender
* Valid values for spreadMethod are 'pad', 'repeat' and 'reflect.'
* If not provided, 'objectBoundingBox' is used as default gradient units, and 'pad' is used as default spread method.
*/
-class GradientRenderer: public ControlRenderer
+class GradientVisual: public Visual::Base
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- GradientRenderer( RendererFactoryCache& factoryCache );
+ GradientVisual( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- ~GradientRenderer();
+ ~GradientVisual();
-public: // from ControlRenderer
+public: // from Visual
/**
- * @copydoc ControlRenderer::SetSize
+ * @copydoc Visual::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc ControlRenderer::SetClipRect
+ * @copydoc Visual::SetClipRect
*/
virtual void SetClipRect( const Rect<int>& clipRect );
/**
- * @copydoc ControlRenderer::SetOffset
+ * @copydoc Visual::SetOffset
*/
virtual void SetOffset( const Vector2& offset );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc ControlRenderer::DoInitialize
+ * @copydoc Visual::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
static void GetStopOffsets(const Property::Value* value, Vector<float>& stopOffsets);
// Undefined
- GradientRenderer( const GradientRenderer& gradientRenderer );
+ GradientVisual( const GradientVisual& gradientVisual );
// Undefined
- GradientRenderer& operator=( const GradientRenderer& gradientRenderer );
+ GradientVisual& operator=( const GradientVisual& gradientVisual );
private:
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_GRADIENT_RENDERER_H__ */
+#endif /* DALI_TOOLKIT_INTERNAL_GRADIENT_VISUAL_H */
{
Gradient::Gradient()
-: mGradientUnits( OBJECT_BOUNDING_BOX ),
- mSpreadMethod( PAD )
+: mGradientUnits( Toolkit::GradientVisual::Units::OBJECT_BOUNDING_BOX ),
+ mSpreadMethod( Toolkit::GradientVisual::SpreadMethod::PAD )
{}
Gradient::~Gradient()
return mGradientStops;
}
-void Gradient::SetGradientUnits( GradientUnits gradientUnits )
+void Gradient::SetGradientUnits( Toolkit::GradientVisual::Units::Type gradientUnits )
{
mGradientUnits = gradientUnits;
}
-Gradient::GradientUnits Gradient::GetGradientUnits() const
+Toolkit::GradientVisual::Units::Type Gradient::GetGradientUnits() const
{
return mGradientUnits;
}
-void Gradient::SetSpreadMethod( SpreadMethod spread )
+void Gradient::SetSpreadMethod( Toolkit::GradientVisual::SpreadMethod::Type spread )
{
mSpreadMethod = spread;
}
-Gradient::SpreadMethod Gradient::GetSpreadMethod() const
+Toolkit::GradientVisual::SpreadMethod::Type Gradient::GetSpreadMethod() const
{
return mSpreadMethod;
}
{
tempFirstStop = true;
Vector4 firstStopColor( mGradientStops[0].mStopColor ); // If spread method is PAD or REFLECT
- if( mSpreadMethod == REPEAT )
+ if( mSpreadMethod == Toolkit::GradientVisual::SpreadMethod::REPEAT )
{
firstStopColor = ( mGradientStops[0].mStopColor * (1.f-mGradientStops[numStops-1].mOffset)
+ mGradientStops[numStops-1].mStopColor * mGradientStops[0].mOffset )
{
tempLastStop = true;
Vector4 lastStopColor( mGradientStops[numStops-1].mStopColor ); // If spread method is PAD or REFLECT
- if( mSpreadMethod == REPEAT )
+ if( mSpreadMethod == Toolkit::GradientVisual::SpreadMethod::REPEAT )
{
lastStopColor = mGradientStops[0].mStopColor;
}
*
*/
-//EXTERNAL INCLUDES
+// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/math/matrix3.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/rendering/texture.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/gradient-visual-properties.h>
+
namespace Dali
{
class Gradient : public RefObject
{
public:
- /**
- * Defines the coordinate system of the attributes
- * (start and end position for linear gradient, circle center and radius for radial gradient)
- */
- enum GradientUnits
- {
- USER_SPACE_ON_USE,
- OBJECT_BOUNDING_BOX
- };
-
- /**
- * Indicates what happens if the gradient starts or ends inside the bounds of the object being painted by the gradient.
- */
- enum SpreadMethod
- {
- PAD, // use the terminal colors of the gradient to fill the remainder of the target region
- REPEAT, // reflect the gradient pattern start-to-end, end-to-start, start-to-end, etc. continuously until the target rectangle is filled
- REFLECT // repeat the gradient pattern start-to-end, start-to-end, start-to-end, etc. continuously until the target region is filled
- };
/**
* The stop node tells the gradient what color it should be at certain position.
* Set the coordinate system used by the gradient attributes.
* @param[in] gradientUnits The the attributes are defined using the current user coordinate system or the bounding box of the shape.
*/
- void SetGradientUnits( GradientUnits gradientUnits );
+ void SetGradientUnits( Toolkit::GradientVisual::Units::Type gradientUnits );
/**
* Get the coordinate system used by the gradient attributes.
* @return USER_SPACE_ON_USE or OBJECT_BOUNDING_BOX
*/
- GradientUnits GetGradientUnits() const;
+ Toolkit::GradientVisual::Units::Type GetGradientUnits() const;
/**
* Indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.
*
* @param[in] spread The method to fill the remainder of target region which is outside the gradient bounds
*/
- void SetSpreadMethod( SpreadMethod spread );
+ void SetSpreadMethod( Toolkit::GradientVisual::SpreadMethod::Type spread );
/**
* Get the filling method for the the remainder of target region which is outside the gradient boun.
* @return PAD, REFLECT or REPEAT
*/
- SpreadMethod GetSpreadMethod() const;
+ Toolkit::GradientVisual::SpreadMethod::Type GetSpreadMethod() const;
/**
* Get the transformation matrix to align the vertices with the gradient line/circle
protected:
- Vector<GradientStop> mGradientStops;
- Matrix3 mAlignmentTransform;
- GradientUnits mGradientUnits;
- SpreadMethod mSpreadMethod;
+ Vector<GradientStop> mGradientStops;
+ Matrix3 mAlignmentTransform;
+ Toolkit::GradientVisual::Units::Type mGradientUnits;
+ Toolkit::GradientVisual::SpreadMethod::Type mSpreadMethod;
};
-#ifndef __DALI_TOOLKIT_INTERNAL_LINEAR_GRADIENT_H__
-#define __DALI_TOOLKIT_INTERNAL_LINEAR_GRADIENT_H__
+#ifndef DALI_TOOLKIT_INTERNAL_LINEAR_GRADIENT_H
+#define DALI_TOOLKIT_INTERNAL_LINEAR_GRADIENT_H
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
*/
-#include <dali-toolkit/internal/controls/renderers/gradient/gradient.h>
+#include <dali-toolkit/internal/visuals/gradient/gradient.h>
#include <dali/public-api/math/vector2.h>
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_LINEAR_GRADIENT_H__ */
+#endif /* DALI_TOOLKIT_INTERNAL_LINEAR_GRADIENT_H */
-#ifndef __DALI_TOOLKIT_INTERNAL_RADIAL_GRADIENT_H__
-#define __DALI_TOOLKIT_INTERNAL_RADIAL_GRADIENT_H__
+#ifndef DALI_TOOLKIT_INTERNAL_RADIAL_GRADIENT_H
+#define DALI_TOOLKIT_INTERNAL_RADIAL_GRADIENT_H
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
*/
-#include <dali-toolkit/internal/controls/renderers/gradient/gradient.h>
+#include <dali-toolkit/internal/visuals/gradient/gradient.h>
#include <dali/public-api/math/vector2.h>
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_RADIAL_GRADIENT_H__ */
+#endif /* DALI_TOOLKIT_INTERNAL_RADIAL_GRADIENT_H */
{
/**
- * The manager for automatic image atlasing. Owned by RendererFactory
+ * The manager for automatic image atlasing. Owned by VisualFactory
*/
class ImageAtlasManager : public RefObject
{
*/
// CLASS HEADER
-#include "image-renderer.h"
+#include "image-visual.h"
// EXTERNAL HEADER
#include <cstring> // for strncasecmp
#include <dali/devel-api/images/atlas.h>
#include <dali/devel-api/images/texture-set-image.h>
#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
// INTERNAL HEADER
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
-#include <dali-toolkit/internal/controls/renderers/image-atlas-manager.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace Dali
{
const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
// fitting modes
-const char * const SHRINK_TO_FIT("SHRINK_TO_FIT");
-const char * const SCALE_TO_FILL("SCALE_TO_FILL");
-const char * const FIT_WIDTH("FIT_WIDTH");
-const char * const FIT_HEIGHT("FIT_HEIGHT");
-const char * const DEFAULT("DEFAULT");
+DALI_ENUM_TO_STRING_TABLE_BEGIN( FITTING_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::FittingMode, SHRINK_TO_FIT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::FittingMode, SCALE_TO_FILL )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::FittingMode, FIT_WIDTH )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::FittingMode, FIT_HEIGHT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::FittingMode, DEFAULT )
+DALI_ENUM_TO_STRING_TABLE_END( FITTING_MODE )
// sampling modes
-const char * const BOX("BOX");
-const char * const NEAREST("NEAREST");
-const char * const LINEAR("LINEAR");
-const char * const BOX_THEN_NEAREST("BOX_THEN_NEAREST");
-const char * const BOX_THEN_LINEAR("BOX_THEN_LINEAR");
-const char * const NO_FILTER("NO_FILTER");
-const char * const DONT_CARE("DONT_CARE");
+DALI_ENUM_TO_STRING_TABLE_BEGIN( SAMPLING_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::SamplingMode, BOX )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::SamplingMode, NEAREST )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::SamplingMode, LINEAR )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::SamplingMode, BOX_THEN_NEAREST )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::SamplingMode, BOX_THEN_LINEAR )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::SamplingMode, NO_FILTER )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::SamplingMode, DONT_CARE )
+DALI_ENUM_TO_STRING_TABLE_END( SAMPLING_MODE )
const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
}\n
);
-Geometry CreateGeometry( RendererFactoryCache& factoryCache, ImageDimensions gridSize )
+Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridSize )
{
Geometry geometry;
if( gridSize == ImageDimensions( 1, 1 ) )
{
- geometry = factoryCache.GetGeometry( RendererFactoryCache::QUAD_GEOMETRY );
+ geometry = factoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
if( !geometry )
{
- geometry = RendererFactoryCache::CreateQuadGeometry();
- factoryCache.SaveGeometry( RendererFactoryCache::QUAD_GEOMETRY, geometry );
+ geometry = VisualFactoryCache::CreateQuadGeometry();
+ factoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry );
}
}
else
{
- geometry = RendererFactoryCache::CreateGridGeometry( gridSize );
+ geometry = VisualFactoryCache::CreateGridGeometry( gridSize );
}
return geometry;
} //unnamed namespace
-ImageRenderer::ImageRenderer( RendererFactoryCache& factoryCache, ImageAtlasManager& atlasManager )
-: ControlRenderer( factoryCache ),
+ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, ImageAtlasManager& atlasManager )
+: Visual::Base( factoryCache ),
mAtlasManager( atlasManager ),
mDesiredSize(),
mFittingMode( FittingMode::DEFAULT ),
{
}
-ImageRenderer::~ImageRenderer()
+ImageVisual::~ImageVisual()
{
}
-void ImageRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void ImageVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
std::string oldImageUrl = mImageUrl;
- Property::Value* imageURLValue = propertyMap.Find( IMAGE_URL_NAME );
+ Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
if( imageURLValue )
{
imageURLValue->Get( mImageUrl );
mImage.Reset();
}
- Property::Value* fittingValue = propertyMap.Find( IMAGE_FITTING_MODE );
+ Property::Value* fittingValue = propertyMap.Find( Toolkit::ImageVisual::Property::FITTING_MODE, IMAGE_FITTING_MODE );
if( fittingValue )
{
- std::string fitting;
- fittingValue->Get( fitting );
-
- mFittingMode = FittingMode::DEFAULT;
- if( fitting == SHRINK_TO_FIT )
- {
- mFittingMode = FittingMode::SHRINK_TO_FIT;
- }
- else if( fitting == SCALE_TO_FILL )
- {
- mFittingMode = FittingMode::SCALE_TO_FILL;
- }
- else if( fitting == FIT_WIDTH )
- {
- mFittingMode = FittingMode::FIT_WIDTH;
- }
- else if( fitting == FIT_HEIGHT )
- {
- mFittingMode = FittingMode::FIT_HEIGHT;
- }
- else if( fitting == DEFAULT )
- {
- mFittingMode = FittingMode::DEFAULT;
- }
- else
- {
- DALI_ASSERT_ALWAYS("Unknown fitting mode");
- }
+ Scripting::GetEnumerationProperty( *fittingValue, FITTING_MODE_TABLE, FITTING_MODE_TABLE_COUNT, mFittingMode );
}
- Property::Value* samplingValue = propertyMap.Find( IMAGE_SAMPLING_MODE );
+ Property::Value* samplingValue = propertyMap.Find( Toolkit::ImageVisual::Property::SAMPLING_MODE, IMAGE_SAMPLING_MODE );
if( samplingValue )
{
- std::string sampling;
- samplingValue->Get( sampling );
-
- mSamplingMode = SamplingMode::DEFAULT;
- if( sampling == BOX )
- {
- mSamplingMode = SamplingMode::BOX;
- }
- else if( sampling == NEAREST )
- {
- mSamplingMode = SamplingMode::NEAREST;
- }
- else if( sampling == LINEAR )
- {
- mSamplingMode = SamplingMode::LINEAR;
- }
- else if( sampling == BOX_THEN_NEAREST )
- {
- mSamplingMode = SamplingMode::BOX_THEN_NEAREST;
- }
- else if( sampling == BOX_THEN_LINEAR )
- {
- mSamplingMode = SamplingMode::BOX_THEN_LINEAR;
- }
- else if( sampling == NO_FILTER )
- {
- mSamplingMode = SamplingMode::NO_FILTER;
- }
- else if( sampling == DONT_CARE )
- {
- mSamplingMode = SamplingMode::DONT_CARE;
- }
- else if( sampling == DEFAULT )
- {
- mSamplingMode = SamplingMode::DEFAULT;
- }
- else
- {
- DALI_ASSERT_ALWAYS("Unknown sampling mode");
- }
+ Scripting::GetEnumerationProperty( *samplingValue, SAMPLING_MODE_TABLE, SAMPLING_MODE_TABLE_COUNT, mSamplingMode );
}
int desiredWidth = 0;
- Property::Value* desiredWidthValue = propertyMap.Find( IMAGE_DESIRED_WIDTH );
+ Property::Value* desiredWidthValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_WIDTH, IMAGE_DESIRED_WIDTH );
if( desiredWidthValue )
{
desiredWidthValue->Get( desiredWidth );
}
int desiredHeight = 0;
- Property::Value* desiredHeightValue = propertyMap.Find( IMAGE_DESIRED_HEIGHT );
+ Property::Value* desiredHeightValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, IMAGE_DESIRED_HEIGHT );
if( desiredHeightValue )
{
desiredHeightValue->Get( desiredHeight );
}
mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
-
}
- Property::Value* syncLoading = propertyMap.Find( SYNCHRONOUS_LOADING );
+ Property::Value* syncLoading = propertyMap.Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, SYNCHRONOUS_LOADING );
if( syncLoading )
{
bool sync;
}
}
-void ImageRenderer::SetSize( const Vector2& size )
+void ImageVisual::SetSize( const Vector2& size )
{
- ControlRenderer::SetSize( size );
+ Visual::Base::SetSize( size );
}
-void ImageRenderer::GetNaturalSize( Vector2& naturalSize ) const
+void ImageVisual::GetNaturalSize( Vector2& naturalSize ) const
{
if(mImage)
{
naturalSize = Vector2::ZERO;
}
-void ImageRenderer::SetClipRect( const Rect<int>& clipRect )
+void ImageVisual::SetClipRect( const Rect<int>& clipRect )
{
- ControlRenderer::SetClipRect( clipRect );
+ Visual::Base::SetClipRect( clipRect );
}
-void ImageRenderer::SetOffset( const Vector2& offset )
+void ImageVisual::SetOffset( const Vector2& offset )
{
}
-Renderer ImageRenderer::CreateRenderer() const
+Renderer ImageVisual::CreateRenderer() const
{
Geometry geometry;
Shader shader;
return renderer;
}
-Renderer ImageRenderer::CreateNativeImageRenderer() const
+Renderer ImageVisual::CreateNativeImageRenderer() const
{
Geometry geometry;
Shader shader;
}
-bool ImageRenderer::IsSynchronousResourceLoading() const
+bool ImageVisual::IsSynchronousResourceLoading() const
{
return mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
}
-void ImageRenderer::DoSynchronousResourceLoading()
+void ImageVisual::DoSynchronousResourceLoading()
{
if( !mImageUrl.empty() )
{
}
}
-Image ImageRenderer::LoadImage( const std::string& url, bool synchronousLoading )
+Image ImageVisual::LoadImage( const std::string& url, bool synchronousLoading )
{
if( synchronousLoading )
{
if( !mPixels )
{
// use broken image
- return RendererFactory::GetBrokenRendererImage();
+ return VisualFactory::GetBrokenVisualImage();
}
Atlas image = Atlas::New( mPixels.GetWidth(), mPixels.GetHeight(), mPixels.GetPixelFormat() );
image.Upload( mPixels, 0, 0 );
else
{
ResourceImage resourceImage = Dali::ResourceImage::New( url, mDesiredSize, mFittingMode, mSamplingMode );
- resourceImage.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
+ resourceImage.LoadingFinishedSignal().Connect( this, &ImageVisual::OnImageLoaded );
return resourceImage;
}
}
-TextureSet ImageRenderer::CreateTextureSet( Vector4& textureRect, const std::string& url, bool synchronousLoading )
+TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, const std::string& url, bool synchronousLoading )
{
TextureSet textureSet;
textureRect = FULL_TEXTURE_RECT;
{
// use broken image
textureSet = TextureSet::New();
- TextureSetImage( textureSet, 0u, RendererFactory::GetBrokenRendererImage() );
+ TextureSetImage( textureSet, 0u, VisualFactory::GetBrokenVisualImage() );
}
else
{
if( !textureSet ) // big image, no atlasing
{
ResourceImage resourceImage = Dali::ResourceImage::New( url, mDesiredSize, mFittingMode, mSamplingMode );
- resourceImage.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
+ resourceImage.LoadingFinishedSignal().Connect( this, &ImageVisual::OnImageLoaded );
textureSet = TextureSet::New();
TextureSetImage( textureSet, 0u, resourceImage );
}
return textureSet;
}
-void ImageRenderer::InitializeRenderer( const std::string& imageUrl )
+void ImageVisual::InitializeRenderer( const std::string& imageUrl )
{
if( imageUrl.empty() )
{
}
}
-void ImageRenderer::InitializeRenderer( const Image& image )
+void ImageVisual::InitializeRenderer( const Image& image )
{
mImpl->mFlags &= ~Impl::IS_FROM_CACHE;
}
-void ImageRenderer::DoSetOnStage( Actor& actor )
+void ImageVisual::DoSetOnStage( Actor& actor )
{
if( !mImageUrl.empty() )
{
}
-void ImageRenderer::DoSetOffStage( Actor& actor )
+void ImageVisual::DoSetOffStage( Actor& actor )
{
//If we own the image then make sure we release it when we go off stage
if( !mImageUrl.empty() )
}
}
-void ImageRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, IMAGE_RENDERER );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
bool sync = IsSynchronousResourceLoading();
map.Insert( SYNCHRONOUS_LOADING, sync );
if( !mImageUrl.empty() )
{
- map.Insert( IMAGE_URL_NAME, mImageUrl );
- map.Insert( IMAGE_DESIRED_WIDTH, mDesiredSize.GetWidth() );
- map.Insert( IMAGE_DESIRED_HEIGHT, mDesiredSize.GetHeight() );
+ map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
+ map.Insert( Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth() );
+ map.Insert( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight() );
}
else if( mImage )
{
- map.Insert( IMAGE_DESIRED_WIDTH, static_cast<int>(mImage.GetWidth()) );
- map.Insert( IMAGE_DESIRED_HEIGHT, static_cast<int>(mImage.GetHeight()) );
+ map.Insert( Toolkit::ImageVisual::Property::DESIRED_WIDTH, static_cast<int>(mImage.GetWidth()) );
+ map.Insert( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, static_cast<int>(mImage.GetHeight()) );
ResourceImage resourceImage = ResourceImage::DownCast(mImage);
if( resourceImage )
{
- map.Insert( IMAGE_URL_NAME, resourceImage.GetUrl() );
- }
- }
-
- switch( mFittingMode )
- {
- case Dali::FittingMode::FIT_HEIGHT:
- {
- map.Insert( IMAGE_FITTING_MODE, FIT_HEIGHT );
- break;
- }
- case Dali::FittingMode::FIT_WIDTH:
- {
- map.Insert( IMAGE_FITTING_MODE, FIT_WIDTH );
- break;
- }
- case Dali::FittingMode::SCALE_TO_FILL:
- {
- map.Insert( IMAGE_FITTING_MODE, SCALE_TO_FILL );
- break;
- }
- case Dali::FittingMode::SHRINK_TO_FIT:
- {
- map.Insert( IMAGE_FITTING_MODE, SHRINK_TO_FIT );
- break;
- }
- default:
- {
- map.Insert( IMAGE_FITTING_MODE, DEFAULT );
- break;
+ map.Insert( Toolkit::ImageVisual::Property::URL, resourceImage.GetUrl() );
}
}
- switch( mSamplingMode )
- {
- case Dali::SamplingMode::BOX:
- {
- map.Insert( IMAGE_SAMPLING_MODE, BOX );
- break;
- }
- case Dali::SamplingMode::NEAREST:
- {
- map.Insert( IMAGE_SAMPLING_MODE, NEAREST );
- break;
- }
- case Dali::SamplingMode::LINEAR:
- {
- map.Insert( IMAGE_SAMPLING_MODE, LINEAR );
- break;
- }
- case Dali::SamplingMode::BOX_THEN_LINEAR:
- {
- map.Insert( IMAGE_SAMPLING_MODE, BOX_THEN_LINEAR );
- break;
- }
- case Dali::SamplingMode::BOX_THEN_NEAREST:
- {
- map.Insert( IMAGE_SAMPLING_MODE, BOX_THEN_NEAREST );
- break;
- }
- case Dali::SamplingMode::NO_FILTER:
- {
- map.Insert( IMAGE_SAMPLING_MODE, NO_FILTER );
- break;
- }
- case Dali::SamplingMode::DONT_CARE:
- {
- map.Insert( IMAGE_SAMPLING_MODE, DONT_CARE );
- break;
- }
- default:
- {
- map.Insert( IMAGE_SAMPLING_MODE, DEFAULT );
- break;
- }
- }
+ map.Insert( Toolkit::ImageVisual::Property::FITTING_MODE, mFittingMode );
+ map.Insert( Toolkit::ImageVisual::Property::SAMPLING_MODE, mSamplingMode );
}
-Shader ImageRenderer::GetImageShader( RendererFactoryCache& factoryCache )
+Shader ImageVisual::GetImageShader( VisualFactoryCache& factoryCache )
{
- Shader shader = factoryCache.GetShader( RendererFactoryCache::IMAGE_SHADER );
+ Shader shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER );
if( !shader )
{
shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- factoryCache.SaveShader( RendererFactoryCache::IMAGE_SHADER, shader );
+ factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER, shader );
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
}
return shader;
}
-void ImageRenderer::SetImage( Actor& actor, const std::string& imageUrl, ImageDimensions size, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode )
+void ImageVisual::SetImage( Actor& actor, const std::string& imageUrl, ImageDimensions size, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode )
{
if( mImageUrl != imageUrl )
{
}
}
-void ImageRenderer::SetImage( Actor& actor, const Image& image )
+void ImageVisual::SetImage( Actor& actor, const Image& image )
{
if( mImage != image )
{
}
}
-void ImageRenderer::ApplyImageToSampler( const Image& image )
+void ImageVisual::ApplyImageToSampler( const Image& image )
{
if( image )
{
}
}
-void ImageRenderer::OnImageLoaded( ResourceImage image )
+void ImageVisual::OnImageLoaded( ResourceImage image )
{
if( image.GetLoadingState() == Dali::ResourceLoadingFailed )
{
- Image brokenImage = RendererFactory::GetBrokenRendererImage();
+ Image brokenImage = VisualFactory::GetBrokenVisualImage();
if( mImpl->mRenderer )
{
ApplyImageToSampler( brokenImage );
}
}
-void ImageRenderer::CleanCache(const std::string& url)
+void ImageVisual::CleanCache(const std::string& url)
{
TextureSet textureSet = mImpl->mRenderer.GetTextures();
}
}
-void ImageRenderer::SetNativeFragmentShaderCode( Dali::NativeImage& nativeImage )
+void ImageVisual::SetNativeFragmentShaderCode( Dali::NativeImage& nativeImage )
{
const char* fragmentPreFix = nativeImage.GetCustomFragmentPreFix();
const char* customSamplerTypename = nativeImage.GetCustomSamplerTypename();
-#ifndef __DALI_TOOLKIT_INTERNAL_IMAGE_RENDERER_H__
-#define __DALI_TOOLKIT_INTERNAL_IMAGE_RENDERER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_IMAGE_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_IMAGE_VISUAL_H
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*/
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
-#include <dali-toolkit/internal/controls/renderers/image-atlas-manager.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
// EXTERNAL INCLUDES
#include <dali/public-api/images/image.h>
namespace Internal
{
-class ImageRenderer;
-typedef IntrusivePtr< ImageRenderer > ImageRendererPtr;
+class ImageVisual;
+typedef IntrusivePtr< ImageVisual > ImageVisualPtr;
/**
- * The renderer which renders an image to the control's quad
+ * The visual which renders an image to the control's quad
*
* The following properties are optional
*
* "DEFAULT"
*
*/
-class ImageRenderer: public ControlRenderer, public ConnectionTracker
+class ImageVisual: public Visual::Base, public ConnectionTracker
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache The RendererFactoryCache object
+ * @param[in] factoryCache The VisualFactoryCache object
* @param[in] atlasManager The atlasManager object
*/
- ImageRenderer( RendererFactoryCache& factoryCache, ImageAtlasManager& atlasManager );
+ ImageVisual( VisualFactoryCache& factoryCache, ImageAtlasManager& atlasManager );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- ~ImageRenderer();
+ ~ImageVisual();
-public: // from ControlRenderer
+public: // from Visual
/**
- * @copydoc ControlRenderer::SetSize
+ * @copydoc Visual::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc ControlRenderer::GetNaturalSize
+ * @copydoc Visual::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @copydoc ControlRenderer::SetClipRect
+ * @copydoc Visual::SetClipRect
*/
virtual void SetClipRect( const Rect<int>& clipRect );
/**
- * @copydoc ControlRenderer::SetOffset
+ * @copydoc Visual::SetOffset
*/
virtual void SetOffset( const Vector2& offset );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc ControlRenderer::DoInitialize
+ * @copydoc Visual::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc ControlRenderer::DoSetOffStage
+ * @copydoc Visual::DoSetOffStage
*/
virtual void DoSetOffStage( Actor& actor );
/**
* Get the standard image rendering shader.
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- static Shader GetImageShader( RendererFactoryCache& factoryCache );
+ static Shader GetImageShader( VisualFactoryCache& factoryCache );
/**
- * @brief Sets the image of this renderer to the resource at imageUrl
- * The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
+ * @brief Sets the image of this visual to the resource at imageUrl
+ * The visual will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
*
* @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] imageUrl The URL of the image resource to use
Dali::SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR );
/**
- * @brief Sets the image of this renderer to use
+ * @brief Sets the image to be rendered by this visual
*
* @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] image The image to use
/**
* @brief Initializes the Dali::Renderer from an image url string
*
- * @param[in] imageUrl The image url string to intialize this ImageRenderer from
+ * @param[in] imageUrl The image url string to intialize this ImageVisual from
*/
void InitializeRenderer( const std::string& imageUrl );
/**
* @brief Initializes the Dali::Renderer from an image handle
*
- * @param[in] image The image handle to intialize this ImageRenderer from
+ * @param[in] image The image handle to intialize this ImageVisual from
*/
void InitializeRenderer( const Image& image );
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_IMAGE_RENDERER_H__ */
+#endif /* DALI_TOOLKIT_INTERNAL_IMAGE_VISUAL_H */
*/
// CLASS HEADER
-#include "mesh-renderer.h"
+#include "mesh-visual.h"
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/common/stage.h>
#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
#include <dali/devel-api/adaptor-framework/file-loader.h>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
#include <fstream>
//INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace Dali
{
GLOSS_INDEX = 2u
};
-const char * const LIGHT_POSITION( "uLightPosition" ); //Shader property
-const char * const OBJECT_MATRIX( "uObjectMatrix" ); //Shader property
-
-const char * const SHADER_TYPE_TEXTURELESS( "TEXTURELESS" );
-const char * const SHADER_TYPE_DIFFUSE_TEXTURE( "DIFFUSE_TEXTURE" );
-const char * const SHADER_TYPE_ALL_TEXTURES( "ALL_TEXTURES" );
+//Property names
+const char * const OBJECT_URL_NAME( "objectUrl" );
+const char * const MATERIAL_URL_NAME( "materialUrl" );
+const char * const TEXTURES_PATH_NAME( "texturesPath" );
+const char * const SHADING_MODE_NAME( "shadingMode" );
+const char * const USE_MIPMAPPING_NAME( "useMipmapping" );
+const char * const USE_SOFT_NORMALS_NAME( "useSoftNormals" );
+const char * const LIGHT_POSITION_NAME( "lightPosition" );
+
+//Shading mode
+DALI_ENUM_TO_STRING_TABLE_BEGIN( SHADING_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::MeshVisual::ShadingMode, TEXTURELESS_WITH_DIFFUSE_LIGHTING )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::MeshVisual::ShadingMode, TEXTURED_WITH_SPECULAR_LIGHTING )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::MeshVisual::ShadingMode, TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING )
+DALI_ENUM_TO_STRING_TABLE_END( SHADING_MODE )
+
+//Shader properties
+const char * const OBJECT_MATRIX_UNIFORM_NAME( "uObjectMatrix" );
+const char * const STAGE_OFFSET_UNIFORM_NAME( "uStageOffset" );
//Shaders
//If a shader requires certain textures, they must be listed in order,
uniform mediump vec3 uSize;\n
uniform mediump mat4 uMvpMatrix;\n
uniform mediump mat4 uModelView;\n
+ uniform mediump mat4 uViewMatrix;\n
uniform mediump mat3 uNormalMatrix;
uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 uLightPosition;\n
+ uniform mediump vec3 lightPosition;\n
+ uniform mediump vec2 uStageOffset;\n
void main()\n
{\n
- vec4 vertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
- vertexPosition = uObjectMatrix * vertexPosition;\n
+ vec4 normalisedVertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
+ vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
vertexPosition = uMvpMatrix * vertexPosition;\n
//Illumination in Model-View space - Transform attributes and uniforms\n
- vec4 vertPos = uModelView * vec4( aPosition.xyz, 1.0 );\n
+ vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;\n
- vec4 center = uModelView * vec4( 0.0, 0.0, 0.0, 1.0 );\n
- vec4 lightPos = vec4( center.x, center.y, uLightPosition.z, 1.0 );\n
- vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
- float lightDiffuse = max( dot( vecToLight, normal ), 0.0 );\n
+ vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
+ mvLightPosition = uViewMatrix * mvLightPosition;\n
+ vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
+
+ float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );\n
vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
gl_Position = vertexPosition;\n
uniform mediump vec3 uSize;\n
uniform mediump mat4 uMvpMatrix;\n
uniform mediump mat4 uModelView;
+ uniform mediump mat4 uViewMatrix;\n
uniform mediump mat3 uNormalMatrix;
uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 uLightPosition;\n
+ uniform mediump vec3 lightPosition;\n
+ uniform mediump vec2 uStageOffset;\n
void main()
{\n
- vec4 vertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
- vertexPosition = uObjectMatrix * vertexPosition;\n
+ vec4 normalisedVertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
+ vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
vertexPosition = uMvpMatrix * vertexPosition;\n
//Illumination in Model-View space - Transform attributes and uniforms\n
- vec4 vertPos = uModelView * vec4( aPosition.xyz, 1.0 );\n
- vec4 center = uModelView * vec4( 0.0, 0.0, 0.0, 1.0 );\n
- vec4 lightPos = vec4( center.x, center.y, uLightPosition.z, 1.0 );\n
+ vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );\n
- vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
- vec3 viewDir = normalize( -vertPos.xyz );
+ vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
+ mvLightPosition = uViewMatrix * mvLightPosition;\n
+ vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
- vec3 halfVector = normalize( viewDir + vecToLight );
+ vec3 viewDirection = normalize( -mvVertexPosition.xyz );
- float lightDiffuse = dot( vecToLight, normal );\n
+ float lightDiffuse = dot( vectorToLight, normal );\n
lightDiffuse = max( 0.0,lightDiffuse );\n
vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
- vec3 reflectDir = reflect( -vecToLight, normal );
- vSpecular = pow( max( dot( reflectDir, viewDir ), 0.0 ), 4.0 );
+ vec3 reflectDirection = reflect( -vectorToLight, normal );
+ vSpecular = pow( max( dot( reflectDirection, viewDirection ), 0.0 ), 4.0 );
vTexCoord = aTexCoord;\n
gl_Position = vertexPosition;\n
uniform mediump vec3 uSize;\n
uniform mediump mat4 uMvpMatrix;\n
uniform mediump mat4 uModelView;
+ uniform mediump mat4 uViewMatrix;\n
uniform mediump mat3 uNormalMatrix;
uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 uLightPosition;\n
-
+ uniform mediump vec3 lightPosition;\n
+ uniform mediump vec2 uStageOffset;\n
void main()
{\n
- vec4 vertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
- vertexPosition = uObjectMatrix * vertexPosition;\n
+ vec4 normalisedVertexPosition = vec4( aPosition * min( uSize.x, uSize.y ), 1.0 );\n
+ vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
vertexPosition = uMvpMatrix * vertexPosition;\n
- vec4 vertPos = uModelView * vec4( aPosition.xyz, 1.0 );\n
- vec4 center = uModelView * vec4( 0.0, 0.0, 0.0, 1.0 );\n
- vec4 lightPos = vec4( center.x, center.y, uLightPosition.z, 1.0 );\n
+ vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
- vec3 tangent = normalize( uNormalMatrix * aTangent );
- vec3 binormal = normalize( uNormalMatrix * aBiNormal );
+ vec3 tangent = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aTangent );
+ vec3 binormal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aBiNormal );
vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );
- vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
- vLightDirection.x = dot( vecToLight, tangent );
- vLightDirection.y = dot( vecToLight, binormal );
- vLightDirection.z = dot( vecToLight, normal );
+ vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
+ mvLightPosition = uViewMatrix * mvLightPosition;\n
+ vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
+ vLightDirection.x = dot( vectorToLight, tangent );
+ vLightDirection.y = dot( vectorToLight, binormal );
+ vLightDirection.z = dot( vectorToLight, normal );
- vec3 viewDir = normalize( -vertPos.xyz );
- vec3 halfVector = normalize( viewDir + vecToLight );
+ vec3 viewDirection = normalize( -mvVertexPosition.xyz );
+ vec3 halfVector = normalize( viewDirection + vectorToLight );
vHalfVector.x = dot( halfVector, tangent );
vHalfVector.y = dot( halfVector, binormal );
vHalfVector.z = dot( halfVector, normal );
} // namespace
-MeshRenderer::MeshRenderer( RendererFactoryCache& factoryCache )
-: ControlRenderer( factoryCache ),
- mShaderType( ALL_TEXTURES ),
+MeshVisual::MeshVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache ),
+ mShadingMode( Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING ),
mUseTexture( true ),
- mUseMipmapping( true )
+ mUseMipmapping( true ),
+ mUseSoftNormals( true )
{
}
-MeshRenderer::~MeshRenderer()
+MeshVisual::~MeshVisual()
{
}
-void MeshRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void MeshVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
- Property::Value* objectUrl = propertyMap.Find( OBJECT_URL );
+ Property::Value* objectUrl = propertyMap.Find( Toolkit::MeshVisual::Property::OBJECT_URL, OBJECT_URL_NAME );
if( !objectUrl || !objectUrl->Get( mObjectUrl ) )
{
- DALI_LOG_ERROR( "Fail to provide object URL to the MeshRenderer object.\n" );
+ DALI_LOG_ERROR( "Fail to provide object URL to the MeshVisual object.\n" );
}
- Property::Value* materialUrl = propertyMap.Find( MATERIAL_URL );
-
+ Property::Value* materialUrl = propertyMap.Find( Toolkit::MeshVisual::Property::MATERIAL_URL, MATERIAL_URL_NAME );
if( !materialUrl || !materialUrl->Get( mMaterialUrl ) || mMaterialUrl.empty() )
{
mUseTexture = false;
}
- Property::Value* imagesUrl = propertyMap.Find( TEXTURES_PATH );
+ Property::Value* imagesUrl = propertyMap.Find( Toolkit::MeshVisual::Property::TEXTURES_PATH, TEXTURES_PATH_NAME );
if( !imagesUrl || !imagesUrl->Get( mTexturesPath ) )
{
//Default behaviour is to assume files are in the same directory,
mTexturesPath.clear();
}
- Property::Value* useMipmapping = propertyMap.Find( USE_MIPMAPPING );
+ Property::Value* shadingMode = propertyMap.Find( Toolkit::MeshVisual::Property::SHADING_MODE, SHADING_MODE_NAME );
+ if( shadingMode )
+ {
+ Scripting::GetEnumerationProperty( *shadingMode, SHADING_MODE_TABLE, SHADING_MODE_TABLE_COUNT, mShadingMode );
+ }
+
+ Property::Value* useMipmapping = propertyMap.Find( Toolkit::MeshVisual::Property::USE_MIPMAPPING, USE_MIPMAPPING_NAME );
if( useMipmapping )
{
useMipmapping->Get( mUseMipmapping );
}
- Property::Value* shaderType = propertyMap.Find( SHADER_TYPE );
- if( shaderType )
+ Property::Value* useSoftNormals = propertyMap.Find( Toolkit::MeshVisual::Property::USE_SOFT_NORMALS, USE_SOFT_NORMALS_NAME );
+ if( useSoftNormals )
+ {
+ useSoftNormals->Get( mUseSoftNormals );
+ }
+
+ Property::Value* lightPosition = propertyMap.Find( Toolkit::MeshVisual::Property::LIGHT_POSITION, LIGHT_POSITION_NAME );
+ if( lightPosition )
{
- std::string shaderTypeString;
- if( shaderType->Get( shaderTypeString ) )
+ if( !lightPosition->Get( mLightPosition ) )
{
- if( shaderTypeString == SHADER_TYPE_TEXTURELESS )
- {
- mShaderType = TEXTURELESS;
- }
- else if( shaderTypeString == SHADER_TYPE_DIFFUSE_TEXTURE )
- {
- mShaderType = DIFFUSE_TEXTURE;
- }
- else if( shaderTypeString == SHADER_TYPE_ALL_TEXTURES )
- {
- mShaderType = ALL_TEXTURES;
- }
- else
- {
- DALI_LOG_ERROR( "Unknown shader type provided to the MeshRenderer object.\n");
- }
+ DALI_LOG_ERROR( "Invalid value passed for light position in MeshRenderer object.\n" );
+ mLightPosition = Vector3::ZERO;
}
}
+ else
+ {
+ //Default behaviour is to place the light directly in front of the object,
+ // at a reasonable distance to light everything on screen.
+ Stage stage = Stage::GetCurrent();
+
+ mLightPosition = Vector3( stage.GetSize().width / 2, stage.GetSize().height / 2, stage.GetSize().width * 5 );
+ }
}
-void MeshRenderer::SetSize( const Vector2& size )
+void MeshVisual::SetSize( const Vector2& size )
{
- ControlRenderer::SetSize( size );
+ Visual::Base::SetSize( size );
// ToDo: renderer responds to the size change
}
-void MeshRenderer::SetClipRect( const Rect<int>& clipRect )
+void MeshVisual::SetClipRect( const Rect<int>& clipRect )
{
- ControlRenderer::SetClipRect( clipRect );
+ Visual::Base::SetClipRect( clipRect );
//ToDo: renderer responds to the clipRect change
}
-void MeshRenderer::SetOffset( const Vector2& offset )
+void MeshVisual::SetOffset( const Vector2& offset )
{
//ToDo: renderer applies the offset
}
-void MeshRenderer::DoSetOnStage( Actor& actor )
+void MeshVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
}
-void MeshRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void MeshVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, MESH_RENDERER );
- map.Insert( OBJECT_URL, mObjectUrl );
- map.Insert( MATERIAL_URL, mMaterialUrl );
- map.Insert( TEXTURES_PATH, mTexturesPath );
-
- std::string shaderTypeString;
- switch( mShaderType )
- {
- case ALL_TEXTURES:
- {
- shaderTypeString = SHADER_TYPE_ALL_TEXTURES;
- break;
- }
-
- case DIFFUSE_TEXTURE:
- {
- shaderTypeString = SHADER_TYPE_DIFFUSE_TEXTURE;
- break;
- }
-
- case TEXTURELESS:
- {
- shaderTypeString = SHADER_TYPE_TEXTURELESS;
- break;
- }
- }
- map.Insert( SHADER_TYPE, shaderTypeString );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::MESH );
+ map.Insert( Toolkit::MeshVisual::Property::OBJECT_URL, mObjectUrl );
+ map.Insert( Toolkit::MeshVisual::Property::MATERIAL_URL, mMaterialUrl );
+ map.Insert( Toolkit::MeshVisual::Property::TEXTURES_PATH, mTexturesPath );
+ map.Insert( Toolkit::MeshVisual::Property::SHADING_MODE, mShadingMode );
+ map.Insert( Toolkit::MeshVisual::Property::USE_MIPMAPPING, mUseMipmapping );
+ map.Insert( Toolkit::MeshVisual::Property::USE_SOFT_NORMALS, mUseSoftNormals );
+ map.Insert( Toolkit::MeshVisual::Property::LIGHT_POSITION, mLightPosition );
}
-void MeshRenderer::InitializeRenderer()
+void MeshVisual::InitializeRenderer()
{
//Try to load the geometry from the file.
if( !LoadGeometry() )
mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON );
}
-void MeshRenderer::SupplyEmptyGeometry()
+void MeshVisual::SupplyEmptyGeometry()
{
mGeometry = Geometry::New();
mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
mImpl->mRenderer = Renderer::New( mGeometry, mShader );
- DALI_LOG_ERROR( "Initialisation error in mesh renderer.\n" );
+ DALI_LOG_ERROR( "Initialisation error in mesh visual.\n" );
}
-void MeshRenderer::UpdateShaderUniforms()
+void MeshVisual::UpdateShaderUniforms()
{
Stage stage = Stage::GetCurrent();
-
- Vector3 lightPosition( 0, 0, stage.GetSize().width );
- mShader.RegisterProperty( LIGHT_POSITION, lightPosition );
+ float width = stage.GetSize().width;
+ float height = stage.GetSize().height;
Matrix scaleMatrix;
scaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
- mShader.RegisterProperty( OBJECT_MATRIX, scaleMatrix );
+
+ mShader.RegisterProperty( STAGE_OFFSET_UNIFORM_NAME, Vector2( width, height ) / 2.0f );
+ mShader.RegisterProperty( LIGHT_POSITION_NAME, mLightPosition );
+ mShader.RegisterProperty( OBJECT_MATRIX_UNIFORM_NAME, scaleMatrix );
}
-void MeshRenderer::CreateShader()
+void MeshVisual::CreateShader()
{
- if( mShaderType == ALL_TEXTURES )
+ if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING )
{
mShader = Shader::New( NORMAL_MAP_VERTEX_SHADER, NORMAL_MAP_FRAGMENT_SHADER );
}
- else if( mShaderType == DIFFUSE_TEXTURE )
+ else if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING )
{
mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
}
UpdateShaderUniforms();
}
-bool MeshRenderer::CreateGeometry()
+bool MeshVisual::CreateGeometry()
{
//Determine if we need to use a simpler shader to handle the provided data
if( !mUseTexture || !mObjLoader.IsDiffuseMapPresent() )
{
- mShaderType = TEXTURELESS;
+ mShadingMode = Toolkit::MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING;
}
- else if( mShaderType == ALL_TEXTURES && (!mObjLoader.IsNormalMapPresent() || !mObjLoader.IsSpecularMapPresent()) )
+ else if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING && (!mObjLoader.IsNormalMapPresent() || !mObjLoader.IsSpecularMapPresent()) )
{
- mShaderType = DIFFUSE_TEXTURE;
+ mShadingMode = Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING;
}
int objectProperties = 0;
- if( mShaderType == DIFFUSE_TEXTURE ||
- mShaderType == ALL_TEXTURES )
+ if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING ||
+ mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING )
{
objectProperties |= ObjLoader::TEXTURE_COORDINATES;
}
- if( mShaderType == ALL_TEXTURES )
+ if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING )
{
objectProperties |= ObjLoader::TANGENTS | ObjLoader::BINORMALS;
}
//Create geometry with attributes required by shader.
- mGeometry = mObjLoader.CreateGeometry( objectProperties );
+ mGeometry = mObjLoader.CreateGeometry( objectProperties, mUseSoftNormals );
if( mGeometry )
{
return true;
}
- DALI_LOG_ERROR( "Failed to load geometry in mesh renderer.\n" );
+ DALI_LOG_ERROR( "Failed to load geometry in mesh visual.\n" );
return false;
}
-bool MeshRenderer::LoadGeometry()
+bool MeshVisual::LoadGeometry()
{
std::streampos fileSize;
Dali::Vector<char> fileContent;
return true;
}
- DALI_LOG_ERROR( "Failed to find object to load in mesh renderer.\n" );
+ DALI_LOG_ERROR( "Failed to find object to load in mesh visual.\n" );
return false;
}
-bool MeshRenderer::LoadMaterial()
+bool MeshVisual::LoadMaterial()
{
std::streampos fileSize;
Dali::Vector<char> fileContent;
return true;
}
- DALI_LOG_ERROR( "Failed to find texture set to load in mesh renderer.\n" );
+ DALI_LOG_ERROR( "Failed to find texture set to load in mesh visual.\n" );
mUseTexture = false;
return false;
}
-bool MeshRenderer::LoadTextures()
+bool MeshVisual::LoadTextures()
{
mTextureSet = TextureSet::New();
- if( mShaderType != TEXTURELESS )
+ if( mShadingMode != Toolkit::MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING )
{
Sampler sampler = Sampler::New();
if( mUseMipmapping )
}
else
{
- DALI_LOG_ERROR( "Failed to load diffuse map texture in mesh renderer.\n");
+ DALI_LOG_ERROR( "Failed to load diffuse map texture in mesh visual.\n");
return false;
}
}
- if( !mNormalTextureUrl.empty() && ( mShaderType == ALL_TEXTURES ) )
+ if( !mNormalTextureUrl.empty() && ( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING ) )
{
std::string imageUrl = mTexturesPath + mNormalTextureUrl;
}
else
{
- DALI_LOG_ERROR( "Failed to load normal map texture in mesh renderer.\n");
+ DALI_LOG_ERROR( "Failed to load normal map texture in mesh visual.\n");
return false;
}
}
- if( !mGlossTextureUrl.empty() && ( mShaderType == ALL_TEXTURES ) )
+ if( !mGlossTextureUrl.empty() && ( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING ) )
{
std::string imageUrl = mTexturesPath + mGlossTextureUrl;
}
else
{
- DALI_LOG_ERROR( "Failed to load gloss map texture in mesh renderer.\n");
+ DALI_LOG_ERROR( "Failed to load gloss map texture in mesh visual.\n");
return false;
}
}
-#ifndef __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__
-#define __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_MESH_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_MESH_VISUAL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
#include <string.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/public-api/visuals/mesh-visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
namespace Dali
{
/**
- * The renderer which renders a 3D object to the control's quad
+ * The visual which renders a 3D object to the control's quad
*
- * The following Property::Map keys are required to create a MeshRender
+ * The following Property::Map keys are required to create a MeshVisual
*
- * | %Property Name | Type | Representing |
- * |-----------------|-------------|-----------------------------------------|
- * | objectUrl | STRING | A URL to the .obj file |
- * | materialUrl | STRING | A URL to the .mtl file |
- * | texturesPath | STRING | A URL of the path to the texture images |
- * | shaderType | STRING | An enum of shader types |
+ * | %Property Name | Type | Representing |
+ * |-----------------|-------------|-----------------------------------------------------------------------|
+ * | objectUrl | STRING | A URL to the .obj file |
+ * | materialUrl | STRING | A URL to the .mtl file |
+ * | texturesPath | STRING | A URL of the path to the texture images |
+ * | shadingMode | STRING | An enum of shading modes |
+ * | useMipmapping | BOOLEAN | If true, use mipmaps for textures. Default true. |
+ * | useSoftNormals | BOOLEAN | If true, average normals at points for smooth textures. Default true. |
+ * | lightPosition | VECTOR3 | The position (on stage) of the light |
*/
-class MeshRenderer: public ControlRenderer
+class MeshVisual: public Visual::Base
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- MeshRenderer( RendererFactoryCache& factoryCache );
+ MeshVisual( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- virtual ~MeshRenderer();
+ virtual ~MeshVisual();
-public: // from ControlRenderer
+public: // from Visual
/**
- * @copydoc ControlRenderer::SetSize
+ * @copydoc Visual::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc ControlRenderer::SetClipRect
+ * @copydoc Visual::SetClipRect
*/
virtual void SetClipRect( const Rect<int>& clipRect );
/**
- * @copydoc ControlRenderer::SetOffset
+ * @copydoc Visual::SetOffset
*/
virtual void SetOffset( const Vector2& offset );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc ControlRenderer::DoInitialize
+ * @copydoc Visual::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
private:
- //Corresponds to the shader that will be used by the mesh renderer.
- enum ShaderType
- {
- TEXTURELESS,
- DIFFUSE_TEXTURE,
- ALL_TEXTURES
- };
-
/**
- * @brief Provide an empty geometry for the renderer to use.
+ * @brief Provide an empty geometry for the visual to use.
* @details For use in error cases where the initialisation has failed for varying reasons.
*/
void SupplyEmptyGeometry();
/**
- * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
+ * @brief Initialize the visual with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
*/
void InitializeRenderer();
void UpdateShaderUniforms();
/**
- * @brief Use the object URL stored in the renderer to load and create the geometry of the object.
+ * @brief Use the object URL stored in the mesh visual to load and create the geometry of the object.
* @return Boolean of success of operation.
*/
bool CreateGeometry();
/**
- * @brief Use the object URL stored in the renderer to load the geometry of the object.
+ * @brief Use the object URL stored in the visual to load the geometry of the object.
* @return Boolean of success of operation.
*/
bool LoadGeometry();
/**
- * @brief Use the material URL stored in the renderer to load the material of the object.
+ * @brief Use the material URL stored in the mesh visual to load the material of the object.
* @return Boolean of success of operation.
*/
bool LoadMaterial();
private:
// Undefined
- MeshRenderer( const MeshRenderer& meshRenderer );
+ MeshVisual( const MeshVisual& meshVisual );
// Undefined
- MeshRenderer& operator=( const MeshRenderer& meshRenderer );
+ MeshVisual& operator=( const MeshVisual& meshVisual );
private:
ObjLoader mObjLoader;
Vector3 mSceneCenter;
Vector3 mSceneSize;
- ShaderType mShaderType;
+
+ Vector3 mLightPosition;
+ Toolkit::MeshVisual::ShadingMode::Value mShadingMode;
bool mUseTexture;
bool mUseMipmapping;
+ bool mUseSoftNormals;
};
} // namespace Internal
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__ */
+#endif /* DALI_TOOLKIT_INTERNAL_MESH_VISUAL_H */
*/
// CLASS HEADER
-#include "npatch-renderer.h"
+#include "npatch-visual.h"
// EXTERNAL INCLUDES
#include <dali/integration-api/platform-abstraction.h>
#include <dali/devel-api/images/texture-set-image.h>
// INTERNAL IINCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-impl.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace Dali
} //unnamed namespace
-/////////////////NPatchRenderer////////////////
+/////////////////NPatchVisual////////////////
-NPatchRenderer::NPatchRenderer( RendererFactoryCache& factoryCache )
-: ControlRenderer( factoryCache ),
+NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache ),
mBorderOnly( false )
{
}
-NPatchRenderer::~NPatchRenderer()
+NPatchVisual::~NPatchVisual()
{
}
-void NPatchRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void NPatchVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
- Property::Value* imageURLValue = propertyMap.Find( IMAGE_URL_NAME );
+ Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
if( imageURLValue )
{
//Read the borderOnly property first since InitialiseFromImage relies on mBorderOnly to be properly set
- Property::Value* borderOnlyValue = propertyMap.Find( BORDER_ONLY );
+ Property::Value* borderOnlyValue = propertyMap.Find( Toolkit::ImageVisual::Property::BORDER_ONLY, BORDER_ONLY );
if( borderOnlyValue )
{
borderOnlyValue->Get( mBorderOnly );
}
}
-void NPatchRenderer::GetNaturalSize( Vector2& naturalSize ) const
+void NPatchVisual::GetNaturalSize( Vector2& naturalSize ) const
{
if( mImage )
{
}
}
-void NPatchRenderer::SetClipRect( const Rect<int>& clipRect )
+void NPatchVisual::SetClipRect( const Rect<int>& clipRect )
{
- ControlRenderer::SetClipRect( clipRect );
+ Visual::Base::SetClipRect( clipRect );
//ToDo: renderer responds to the clipRect change
}
-void NPatchRenderer::SetOffset( const Vector2& offset )
+void NPatchVisual::SetOffset( const Vector2& offset )
{
//ToDo: renderer applies the offset
}
-Geometry NPatchRenderer::CreateGeometry()
+Geometry NPatchVisual::CreateGeometry()
{
Geometry geometry;
if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
{
if( !mBorderOnly )
{
- geometry = mFactoryCache.GetGeometry( RendererFactoryCache::NINE_PATCH_GEOMETRY );
+ geometry = mFactoryCache.GetGeometry( VisualFactoryCache::NINE_PATCH_GEOMETRY );
if( !geometry )
{
geometry = CreateGeometry( Uint16Pair( 3, 3 ) );
- mFactoryCache.SaveGeometry( RendererFactoryCache::NINE_PATCH_GEOMETRY, geometry );
+ mFactoryCache.SaveGeometry( VisualFactoryCache::NINE_PATCH_GEOMETRY, geometry );
}
}
else
{
- geometry = mFactoryCache.GetGeometry( RendererFactoryCache::NINE_PATCH_BORDER_GEOMETRY );
+ geometry = mFactoryCache.GetGeometry( VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY );
if( !geometry )
{
geometry = CreateGeometryBorder( Uint16Pair( 3, 3 ) );
- mFactoryCache.SaveGeometry( RendererFactoryCache::NINE_PATCH_BORDER_GEOMETRY, geometry );
+ mFactoryCache.SaveGeometry( VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY, geometry );
}
}
}
return geometry;
}
-Shader NPatchRenderer::CreateShader()
+Shader NPatchVisual::CreateShader()
{
Shader shader;
if( !mImpl->mCustomShader )
{
if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
{
- shader = mFactoryCache.GetShader( RendererFactoryCache::NINE_PATCH_SHADER );
+ shader = mFactoryCache.GetShader( VisualFactoryCache::NINE_PATCH_SHADER );
if( !shader )
{
shader = Shader::New( VERTEX_SHADER_3X3, FRAGMENT_SHADER );
- mFactoryCache.SaveShader( RendererFactoryCache::NINE_PATCH_SHADER, shader );
+ mFactoryCache.SaveShader( VisualFactoryCache::NINE_PATCH_SHADER, shader );
}
}
else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
else
{
const char* fragmentShader = FRAGMENT_SHADER;
- Dali::Shader::ShaderHints hints = Dali::Shader::HINT_NONE;
+ Dali::Shader::Hint::Value hints = Dali::Shader::Hint::NONE;
if( !mImpl->mCustomShader->mFragmentShader.empty() )
{
return shader;
}
-void NPatchRenderer::InitializeRenderer()
+void NPatchVisual::InitializeRenderer()
{
Geometry geometry = CreateGeometry();
Shader shader = CreateShader();
}
-void NPatchRenderer::DoSetOnStage( Actor& actor )
+void NPatchVisual::DoSetOnStage( Actor& actor )
{
if( !mCroppedImage )
{
}
}
-void NPatchRenderer::DoSetOffStage( Actor& actor )
+void NPatchVisual::DoSetOffStage( Actor& actor )
{
mCroppedImage.Reset();
actor.RemoveRenderer( mImpl->mRenderer );
mImpl->mRenderer.Reset();
}
-void NPatchRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void NPatchVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, IMAGE_RENDERER );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
if( !mImageUrl.empty() )
{
- map.Insert( IMAGE_URL_NAME, mImageUrl );
+ map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
}
else if( mImage )
{
- map.Insert( IMAGE_URL_NAME, mImage.GetUrl() );
+ map.Insert( Toolkit::ImageVisual::Property::URL, mImage.GetUrl() );
}
- map.Insert( BORDER_ONLY, mBorderOnly );
+ map.Insert( Toolkit::ImageVisual::Property::BORDER_ONLY, mBorderOnly );
}
-void NPatchRenderer::ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t oldGridY )
+void NPatchVisual::ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t oldGridY )
{
//check to see if the border style has changed
}
}
-void NPatchRenderer::SetImage( const std::string& imageUrl, bool borderOnly )
+void NPatchVisual::SetImage( const std::string& imageUrl, bool borderOnly )
{
bool oldBorderOnly = mBorderOnly;
size_t oldGridX = mStretchPixelsX.Size();
}
}
-void NPatchRenderer::SetImage( NinePatchImage image, bool borderOnly )
+void NPatchVisual::SetImage( NinePatchImage image, bool borderOnly )
{
bool oldBorderOnly = mBorderOnly;
size_t oldGridX = mStretchPixelsX.Size();
}
}
-void NPatchRenderer::InitializeFromImage( NinePatchImage nPatch )
+void NPatchVisual::InitializeFromImage( NinePatchImage nPatch )
{
mCroppedImage = nPatch.CreateCroppedBufferImage();
if( !mCroppedImage )
mStretchPixelsY = nPatch.GetStretchPixelsY();
}
-void NPatchRenderer::InitializeFromBrokenImage()
+void NPatchVisual::InitializeFromBrokenImage()
{
- mCroppedImage = RendererFactory::GetBrokenRendererImage();
+ mCroppedImage = VisualFactory::GetBrokenVisualImage();
mImageSize = ImageDimensions( mCroppedImage.GetWidth(), mCroppedImage.GetHeight() );
mStretchPixelsX.Clear();
mStretchPixelsY.PushBack( Uint16Pair( 0, mImageSize.GetHeight() ) );
}
-void NPatchRenderer::ApplyImageToSampler()
+void NPatchVisual::ApplyImageToSampler()
{
TextureSet textureSet = mImpl->mRenderer.GetTextures();
if( textureSet )
}
}
-Geometry NPatchRenderer::CreateGeometry( Uint16Pair gridSize )
+Geometry NPatchVisual::CreateGeometry( Uint16Pair gridSize )
{
uint16_t gridWidth = gridSize.GetWidth();
uint16_t gridHeight = gridSize.GetHeight();
return GenerateGeometry( vertices, indices );
}
-Geometry NPatchRenderer::CreateGeometryBorder( Uint16Pair gridSize )
+Geometry NPatchVisual::CreateGeometryBorder( Uint16Pair gridSize )
{
uint16_t gridWidth = gridSize.GetWidth();
uint16_t gridHeight = gridSize.GetHeight();
-#ifndef DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H
-#define DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H
+#ifndef DALI_TOOLKIT_INTERNAL_N_PATCH_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_N_PATCH_VISUAL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
*/
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
// EXTERNAL INCLUDES
#include <dali/public-api/images/image.h>
{
/**
- * The renderer which renders an 9 patch image to the control's quad
+ * The visual which renders an 9 patch image to the control's quad
*
* The following properties are optional
*
* | borderOnly | BOOLEAN
*
*/
-class NPatchRenderer: public ControlRenderer
+class NPatchVisual: public Visual::Base
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- NPatchRenderer( RendererFactoryCache& factoryCache );
+ NPatchVisual( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- ~NPatchRenderer();
+ ~NPatchVisual();
-public: // from ControlRenderer
+public: // from Visual
/**
- * @copydoc ControlRenderer::GetNaturalSize
+ * @copydoc Visual::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @copydoc ControlRenderer::SetClipRect
+ * @copydoc Visual::SetClipRect
*/
virtual void SetClipRect( const Rect<int>& clipRect );
/**
- * @copydoc ControlRenderer::SetOffset
+ * @copydoc Visual::SetOffset
*/
virtual void SetOffset( const Vector2& offset );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc ControlRenderer::DoInitialize
+ * @copydoc Visual::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc ControlRenderer::DoSetOffStage
+ * @copydoc Visual::DoSetOffStage
*/
virtual void DoSetOffStage( Actor& actor );
public:
/**
- * @brief Sets the 9 patch image of this renderer to the resource at imageUrl
- * The renderer will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
+ * @brief Sets the 9 patch image of this visual to the resource at imageUrl
+ * The visual will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
*
* @param[in] imageUrl The URL to 9 patch image resource to use
* @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
void SetImage( const std::string& imageUrl, bool borderOnly = false );
/**
- * @brief Sets the 9 patch image of this renderer to the 9 patch image
+ * @brief Sets the 9 patch image of this viusal to the 9 patch image
*
* @param[in] image The NinePatchImage to use
* @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
Shader CreateShader();
/**
- * @brief Creates a geometry for the grid size to be used by this renderers' shaders
+ * @brief Creates a geometry for the grid size to be used by this visuals' shaders
*
* @param[in] gridSize The grid size of the solid geometry to create
* @return Returns the created geometry for the grid size
Geometry CreateGeometry( Uint16Pair gridSize );
/**
- * @brief Creates a geometry with the border only for the grid size to be used by this renderers' shaders
+ * @brief Creates a geometry with the border only for the grid size to be used by this visuals' shaders
* e.g. a 5x4 grid would create a geometry that would look like:
*
* ---------------------
private:
- NinePatchImage mImage; ///< The image to render if the renderer was set from an NinePatchImage, empty otherwise
+ NinePatchImage mImage; ///< The image to render if the visual was set from an NinePatchImage, empty otherwise
Image mCroppedImage;
- std::string mImageUrl; ///< The url to the image resource to render if the renderer was set from an image resource url, empty otherwise
+ std::string mImageUrl; ///< The url to the image resource to render if the visual was set from an image resource url, empty otherwise
NinePatchImage::StretchRanges mStretchPixelsX;
NinePatchImage::StretchRanges mStretchPixelsY;
ImageDimensions mImageSize;
} // namespace Dali
-#endif // DALI_TOOLKIT_INTERNAL_N_PATCH_RENDERER_H
+#endif // DALI_TOOLKIT_INTERNAL_N_PATCH_VISUAL_H
*/
// CLASS HEADER
-#include "primitive-renderer.h"
+#include "primitive-visual.h"
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/common/constants.h>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
-//INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace Dali
{
namespace
{
+// shapes
+DALI_ENUM_TO_STRING_TABLE_BEGIN( SHAPE_TYPE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::PrimitiveVisual::Shape, SPHERE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::PrimitiveVisual::Shape, CONICAL_FRUSTRUM )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::PrimitiveVisual::Shape, CONE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::PrimitiveVisual::Shape, CYLINDER )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::PrimitiveVisual::Shape, CUBE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::PrimitiveVisual::Shape, OCTAHEDRON )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::PrimitiveVisual::Shape, BEVELLED_CUBE )
+DALI_ENUM_TO_STRING_TABLE_END( SHAPE_TYPE )
+
+//Property names
+const char * const PRIMITIVE_SHAPE( "shape" );
+const char * const SHAPE_COLOR( "shapeColor" );
+const char * const SLICES( "slices" );
+const char * const STACKS( "stacks" );
+const char * const SCALE_TOP_RADIUS( "scaleTopRadius" );
+const char * const SCALE_BOTTOM_RADIUS( "scaleBottomRadius" );
+const char * const SCALE_HEIGHT( "scaleHeight" );
+const char * const SCALE_RADIUS( "scaleRadius" );
+const char * const SCALE_DIMENSIONS( "scaleDimensions" );
+const char * const BEVEL_PERCENTAGE( "bevelPercentage" );
+const char * const BEVEL_SMOOTHNESS( "bevelSmoothness" );
+const char * const LIGHT_POSITION_UNIFORM_NAME( "lightPosition" );
+
//Primitive property defaults
const int DEFAULT_SLICES = 128; ///< For spheres and conics
const int DEFAULT_STACKS = 128; ///< For spheres and conics
const float MIN_SMOOTHNESS = 0.0; ///< Minimum bevel smoothness for bevelled cubes
const float MAX_SMOOTHNESS = 1.0; ///< Maximum bevel smoothness for bevelled cubes
-const char * const RENDERER_TYPE_VALUE( "PRIMITIVE" );
-
//Specific shape labels.
const char * const SPHERE_LABEL( "SPHERE" );
const char * const CONE_LABEL( "CONE" );
const char * const OBJECT_MATRIX_UNIFORM_NAME( "uObjectMatrix" );
const char * const COLOR_UNIFORM_NAME( "uColor" );
const char * const OBJECT_DIMENSIONS_UNIFORM_NAME( "uObjectDimensions" );
-const char * const STAGE_SIZE_UNIFORM_NAME( "uStageSize" );
+const char * const STAGE_OFFSET_UNIFORM_NAME( "uStageOffset" );
//Vertex properties
const char * const POSITION( "aPosition");
uniform mediump mat4 uViewMatrix;\n
uniform mediump mat3 uNormalMatrix;\n
uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 uLightPosition;\n
- uniform mediump vec3 uStageSize;\n
+ uniform mediump vec3 lightPosition;\n
+ uniform mediump vec2 uStageOffset;\n
void main()\n
{\n
vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;\n
- vec3 stageOffset = vec3( uStageSize.xy, 0 ) / 2.0;\n
- vec4 lightPosition = vec4( ( uLightPosition - stageOffset ), 1.0 );\n
- lightPosition = uViewMatrix * lightPosition;\n
- vec3 vectorToLight = normalize( lightPosition.xyz - mvVertexPosition.xyz );\n
+ vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
+ mvLightPosition = uViewMatrix * mvLightPosition;\n
+ vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );\n
vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
} // namespace
-PrimitiveRenderer::PrimitiveRenderer( RendererFactoryCache& factoryCache )
-: ControlRenderer( factoryCache ),
+PrimitiveVisual::PrimitiveVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache ),
mColor( DEFAULT_COLOR ),
mScaleDimensions( Vector3::ONE ),
mScaleTopRadius( DEFAULT_SCALE_TOP_RADIUS ),
mBevelSmoothness( DEFAULT_BEVEL_SMOOTHNESS ),
mSlices( DEFAULT_SLICES ),
mStacks( DEFAULT_STACKS ),
- mPrimitiveType( SPHERE )
+ mPrimitiveType( Toolkit::PrimitiveVisual::Shape::SPHERE )
{
}
-PrimitiveRenderer::~PrimitiveRenderer()
+PrimitiveVisual::~PrimitiveVisual()
{
}
-void PrimitiveRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void PrimitiveVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
//Find out which shape to renderer.
- Property::Value* primitiveType = propertyMap.Find( PRIMITIVE_SHAPE );
- if( primitiveType )
+ Property::Value* primitiveTypeValue = propertyMap.Find( Toolkit::PrimitiveVisual::Property::SHAPE, PRIMITIVE_SHAPE );
+ if( primitiveTypeValue )
{
- if( primitiveType->Get( mShape ) )
- {
- //Set property type as an enum.
- if( mShape == SPHERE_LABEL )
- {
- mPrimitiveType = SPHERE;
- }
- else if( mShape == CONE_LABEL )
- {
- mPrimitiveType = CONE;
- }
- else if( mShape == CONICAL_FRUSTRUM_LABEL )
- {
- mPrimitiveType = CONICAL_FRUSTRUM;
- }
- else if( mShape == CYLINDER_LABEL )
- {
- mPrimitiveType = CYLINDER;
- }
- else if( mShape == CUBE_LABEL )
- {
- mPrimitiveType = CUBE;
- }
- else if( mShape == OCTAHEDRON_LABEL )
- {
- mPrimitiveType = OCTAHEDRON;
- }
- else if( mShape == BEVELLED_CUBE_LABEL )
- {
- mPrimitiveType = BEVELLED_CUBE;
- }
- else
- {
- DALI_LOG_ERROR( "No known shape in PrimitiveRenderer.\n" );
- }
- }
- else
- {
- DALI_LOG_ERROR( "Invalid type for shape in PrimitiveRenderer.\n" );
- }
+ Scripting::GetEnumerationProperty( *primitiveTypeValue, SHAPE_TYPE_TABLE, SHAPE_TYPE_TABLE_COUNT, mPrimitiveType );
}
else
{
- DALI_LOG_ERROR( "Fail to provide shape to the PrimitiveRenderer object.\n" );
+ DALI_LOG_ERROR( "Fail to provide shape to the PrimitiveVisual object.\n" );
}
//Read in other potential properties.
- Property::Value* color = propertyMap.Find( SHAPE_COLOR );
+ Property::Value* color = propertyMap.Find( Toolkit::PrimitiveVisual::Property::COLOR, SHAPE_COLOR );
if( color && !color->Get( mColor ) )
{
- DALI_LOG_ERROR( "Invalid type for color in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for color in PrimitiveVisual.\n" );
}
- Property::Value* slices = propertyMap.Find( SLICES );
+ Property::Value* slices = propertyMap.Find( Toolkit::PrimitiveVisual::Property::SLICES, SLICES );
if( slices )
{
if( slices->Get( mSlices ) )
}
else
{
- DALI_LOG_ERROR( "Invalid type for slices in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for slices in PrimitiveVisual.\n" );
}
}
- Property::Value* stacks = propertyMap.Find( STACKS );
+ Property::Value* stacks = propertyMap.Find( Toolkit::PrimitiveVisual::Property::STACKS, STACKS );
if( stacks )
{
if( stacks->Get( mStacks ) )
}
else
{
- DALI_LOG_ERROR( "Invalid type for stacks in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for stacks in PrimitiveVisual.\n" );
}
}
- Property::Value* scaleTop = propertyMap.Find( SCALE_TOP_RADIUS );
+ Property::Value* scaleTop = propertyMap.Find( Toolkit::PrimitiveVisual::Property::SCALE_TOP_RADIUS, SCALE_TOP_RADIUS );
if( scaleTop && !scaleTop->Get( mScaleTopRadius ) )
{
- DALI_LOG_ERROR( "Invalid type for scale top radius in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale top radius in PrimitiveVisual.\n" );
}
- Property::Value* scaleBottom = propertyMap.Find( SCALE_BOTTOM_RADIUS );
+ Property::Value* scaleBottom = propertyMap.Find( Toolkit::PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, SCALE_BOTTOM_RADIUS );
if( scaleBottom && !scaleBottom->Get( mScaleBottomRadius ) )
{
- DALI_LOG_ERROR( "Invalid type for scale bottom radius in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale bottom radius in PrimitiveVisual.\n" );
}
- Property::Value* scaleHeight = propertyMap.Find( SCALE_HEIGHT );
+ Property::Value* scaleHeight = propertyMap.Find( Toolkit::PrimitiveVisual::Property::SCALE_HEIGHT, SCALE_HEIGHT );
if( scaleHeight && !scaleHeight->Get( mScaleHeight ) )
{
- DALI_LOG_ERROR( "Invalid type for scale height in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale height in PrimitiveVisual.\n" );
}
- Property::Value* scaleRadius = propertyMap.Find( SCALE_RADIUS );
+ Property::Value* scaleRadius = propertyMap.Find( Toolkit::PrimitiveVisual::Property::SCALE_RADIUS, SCALE_RADIUS );
if( scaleRadius && !scaleRadius->Get( mScaleRadius ) )
{
- DALI_LOG_ERROR( "Invalid type for scale radius in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale radius in PrimitiveVisual.\n" );
}
- Property::Value* dimensions = propertyMap.Find( SCALE_DIMENSIONS );
+ Property::Value* dimensions = propertyMap.Find( Toolkit::PrimitiveVisual::Property::SCALE_DIMENSIONS, SCALE_DIMENSIONS );
if( dimensions )
{
if( dimensions->Get( mScaleDimensions ) )
}
else
{
- DALI_LOG_ERROR( "Invalid type for scale dimensions in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for scale dimensions in PrimitiveVisual.\n" );
}
}
- Property::Value* bevel = propertyMap.Find( BEVEL_PERCENTAGE );
+ Property::Value* bevel = propertyMap.Find( Toolkit::PrimitiveVisual::Property::BEVEL_PERCENTAGE, BEVEL_PERCENTAGE );
if( bevel )
{
if( bevel->Get( mBevelPercentage ) )
}
else
{
- DALI_LOG_ERROR( "Invalid type for bevel percentage in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for bevel percentage in PrimitiveVisual.\n" );
}
}
- Property::Value* smoothness = propertyMap.Find( BEVEL_SMOOTHNESS );
+ Property::Value* smoothness = propertyMap.Find( Toolkit::PrimitiveVisual::Property::BEVEL_SMOOTHNESS, BEVEL_SMOOTHNESS );
if( smoothness )
{
if( smoothness->Get( mBevelSmoothness ) )
}
else
{
- DALI_LOG_ERROR( "Invalid type for bevel smoothness in PrimitiveRenderer.\n" );
+ DALI_LOG_ERROR( "Invalid type for bevel smoothness in PrimitiveVisual.\n" );
}
}
//Read in light position.
- Property::Value* lightPosition = propertyMap.Find( LIGHT_POSITION_UNIFORM_NAME );
+ Property::Value* lightPosition = propertyMap.Find( Toolkit::PrimitiveVisual::Property::LIGHT_POSITION, LIGHT_POSITION_UNIFORM_NAME );
if( lightPosition )
{
if( !lightPosition->Get( mLightPosition ) )
{
- DALI_LOG_ERROR( "Invalid value passed for light position in MeshRenderer object.\n" );
+ DALI_LOG_ERROR( "Invalid value passed for light position in MeshVisual object.\n" );
mLightPosition = Vector3::ZERO;
}
}
}
}
-void PrimitiveRenderer::SetSize( const Vector2& size )
+void PrimitiveVisual::SetSize( const Vector2& size )
{
- ControlRenderer::SetSize( size );
+ Visual::Base::SetSize( size );
// ToDo: renderer responds to the size change
}
-void PrimitiveRenderer::SetClipRect( const Rect<int>& clipRect )
+void PrimitiveVisual::SetClipRect( const Rect<int>& clipRect )
{
- ControlRenderer::SetClipRect( clipRect );
+ Visual::Base::SetClipRect( clipRect );
//ToDo: renderer responds to the clipRect change
}
-void PrimitiveRenderer::SetOffset( const Vector2& offset )
+void PrimitiveVisual::SetOffset( const Vector2& offset )
{
//ToDo: renderer applies the offset
}
-void PrimitiveRenderer::DoSetOnStage( Actor& actor )
+void PrimitiveVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
}
-void PrimitiveRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void PrimitiveVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, RENDERER_TYPE_VALUE );
- map.Insert( PRIMITIVE_SHAPE, mShape );
- map.Insert( SHAPE_COLOR, mColor );
- map.Insert( SLICES, mSlices );
- map.Insert( STACKS, mStacks );
- map.Insert( SCALE_TOP_RADIUS, mScaleTopRadius );
- map.Insert( SCALE_BOTTOM_RADIUS, mScaleBottomRadius );
- map.Insert( SCALE_HEIGHT, mScaleHeight );
- map.Insert( SCALE_RADIUS, mScaleRadius );
- map.Insert( SCALE_DIMENSIONS, mScaleDimensions );
- map.Insert( BEVEL_PERCENTAGE, mBevelPercentage );
- map.Insert( BEVEL_SMOOTHNESS, mBevelSmoothness );
- map.Insert( LIGHT_POSITION_UNIFORM_NAME, mLightPosition );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::PRIMITIVE );
+ map.Insert( Toolkit::PrimitiveVisual::Property::SHAPE, mPrimitiveType );
+ map.Insert( Toolkit::PrimitiveVisual::Property::COLOR, mColor );
+ map.Insert( Toolkit::PrimitiveVisual::Property::SLICES, mSlices );
+ map.Insert( Toolkit::PrimitiveVisual::Property::STACKS, mStacks );
+ map.Insert( Toolkit::PrimitiveVisual::Property::SCALE_TOP_RADIUS, mScaleTopRadius );
+ map.Insert( Toolkit::PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, mScaleBottomRadius );
+ map.Insert( Toolkit::PrimitiveVisual::Property::SCALE_HEIGHT, mScaleHeight );
+ map.Insert( Toolkit::PrimitiveVisual::Property::SCALE_RADIUS, mScaleRadius );
+ map.Insert( Toolkit::PrimitiveVisual::Property::SCALE_DIMENSIONS, mScaleDimensions );
+ map.Insert( Toolkit::PrimitiveVisual::Property::BEVEL_PERCENTAGE, mBevelPercentage );
+ map.Insert( Toolkit::PrimitiveVisual::Property::BEVEL_SMOOTHNESS, mBevelSmoothness );
+ map.Insert( Toolkit::PrimitiveVisual::Property::LIGHT_POSITION, mLightPosition );
}
-void PrimitiveRenderer::InitializeRenderer()
+void PrimitiveVisual::InitializeRenderer()
{
if( !mGeometry )
{
}
mImpl->mRenderer = Renderer::New( mGeometry, mShader );
+ mImpl->mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
}
-void PrimitiveRenderer::UpdateShaderUniforms()
+void PrimitiveVisual::UpdateShaderUniforms()
{
Stage stage = Stage::GetCurrent();
float width = stage.GetSize().width;
Matrix scaleMatrix;
scaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
- mShader.RegisterProperty( STAGE_SIZE_UNIFORM_NAME, Vector3( width, height, std::min( width, height ) ) );
+ mShader.RegisterProperty( STAGE_OFFSET_UNIFORM_NAME, Vector2( width, height ) / 2.0f );
mShader.RegisterProperty( LIGHT_POSITION_UNIFORM_NAME, mLightPosition );
mShader.RegisterProperty( OBJECT_MATRIX_UNIFORM_NAME, scaleMatrix );
mShader.RegisterProperty( COLOR_UNIFORM_NAME, mColor );
mShader.RegisterProperty( OBJECT_DIMENSIONS_UNIFORM_NAME, mObjectDimensions );
}
-void PrimitiveRenderer::CreateShader()
+void PrimitiveVisual::CreateShader()
{
mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
UpdateShaderUniforms();
}
-void PrimitiveRenderer::CreateGeometry()
+void PrimitiveVisual::CreateGeometry()
{
Dali::Vector<Vertex> vertices;
Dali::Vector<unsigned short> indices;
switch( mPrimitiveType )
{
- case SPHERE:
+ case Toolkit::PrimitiveVisual::Shape::SPHERE:
{
CreateSphere( vertices, indices, mSlices, mStacks );
break;
}
- case CONE:
+ case Toolkit::PrimitiveVisual::Shape::CONE:
{
//Create a conic with zero top radius.
CreateConic( vertices, indices, 0, mScaleBottomRadius, mScaleHeight, mSlices );
break;
}
- case CONICAL_FRUSTRUM:
+ case Toolkit::PrimitiveVisual::Shape::CONICAL_FRUSTRUM:
{
CreateConic( vertices, indices, mScaleTopRadius, mScaleBottomRadius, mScaleHeight, mSlices );
break;
}
- case CYLINDER:
+ case Toolkit::PrimitiveVisual::Shape::CYLINDER:
{
//Create a conic with equal radii on the top and bottom.
CreateConic( vertices, indices, mScaleRadius, mScaleRadius, mScaleHeight, mSlices );
break;
}
- case CUBE:
+ case Toolkit::PrimitiveVisual::Shape::CUBE:
{
//Create a cube by creating a bevelled cube with minimum bevel.
CreateBevelledCube( vertices, indices, mScaleDimensions, 0.0, 0.0 );
break;
}
- case OCTAHEDRON:
+ case Toolkit::PrimitiveVisual::Shape::OCTAHEDRON:
{
//Create an octahedron by creating a bevelled cube with maximum bevel.
CreateBevelledCube( vertices, indices, mScaleDimensions, 1.0, mBevelSmoothness );
break;
}
- case BEVELLED_CUBE:
+ case Toolkit::PrimitiveVisual::Shape::BEVELLED_CUBE:
{
CreateBevelledCube( vertices, indices, mScaleDimensions, mBevelPercentage, mBevelSmoothness );
break;
mGeometry.SetIndexBuffer( &indices[0], indices.Size() );
}
-void PrimitiveRenderer::CreateSphere( Vector<Vertex>& vertices, Vector<unsigned short>& indices, int slices, int stacks )
+void PrimitiveVisual::CreateSphere( Vector<Vertex>& vertices, Vector<unsigned short>& indices, int slices, int stacks )
{
ComputeSphereVertices( vertices, slices, stacks );
FormSphereTriangles( indices, slices, stacks );
mObjectDimensions = Vector3::ONE;
}
-void PrimitiveRenderer::CreateConic( Vector<Vertex>& vertices, Vector<unsigned short>& indices, float scaleTopRadius,
+void PrimitiveVisual::CreateConic( Vector<Vertex>& vertices, Vector<unsigned short>& indices, float scaleTopRadius,
float scaleBottomRadius, float scaleHeight, int slices )
{
ComputeConicVertices( vertices, scaleTopRadius, scaleBottomRadius, scaleHeight, slices );
xDimension / largestDimension );
}
-void PrimitiveRenderer::CreateBevelledCube( Vector<Vertex>& vertices, Vector<unsigned short>& indices,
+void PrimitiveVisual::CreateBevelledCube( Vector<Vertex>& vertices, Vector<unsigned short>& indices,
Vector3 dimensions, float bevelPercentage, float bevelSmoothness )
{
dimensions.Normalize();
mObjectDimensions = dimensions;
}
-void PrimitiveRenderer::ComputeCircleTables( Vector<float>& sinTable, Vector<float>& cosTable, int divisions,
+void PrimitiveVisual::ComputeCircleTables( Vector<float>& sinTable, Vector<float>& cosTable, int divisions,
bool halfCircle )
{
if( divisions < 0 )
}
}
-void PrimitiveRenderer::ComputeSphereVertices( Vector<Vertex>& vertices, int slices, int stacks )
+void PrimitiveVisual::ComputeSphereVertices( Vector<Vertex>& vertices, int slices, int stacks )
{
//Tables for calculating slices angles and stacks angles, respectively.
Vector<float> sinTable1;
float z;
//Top stack.
- vertices[vertexIndex].position = Vector3( 0.0, 0.0, 0.5 );
- vertices[vertexIndex].normal = Vector3( 0.0, 0.0, 1.0 );
+ vertices[vertexIndex].position = Vector3( 0.0, 0.5, 0.0 );
+ vertices[vertexIndex].normal = Vector3( 0.0, 1.0, 0.0 );
vertexIndex++;
//Middle stacks.
for( int j = 0; j < slices; j++, vertexIndex++ )
{
x = cosTable1[j] * sinTable2[i];
- y = sinTable1[j] * sinTable2[i];
- z = cosTable2[i];
+ y = cosTable2[i];
+ z = sinTable1[j] * sinTable2[i];
vertices[vertexIndex].position = Vector3( x / 2.0f, y / 2.0f, z / 2.0f );
vertices[vertexIndex].normal = Vector3( x, y, z );
}
//Bottom stack.
- vertices[vertexIndex].position = Vector3( 0.0, 0.0, -0.5 );
- vertices[vertexIndex].normal = Vector3( 0.0, 0.0, -1.0 );
+ vertices[vertexIndex].position = Vector3( 0.0, -0.5, 0.0 );
+ vertices[vertexIndex].normal = Vector3( 0.0, -1.0, 0.0 );
}
-void PrimitiveRenderer::FormSphereTriangles( Vector<unsigned short>& indices, int slices, int stacks )
+void PrimitiveVisual::FormSphereTriangles( Vector<unsigned short>& indices, int slices, int stacks )
{
if( stacks <= 1 )
{
for( int i = 1; i <= slices; i++, indiceIndex += 3 )
{
indices[indiceIndex] = 0;
- indices[indiceIndex + 1] = i;
if( i == slices )
{
//End, so loop around.
- indices[indiceIndex + 2] = 1;
+ indices[indiceIndex + 1] = 1;
}
else
{
- indices[indiceIndex + 2] = i + 1;
+ indices[indiceIndex + 1] = i + 1;
}
+ indices[indiceIndex + 2] = i;
}
//Middle Stacks. Want to form triangles between the top and bottom stacks, so loop up to the number of stacks - 2.
{
//End, so loop around.
indices[indiceIndex] = previousCycleBeginning + j;
- indices[indiceIndex + 1] = currentCycleBeginning + j;
- indices[indiceIndex + 2] = previousCycleBeginning;
+ indices[indiceIndex + 1] = previousCycleBeginning;
+ indices[indiceIndex + 2] = currentCycleBeginning + j;
indices[indiceIndex + 3] = currentCycleBeginning + j;
- indices[indiceIndex + 4] = currentCycleBeginning;
- indices[indiceIndex + 5] = previousCycleBeginning;
+ indices[indiceIndex + 4] = previousCycleBeginning;
+ indices[indiceIndex + 5] = currentCycleBeginning;
}
else
{
indices[indiceIndex] = previousCycleBeginning + j;
- indices[indiceIndex + 1] = currentCycleBeginning + j;
- indices[indiceIndex + 2] = previousCycleBeginning + 1 + j;
+ indices[indiceIndex + 1] = previousCycleBeginning + 1 + j;
+ indices[indiceIndex + 2] = currentCycleBeginning + j;
indices[indiceIndex + 3] = currentCycleBeginning + j;
- indices[indiceIndex + 4] = currentCycleBeginning + 1 + j;
- indices[indiceIndex + 5] = previousCycleBeginning + 1 + j;
+ indices[indiceIndex + 4] = previousCycleBeginning + 1 + j;
+ indices[indiceIndex + 5] = currentCycleBeginning + 1 + j;
}
}
}
}
}
-void PrimitiveRenderer::ComputeConicVertices( Vector<Vertex>& vertices, float scaleTopRadius,
+void PrimitiveVisual::ComputeConicVertices( Vector<Vertex>& vertices, float scaleTopRadius,
float scaleBottomRadius, float scaleHeight, int slices )
{
int vertexIndex = 0; //Track progress through vertices.
vertexIndex++;
}
-void PrimitiveRenderer::FormConicTriangles( Vector<unsigned short>& indices, float scaleTopRadius,
+void PrimitiveVisual::FormConicTriangles( Vector<unsigned short>& indices, float scaleTopRadius,
float scaleBottomRadius, int slices )
{
int indiceIndex = 0; //Track progress through indices.
for( int i = 0; i < slices; i++, indiceIndex += 3 )
{
indices[indiceIndex] = bottomFaceCycleBeginning;
- indices[indiceIndex + 1] = bottomFaceCycleBeginning + i;
if( i == slices - 1 )
{
//End, so loop around.
- indices[indiceIndex + 2] = bottomFaceCycleBeginning;
+ indices[indiceIndex + 1] = bottomFaceCycleBeginning;
}
else
{
- indices[indiceIndex + 2] = bottomFaceCycleBeginning + i + 1;
+ indices[indiceIndex + 1] = bottomFaceCycleBeginning + i + 1;
}
+ indices[indiceIndex + 2] = bottomFaceCycleBeginning + i;
}
}
else if( !coneTop || !coneBottom )
for( int i = 1; i <= slices; i++, indiceIndex += 3 )
{
indices[indiceIndex] = 2 * slices + 1;
- indices[indiceIndex + 1] = slices + i;
if( i == slices )
{
//End, so loop around.
- indices[indiceIndex + 2] = slices + 1;
+ indices[indiceIndex + 1] = slices + 1;
}
else
{
- indices[indiceIndex + 2] = slices + i + 1;
+ indices[indiceIndex + 1] = slices + i + 1;
}
+ indices[indiceIndex + 2] = slices + i;
}
}
}
-void PrimitiveRenderer::ComputeCubeVertices( Vector<Vertex>& vertices, Vector3 dimensions )
+void PrimitiveVisual::ComputeCubeVertices( Vector<Vertex>& vertices, Vector3 dimensions )
{
int numVertices = 4 * 6; //Four per face.
int vertexIndex = 0; //Tracks progress through vertices.
}
-void PrimitiveRenderer::FormCubeTriangles( Vector<unsigned short>& indices )
+void PrimitiveVisual::FormCubeTriangles( Vector<unsigned short>& indices )
{
int numTriangles = 12;
int triangleIndex = 0; //Track progress through indices.
//Top face.
indices[triangleIndex] = 0;
- indices[triangleIndex + 1] = 1;
- indices[triangleIndex + 2] = 2;
+ indices[triangleIndex + 1] = 2;
+ indices[triangleIndex + 2] = 1;
indices[triangleIndex + 3] = 2;
- indices[triangleIndex + 4] = 3;
- indices[triangleIndex + 5] = 0;
+ indices[triangleIndex + 4] = 0;
+ indices[triangleIndex + 5] = 3;
triangleIndex += 6;
int topFaceStart = 4;
for( int i = 0; i < 8; i += 2, triangleIndex += 6 )
{
indices[triangleIndex ] = i + topFaceStart;
- indices[triangleIndex + 1] = i + bottomFaceStart + 1;
- indices[triangleIndex + 2] = i + topFaceStart + 1;
+ indices[triangleIndex + 1] = i + topFaceStart + 1;
+ indices[triangleIndex + 2] = i + bottomFaceStart + 1;
indices[triangleIndex + 3] = i + topFaceStart;
- indices[triangleIndex + 4] = i + bottomFaceStart;
- indices[triangleIndex + 5] = i + bottomFaceStart + 1;
+ indices[triangleIndex + 4] = i + bottomFaceStart + 1;
+ indices[triangleIndex + 5] = i + bottomFaceStart;
}
//Bottom face.
indices[triangleIndex + 5] = 20;
}
-void PrimitiveRenderer::ComputeOctahedronVertices( Vector<Vertex>& vertices, Vector3 dimensions, float smoothness )
+void PrimitiveVisual::ComputeOctahedronVertices( Vector<Vertex>& vertices, Vector3 dimensions, float smoothness )
{
int numVertices = 3 * 8; //Three per face
int vertexIndex = 0; //Tracks progress through vertices.
//End, so loop around.
vertices[vertexIndex ].position = positions[0];
vertices[vertexIndex ].normal = outerNormals[0] * smoothness + normals[i] * (1 - smoothness);
- vertices[vertexIndex + 1].position = positions[i + 1];
- vertices[vertexIndex + 1].normal = outerNormals[i + 1] * smoothness + normals[i] * (1 - smoothness);
- vertices[vertexIndex + 2].position = positions[1];
- vertices[vertexIndex + 2].normal = outerNormals[1] * smoothness + normals[i] * (1 - smoothness);
+ vertices[vertexIndex + 1].position = positions[1];
+ vertices[vertexIndex + 1].normal = outerNormals[1] * smoothness + normals[i] * (1 - smoothness);
+ vertices[vertexIndex + 2].position = positions[i + 1];
+ vertices[vertexIndex + 2].normal = outerNormals[i + 1] * smoothness + normals[i] * (1 - smoothness);
}
else
{
vertices[vertexIndex ].position = positions[0];
vertices[vertexIndex ].normal = outerNormals[0] * smoothness + normals[i] * (1 - smoothness);
- vertices[vertexIndex + 1].position = positions[i + 1];
- vertices[vertexIndex + 1].normal = outerNormals[i + 1] * smoothness + normals[i] * (1 - smoothness);
- vertices[vertexIndex + 2].position = positions[i + 2];
- vertices[vertexIndex + 2].normal = outerNormals[i + 2] * smoothness + normals[i] * (1 - smoothness);
+ vertices[vertexIndex + 1].position = positions[i + 2];
+ vertices[vertexIndex + 1].normal = outerNormals[i + 2] * smoothness + normals[i] * (1 - smoothness);
+ vertices[vertexIndex + 2].position = positions[i + 1];
+ vertices[vertexIndex + 2].normal = outerNormals[i + 1] * smoothness + normals[i] * (1 - smoothness);
}
}
}
}
-void PrimitiveRenderer::FormOctahedronTriangles( Vector<unsigned short>& indices )
+void PrimitiveVisual::FormOctahedronTriangles( Vector<unsigned short>& indices )
{
int numTriangles = 8;
int numIndices = numTriangles * 3;
}
}
-void PrimitiveRenderer::ComputeBevelledCubeVertices( Vector<Vertex>& vertices, Vector3 dimensions,
+void PrimitiveVisual::ComputeBevelledCubeVertices( Vector<Vertex>& vertices, Vector3 dimensions,
float bevelPercentage, float bevelSmoothness )
{
int numPositions = 24;
normalIndex++;
}
-void PrimitiveRenderer::FormBevelledCubeTriangles( Vector<unsigned short>& indices )
+void PrimitiveVisual::FormBevelledCubeTriangles( Vector<unsigned short>& indices )
{
int numTriangles = 44; //(Going from top to bottom, that's 2 + 12 + 16 + 12 + 2)
int indiceIndex = 0; //Track progress through indices.
//Top face.
indices[indiceIndex ] = vertexIndex;
- indices[indiceIndex + 1] = vertexIndex + 1;
- indices[indiceIndex + 2] = vertexIndex + 2;
+ indices[indiceIndex + 1] = vertexIndex + 2;
+ indices[indiceIndex + 2] = vertexIndex + 1;
indices[indiceIndex + 3] = vertexIndex + 0;
- indices[indiceIndex + 4] = vertexIndex + 2;
- indices[indiceIndex + 5] = vertexIndex + 3;
+ indices[indiceIndex + 4] = vertexIndex + 3;
+ indices[indiceIndex + 5] = vertexIndex + 2;
indiceIndex += 6;
vertexIndex += 4;
{
//Triangle part.
indices[indiceIndex ] = vertexIndex;
- indices[indiceIndex + 1] = vertexIndex + 1;
- indices[indiceIndex + 2] = vertexIndex + 2;
+ indices[indiceIndex + 1] = vertexIndex + 2;
+ indices[indiceIndex + 2] = vertexIndex + 1;
//Rectangle part.
indices[indiceIndex + 3] = vertexIndex + 3;
indices[indiceIndex + 4] = vertexIndex + 4;
indices[indiceIndex + 5] = vertexIndex + 5;
indices[indiceIndex + 6] = vertexIndex + 4;
- indices[indiceIndex + 7] = vertexIndex + 5;
- indices[indiceIndex + 8] = vertexIndex + 6;
+ indices[indiceIndex + 7] = vertexIndex + 6;
+ indices[indiceIndex + 8] = vertexIndex + 5;
}
//Side faces.
indices[indiceIndex + 1] = vertexIndex + 1;
indices[indiceIndex + 2] = vertexIndex + 2;
indices[indiceIndex + 3] = vertexIndex + 1;
- indices[indiceIndex + 4] = vertexIndex + 2;
- indices[indiceIndex + 5] = vertexIndex + 3;
+ indices[indiceIndex + 4] = vertexIndex + 3;
+ indices[indiceIndex + 5] = vertexIndex + 2;
}
//Bottom slopes.
indices[indiceIndex + 4] = vertexIndex + 4;
indices[indiceIndex + 5] = vertexIndex + 5;
indices[indiceIndex + 6] = vertexIndex + 4;
- indices[indiceIndex + 7] = vertexIndex + 5;
- indices[indiceIndex + 8] = vertexIndex + 6;
+ indices[indiceIndex + 7] = vertexIndex + 6;
+ indices[indiceIndex + 8] = vertexIndex + 5;
}
//Bottom face.
-#ifndef DALI_TOOLKIT_INTERNAL_PRIMITIVE_RENDERER_H
-#define DALI_TOOLKIT_INTERNAL_PRIMITIVE_RENDERER_H
+#ifndef DALI_TOOLKIT_INTERNAL_PRIMITIVE_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_PRIMITIVE_VISUAL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/public-api/visuals/primitive-visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
{
/**
- * The renderer which renders a simple 3D shape to the control's quad
+ * The visual which renders a simple 3D shape to the control's quad
+ *
+ * Primitives are created with clockwise winding and back-face culling by default.
*
* The following properties are required to create a PrimitiveRender
*
*
* | %Property Name | Type | Shapes Affected |
* |-------------------|-------------|------------------------------------------|
- * | color | VECTOR4 | all |
+ * | shapeColor | VECTOR4 | all |
* | slices | INTEGER | sphere, cone, conical frustrum, cylinder |
* | stacks | INTEGER | sphere |
* | scaleTopRadius | FLOAT | conical frustrum |
*
* Note: slices and stacks both have an upper limit of 255.
*
- * Finally, the following can be used to affect the renderer's shader
+ * Finally, the following can be used to affect the visual's shader
*
* | %Property Name | Type | Representing |
* |-----------------|-------------|-----------------------------------------|
- * | uLightPosition | VECTOR3 | The position (on stage) of the light |
+ * | lightPosition | VECTOR3 | The position (on stage) of the light |
*/
-class PrimitiveRenderer: public ControlRenderer
+class PrimitiveVisual: public Visual::Base
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- PrimitiveRenderer( RendererFactoryCache& factoryCache );
+ PrimitiveVisual( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- virtual ~PrimitiveRenderer();
+ virtual ~PrimitiveVisual();
-public: // from ControlRenderer
+public: // from Visual
/**
- * @copydoc ControlRenderer::SetSize
+ * @copydoc Visual::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc ControlRenderer::SetClipRect
+ * @copydoc Visual::SetClipRect
*/
virtual void SetClipRect( const Rect<int>& clipRect );
/**
- * @copydoc ControlRenderer::SetOffset
+ * @copydoc Visual::SetOffset
*/
virtual void SetOffset( const Vector2& offset );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc ControlRenderer::DoInitialize
+ * @copydoc Visual::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
private:
- enum PrimitiveType
- {
- SPHERE,
- CONE,
- CONICAL_FRUSTRUM,
- CYLINDER,
- CUBE,
- OCTAHEDRON,
- BEVELLED_CUBE
- };
-
//Simple struct to store the position and normal of a single vertex.
struct Vertex
{
private:
// Undefined
- PrimitiveRenderer( const PrimitiveRenderer& PrimitiveRenderer );
+ PrimitiveVisual( const PrimitiveVisual& PrimitiveVisual );
// Undefined
- PrimitiveRenderer& operator=( const PrimitiveRenderer& PrimitiveRenderer );
+ PrimitiveVisual& operator=( const PrimitiveVisual& PrimitiveVisual );
private:
Shader mShader;
Geometry mGeometry;
- std::string mShape; //Shape to render, as string.
Vector4 mColor; //Color of shape.
Vector3 mObjectDimensions; //Dimensions of shape, scaled to be between 0.0 and 1.0.
int mSlices; ///< Number of slices to use when creating certain objects.
int mStacks; ///< Number of stacks to use when creating certain objects.
- PrimitiveType mPrimitiveType; //Shape to render, as enum.
+ Toolkit::PrimitiveVisual::Shape::Type mPrimitiveType; //Shape to render, as enum.
};
} // namespace Internal
} // namespace Dali
-#endif /* DALI_TOOLKIT_INTERNAL_PRIMITIVE_RENDERER_H */
+#endif /* DALI_TOOLKIT_INTERNAL_PRIMITIVE_VISUAL_H */
// INTERNAL INCLUDES
#include <dali-toolkit/third-party/nanosvg/nanosvgrast.h>
-#include <dali-toolkit/internal/controls/renderers/svg/svg-renderer.h>
+#include <dali-toolkit/internal/visuals/svg/svg-visual.h>
namespace Dali
{
namespace Internal
{
-RasterizingTask::RasterizingTask( SvgRenderer* svgRenderer, NSVGimage* parsedSvg, unsigned int width, unsigned int height )
-: mSvgRenderer( svgRenderer ),
+RasterizingTask::RasterizingTask( SvgVisual* svgRenderer, NSVGimage* parsedSvg, unsigned int width, unsigned int height )
+: mSvgVisual( svgRenderer ),
mParsedSvg( parsedSvg ),
mWidth( width ),
mHeight( height )
}
}
-SvgRenderer* RasterizingTask::GetSvgRenderer() const
+SvgVisual* RasterizingTask::GetSvgVisual() const
{
- return mSvgRenderer.Get();
+ return mSvgVisual.Get();
}
PixelData RasterizingTask::GetPixelData() const
// Older task which waiting to rasterize and apply the svg to the same renderer is expired.
for( std::vector< RasterizingTaskPtr >::iterator it = mRasterizeTasks.begin(), endIt = mRasterizeTasks.end(); it != endIt; ++it )
{
- if( (*it) && (*it)->GetSvgRenderer() == task->GetSvgRenderer() )
+ if( (*it) && (*it)->GetSvgVisual() == task->GetSvgVisual() )
{
mRasterizeTasks.erase( it );
break;
return nextTask;
}
-void SvgRasterizeThread::RemoveTask( SvgRenderer* renderer )
+void SvgRasterizeThread::RemoveTask( SvgVisual* visual )
{
// Lock while remove task from the queue
ConditionalWait::ScopedLock lock( mConditionalWait );
{
for( std::vector< RasterizingTaskPtr >::iterator it = mRasterizeTasks.begin(), endIt = mRasterizeTasks.end(); it != endIt; ++it )
{
- if( (*it) && (*it)->GetSvgRenderer() == renderer )
+ if( (*it) && (*it)->GetSvgVisual() == visual )
{
mRasterizeTasks.erase( it );
break;
namespace Internal
{
-class SvgRenderer;
-typedef IntrusivePtr< SvgRenderer > SvgRendererPtr;
+class SvgVisual;
+typedef IntrusivePtr< SvgVisual > SvgVisualPtr;
class RasterizingTask;
typedef IntrusivePtr< RasterizingTask > RasterizingTaskPtr;
* The svg rasterizing tasks to be processed in the worker thread.
*
* Life cycle of a rasterizing task is as follows:
- * 1. Created by SvgRenderer in the main thread
+ * 1. Created by SvgVisual in the main thread
* 2. Queued in the worked thread waiting to be processed.
* 3. If this task gets its turn to do the rasterization, it triggers main thread to apply the rasterized image to material then been deleted in main thread call back
- * Or if this task is been removed ( new image/size set to the renderer or actor off stage) before its turn to be processed, it then been deleted in the worker thread.
+ * Or if this task is been removed ( new image/size set to the visual or actor off stage) before its turn to be processed, it then been deleted in the worker thread.
*/
class RasterizingTask : public RefObject
{
* @param[in] width The rasterization width.
* @param[in] height The rasterization height.
*/
- RasterizingTask( SvgRenderer* svgRenderer, NSVGimage* parsedSvg, unsigned int width, unsigned int height );
+ RasterizingTask( SvgVisual* svgRenderer, NSVGimage* parsedSvg, unsigned int width, unsigned int height );
/**
* Do the rasterization with the given rasterizer.
void Rasterize( NSVGrasterizer* rasterizer );
/**
- * Get the svg renderer
+ * Get the svg visual
*/
- SvgRenderer* GetSvgRenderer() const;
+ SvgVisual* GetSvgVisual() const;
/**
* Get the rasterization result.
RasterizingTask& operator=( const RasterizingTask& task );
private:
- SvgRendererPtr mSvgRenderer;
+ SvgVisualPtr mSvgVisual;
PixelData mPixelData;
NSVGimage* mParsedSvg;
unsigned int mWidth;
RasterizingTaskPtr NextCompletedTask();
/**
- * Remove the task with the given renderer from the waiting queue, called by main thread.
+ * Remove the task with the given visual from the waiting queue, called by main thread.
*
* Typically called when the actor is put off stage, so the renderer is not needed anymore.
*
- * @param[in] renderer The renderer pointer.
+ * @param[in] visual The visual pointer.
*/
- void RemoveTask( SvgRenderer* renderer );
+ void RemoveTask( SvgVisual* visual );
/**
* Delete the parsed SVG image, called by main thread.
*/
// CLASS HEADER
-#include "svg-renderer.h"
+#include "svg-visual.h"
// EXTERNAL INCLUDES
#include <dali/public-api/images/buffer-image.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
#include <dali-toolkit/third-party/nanosvg/nanosvg.h>
-#include <dali-toolkit/internal/controls/renderers/svg/svg-rasterize-thread.h>
-#include <dali-toolkit/internal/controls/renderers/image/image-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
+#include <dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h>
+#include <dali-toolkit/internal/visuals/image/image-visual.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
namespace
namespace Internal
{
-SvgRenderer::SvgRenderer( RendererFactoryCache& factoryCache, ImageAtlasManager& atlasManager )
-: ControlRenderer( factoryCache ),
+SvgVisual::SvgVisual( VisualFactoryCache& factoryCache, ImageAtlasManager& atlasManager )
+: Visual::Base( factoryCache ),
mAtlasRect( FULL_TEXTURE_RECT ),
mAtlasManager( atlasManager ),
mParsedImage( NULL )
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
}
-SvgRenderer::~SvgRenderer()
+SvgVisual::~SvgVisual()
{
if( mParsedImage )
{
}
}
-bool SvgRenderer::IsSvgUrl( const std::string& url )
+bool SvgVisual::IsSvgUrl( const std::string& url )
{
return url.substr( url.find_last_of(".") + 1 ) == "svg";
}
-void SvgRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void SvgVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
{
- Property::Value* imageURLValue = propertyMap.Find( IMAGE_URL_NAME );
+ Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
if( imageURLValue )
{
std::string imageUrl;
}
}
-void SvgRenderer::DoSetOnStage( Actor& actor )
+void SvgVisual::DoSetOnStage( Actor& actor )
{
- Shader shader = ImageRenderer::GetImageShader( mFactoryCache );
- Geometry geometry = mFactoryCache.GetGeometry( RendererFactoryCache::QUAD_GEOMETRY );
+ Shader shader = ImageVisual::GetImageShader( mFactoryCache );
+ Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
if( !geometry )
{
geometry = mFactoryCache.CreateQuadGeometry();
- mFactoryCache.SaveGeometry( RendererFactoryCache::QUAD_GEOMETRY, geometry );
+ mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry );
}
TextureSet textureSet = TextureSet::New();
mImpl->mRenderer = Renderer::New( geometry, shader );
}
}
-void SvgRenderer::DoSetOffStage( Actor& actor )
+void SvgVisual::DoSetOffStage( Actor& actor )
{
mFactoryCache.GetSVGRasterizationThread()->RemoveTask( this );
mImpl->mRenderer.Reset();
}
-void SvgRenderer::GetNaturalSize( Vector2& naturalSize ) const
+void SvgVisual::GetNaturalSize( Vector2& naturalSize ) const
{
if( mParsedImage )
{
}
}
-void SvgRenderer::SetSize( const Vector2& size )
+void SvgVisual::SetSize( const Vector2& size )
{
if(mImpl->mSize != size && mParsedImage && GetIsOnStage() )
{
mImpl->mSize = size;
}
-void SvgRenderer::DoCreatePropertyMap( Property::Map& map ) const
+void SvgVisual::DoCreatePropertyMap( Property::Map& map ) const
{
map.Clear();
- map.Insert( RENDERER_TYPE, IMAGE_RENDERER );
+ map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
if( !mImageUrl.empty() )
{
- map.Insert( IMAGE_URL_NAME, mImageUrl );
+ map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
}
}
-void SvgRenderer::SetImage( const std::string& imageUrl, ImageDimensions size )
+void SvgVisual::SetImage( const std::string& imageUrl, ImageDimensions size )
{
if( mImageUrl != imageUrl )
{
}
}
-void SvgRenderer::AddRasterizationTask( const Vector2& size )
+void SvgVisual::AddRasterizationTask( const Vector2& size )
{
if( mImpl->mRenderer && mParsedImage )
{
}
}
-void SvgRenderer::ApplyRasterizedImage( PixelData rasterizedPixelData )
+void SvgVisual::ApplyRasterizedImage( PixelData rasterizedPixelData )
{
if( GetIsOnStage() )
{
-#ifndef __DALI_TOOLKIT_INTERNAL_SVG_RENDERER_H__
-#define __DALI_TOOLKIT_INTERNAL_SVG_RENDERER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
*/
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
-#include <dali-toolkit/internal/controls/renderers/image-atlas-manager.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
struct NSVGimage;
{
/**
- * The renderer which renders a svg image
+ * The visual which renders a svg image
*
* The following property is essential
*
* | url | STRING |
*
*/
-class SvgRenderer: public ControlRenderer
+class SvgVisual: public Visual::Base
{
public:
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- SvgRenderer( RendererFactoryCache& factoryCache, ImageAtlasManager& atlasManager );
+ SvgVisual( VisualFactoryCache& factoryCache, ImageAtlasManager& atlasManager );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- ~SvgRenderer();
+ ~SvgVisual();
-public: // from ControlRenderer
+public: // from Visual
/**
- * @copydoc ControlRenderer::GetNaturalSize
+ * @copydoc Visual::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * @copydoc ControlRenderer::SetSize
+ * @copydoc Visual::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc ControlRenderer::CreatePropertyMap
+ * @copydoc Visual::CreatePropertyMap
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
protected:
/**
- * @copydoc ControlRenderer::DoInitialize
+ * @copydoc Visual::DoInitialize
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc ControlRenderer::DoSetOnStage
+ * @copydoc Visual::DoSetOnStage
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * @copydoc ControlRenderer::DoSetOffStage
+ * @copydoc Visual::DoSetOffStage
*/
virtual void DoSetOffStage( Actor& actor );
static bool IsSvgUrl( const std::string& url );
/**
- * @brief Sets the svg image of this renderer to the resource at imageUrl
- * The renderer will parse the svg image once it is set.
+ * @brief Sets the svg image of this visual to the resource at imageUrl
+ * The visual will parse the svg image once it is set.
* And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
*
* @param[in] imageUrl The URL to svg resource to use
void SetImage( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
/**
- * @bried Apply the rasterized image to the renderer.
+ * @bried Apply the rasterized image to the visual.
*
* @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
*/
private:
/**
- * @bried Rasterize the svg with the given size, and add it to the renderer.
+ * @bried Rasterize the svg with the given size, and add it to the visual.
*
* @param[in] size The target size of the SVG rasterization.
*/
// Undefined
- SvgRenderer( const SvgRenderer& svgRenderer );
+ SvgVisual( const SvgVisual& svgRenderer );
// Undefined
- SvgRenderer& operator=( const SvgRenderer& svgRenderer );
+ SvgVisual& operator=( const SvgVisual& svgRenderer );
private:
Vector4 mAtlasRect;
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_SVG_RENDERER_H__ */
+#endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */
--- /dev/null
+/*
+ * Copyright (c) 2016 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 <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( SHADER_HINT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, NONE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, OUTPUT_IS_TRANSPARENT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, MODIFIES_GEOMETRY )
+DALI_ENUM_TO_STRING_TABLE_END( SHADER_HINT )
+
+} // unnamed namespace
+
+Internal::Visual::Base::Impl::Impl()
+: mCustomShader(NULL),
+ mDepthIndex( 0.0f ),
+ mFlags( 0 )
+{
+}
+
+Internal::Visual::Base::Impl::~Impl()
+{
+ delete mCustomShader;
+}
+
+Internal::Visual::Base::Impl::CustomShader::CustomShader( const Property::Map& map )
+: mGridSize( 1, 1 ),
+ mHints( Shader::Hint::NONE )
+{
+ SetPropertyMap( map );
+}
+
+void Internal::Visual::Base::Impl::CustomShader::SetPropertyMap( const Property::Map& shaderMap )
+{
+ mVertexShader.clear();
+ mFragmentShader.clear();
+ mGridSize = ImageDimensions( 1, 1 );
+ mHints = Shader::Hint::NONE;
+
+ Property::Value* vertexShaderValue = shaderMap.Find( Toolkit::Visual::Shader::Property::VERTEX_SHADER, CUSTOM_VERTEX_SHADER );
+ if( vertexShaderValue )
+ {
+ if( !vertexShaderValue->Get( mVertexShader ) )
+ {
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_VERTEX_SHADER );
+ }
+ }
+
+ Property::Value* fragmentShaderValue = shaderMap.Find( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, CUSTOM_FRAGMENT_SHADER );
+ if( fragmentShaderValue )
+ {
+ if( !fragmentShaderValue->Get( mFragmentShader ) )
+ {
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_FRAGMENT_SHADER );
+ }
+ }
+
+ Property::Value* subdivideXValue = shaderMap.Find( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X, CUSTOM_SUBDIVIDE_GRID_X );
+ if( subdivideXValue )
+ {
+ int subdivideX;
+ if( !subdivideXValue->Get( subdivideX ) || subdivideX < 1 )
+ {
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_X );
+ }
+ else
+ {
+ mGridSize = ImageDimensions( subdivideX, mGridSize.GetY() );
+ }
+ }
+
+ Property::Value* subdivideYValue = shaderMap.Find( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y, CUSTOM_SUBDIVIDE_GRID_Y );
+ if( subdivideYValue )
+ {
+ int subdivideY;
+ if( !subdivideYValue->Get( subdivideY ) || subdivideY < 1 )
+ {
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_Y );
+ }
+ else
+ {
+ mGridSize = ImageDimensions( mGridSize.GetX(), subdivideY );
+ }
+ }
+
+ Property::Value* hintsValue = shaderMap.Find( Toolkit::Visual::Shader::Property::HINTS, CUSTOM_SHADER_HINTS );
+ if( hintsValue )
+ {
+ if ( ! Scripting::GetBitmaskEnumerationProperty( *hintsValue, SHADER_HINT_TABLE, SHADER_HINT_TABLE_COUNT, mHints ) )
+ {
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint or an array of hint strings", CUSTOM_SHADER_HINTS );
+ }
+ }
+}
+
+void Internal::Visual::Base::Impl::CustomShader::CreatePropertyMap( Property::Map& map ) const
+{
+ if( !mVertexShader.empty() || !mFragmentShader.empty() )
+ {
+ Property::Map customShader;
+ if( !mVertexShader.empty() )
+ {
+ customShader.Insert( Toolkit::Visual::Shader::Property::VERTEX_SHADER, mVertexShader );
+ }
+ if( !mFragmentShader.empty() )
+ {
+ customShader.Insert( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, mFragmentShader );
+ }
+
+ if( mGridSize.GetWidth() != 1 )
+ {
+ customShader.Insert( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X, mGridSize.GetWidth() );
+ }
+ if( mGridSize.GetHeight() != 1 )
+ {
+ customShader.Insert( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y, mGridSize.GetHeight() );
+ }
+
+ if( mHints != Dali::Shader::Hint::NONE )
+ {
+ customShader.Insert( Toolkit::Visual::Shader::Property::HINTS, static_cast< int >( mHints ) );
+ }
+
+ map.Insert( Toolkit::Visual::Property::SHADER, customShader );
+ }
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
-#ifndef DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_DATA_IMPL_H
-#define DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_DATA_IMPL_H
+#ifndef DALI_TOOLKIT_INTERNAL_VISUAL_BASE_DATA_IMPL_H
+#define DALI_TOOLKIT_INTERNAL_VISUAL_BASE_DATA_IMPL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
#include <dali/public-api/rendering/renderer.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
namespace Internal
{
-struct Internal::ControlRenderer::Impl
+namespace Visual
+{
+
+struct Base::Impl
{
enum Flags
{
std::string mVertexShader;
std::string mFragmentShader;
Dali::ImageDimensions mGridSize;
- Dali::Shader::ShaderHints mHints; //(bitfield) values from enum Shader::Hints
+ Dali::Shader::Hint::Value mHints; //(bitfield) values from enum Shader::Hint
CustomShader( const Property::Map& map );
void SetPropertyMap( const Property::Map& map );
~Impl();
};
+} // namespace Visual
+
} // namespace Internal
} // namespace Toolkit
} // namespace Dali
-#endif // DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_DATA_IMPL_H
+#endif // DALI_TOOLKIT_INTERNAL_VISUAL_BASE_DATA_IMPL_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*/
// CLASS HEADER
-#include "control-renderer-impl.h"
+#include "visual-base-impl.h"
// EXTERNAL HEADER
#include <dali/public-api/common/dali-common.h>
#include <dali/integration-api/debug.h>
//INTERNAL HEARDER
-#include <dali-toolkit/internal/controls/renderers/control-renderer-data-impl.h>
-
-namespace
-{
-//custom shader
-const char * const CUSTOM_SHADER( "shader" );
-const char * const CUSTOM_VERTEX_SHADER( "vertexShader" );
-const char * const CUSTOM_FRAGMENT_SHADER( "fragmentShader" );
-const char * const CUSTOM_SUBDIVIDE_GRID_X( "subdivideGridX" );
-const char * const CUSTOM_SUBDIVIDE_GRID_Y( "subdivideGridY" );
-const char * const CUSTOM_SHADER_HINTS( "hints" ); ///< type INTEGER; (bitfield) values from enum Shader::Hints
-}
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
namespace Dali
{
namespace Internal
{
-ControlRenderer::ControlRenderer( RendererFactoryCache& factoryCache )
+namespace Visual
+{
+
+Base::Base( VisualFactoryCache& factoryCache )
: mImpl( new Impl() ),
mFactoryCache( factoryCache )
{
}
-ControlRenderer::~ControlRenderer()
+Base::~Base()
{
delete mImpl;
}
-void ControlRenderer::SetCustomShader( const Property::Map& shaderMap )
+void Base::SetCustomShader( const Property::Map& shaderMap )
{
if( mImpl->mCustomShader )
{
}
}
-void ControlRenderer::Initialize( Actor& actor, const Property::Map& propertyMap )
+void Base::Initialize( Actor& actor, const Property::Map& propertyMap )
{
- Property::Value* customShaderValue = propertyMap.Find( CUSTOM_SHADER );
+ Property::Value* customShaderValue = propertyMap.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
if( customShaderValue )
{
Property::Map shaderMap;
DoInitialize( actor, propertyMap );
}
-void ControlRenderer::SetSize( const Vector2& size )
+void Base::SetSize( const Vector2& size )
{
mImpl->mSize = size;
}
-const Vector2& ControlRenderer::GetSize() const
+const Vector2& Base::GetSize() const
{
return mImpl->mSize;
}
-void ControlRenderer::GetNaturalSize( Vector2& naturalSize ) const
+void Base::GetNaturalSize( Vector2& naturalSize ) const
{
naturalSize = Vector2::ZERO;
}
-void ControlRenderer::SetClipRect( const Rect<int>& clipRect )
+void Base::SetClipRect( const Rect<int>& clipRect )
{
}
-void ControlRenderer::SetOffset( const Vector2& offset )
+void Base::SetOffset( const Vector2& offset )
{
mImpl->mOffset = offset;
}
-void ControlRenderer::SetDepthIndex( float index )
+void Base::SetDepthIndex( float index )
{
mImpl->mDepthIndex = index;
if( mImpl->mRenderer )
}
}
-float ControlRenderer::GetDepthIndex() const
+float Base::GetDepthIndex() const
{
return mImpl->mDepthIndex;
}
-void ControlRenderer::SetOnStage( Actor& actor )
+void Base::SetOnStage( Actor& actor )
{
DoSetOnStage( actor );
mImpl->mFlags |= Impl::IS_ON_STAGE;
}
-void ControlRenderer::SetOffStage( Actor& actor )
+void Base::SetOffStage( Actor& actor )
{
if( GetIsOnStage() )
{
}
}
-void ControlRenderer::EnablePreMultipliedAlpha( bool preMultipled )
+void Base::EnablePreMultipliedAlpha( bool preMultipled )
{
if(preMultipled)
{
}
}
-bool ControlRenderer::IsPreMultipliedAlphaEnabled() const
+bool Base::IsPreMultipliedAlphaEnabled() const
{
return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
}
-void ControlRenderer::DoSetOnStage( Actor& actor )
+void Base::DoSetOnStage( Actor& actor )
{
}
-void ControlRenderer::DoSetOffStage( Actor& actor )
+void Base::DoSetOffStage( Actor& actor )
{
actor.RemoveRenderer( mImpl->mRenderer );
mImpl->mRenderer.Reset();
}
-void ControlRenderer::CreatePropertyMap( Property::Map& map ) const
+void Base::CreatePropertyMap( Property::Map& map ) const
{
DoCreatePropertyMap( map );
}
}
-bool ControlRenderer::GetIsOnStage() const
+bool Base::GetIsOnStage() const
{
return mImpl->mFlags & Impl::IS_ON_STAGE;
}
-bool ControlRenderer::GetIsFromCache() const
+bool Base::GetIsFromCache() const
{
return mImpl->mFlags & Impl::IS_FROM_CACHE;
}
+} // namespace Visual
+
} // namespace Internal
} // namespace Toolkit
-#ifndef DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H
-#define DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H
+#ifndef DALI_TOOLKIT_INTERNAL_VISUAL_H
+#define DALI_TOOLKIT_INTERNAL_VISUAL_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
#include <dali/public-api/rendering/shader.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
namespace Dali
{
namespace Internal
{
+namespace Visual
+{
+
/**
- * Base class for all Control rendering logic. A control may have multiple control renderers.
+ * Base class for all Control rendering logic. A control may have multiple visuals.
*
- * Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
+ * Note: The visual responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
*
* The following properties are optional
*
* | subdivideGridY | INT |
* | shaderHints | INT |
*/
-class ControlRenderer : public BaseObject
+class Base : public BaseObject
{
public:
/**
- * Initialisation of the renderer, this API should only called by the RendererFactory:
+ * Initialisation of the visual, this API should only called by the VisualFactory:
* request the geometry and shader from the cache, if not available, create and save to the cache for sharing;
* record the property values.
*
- * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
- * @param[in] propertyMap The properties for the requested ControlRenderer object.
+ * @param[in] actor The Actor the visual is applied to if, empty if the visual has not been applied to any Actor
+ * @param[in] propertyMap The properties for the requested Visual object.
*/
void Initialize( Actor& actor, const Property::Map& propertyMap );
/**
- * @copydoc Toolkit::ControlRenderer::SetSize
+ * @copydoc Toolkit::Visual::Base::SetSize
*/
virtual void SetSize( const Vector2& size );
/**
- * @copydoc Toolkit::ControlRenderer::GetSize
+ * @copydoc Toolkit::Visual::Base::GetSize
*/
const Vector2& GetSize() const;
/**
- * @copydoc Toolkit::ControlRenderer::GetNaturalSize
+ * @copydoc Toolkit::Visual::Base::GetNaturalSize
*/
virtual void GetNaturalSize( Vector2& naturalSize ) const;
/**
- * ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
+ * ToDo: Add this function to Toolkit::Visual when it is fully implemented.
*
- * Set the clip rectangular of this renderer.
- * The contents of the renderer will not be visible outside this rectangular.
+ * Set the clip rectangular of this visual.
+ * The contents of the visual will not be visible outside this rectangular.
*
* @param [in] clipRect The clipping rectangular.
*/
virtual void SetClipRect( const Rect<int>& clipRect );
/**
- *ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
+ *ToDo: Add this function to Toolkit::Visual when it is fully implemented.
*
- * Reposition this renderer with a 2D offset.
+ * Reposition this visual with a 2D offset.
*
- * @param[in] offset The offset to reposition the renderer.
+ * @param[in] offset The offset to reposition the visual.
*/
virtual void SetOffset( const Vector2& offset );
/**
- * @copydoc Toolkit::ControlRenderer::SetDepthIndex
+ * @copydoc Toolkit::Visual::Base::SetDepthIndex
*/
void SetDepthIndex( float index );
/**
- * @copydoc Toolkit::ControlRenderer::GetDepthIndex
+ * @copydoc Toolkit::Visual::Base::GetDepthIndex
*/
float GetDepthIndex() const;
/**
- * @copydoc Toolkit::ControlRenderer::SetOnStage
+ * @copydoc Toolkit::Visual::Base::SetOnStage
* @pre Impl->mGeometry must be created before this method is called
*/
void SetOnStage( Actor& actor );
/**
- * @copydoc Toolkit::ControlRenderer::SetOffStage
+ * @copydoc Toolkit::Visual::Base::SetOffStage
*/
void SetOffStage( Actor& actor );
/**
- * @copydoc Toolkit::ControlRenderer::CreatePropertyMap
+ * @copydoc Toolkit::Visual::Base::CreatePropertyMap
*/
void CreatePropertyMap( Property::Map& map ) const;
/**
* @brief Constructor.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
- ControlRenderer( RendererFactoryCache& factoryCache );
+ Base( VisualFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
- virtual ~ControlRenderer();
+ virtual ~Base();
protected:
/**
* @brief Called by CreatePropertyMap() allowing sub classes to respond to the CreatePropertyMap event
*
- * @param[out] map The renderer property map.
+ * @param[out] map The visual property map.
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const = 0;
/**
* @brief Called by Initialize() allowing sub classes to respond to the Initialize event
*
- * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
- * @param[in] propertyMap The properties for the requested ControlRenderer object.
+ * @param[in] actor The Actor the visual is applied to if, empty if the visual has not been applied to any Actor
+ * @param[in] propertyMap The properties for the requested Visual object.
*/
virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap ) {};
/**
* @brief Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
*
- * @param[in] actor The actor applying this renderer.
+ * @param[in] actor The actor applying this visual.
*/
virtual void DoSetOnStage( Actor& actor );
/**
* @brief Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
*
- * @param[in] actor The actor applying this renderer.
+ * @param[in] actor The actor applying this visual.
*/
virtual void DoSetOffStage( Actor& actor );
protected:
/**
- * @brief Gets the on stage state for this ControlRenderer
+ * @brief Gets the on stage state for this Visual
*
- * @return Returns true if this ControlRenderer is on stage, false if it is off the stage
+ * @return Returns true if this Visual is on stage, false if it is off the stage
*/
bool GetIsOnStage() const;
private:
// Undefined
- ControlRenderer( const ControlRenderer& renderer );
+ Base( const Visual::Base& visual );
// Undefined
- ControlRenderer& operator=( const ControlRenderer& renderer );
+ Base& operator=( const Visual::Base& visual );
protected:
struct Impl;
Impl* mImpl;
- RendererFactoryCache& mFactoryCache;
+ VisualFactoryCache& mFactoryCache;
};
+} // namspace Visual
+
} // namespace Internal
-inline const Internal::ControlRenderer& GetImplementation(const Toolkit::ControlRenderer& renderer)
+inline const Internal::Visual::Base& GetImplementation(const Toolkit::Visual::Base& visualBase )
{
- DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
+ DALI_ASSERT_ALWAYS( visualBase && "visual base handle is empty" );
- const BaseObject& handle = renderer.GetBaseObject();
+ const BaseObject& handle = visualBase.GetBaseObject();
- return static_cast<const Internal::ControlRenderer&>(handle);
+ return static_cast<const Internal::Visual::Base&>(handle);
}
-inline Internal::ControlRenderer& GetImplementation(Toolkit::ControlRenderer& renderer)
+inline Internal::Visual::Base& GetImplementation(Toolkit::Visual::Base& visualBase)
{
- DALI_ASSERT_ALWAYS( renderer && "ControlRenderer handle is empty" );
+ DALI_ASSERT_ALWAYS( visualBase && "visual base handle is empty" );
- BaseObject& handle = renderer.GetBaseObject();
+ BaseObject& handle = visualBase.GetBaseObject();
- return static_cast<Internal::ControlRenderer&>(handle);
+ return static_cast<Internal::Visual::Base&>(handle);
}
} // namespace Toolkit
} // namespace Dali
-#endif // DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H
+#endif // DALI_TOOLKIT_INTERNAL_VISUAL_H
*/
// CLASS HEADER
-#include "renderer-factory-cache.h"
+#include "visual-factory-cache.h"
// EXTERNAL HEADER
#include <dali/devel-api/common/hash.h>
// INTERNAL HEADER
-#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/svg/svg-renderer.h>
+#include <dali-toolkit/internal/visuals/color/color-visual.h>
+#include <dali-toolkit/internal/visuals/svg/svg-visual.h>
namespace Dali
{
namespace Internal
{
-RendererFactoryCache::RendererFactoryCache()
+VisualFactoryCache::VisualFactoryCache()
: mSvgRasterizeThread( NULL )
{
}
-RendererFactoryCache::~RendererFactoryCache()
+VisualFactoryCache::~VisualFactoryCache()
{
SvgRasterizeThread::TerminateThread( mSvgRasterizeThread );
}
-Geometry RendererFactoryCache::GetGeometry( GeometryType type )
+Geometry VisualFactoryCache::GetGeometry( GeometryType type )
{
return mGeometry[type];
}
-void RendererFactoryCache::SaveGeometry( GeometryType type, Geometry geometry )
+void VisualFactoryCache::SaveGeometry( GeometryType type, Geometry geometry )
{
mGeometry[type] = geometry;
}
-Shader RendererFactoryCache::GetShader( ShaderType type )
+Shader VisualFactoryCache::GetShader( ShaderType type )
{
return mShader[type];
}
-void RendererFactoryCache::SaveShader( ShaderType type, Shader shader )
+void VisualFactoryCache::SaveShader( ShaderType type, Shader shader )
{
mShader[type] = shader;
}
-int RendererFactoryCache::FindRenderer( const std::string& key ) const
+int VisualFactoryCache::FindRenderer( const std::string& key ) const
{
int hash = Dali::CalculateHash( key );
return -1;
}
-Renderer RendererFactoryCache::GetRenderer( const std::string& key ) const
+Renderer VisualFactoryCache::GetRenderer( const std::string& key ) const
{
int index = FindRenderer( key );
if( index != -1 )
}
}
-void RendererFactoryCache::SaveRenderer( const std::string& key, Renderer& renderer )
+void VisualFactoryCache::SaveRenderer( const std::string& key, Renderer& renderer )
{
int hash = Dali::CalculateHash( key );
const CachedRenderer* cachedRenderer = new CachedRenderer( key, renderer );
}
}
-bool RendererFactoryCache::CleanRendererCache( const std::string& key )
+bool VisualFactoryCache::CleanRendererCache( const std::string& key )
{
int index = FindRenderer( key );
if( index != -1 )
return false;
}
-void RendererFactoryCache::CacheDebugRenderer( Renderer& renderer )
+void VisualFactoryCache::CacheDebugRenderer( Renderer& renderer )
{
mDebugRenderer = renderer;
}
-Renderer RendererFactoryCache::GetDebugRenderer()
+Renderer VisualFactoryCache::GetDebugRenderer()
{
return mDebugRenderer;
}
-Geometry RendererFactoryCache::CreateQuadGeometry()
+Geometry VisualFactoryCache::CreateQuadGeometry()
{
const float halfWidth = 0.5f;
const float halfHeight = 0.5f;
// Create the geometry object
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( quadVertices );
- geometry.SetGeometryType( Geometry::TRIANGLE_STRIP );
+ geometry.SetType( Geometry::TRIANGLE_STRIP );
return geometry;
}
-SvgRasterizeThread* RendererFactoryCache::GetSVGRasterizationThread()
+SvgRasterizeThread* VisualFactoryCache::GetSVGRasterizationThread()
{
if( !mSvgRasterizeThread )
{
- mSvgRasterizeThread = new SvgRasterizeThread( new EventThreadCallback( MakeCallback( this, &RendererFactoryCache::ApplyRasterizedSVGToSampler ) ) );
+ mSvgRasterizeThread = new SvgRasterizeThread( new EventThreadCallback( MakeCallback( this, &VisualFactoryCache::ApplyRasterizedSVGToSampler ) ) );
mSvgRasterizeThread->Start();
}
return mSvgRasterizeThread;
}
-void RendererFactoryCache::ApplyRasterizedSVGToSampler()
+void VisualFactoryCache::ApplyRasterizedSVGToSampler()
{
while( RasterizingTaskPtr task = mSvgRasterizeThread->NextCompletedTask() )
{
- task->GetSvgRenderer()->ApplyRasterizedImage( task->GetPixelData() );
+ task->GetSvgVisual()->ApplyRasterizedImage( task->GetPixelData() );
}
}
-Geometry RendererFactoryCache::CreateGridGeometry( Uint16Pair gridSize )
+Geometry VisualFactoryCache::CreateGridGeometry( Uint16Pair gridSize )
{
uint16_t gridWidth = gridSize.GetWidth();
uint16_t gridHeight = gridSize.GetHeight();
geometry.SetIndexBuffer( &indices[ 0 ], indices.Size() );
}
- geometry.SetGeometryType( Geometry::TRIANGLE_STRIP );
+ geometry.SetType( Geometry::TRIANGLE_STRIP );
return geometry;
}
-#ifndef DALI_TOOLKIT_RENDERER_FACTORY_CACHE_H
-#define DALI_TOOLKIT_RENDERER_FACTORY_CACHE_H
+#ifndef DALI_TOOLKIT_VISUAL_FACTORY_CACHE_H
+#define DALI_TOOLKIT_VISUAL_FACTORY_CACHE_H
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
{
/**
- * Caches shaders and geometries. Owned by RenderFactory.
+ * Caches shaders and geometries. Owned by VisualFactory.
*/
-class RendererFactoryCache : public RefObject
+class VisualFactoryCache : public RefObject
{
public:
/**
* @brief Constructor
*/
- RendererFactoryCache();
+ VisualFactoryCache();
/**
* Request geometry of the given type.
/**
* A reference counted object may only be deleted by calling Unreference()
*/
- virtual ~RendererFactoryCache();
+ virtual ~VisualFactoryCache();
/**
* Undefined copy constructor.
*/
- RendererFactoryCache(const RendererFactoryCache&);
+ VisualFactoryCache(const VisualFactoryCache&);
/**
* Undefined assignment operator.
*/
- RendererFactoryCache& operator=(const RendererFactoryCache& rhs);
+ VisualFactoryCache& operator=(const VisualFactoryCache& rhs);
private:
struct CachedRenderer
typedef Dali::OwnerContainer< const CachedRenderer* > CachedRenderers;
/**
- * @brief Finds the first index into the cached renderers from the url
+ * @brief Finds the first index into the cached visuals from the url
*
* @return Returns the first index into the cached renderer from the url if it exists in the cache, otherwise returns -1
*/
} // namespace Dali
-#endif // DALI_TOOLKIT_RENDERER_FACTORY_CACHE_H
+#endif // DALI_TOOLKIT_VISUAL_FACTORY_CACHE_H
--- /dev/null
+ /*
+ * Copyright (c) 2016 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 <dali-toolkit/internal/visuals/visual-factory-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/visuals/border/border-visual.h>
+#include <dali-toolkit/internal/visuals/color/color-visual.h>
+#include <dali-toolkit/internal/visuals/debug/debug-visual.h>
+#include <dali-toolkit/internal/visuals/gradient/gradient-visual.h>
+#include <dali-toolkit/internal/visuals/npatch/npatch-visual.h>
+#include <dali-toolkit/internal/visuals/image/image-visual.h>
+#include <dali-toolkit/internal/visuals/svg/svg-visual.h>
+#include <dali-toolkit/internal/visuals/mesh/mesh-visual.h>
+#include <dali-toolkit/internal/visuals/primitive/primitive-visual.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
+
+namespace
+{
+const char * const BROKEN_VISUAL_IMAGE_URL( DALI_IMAGE_DIR "broken.png");
+}
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( VISUAL_TYPE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, BORDER )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, COLOR )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, GRADIENT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, IMAGE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, MESH )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, PRIMITIVE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, DEBUG )
+DALI_ENUM_TO_STRING_TABLE_END( VISUAL_TYPE )
+
+const char * const VISUAL_TYPE( "visualType" );
+
+BaseHandle Create()
+{
+ BaseHandle handle = Toolkit::VisualFactory::Get();
+
+ return handle;
+}
+
+DALI_TYPE_REGISTRATION_BEGIN_CREATE( Toolkit::VisualFactory, Dali::BaseHandle, Create, true )
+DALI_TYPE_REGISTRATION_END()
+
+} // namespace
+
+VisualFactory::VisualFactory( bool debugEnabled )
+:mDebugEnabled( debugEnabled )
+{
+}
+
+VisualFactory::~VisualFactory()
+{
+}
+
+Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& propertyMap )
+{
+ // Create factory cache if it hasn't already been
+ if( !mFactoryCache )
+ {
+ mFactoryCache = new VisualFactoryCache();
+ }
+
+ // Return a new DebugVisual if we have debug enabled
+ if( mDebugEnabled )
+ {
+ return Toolkit::Visual::Base( new DebugVisual( *( mFactoryCache.Get() ) ) );
+ }
+
+ Visual::Base* visualPtr = NULL;
+
+ Property::Value* typeValue = propertyMap.Find( Toolkit::Visual::Property::TYPE, VISUAL_TYPE );
+ Toolkit::Visual::Type visualType = Toolkit::Visual::IMAGE; // Default to IMAGE type
+ if( typeValue )
+ {
+ Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, visualType );
+ }
+
+ switch( visualType )
+ {
+ case Toolkit::Visual::BORDER:
+ {
+ visualPtr = new BorderVisual( *( mFactoryCache.Get() ) );
+ break;
+ }
+
+ case Toolkit::Visual::COLOR:
+ {
+ visualPtr = new ColorVisual( *( mFactoryCache.Get() ) );
+ break;
+ }
+
+ case Toolkit::Visual::GRADIENT:
+ {
+ visualPtr = new GradientVisual( *( mFactoryCache.Get() ) );
+ break;
+ }
+
+ default: // Default to Image type if unknown (check if there is a URL)
+ case Toolkit::Visual::IMAGE:
+ {
+ Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
+ std::string imageUrl;
+ if( imageURLValue && imageURLValue->Get( imageUrl ) )
+ {
+ if( NinePatchImage::IsNinePatchUrl( imageUrl ) )
+ {
+ visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
+ }
+ else
+ {
+ CreateAtlasManager();
+
+ if( SvgVisual::IsSvgUrl( imageUrl ) )
+ {
+ visualPtr = new SvgVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
+ }
+ else
+ {
+ visualPtr = new ImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
+ }
+ }
+ }
+ else if( propertyMap.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER ) )
+ {
+ // Create Image Visual if it has a shader
+ // TODO: This is required because of EffectsView which should be fixed
+ CreateAtlasManager();
+ visualPtr = new ImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
+ }
+ break;
+ }
+
+ case Toolkit::Visual::MESH:
+ {
+ visualPtr = new MeshVisual( *( mFactoryCache.Get() ) );
+ break;
+ }
+
+ case Toolkit::Visual::PRIMITIVE:
+ {
+ visualPtr = new PrimitiveVisual( *( mFactoryCache.Get() ) );
+ break;
+ }
+
+ case Toolkit::Visual::DEBUG:
+ {
+ visualPtr = new DebugVisual( *( mFactoryCache.Get() ) );
+ break;
+ }
+ }
+
+ if( visualPtr )
+ {
+ Actor actor;
+ visualPtr->Initialize( actor, propertyMap );
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Renderer type unknown" );
+ }
+
+ return Toolkit::Visual::Base( visualPtr );
+}
+
+Toolkit::Visual::Base VisualFactory::CreateVisual( const Image& image )
+{
+ if( !mFactoryCache )
+ {
+ mFactoryCache = new VisualFactoryCache();
+ }
+
+ if( mDebugEnabled )
+ {
+ return Toolkit::Visual::Base( new DebugVisual( *( mFactoryCache.Get() ) ) );
+ }
+
+ NinePatchImage npatchImage = NinePatchImage::DownCast( image );
+ if( npatchImage )
+ {
+ NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
+ visualPtr->SetImage( npatchImage );
+
+ return Toolkit::Visual::Base( visualPtr );
+ }
+ else
+ {
+ CreateAtlasManager();
+ ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
+ Actor actor;
+ visualPtr->SetImage( actor, image );
+
+ return Toolkit::Visual::Base( visualPtr );
+ }
+}
+
+Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, ImageDimensions size )
+{
+ if( !mFactoryCache )
+ {
+ mFactoryCache = new VisualFactoryCache();
+ }
+
+ if( mDebugEnabled )
+ {
+ return Toolkit::Visual::Base( new DebugVisual( *( mFactoryCache.Get() ) ) );
+ }
+
+ if( NinePatchImage::IsNinePatchUrl( url ) )
+ {
+ NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
+ visualPtr->SetImage( url );
+
+ return Toolkit::Visual::Base( visualPtr );
+ }
+ else if( SvgVisual::IsSvgUrl( url ) )
+ {
+ CreateAtlasManager();
+ SvgVisual* visualPtr = new SvgVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
+ visualPtr->SetImage( url, size );
+ return Toolkit::Visual::Base( visualPtr );
+ }
+ else
+ {
+ CreateAtlasManager();
+ ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
+ Actor actor;
+ visualPtr->SetImage( actor, url, size );
+
+ return Toolkit::Visual::Base( visualPtr );
+ }
+}
+
+Image VisualFactory::GetBrokenVisualImage()
+{
+ return ResourceImage::New( BROKEN_VISUAL_IMAGE_URL );
+}
+
+void VisualFactory::CreateAtlasManager()
+{
+ if( !mAtlasManager )
+ {
+ Shader shader = ImageVisual::GetImageShader( *( mFactoryCache.Get() ) );
+ mAtlasManager = new ImageAtlasManager();
+ mAtlasManager->SetBrokenImage( BROKEN_VISUAL_IMAGE_URL );
+ }
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H
+#define DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H
+
+/*
+ * Copyright (c) 2016 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 <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+class VisualFactoryCache;
+typedef IntrusivePtr<VisualFactoryCache> VisualFactoryCachePtr;
+
+class ImageAtlasManager;
+typedef IntrusivePtr<ImageAtlasManager> ImageAtlasManagerPtr;
+
+/**
+ * @copydoc Toolkit::VisualFactory
+ */
+class VisualFactory : public BaseObject
+{
+public:
+
+ /**
+ * @brief Constructor
+ *
+ * @param[in] debugEnabled If true, use debug renderer to replace all the concrete renderer.
+ */
+ VisualFactory( bool debugEnabled );
+
+ /**
+ * @copydoc Toolkit::RenderFactory::CreateVisual( const Property::Map& )
+ */
+ Toolkit::Visual::Base CreateVisual( const Property::Map& propertyMap );
+
+ /**
+ * @copydoc Toolkit::RenderFactory::CreateVisual( const Image& )
+ */
+ Toolkit::Visual::Base CreateVisual( const Image& image );
+
+ /**
+ * @copydoc Toolkit::RenderFactory::CreateVisual( const std::string&, ImageDimensions )
+ */
+ Toolkit::Visual::Base CreateVisual( const std::string& image, ImageDimensions size );
+
+public:
+ /**
+ * @brief Returns an image to be used when a visual has failed to correctly render
+ */
+ static Image GetBrokenVisualImage();
+
+protected:
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~VisualFactory();
+
+private:
+
+ /**
+ * Prepare the atlas manager
+ */
+ void CreateAtlasManager();
+
+ /**
+ * Undefined copy constructor.
+ */
+ VisualFactory(const VisualFactory&);
+
+ /**
+ * Undefined assignment operator.
+ */
+ VisualFactory& operator=(const VisualFactory& rhs);
+
+private:
+
+ VisualFactoryCachePtr mFactoryCache;
+ ImageAtlasManagerPtr mAtlasManager;
+ bool mDebugEnabled;
+};
+
+} // namespace Internal
+
+inline const Internal::VisualFactory& GetImplementation(const Toolkit::VisualFactory& factory)
+{
+ DALI_ASSERT_ALWAYS( factory && "VisualFactory handle is empty" );
+
+ const BaseObject& handle = factory.GetBaseObject();
+
+ return static_cast<const Internal::VisualFactory&>(handle);
+}
+
+inline Internal::VisualFactory& GetImplementation(Toolkit::VisualFactory& factory)
+{
+ DALI_ASSERT_ALWAYS( factory && "VisualFactory handle is empty" );
+
+ BaseObject& handle = factory.GetBaseObject();
+
+ return static_cast<Internal::VisualFactory&>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H */
--- /dev/null
+ /*
+ * Copyright (c) 2016 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 "visual-string-constants.h"
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+// Custom shader
+const char * const CUSTOM_SHADER( "shader" );
+const char * const CUSTOM_VERTEX_SHADER( "vertexShader" );
+const char * const CUSTOM_FRAGMENT_SHADER( "fragmentShader" );
+const char * const CUSTOM_SUBDIVIDE_GRID_X( "subdivideGridX" );
+const char * const CUSTOM_SUBDIVIDE_GRID_Y( "subdivideGridY" );
+const char * const CUSTOM_SHADER_HINTS( "hints" );
+
+// Image visual
+const char * const IMAGE_URL_NAME("url");
+const char * const ATLAS_RECT_UNIFORM_NAME ( "uAtlasRect" );
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_VISUAL_STRING_CONSTANTS_H
+#define DALI_TOOLKIT_INTERNAL_VISUAL_STRING_CONSTANTS_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+// Custom shader
+extern const char * const CUSTOM_SHADER;
+extern const char * const CUSTOM_VERTEX_SHADER;
+extern const char * const CUSTOM_FRAGMENT_SHADER;
+extern const char * const CUSTOM_SUBDIVIDE_GRID_X;
+extern const char * const CUSTOM_SUBDIVIDE_GRID_Y;
+extern const char * const CUSTOM_SHADER_HINTS;
+
+// Image visual
+extern const char * const IMAGE_URL_NAME;
+extern const char * const ATLAS_RECT_UNIFORM_NAME;
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* DALI_TOOLKIT_INTERNAL_VISUAL_STRING_CONSTANTS_H */
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
-#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
+#include <dali-toolkit/internal/visuals/color/color-visual.h>
namespace Dali
{
Impl(Control& controlImpl)
: mControlImpl( controlImpl ),
mStyleName(""),
- mBackgroundRenderer(),
+ mBackgroundVisual(),
mBackgroundColor(Color::TRANSPARENT),
mStartingPinchScale( NULL ),
mKeyEventSignal(),
{
DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
Property::Map map;
- if( controlImpl.mImpl->mBackgroundRenderer )
+ if( controlImpl.mImpl->mBackgroundVisual )
{
- controlImpl.mImpl->mBackgroundRenderer.CreatePropertyMap( map );
+ controlImpl.mImpl->mBackgroundVisual.CreatePropertyMap( map );
}
value = map;
break;
case Toolkit::Control::Property::BACKGROUND:
{
Property::Map map;
- if( controlImpl.mImpl->mBackgroundRenderer )
+ if( controlImpl.mImpl->mBackgroundVisual )
{
- (controlImpl.mImpl->mBackgroundRenderer).CreatePropertyMap( map );
+ (controlImpl.mImpl->mBackgroundVisual).CreatePropertyMap( map );
}
value = map;
Control& mControlImpl;
std::string mStyleName;
- Toolkit::ControlRenderer mBackgroundRenderer; ///< The control renderer to render the background
- Vector4 mBackgroundColor; ///< The color of the background renderer
+ Toolkit::Visual::Base mBackgroundVisual; ///< The visual to render the background
+ Vector4 mBackgroundColor; ///< The color of the background visual
Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
Toolkit::Control::KeyEventSignalType mKeyEventSignal;
Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
Actor self( Self() );
mImpl->mBackgroundColor = color;
Property::Map map;
- map[ RENDERER_TYPE ] = COLOR_RENDERER;
- map[ "mixColor" ] = color;
- InitializeControlRenderer( self, mImpl->mBackgroundRenderer, map );
- if( mImpl->mBackgroundRenderer )
+ map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
+ map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
+ InitializeVisual( self, mImpl->mBackgroundVisual, map );
+ if( mImpl->mBackgroundVisual )
{
- mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
}
}
void Control::SetBackground( const Property::Map& map )
{
Actor self( Self() );
- InitializeControlRenderer( self, mImpl->mBackgroundRenderer, map );
- if( mImpl->mBackgroundRenderer )
+ InitializeVisual( self, mImpl->mBackgroundVisual, map );
+ if( mImpl->mBackgroundVisual )
{
- mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
}
}
void Control::SetBackgroundImage( Image image )
{
Actor self( Self() );
- InitializeControlRenderer( self, mImpl->mBackgroundRenderer, image );
- if( mImpl->mBackgroundRenderer )
+ InitializeVisual( self, mImpl->mBackgroundVisual, image );
+ if( mImpl->mBackgroundVisual )
{
- mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
}
}
void Control::ClearBackground()
{
Actor self( Self() );
- mImpl->mBackgroundRenderer.RemoveAndReset( self );
+ mImpl->mBackgroundVisual.RemoveAndReset( self );
}
void Control::EnableGestureDetection(Gesture::Type type)
void Control::OnStageConnection( int depth )
{
- if( mImpl->mBackgroundRenderer)
+ if( mImpl->mBackgroundVisual)
{
Actor self( Self() );
- mImpl->mBackgroundRenderer.SetOnStage( self );
+ mImpl->mBackgroundVisual.SetOnStage( self );
}
}
void Control::OnStageDisconnection()
{
- if( mImpl->mBackgroundRenderer )
+ if( mImpl->mBackgroundVisual )
{
Actor self( Self() );
- mImpl->mBackgroundRenderer.SetOffStage( self );
+ mImpl->mBackgroundVisual.SetOffStage( self );
}
}
void Control::OnSizeSet(const Vector3& targetSize)
{
- if( mImpl->mBackgroundRenderer )
+ if( mImpl->mBackgroundVisual )
{
Vector2 size( targetSize );
- mImpl->mBackgroundRenderer.SetSize( size );
+ mImpl->mBackgroundVisual.SetSize( size );
}
}
Vector3 Control::GetNaturalSize()
{
- if( mImpl->mBackgroundRenderer )
+ if( mImpl->mBackgroundVisual )
{
Vector2 naturalSize;
- mImpl->mBackgroundRenderer.GetNaturalSize(naturalSize);
+ mImpl->mBackgroundVisual.GetNaturalSize(naturalSize);
return Vector3(naturalSize);
}
return Vector3::ZERO;
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 44;
+const unsigned int TOOLKIT_MICRO_VERSION = 45;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
public_api_header_files = \
$(public_api_src_dir)/dali-toolkit-version.h \
- $(public_api_src_dir)/enums.h
+ $(public_api_src_dir)/enums.h \
+ $(public_api_src_dir)/toolkit-property-index-ranges.h
public_api_controls_header_files = \
$(public_api_src_dir)/controls/control-impl.h \
public_api_video_view_header_files = \
$(public_api_src_dir)/controls/video-view/video-view.h
+
+public_api_visuals_header_files = \
+ $(public_api_src_dir)/visuals/border-visual-properties.h \
+ $(public_api_src_dir)/visuals/color-visual-properties.h \
+ $(public_api_src_dir)/visuals/gradient-visual-properties.h \
+ $(public_api_src_dir)/visuals/image-visual-properties.h \
+ $(public_api_src_dir)/visuals/mesh-visual-properties.h \
+ $(public_api_src_dir)/visuals/primitive-visual-properties.h \
+ $(public_api_src_dir)/visuals/visual-properties.h
--- /dev/null
+#ifndef DALI_TOOLKIT_PROPERTY_INDEX_RANGES_H
+#define DALI_TOOLKIT_PROPERTY_INDEX_RANGES_H
+
+/*
+ * Copyright (c) 2016 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 <dali/public-api/object/property-index-ranges.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+enum PropertyRanges
+{
+ VISUAL_PROPERTY_BASE_START_INDEX = CORE_PROPERTY_MAX_INDEX + 1, ///< Visual Property Base Start Index. @SINCE_1_1.45
+ VISUAL_PROPERTY_BASE_END_INDEX = VISUAL_PROPERTY_BASE_START_INDEX + 100, ///< Visual Property Base End Index. @SINCE_1_1.45
+ VISUAL_PROPERTY_START_INDEX = VISUAL_PROPERTY_BASE_END_INDEX + 1, ///< Visual Property Start Index. @SINCE_1_1.45
+ VISUAL_PROPERTY_END_INDEX = VISUAL_PROPERTY_START_INDEX + 100000, ///< Visual Property End Index. @SINCE_1_1.45
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_PROPERTY_INDEX_RANGES_H
--- /dev/null
+#ifndef DALI_TOOLKIT_BORDER_VISUAL_PROPERTIES_H
+#define DALI_TOOLKIT_BORDER_VISUAL_PROPERTIES_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace BorderVisual
+{
+
+namespace Property
+{
+
+enum
+{
+ /**
+ * @brief The color of the border.
+ * @details Name "borderColor", type Property::VECTOR4.
+ * @SINCE_1_1.45
+ * @note Mandatory.
+ */
+ COLOR = VISUAL_PROPERTY_START_INDEX,
+
+ /**
+ * @brief The width of the border (in pixels).
+ * @details Name "borderSize", type Property::FLOAT.
+ * @SINCE_1_1.45
+ * @note Mandatory.
+ */
+ SIZE,
+
+ /**
+ * @brief Whether anti-aliasing of the border is required.
+ * @details Name "antiAliasing", type Property::BOOLEAN.
+ * @SINCE_1_1.45
+ * @note Optional. If not supplied, default is false.
+ */
+ ANTI_ALIASING,
+};
+
+} // namespace Property
+
+} // namespace BorderVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_BORDER_VISUAL_PROPERTIES_H
--- /dev/null
+#ifndef DALI_TOOLKIT_COLOR_VISUAL_PROPERTIES_H
+#define DALI_TOOLKIT_COLOR_VISUAL_PROPERTIES_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace ColorVisual
+{
+
+namespace Property
+{
+
+enum
+{
+ /**
+ * @brief The solid color required.
+ * @details Name "mixColor", type Property::VECTOR4.
+ * @SINCE_1_1.45
+ * @note Mandatory.
+ */
+ MIX_COLOR = VISUAL_PROPERTY_START_INDEX,
+};
+
+} // namespace Property
+
+} // namespace ColorVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_COLOR_VISUAL_PROPERTIES_H
--- /dev/null
+#ifndef DALI_TOOLKIT_GRADIENT_VISUAL_PROPERTIES_H
+#define DALI_TOOLKIT_GRADIENT_VISUAL_PROPERTIES_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace GradientVisual
+{
+
+namespace Property
+{
+
+enum
+{
+ /**
+ * @brief The start position of a linear gradient.
+ * @details Name "startPosition", type Property::VECTOR2.
+ * @SINCE_1_1.45
+ * @note Mandatory for Linear.
+ */
+ START_POSITION = VISUAL_PROPERTY_START_INDEX,
+
+ /**
+ * @brief The end position of a linear gradient.
+ * @details Name "endPosition", type Property::VECTOR2.
+ * @SINCE_1_1.45
+ * @note Mandatory for Linear.
+ */
+ END_POSITION,
+
+ /**
+ * @brief The center point of a radial gradient.
+ * @details Name "center", type Property::VECTOR2.
+ * @SINCE_1_1.45
+ * @note Mandatory for Radial.
+ */
+ CENTER,
+
+ /**
+ * @brief The size of the radius of a radial gradient.
+ * @details Name "radius", type Property::FLOAT.
+ * @SINCE_1_1.45
+ * @note Mandatory for Radial.
+ */
+ RADIUS,
+
+ /**
+ * @brief All the stop offsets.
+ * @details Name "stopOffset", type Property::ARRAY of Property::FLOAT.
+ * @SINCE_1_1.45
+ * @note Optional. If not supplied, default is 0.0 and 1.0.
+ */
+ STOP_OFFSET,
+
+ /**
+ * @brief The color at the stop offsets.
+ * @details Name "stopColor", type Property::ARRAY of Property::VECTOR4.
+ * @SINCE_1_1.45
+ * @note Mandatory. At least 2 values required to show a gradient.
+ */
+ STOP_COLOR,
+
+ /**
+ * @brief Defines the coordinate system for certain attributes of the points in a gradient.
+ * @details Name "units", type Units::Type (Property::INTEGER) or Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional. If not supplied, default is Units::OBJECT_BOUNDING_BOX.
+ * @see Units::Type
+ */
+ UNITS,
+
+ /**
+ * @brief Indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.
+ * @details Name "spreadMethod", type SpreadMethod::Type (Property::INTEGER) or Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional. If not supplied, default is SpreadMethod::PAD.
+ * @see SpreadMethod::Type
+ */
+ SPREAD_METHOD
+};
+
+} // namespace Property
+
+namespace Units
+{
+
+/**
+ * @brief The type of coordinate system for certain attributes of the points in a gradient.
+ *
+ * This applies to the:
+ * - Start (x1, y1) and End (x2 and y2) points of a line if using a linear gradient.
+ * - Center point (cx, cy) and radius (r) of a circle if using a radial gradient.
+ */
+enum Type
+{
+ OBJECT_BOUNDING_BOX, ///< Uses the normals for the start, end & center points, i.e. top-left is (-0.5, -0.5) and bottom-right is (0.5, 0.5). @SINCE_1_1.45
+ USER_SPACE ///< Uses the user coordinates for the start, end & center points, i.e. in a 200 by 200 control, top-left is (0, 0) and bottom-right is (200, 200). @SINCE_1_1.45
+};
+
+} // namespace Units
+
+namespace SpreadMethod
+{
+
+/**
+ * @brief Policies that define what happens if the gradient starts or ends inside the bounds of the target rectangle.
+ */
+enum Type
+{
+ PAD, ///< Uses the terminal colors of the gradient to fill the remainder of the quad. @SINCE_1_1.45
+ REFLECT, ///< Reflect the gradient pattern start-to-end, end-to-start, start-to-end etc. until the quad is filled. @SINCE_1_1.45
+ REPEAT ///< Repeat the gradient pattern start-to-end, start-to-end, start-to-end etc. until the quad is filled. @SINCE_1_1.45
+};
+
+} // namespace SpreadMethod
+
+} // namespace GradientVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_GRADIENT_VISUAL_PROPERTIES_H
--- /dev/null
+#ifndef DALI_TOOLKIT_IMAGE_VISUAL_PROPERTIES_H
+#define DALI_TOOLKIT_IMAGE_VISUAL_PROPERTIES_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace ImageVisual
+{
+
+namespace Property
+{
+
+enum
+{
+ /**
+ * @brief The URL of the image.
+ * @details Name "url", type Property::STRING.
+ * @SINCE_1_1.45
+ * @note Mandatory.
+ */
+ URL = VISUAL_PROPERTY_START_INDEX,
+
+ /**
+ * @brief Fitting options, used when resizing images to fit desired dimensions.
+ * @details Name "fittingMode", type Dali::FittingMode (Property::INTEGER) or Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional. If not supplied, default is FittingMode::SHRINK_TO_FIT.
+ * @note For Normal Quad images only.
+ * @see Dali::FittingMode
+ */
+ FITTING_MODE,
+
+ /**
+ * @brief Filtering options, used when resizing images to sample original pixels.
+ * @details Name "samplingMode", type Dali::SamplingMode (Property::INTEGER) or Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional. If not supplied, default is SamplingMode::BOX.
+ * @note For Normal Quad images only.
+ * @see Dali::SamplingMode
+ */
+ SAMPLING_MODE,
+
+ /**
+ * @brief The desired image width.
+ * @details Name "desiredWidth", type Property::INTEGER.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the actual image width is used.
+ * @note For Normal Quad images only.
+ */
+ DESIRED_WIDTH,
+
+ /**
+ * @brief The desired image height.
+ * @details Name "desiredHeight", type Property::INTEGER.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the actual image height is used.
+ * @note For Normal Quad images only.
+ */
+ DESIRED_HEIGHT,
+
+ /**
+ * @brief Whether to load the image synchronously.
+ * @details Name "synchronousLoading", type Property::BOOLEAN.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is false, i.e. the image is loaded asynchronously.
+ * @note For Normal Quad images only.
+ */
+ SYNCHRONOUS_LOADING,
+
+ /**
+ * @brief If true, only draws the borders.
+ * @details Name "borderOnly", type Property::BOOLEAN.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is false.
+ * @note For N-Patch images only.
+ */
+ BORDER_ONLY,
+};
+
+} // namespace Property
+
+} // namespace ImageVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_IMAGE_VISUAL_PROPERTIES_H
--- /dev/null
+#ifndef DALI_TOOLKIT_MESH_VISUAL_PROPERTIES_H
+#define DALI_TOOLKIT_MESH_VISUAL_PROPERTIES_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace MeshVisual
+{
+
+namespace Property
+{
+
+enum
+{
+ /**
+ * @brief The location of the ".obj" file.
+ * @details Name "objectUrl", type Property::STRING.
+ * @SINCE_1_1.45
+ * @note Mandatory.
+ */
+ OBJECT_URL = VISUAL_PROPERTY_START_INDEX,
+
+ /**
+ * @brief The location of the ".mtl" file.
+ * @details Name "materialUrl", type Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, then a textureless object is assumed.
+ */
+ MATERIAL_URL,
+
+ /**
+ * @brief Path to the directory the textures (including gloss and normal) are stored in.
+ * @details Name "texturesPath", type Property::STRING.
+ * @SINCE_1_1.45
+ * @note Mandatory if using material.
+ */
+ TEXTURES_PATH,
+
+ /**
+ * @brief Sets the type of shading mode that the mesh will use.
+ * @details Name "shadingMode", type ShadingMode::Value (Property::INTEGER) or Property::STRING.
+ * If anything the specified shading mode requires is missing, a simpler mode that can be handled with what has been supplied will be used instead.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, it will use the best it can support (will try ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING first).
+ * @see ShadingMode::Value
+ */
+ SHADING_MODE,
+
+ /**
+ * @brief Whether to use mipmaps for textures or not.
+ * @details Name "useMipmapping", type Property::BOOLEAN.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is true.
+ */
+ USE_MIPMAPPING,
+
+ /**
+ * @brief Whether to average normals at each point to smooth textures or not.
+ * @details Name "useSoftNormals", type Property::BOOLEAN.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is true.
+ */
+ USE_SOFT_NORMALS,
+
+ /**
+ * @brief The position, in stage space, of the point light that applies lighting to the model.
+ * @details Name "lightPosition", type Property::VECTOR3.
+ * This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
+ * and using all zeroes will place the light at the top left corner.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is an offset outwards from the center of the screen.
+ */
+ LIGHT_POSITION,
+};
+
+} // namespace Property
+
+namespace ShadingMode
+{
+
+enum Value
+{
+ TEXTURELESS_WITH_DIFFUSE_LIGHTING, ///< *Simplest*. One color that is lit by ambient and diffuse lighting. @SINCE_1_1.45
+ TEXTURED_WITH_SPECULAR_LIGHTING, ///< Uses only the visual image textures provided with specular lighting in addition to ambient and diffuse lighting. @SINCE_1_1.45
+ TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING ///< Uses all textures provided including a gloss, normal and texture map along with specular, ambient and diffuse lighting. @SINCE_1_1.45
+};
+
+} // namespace ShadingMode
+
+} // namespace MeshVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_MESH_VISUAL_PROPERTIES_H
--- /dev/null
+#ifndef DALI_TOOLKIT_PRIMITIVE_VISUAL_PROPERTIES_H
+#define DALI_TOOLKIT_PRIMITIVE_VISUAL_PROPERTIES_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace PrimitiveVisual
+{
+
+namespace Property
+{
+
+enum
+{
+ /**
+ * @brief The specific shape to render.
+ * @details Name "shape", type Shape::Type (Property::INTEGER) or Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is Shape::SPHERE.
+ * @see Shape::Type
+ */
+ SHAPE = VISUAL_PROPERTY_START_INDEX,
+
+ /**
+ * @brief The color of the shape.
+ * @details Name "shapeColor", type Property::VECTOR4.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is Vector4(0.5, 0.5, 0.5, 1.0).
+ * @note Applies to ALL shapes.
+ */
+ COLOR,
+
+ /**
+ * @brief The number of slices as you go around the shape.
+ * @details Name "slices", type Property::INTEGER.
+ * For spheres and conical frustrums, this determines how many divisions there are as you go around the object.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is 128.
+ * @note Applies to:
+ * - Shape::SPHERE
+ * - Shape::CONICAL_FRUSTRUM
+ * - Shape::CONE
+ * - Shape::CYLINDER
+ * @note The range is from 1 to 255.
+ */
+ SLICES,
+
+ /**
+ * @brief The number of stacks as you go down the shape.
+ * @details Name "stacks", type Property::INTEGER.
+ * For spheres, 'stacks' determines how many layers there are as you go down the object.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is 128.
+ * @note Applies to:
+ * - Shape::SPHERE
+ * @note The range is from 1 to 255.
+ */
+ STACKS,
+
+ /**
+ * @brief The scale of the radius of the top circle of a conical frustrum.
+ * @details Name "scaleTopRadius", type Property::FLOAT.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is 1.0f.
+ * @note Applies to:
+ * - Shape::CONICAL_FRUSTRUM
+ * @note Only values greater than or equal to 0.0f are accepted.
+ */
+ SCALE_TOP_RADIUS,
+
+ /**
+ * @brief The scale of the radius of the bottom circle of a conical frustrum.
+ * @details Name "scaleBottomRadius", type Property::FLOAT.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is 1.5f.
+ * @note Applies to:
+ * - Shape::CONICAL_FRUSTRUM
+ * - Shape::CONE
+ * @note Only values greater than or equal to 0.0f are accepted.
+ */
+ SCALE_BOTTOM_RADIUS,
+
+ /**
+ * @brief The scale of the height of a conic.
+ * @details Name "scaleHeight", type Property::FLOAT.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is 3.0f.
+ * @note Applies to:
+ * - Shape::CONICAL_FRUSTRUM
+ * - Shape::CONE
+ * - Shape::CYLINDER
+ * @note Only values greater than or equal to 0.0f are accepted.
+ */
+ SCALE_HEIGHT,
+
+ /**
+ * @brief The scale of the radius of a cylinder.
+ * @details Name "scaleRadius", type Property::FLOAT.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is 1.0f.
+ * @note Applies to:
+ * - Shape::CYLINDER
+ * @note Only values greater than or equal to 0.0f are accepted.
+ */
+ SCALE_RADIUS,
+
+ /**
+ * @brief The dimensions of a cuboid. Scales in the same fashion as a 9-patch image.
+ * @details Name "scaleDimensions", type Property::VECTOR3.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is Vector3::ONE.
+ * @note Applies to:
+ * - Shape::CUBE
+ * - Shape::OCTAHEDRON
+ * - Shape::BEVELLED_CUBE
+ * @note Each vector3 parameter should be greater than or equal to 0.0f.
+ */
+ SCALE_DIMENSIONS,
+
+ /**
+ * @brief Determines how bevelled the cuboid should be, based off the smallest dimension.
+ * @details Name "bevelPercentage", type Property::FLOAT.
+ * Bevel percentage ranges from 0.0 to 1.0. It affects the ratio of the outer face widths to the width of the overall cube.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is 0.0f (no bevel).
+ * @note Applies to:
+ * - Shape::BEVELLED_CUBE
+ * @note The range is from 0.0f to 1.0f.
+ */
+ BEVEL_PERCENTAGE,
+
+ /**
+ * @brief Defines how smooth the bevelled edges should be.
+ * @details Name "bevelSmoothness", type Property::FLOAT.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is 0.0f (sharp edges).
+ * @note Applies to:
+ * - Shape::BEVELLED_CUBE
+ * @note The range is from 0.0f to 1.0f.
+ */
+ BEVEL_SMOOTHNESS,
+
+ /**
+ * @brief The position, in stage space, of the point light that applies lighting to the model.
+ * @details Name "lightPosition", type Property::VECTOR3.
+ * This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
+ * and using all zeroes will place the light at the top left corner.
+ * @SINCE_1_1.45
+ * @note Optional. If not specified, the default is an offset outwards from the center of the screen.
+ * @note Applies to ALL shapes.
+ */
+ LIGHT_POSITION,
+};
+
+} // namespace Property
+
+namespace Shape
+{
+
+/**
+ * @brief The primitive shape to render.
+ */
+enum Type
+{
+ SPHERE, ///< A perfectly round geometrical object in three-dimensional space. @SINCE_1_1.45
+ CONICAL_FRUSTRUM, ///< The area bound between two circles, i.e. a cone with the tip removed. @SINCE_1_1.45
+ CONE, ///< Equivalent to a conical frustrum with top radius of zero. @SINCE_1_1.45
+ CYLINDER, ///< Equivalent to a conical frustrum with equal radii for the top and bottom circles. @SINCE_1_1.45
+ CUBE, ///< Equivalent to a bevelled cube with a bevel percentage of zero. @SINCE_1_1.45
+ OCTAHEDRON, ///< Equivalent to a bevelled cube with a bevel percentage of one. @SINCE_1_1.45
+ BEVELLED_CUBE, ///< A cube/cuboid with all edges flattened to some degree. @SINCE_1_1.45
+};
+}
+
+} // namespace PrimitiveVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_PRIMITIVE_VISUAL_PROPERTIES_H
--- /dev/null
+#ifndef DALI_TOOLKIT_VISUAL_PROPERTIES_H
+#define DALI_TOOLKIT_VISUAL_PROPERTIES_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Visual
+{
+
+/**
+ * @brief All the visual types.
+ * @SINCE_1_1.45
+ */
+enum Type
+{
+ BORDER, ///< Renders a solid color as an internal border to the control's quad. @SINCE_1_1.45
+ COLOR, ///< Renders a solid color to the control's quad. @SINCE_1_1.45
+ GRADIENT, ///< Renders a smooth transition of colors to the control's quad. @SINCE_1_1.45
+ IMAGE, ///< Renders an image into the control's quad. @SINCE_1_1.45
+ MESH, ///< Renders a mesh using an "obj" file, optionally with textures provided by an "mtl" file. @SINCE_1_1.45
+ PRIMITIVE, ///< Renders a simple 3D shape, such as a cube or sphere. @SINCE_1_1.45
+ DEBUG, ///< Renders a simple wire-frame outlining a quad. @SINCE_1_1.45
+};
+
+namespace Property
+{
+
+enum
+{
+ /**
+ * @brief The index for the visual type.
+ * @details Name "visualType", type [Type](@ref Dali::Toolkit::Visual::Type) (Property::INTEGER) or Property::STRING.
+ * @SINCE_1_1.45
+ * @note Mandatory.
+ * @see Type
+ */
+ TYPE = VISUAL_PROPERTY_BASE_START_INDEX,
+
+ /**
+ * @brief The shader to use in the visual.
+ * @details Name "shader", type Property::Map.
+ * @SINCE_1_1.45
+ * @note Optional.
+ * @note Will override the existing shaders.
+ * @see Shader::Property
+ */
+ SHADER
+};
+
+} // namespace Property
+
+namespace Shader
+{
+
+namespace Property
+{
+
+enum
+{
+ /**
+ * @brief The vertex shader.
+ * @details Name "vertexShader", type Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional
+ * @note If not supplied, the visual's already set vertex shader is used.
+ */
+ VERTEX_SHADER,
+
+ /**
+ * @brief The fragment shader.
+ * @details Name "fragmentShader", type Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional
+ * @note If not supplied, the visual's already set fragment shader is used.
+ */
+ FRAGMENT_SHADER,
+
+ /**
+ * @brief How to subdivide the grid along the X-Axis.
+ * @details Name "subdivideGridX", type Property::INTEGER.
+ * @SINCE_1_1.45
+ * @note Optional
+ * @note If not supplied, the default is 1.
+ * @note Value should be greater than or equal to 1.
+ */
+ SUBDIVIDE_GRID_X,
+
+ /**
+ * @brief How to subdivide the grid along the Y-Axis.
+ * @details Name "subdivideGridY", type Property::INTEGER.
+ * @SINCE_1_1.45
+ * @note Optional
+ * @note If not supplied, the default is 1.
+ * @note Value should be greater than or equal to 1.
+ */
+ SUBDIVIDE_GRID_Y,
+
+ /**
+ * @brief Hints for rendering.
+ * @details Name "hints", type Dali::Shader::Hint (Property::INTEGER), Property::STRING or Property::ARRAY of Property::STRING.
+ * @SINCE_1_1.45
+ * @note Optional
+ * @note If not supplied, the default is Dali::Shader::Hint::NONE.
+ */
+ HINTS,
+};
+
+} // namespace Property
+
+} // namespace Shader
+
+} // namespace Visual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_VISUAL_PROPERTIES_H
"popupIconColor":[1.0,1.0,1.0,1.0],
"popupPressedColor":[0.24,0.72,0.8,0.11],
"background": {
- "rendererType": "IMAGE",
+ "visualType": "IMAGE",
"url": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
},
"popupFadeInDuration":0.25,
"popupIconColor":[1.0,1.0,1.0,1.0],
"popupPressedColor":[0.24,0.72,0.8,0.11],
"background": {
- "rendererType": "IMAGE",
+ "visualType": "IMAGE",
"url": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
},
"popupFadeInDuration":0.25,
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
// Set another property to set the image-map
Property::Map imageMap;
- imageMap[ "rendererType" ] = "IMAGE";
- imageMap[ "url" ] = IMAGE_CARDS;
- imageMap[ "desiredWidth" ] = 100;
- imageMap[ "desiredHeight" ] = 100;
+ imageMap[ Visual::Property::TYPE ] = Visual::IMAGE;
+ imageMap[ ImageVisual::Property::URL ] = IMAGE_CARDS;
+ imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 100;
+ imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 100;
mImageView.SetProperty( ImageView::Property::IMAGE, imageMap );
// Add the image view to the stage
+ [9 Patch Image](@ref resource-9-patch)
+ [Buffer Image](@ref resource-buffer)
-### Control Base Class & Renderers
+### Control Base Class & Visuals
+ [Background Feature](@ref background)
+ Keyboard Focus
+ [Accessibility](@ref accessibility)
- + [Control Renderers](@ref control-renderers)
+ + [Visuals](@ref visuals)
### UI Components
+ Buttons
+ Environment Variables
+ [Resource Tracking](@ref resourcetracking)
+ Logging
- + [Debug Renderer](@ref debugrenderer)
+ + [Debug Visual](@ref debugvisual)
+ [Stagehand - DALi Visual Debugger](@ref stagehand)
### Viewing Modes
</td>
</table>
-@section background-renderer Background Renderer
+@section background-visual Background Visual
-The background can be set to use a specified renderer, e.g the border renderer
+The background can be set to use a specified visual, e.g the border visual
@code
-Property::Map renderer;
-renderer.Insert("rendererType","BORDER");
-renderer.Insert("borderColor",COLOR::RED);
-renderer.Insert("borderSize",20.f);
+Property::Map visual;
+visual.Insert( Visual::Property::Type,Visual::BORDER );
+visual.Insert( BorderVisual::Property::COLOR, COLOR::RED );
+visual.Insert( BorderVisual::Property::SIZE, 20.f );
-control.SetProperty( Control::Property::BACKGROUND, renderer);
+control.SetProperty( Control::Property::BACKGROUND, visual);
@endcode
then the above image will look like:
* @endcode
*
* <h3 class="pg">The IMAGE property</h3>
- * the IMAGE property allows you to change many aspects of the image that is renderered.
+ * the IMAGE property allows you to change many aspects of the image that is rendered.
* This property can either be a string for a image url path or a Property::Map that specifies
* the image in more detail.
*
- * <h3 class="pg">Renderers</h3>
- * You can specify a specific renderer instead of using the default Image Renderer, e.g to use the Border Renderer.
+ * <h3 class="pg">Visuals</h3>
+ * You can specify a specific visual instead of using the default Image Visual, e.g to use the Border Visual.
*
* @code
- * Property::Map renderer;
- * renderer.Insert("rendererType","BORDER");
- * renderer.Insert("borderColor",COLOR::RED);
- * renderer.Insert("borderSize",20.f);
+ * Property::Map visual;
+ * visual.Insert( Visual::Property::Type,Visual::BORDER );
+ * visual.Insert( BorderVisual::Property::COLOR, COLOR::RED );
+ * visual.Insert( BorderVisual::Property::SIZE, 20.f );
*
* Dali::Toolkit::ImageView myImageView = Dali::Toolkit::ImageView::New();
- * myImageView.SetProperty( Control::Property::IMAGE, renderer);
+ * myImageView.SetProperty( Control::Property::IMAGE, visual );
* @endcode
* <h3 class="pg">Resizing at Load Time</h3>
// Set an image view property
imageView.image = {
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url": "images/icon-0.png",
"desiredWidth" : 100,
"desiredHeight" : 100
"position": [0, 0, 0],
"image":
{
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url" : "images/icon-0.png",
"desiredWidth" : 100,
"desiredHeight" : 100
* <h2 class="pg">Custom Shader Effects</h2>
* The custom shader lets the developers create their own shader effects by specifying the vertex and pixel shaders.
*
- * To set a custom shader to ImageRenderer you have to pass it through as a Property::Map
+ * To set a custom shader to ImageVisual you have to pass it through as a Property::Map
* @code
* //an example vertex shader
* const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+++ /dev/null
-<!--
-/**-->
-
-# Control Renderers {#control-renderers}
-
-Control Renderers provide reusable renderering logic which can be used by all controls.
-This means that custom controls do not have to create actors, they can just reuse the existing renderers which increases performance as well.
-
-Control Renderers reuse geometry, shader etc. across controls and manages the renderer and material to exist only when the control is on-stage.
-Additionaly, they respond to actor size and color change, while also providing clipping at the renderer level.
-
-DALi provides the following renderers:
- + [Color](@ref color-renderer)
- + [Gradient](@ref gradient-renderer)
- + [Image](@ref image-renderers)
- + [Border](@ref border-renderer)
- + [Mesh](@ref mesh-renderer)
- + [Primitive](@ref primitive-renderer)
-
-Controls can provide properties that allow users to specify the renderer type.
-Setting renderer properties are done via a property map.
-The **rendererType** field in the property map specifies the renderer to use/create.
-This is required to avoid ambiguity as multiple renderers may be capable of rendering the same contents.
-___________________________________________________________________________________________________
-
-## Color Renderer {#color-renderer}
-
-Renders a solid color to the control's quad.
-
-![ ](../assets/img/renderers/color-renderer.png)
-![ ](renderers/color-renderer.png)
-
-### Properties Supported
-
-**RendererType:** "COLOR"
-
-| Property Name | Type | Required | Description |
-|---------------|:-------:|:--------:|---------------------------|
-| mixColor | VECTOR4 | Yes | The solid color required. |
-
-### Usage
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-map[ "rendererType" ] = "COLOR";
-map[ "mixColor" ] = Color::RED;
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-~~~{.js}
-// JavaScript
-var control = new dali.Control( "Control" );
-
-control.background =
-{
- rendererType : "COLOR",
- mixColor : dali.COLOR_RED
-};
-~~~
-___________________________________________________________________________________________________
-
-## Gradient Renderer {#gradient-renderer}
-
-Renders a smooth transition of colors to the control's quad.
-
-Both Linear and Radial gradients are supported.
-
-| Linear | Radial |
-|--------|--------|
-| ![ ](../assets/img/renderers/linear-gradient-renderer.png) ![ ](renderers/linear-gradient-renderer.png) | ![ ](../assets/img/renderers/radial-gradient-renderer.png) ![ ](renderers/radial-gradient-renderer.png) |
-
-### Properties Supported
-
-**RendererType:** "GRADIENT"
-
-| Property Name | Type | Required | Description |
-|------------------------------------------------------|:----------------:|:----------:|--------------------------------------------------------------------------|
-| startPosition | VECTOR2 | For Linear | The start position of the linear gradient. |
-| endPosition | VECTOR2 | For Linear | The end position of the linear gradient. |
-| center | VECTOR2 | For Radial | The center point of the gradient. |
-| radius | FLOAT | For Radial | The size of the radius. |
-| stopOffset | ARRAY of FLOAT | No | All the stop offsets. If not supplied default is 0.0 and 1.0. |
-| stopColor | ARRAY of VECTOR4 | Yes | The color at those stop offsets. At least 2 required to show a gradient. |
-| [units](@ref gradient-renderer-units) | STRING | No | *OBJECT_BOUNDING_BOX* or *USER_SPACE*. Default: *OBJECT_BOUNDING_BOX*. |
-| [spreadMethod](@ref gradient-renderer-spread-method) | STRING | No | *PAD*, *REFLECT* or *REPEAT*. Default: *PAD*. |
-
-If the *stopOffset* and *stopColor* arrays do not have the same number of elements, then the minimum of the two is used as the stop points.
-
-### Units {#gradient-renderer-units}
-
-Defines the coordinate system for the attributes:
- + Start (x1, y1) and End (x2 and y2) points of a line if using a linear gradient.
- + Center point (cx, cy) and radius (r) of a circle if using a radial gradient.
-
-| Value | Description |
-|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
-| OBJECT_BOUNDING_BOX | *Default*. Uses the normals for the start, end & center points, i.e. top-left is (-0.5, -0.5) and bottom-right is (0.5, 0.5). |
-| USER_SPACE | Uses the user coordinates for the start, end & center points, i.e. in a 200 by 200 control, top-left is (0, 0) and bottom-right is (200, 200). |
-
-### Spread Method {#gradient-renderer-spread-method}
-
-Indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.
-
-| Value | Description |
-|---------|------------------------------------------------------------------------------------------------------|
-| PAD | *Default*. Uses the terminal colors of the gradient to fill the remainder of the quad. |
-| REFLECT | Reflect the gradient pattern start-to-end, end-to-start, start-to-end etc. until the quad is filled. |
-| REPEAT | Repeat the gradient pattern start-to-end, start-to-end, start-to-end etc. until the quad is filled. |
-
-### Usage
-
-**Linear:**
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-map[ "rendererType" ] = "GRADIENT";
-map[ "startPosition" ] = Vector2( 0.5f, 0.5f );
-map[ "endPosition" ] = Vector2( -0.5f, -0.5f );
-
-Dali::Property::Array stopOffsets;
-stopOffsets.PushBack( 0.0f );
-stopOffsets.PushBack( 0.3f );
-stopOffsets.PushBack( 0.6f );
-stopOffsets.PushBack( 0.8f );
-stopOffsets.PushBack( 1.f );
-map[ "stopOffset" ] = stopOffsets;
-
-Dali::Property::Array stopColors;
-stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
-stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
-stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
-stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
-stopColors.PushBack( Color::YELLOW );
-map[ "stopColor" ] = stopColors;
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-~~~{.js}
-// JavaScript
-var control = new dali.Control( "Control" );
-
-control.background =
-{
- rendererType : "GRADIENT",
- startPosition : [ 0.5, 0.5 ],
- endPosition : [ -0.5, -0.5 ],
- stopOffset : [ 0.0, 0.3, 0.6, 0.8, 1.0 ],
- stopColor : [
- [ 129 / 255, 198 / 255, 193 / 255, 255 / 255 ],
- [ 196 / 255, 198 / 255, 71 / 255, 122 / 255 ],
- [ 214 / 255, 37 / 255, 139 / 255, 191 / 255 ],
- [ 129 / 255, 198 / 255, 193 / 255, 150 / 255 ],
- dali.COLOR_YELLOW
- ]
-};
-~~~
-
-**Radial:**
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-map[ "rendererType" ] = "GRADIENT";
-map[ "center" ] = Vector2( 0.5f, 0.5f );
-map[ "radius" ] = 1.414f;
-
-Dali::Property::Array stopOffsets;
-stopOffsets.PushBack( 0.0f );
-stopOffsets.PushBack( 0.3f );
-stopOffsets.PushBack( 0.6f );
-stopOffsets.PushBack( 0.8f );
-stopOffsets.PushBack( 1.f );
-map[ "stopOffset" ] = stopOffsets;
-
-Dali::Property::Array stopColors;
-stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
-stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
-stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
-stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
-stopColors.PushBack( Color::YELLOW );
-map[ "stopColor" ] = stopColors;
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-~~~{.js}
-// JavaScript
-var control = new dali.Control( "Control" );
-
-control.background =
-{
- rendererType : "GRADIENT",
- center : [ 0.5, 0.5 ],
- radius : 1.414,
- stopOffset : [ 0.0, 0.3, 0.6, 0.8, 1.0 ],
- stopColor : [
- [ 129 / 255, 198 / 255, 193 / 255, 255 / 255 ],
- [ 196 / 255, 198 / 255, 71 / 255, 122 / 255 ],
- [ 214 / 255, 37 / 255, 139 / 255, 191 / 255 ],
- [ 129 / 255, 198 / 255, 193 / 255, 150 / 255 ],
- dali.COLOR_YELLOW
- ]
-};
-~~~
-___________________________________________________________________________________________________
-
-## Image Renderers {#image-renderers}
-
-Renders an image into the control's quad.
-
-Depending on the extension of the image, different renderer is provided to render the image onto the screen.
-
- + [Normal](@ref image-renderer)
- + [N-Patch](@ref n-patch-renderer)
- + [SVG](@ref svg-renderer)
-
-___________________________
-
-### Normal {#image-renderer}
-
-Renders a raster image ( jpg, png etc.) into the control's quad.
-
-![ ](../assets/img/renderers/image-renderer.png)
-![ ](renderers/image-renderer.png)
-
-#### Properties Supported
-
-**RendererType:** "IMAGE"
-
-| Property Name | Type | Required | Description |
-|------------------------------------------------------|:--------:|:--------:|----------------------------------------------------------------------------------------------------------------|
-| url | STRING | Yes | The URL of the image. |
-| [fittingMode](@ref resourceimagescaling-fittingmode) | STRING | No | *SHRINK_TO_FIT*, *SCALE_TO_FILL*, *FIT_WIDTH* or *FIT_HEIGHT*. Default: *SHRINK_TO_FIT*. |
-| [samplingMode](@ref resourceimagescaling-scaling) | STRING | No | *BOX*, *NEAREST*, *LINEAR*, *BOX_THEN_NEAREST*, *BOX_THEN_LINEAR*, *NO_FILTER* or *DONT_CARE*. Default: *BOX*. |
-| desiredWidth | INT | No | The desired image width. Will use actual image width if not specified. |
-| desiredHeight | INT | No | The desired image height. Will use actual image height if not specified. |
-
-#### Usage
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-map[ "rendererType" ] = "IMAGE";
-map[ "url" ] = "path-to-image.jpg";
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-~~~{.js}
-// JavaScript
-var control = new dali.Control( "Control" );
-
-control.background =
-{
- rendererType : "IMAGE",
- url : "path-to-image.jpg"
-};
-~~~
-___________________________________________________________________________________________________
-
-### N-Patch {#n-patch-renderer}
-
-Renders an n-patch or a 9-patch image into the control's quad.
-
-![ ](../assets/img/renderers/n-patch-renderer.png)
-![ ](renderers/n-patch-renderer.png)
-
-#### Properties Supported
-
-**RendererType:** "IMAGE"
-
-| Property Name | Type | Required | Description |
-|---------------|:-------:|:--------:|----------------------------------|
-| url | STRING | Yes | The URL of the n-patch image. |
-| borderOnly | BOOLEAN | No | If true, only draws the borders. |
-
-#### Usage
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-
-map[ "rendererType" ] = "IMAGE";
-map[ "url" ] = "path-to-image.9.png";
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-~~~{.js}
-// JavaScript
-var control = new dali.Control( "Control" );
-
-control.background =
-{
- rendererType : "IMAGE",
- url : "path-to-image.9.png"
-};
-~~~
-
-___________________________________________________________________________________________________
-
-### SVG {#svg-renderer}
-
-Renders a svg image into the control's quad.
-
-#### Features: SVG Tiny 1.2 specification
-
-**supported:**
-
- * basic shapes
- * paths
- * solid color fill
- * gradient color fill
- * solid color stroke
-
-**not supported:**
-
- * gradient color stroke
- * dash array stroke
- * view box
- * text
- * clip path
-
-<div style="width:300px">
-
-![ ](../assets/img/renderers/svg-renderer.svg)
-
-</div>
-
-<div style="width:300px">
-
-![ ](renderers/svg-renderer.svg)
-
-</div>
-
-
-#### Properties Supported
-
-**RendererType:** "IMAGE"
-
-| Property Name | Type | Required | Description |
-|---------------|:-------:|:--------:|----------------------------------|
-| url | STRING | Yes | The URL of the SVG image. |
-
-#### Usage
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-
-map[ "rendererType" ] = "IMAGE";
-map[ "url" ] = "path-to-image.svg";
-
-control.SetSize( 200.f, 200.f );
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-~~~{.js}
-// JavaScript
-var control = new dali.Control( "Control" );
-
-control.background =
-{
- rendererType : "IMAGE",
- url : "path-to-image.svg"
-};
-~~~
-___________________________________________________________________________________________________
-
-## Border Renderer {#border-renderer}
-
-Renders a solid color as an internal border to the control's quad.
-
-![ ](../assets/img/renderers/border-renderer.png)
-![ ](renderers/border-renderer.png)
-
-### Properties Supported
-
-**RendererType:** "BORDER"
-
-| Property Name | Type | Required | Description |
-|---------------|:-------:|:--------:|--------------------------------------------------|
-| borderColor | VECTOR4 | Yes | The color of the border. |
-| borderSize | FLOAT | Yes | The width of the border (in pixels). |
-| antiAliasing | BOOLEAN | No | Whether anti-aliasing of the border is required. |
-
-### Usage
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-
-map[ "rendererType" ] = "BORDER";
-map[ "borderColor" ] = Color::BLUE;
-map[ "borderSize" ] = 5.0f;
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-~~~{.js}
-// JavaScript
-var control = new dali.Control( "Control" );
-
-control.background =
-{
- rendererType : "BORDER",
- borderColor : dali.COLOR_BLUE,
- borderSize = 5
-};
-~~~
-
-___________________________________________________________________________________________________
-
-## Mesh Renderer {#mesh-renderer}
-
-Renders a mesh using a .obj file, optionally with textures provided by a mtl file. Scaled to fit the control.
-
-![ ](../assets/img/renderers/mesh-renderer.png)
-![ ](renderers/mesh-renderer.png)
-
-### Properties Supported
-
-**RendererType** "MESH"
-
-| Property Name | Type | Required | Description |
-|----------------------------------------------|:-------:|:------------------:|--------------------------------------------------------------------------------|
-| objectUrl | STRING | Yes | The location of the ".obj" file. |
-| materialUrl | STRING | No | The location of the ".mtl" file. Leave blank for a textureless object. |
-| texturesPath | STRING | If using material | Path to the directory the textures (including gloss and normal) are stored in. |
-| [shaderType](@ref mesh-renderer-shader-type) | STRING | No | Sets the type of shader to be used with the mesh. |
-
-### Shader Type {#mesh-renderer-shader-type}
-
-When specifying the shader type, if anything the shader requires is missing, a simpler type that can be handled with what has been supplied will be used instead.
-
-**Possible values:**
-
-| String Value | Description |
-|-----------------|------------------------------------------------|
-| TEXTURELESS | *Simplest*. A flat color with shading is used. |
-| DIFFUSE_TEXTURE | Textured. |
-| ALL_TEXTURES | Has a gloss, normal map and texture map. |
-
-### Usage
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-
-map[ "rendererType" ] = "MESH";
-map[ "objectUrl" ] = "home/models/Dino.obj";
-map[ "materialUrl" ] = "home/models/Dino.mtl";
-map[ "texturesPath" ] = "home/images/";
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-___________________________________________________________________________________________________
-
-## Primitive Renderer {#primitive-renderer}
-
-Renders a simple 3D shape, such as a cube or sphere. Scaled to fit the control.
-
-![ ](../assets/img/renderers/cube.png)
-![ ](renderers/cube.png)
-
-### Properties Supported
-
-**RendererType** "PRIMITIVE"
-
-| Property Name | Type | Description | Default Value | Range |
-|---------------------------------------|:-------:|---------------------------------------------------------------------------------|:--------------------:|:------------------------------:|
-| [shape](@ref shape-details) | STRING | The specific shape to render. | "SPHERE" | [See list](@ref shape-details) |
-| color | VECTOR4 | The color of the shape. | (0.5, 0.5, 0.5, 1.0) | 0.0 - 1.0 for each |
-| [slices](@ref slices-details) | INT | The number of slices as you go around the shape. | 128 | 1 - 255 |
-| [stacks](@ref stacks-details) | INT | The number of stacks as you go down the shape. | 128 | 1 - 255 |
-| scaleTopRadius | FLOAT | The scale of the radius of the top circle of a conical frustrum. | 1.0 | ≥ 0.0 |
-| scaleBottomRadius | FLOAT | The scale of the radius of the bottom circle of a conical frustrum. | 1.5 | ≥ 0.0 |
-| scaleHeight | FLOAT | The scale of the height of a conic. | 3.0 | > 0.0 |
-| scaleRadius | FLOAT | The scale of the radius of a cylinder. | 1.0 | > 0.0 |
-| scaleDimensions | VECTOR3 | The dimensions of a cuboid. Scales in the same fashion as a 9-patch image. | (1.0, 1.0, 1.0) | > 0.0 for each |
-| [bevelPercentage](@ref bevel-details) | FLOAT | Determines how bevelled the cuboid should be, based off the smallest dimension. | 0.0 (no bevel) | 0.0 - 1.0 |
-| bevelSmoothness | FLOAT | Defines how smooth the bevelled edges should be. | 0.0 (sharp edges) | 0.0 - 1.0 |
-| uLightPosition | VECTOR3 | The position, in stage space, of the point light that applies lighting to the model. This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center, and using all zeroes will place the light at the upper left back corner. Note that this corresponds to a shader property, so it can be registered and set in the actor as well. | (Offset outwards from the center of the screen.) | Unlimited |
-
-### Shapes {#shape-details}
-
-There are six shapes that can be chosen, some of which are simplified specialisations of another.
-
-| Value | Description | Parameters |
-|------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------|
-| SPHERE | *Default*. | color, slices, stacks |
-| CONICAL_FRUSTRUM | The area bound between two circles, i.e. a cone with the tip removed. | color, scaleTopRadius, scaleBottomRadius, scaleHeight, slices |
-| CONE | Equivalent to a conical frustrum with top radius of zero. | color, scaleBottomRadius, scaleHeight, slices |
-| CYLINDER | Equivalent to a conical frustrum with equal radii for the top and bottom circles. | color, scaleRadius, scaleHeight, slices |
-| CUBE | Equivalent to a bevelled cube with a bevel percentage of zero. | color, scaleDimensions |
-| OCTAHEDRON | Equivalent to a bevelled cube with a bevel percentage of one. | color, scaleDimensions |
-| BEVELLED_CUBE | A cube/cuboid with all edges flattened to some degree. | color, scaleDimensions, bevelPercentage, bevelSmoothness |
-
-Examples below:
-
-**sphere:**
-
-![ ](../assets/img/renderers/sphere.png)
-![ ](renderers/sphere.png)
-
-**conics:**
-
-| Frustrum | Cone | Cylinder |
-|----------|------|----------|
-| ![ ](../assets/img/renderers/conical-frustrum.png) ![ ](renderers/conical-frustrum.png) | ![ ](../assets/img/renderers/cone.png) ![ ](renderers/cone.png) | ![ ](../assets/img/renderers/cylinder.png) ![ ](renderers/cylinder.png) |
-
-### Bevel {#bevel-details}
-
-Bevel percentage ranges from 0.0 to 1.0. It affects the ratio of the outer face widths to the width of the overall cube, as shown:
-
-| 0.0 ( cube) | 0.3 | 0.7 | 1.0 (octahedron) |
-|-------------|-----|-----|------------------|
-| ![ ](../assets/img/renderers/cube.png) ![ ](renderers/cube.png) | ![ ](../assets/img/renderers/bevelled-cube-low.png) ![ ](renderers/bevelled-cube-low.png) | ![ ](../assets/img/renderers/bevelled-cube-high.png) ![ ](renderers/bevelled-cube-high.png) | ![ ](../assets/img/renderers/octahedron.png) ![ ](renderers/octahedron.png) |
-
-### Slices {#slices-details}
-
-For spheres and conical frustrums, 'slices' determines how many divisions there are as you go around the object. Note that spheres are rendered along the Z-axis, and so will appear rotated.
-
-![ ](../assets/img/renderers/slices.png)
-![ ](renderers/slices.png)
-
-### Stacks {#stacks-details}
-
-For spheres, 'stacks' determines how many layers there are as you go down the object. Note that spheres are rendered along the Z-axis, and so will appear rotated.
-
-![ ](../assets/img/renderers/stacks.png)
-![ ](renderers/stacks.png)
-
-### Usage
-
-**sphere**
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-
-map[ "rendererType" ] = "PRIMITIVE";
-map[ "shape" ] = "SPHERE";
-map[ "color" ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-**conical frustrum**
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-
-map[ "rendererType" ] = "PRIMITIVE";
-map[ "shape" ] = "CONICAL_FRUSTRUM";
-map[ "color" ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
-map[ "scaleTopRadius" ] = 1.0f;
-map[ "scaleBottomRadius" ] = 1.5f;
-map[ "scaleHeight" ] = 3.0f;
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-**bevelled cube**
-
-~~~{.cpp}
-// C++
-Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
-
-Dali::Property::Map map;
-
-map[ "rendererType" ] = "PRIMITIVE";
-map[ "shape" ] = "BEVELLED_CUBE";
-map[ "color" ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
-map[ "bevelPercentage" ] = 0.4f;
-
-control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
-~~~
-
-@class _Guide_Control_Renderers
-
-*/
To render content, the required actors can be created and added to the control itself as its children.
However, this solution is not fully optimised and means extra actors will be added, and thus, need to be processed by DALi.
-Controls should be as generic as possible so the recommendation is to re-use control renderers to create the content required as described in the [Control Renderers](@ref control-renderers) section.
+Controls should be as generic as possible so the recommendation is to re-use visuals to create the content required as described in the [Visuals](@ref visuals) section.
Currently, this is devel-api though, so is subject to change.
![ ](../assets/img/creating-custom-controls/rendering.png)
// C++
void MyUIControlImpl::OnInitialize()
{
- // Create renderers, register events etc.
+ // Create visuals, register events etc.
}
~~~
___________________________________________________________________________________________________
+++ /dev/null
-<!--
-/**-->
-
-# Debug Renderer {#debugrenderer}
-
-## Enable debug rendering
-
-Setting DALI_DEBUG_RENDERING environment variable will enable the renderer debuging.
-
-Then, every concrete control renderer( ColorRenderer, BorderRenderer, ImageRenderer, GradientRenderer, etc. ) is replaced with a DebugRenderer object.
-Debug renderer renders a simple quad wireframe, so that the control layout and scene structure is clearly displayed.
-
-### Example:
-~~~{.bash}
-sh-4.1$ DALI_DEBUG_RENDERING=1 /usr/apps/com.samsung.dali-demo/bin/blocks.example
-~~~
-
-![ ](../assets/img/debug-renderer/debug-blocks.png)
-![ ](debug-blocks.png)
-
-
--- /dev/null
+<!--
+/**-->
+
+# Debug Visual {#debugvisual}
+
+## Enable debug rendering
+
+Setting DALI_DEBUG_RENDERING environment variable will enable the visual debuging.
+
+Then, every concrete visual ( ColorVisual, BorderVisual, ImageVisual, GradientVisual, etc. ) is replaced with a DebugVisual object.
+Debug visual renders a simple quad wireframe, so that the control layout and scene structure is clearly displayed.
+
+### Example:
+~~~{.bash}
+sh-4.1$ DALI_DEBUG_RENDERING=1 /usr/apps/com.samsung.dali-demo/bin/blocks.example
+~~~
+
+![ ](../assets/img/debug-visual/debug-blocks.png)
+![ ](debug-blocks.png)
+
+
--- /dev/null
+<!--
+/**-->
+
+# Visuals {#visuals}
+
+Visuals provide reusable rendering logic which can be used by all controls.
+This means that custom controls do not have to create actors, they can just reuse the existing visuals which increases performance.
+
+Visuals reuse geometry, shaders etc. across controls and manages the renderer and material to exist only when the control is on-stage.
+Additionaly, they respond to actor size and color change, while also providing clipping at the renderer level.
+
+DALi provides the following visuals:
+ + [Color](@ref color-visual)
+ + [Gradient](@ref gradient-visual)
+ + [Image](@ref image-visuals)
+ + [Border](@ref border-visual)
+ + [Mesh](@ref mesh-visual)
+ + [Primitive](@ref primitive-visual)
+
+Controls can provide properties that allow users to specify the visual type ( visualType ).
+Setting visual properties are done via a property map.
+The **visualType** field in the property map specifies the visual to use/create.
+This is required to avoid ambiguity as multiple visuals may be capable of rendering the same contents.
+___________________________________________________________________________________________________
+
+## Color Visual {#color-visual}
+
+Renders a solid color to the control's quad.
+
+![ ](../assets/img/visuals/color-visual.png)
+![ ](visuals/color-visual.png)
+
+### Properties Supported
+
+**VisualType:** Dali::Toolkit::Visual::COLOR, "COLOR"
+
+| Property | String | Type | Required | Description |
+|-------------------------------------------------|----------|:-------:|:--------:|---------------------------|
+| Dali::Toolkit::ColorVisual::Property::MIX_COLOR | mixColor | VECTOR4 | Yes | The solid color required. |
+
+### Usage
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::COLOR;
+map[ ColorVisual::Property::MIX_COLOR ] = Color::RED;
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+~~~{.js}
+// JavaScript
+var control = new dali.Control( "Control" );
+
+control.background =
+{
+ visualType : "COLOR",
+ mixColor : dali.COLOR_RED
+};
+~~~
+___________________________________________________________________________________________________
+
+## Gradient Visual {#gradient-visual}
+
+Renders a smooth transition of colors to the control's quad.
+
+Both Linear and Radial gradients are supported.
+
+| Linear | Radial |
+|--------|--------|
+| ![ ](../assets/img/visuals/linear-gradient-visual.png) ![ ](visuals/linear-gradient-visual.png) | ![ ](../assets/img/visuals/radial-gradient-visual.png) ![ ](visuals/radial-gradient-visual.png) |
+
+### Properties Supported
+
+**VisualType:** Dali::Toolkit::Visual::GRADIENT, "GRADIENT"
+
+| Property | String | Type | Required | Description |
+|---------------------------------------------------------|---------------|:-----------------:|:----------:|------------------------------------------------------------------------------------------------------------------|
+| Dali::Toolkit::GradientVisual::Property::START_POSITION | startPosition | VECTOR2 | For Linear | The start position of the linear gradient. |
+| Dali::Toolkit::GradientVisual::Property::END_POSITION | endPosition | VECTOR2 | For Linear | The end position of the linear gradient. |
+| Dali::Toolkit::GradientVisual::Property::CENTER | center | VECTOR2 | For Radial | The center point of the gradient. |
+| Dali::Toolkit::GradientVisual::Property::RADIUS | radius | FLOAT | For Radial | The size of the radius. |
+| Dali::Toolkit::GradientVisual::Property::STOP_OFFSET | stopOffset | ARRAY of FLOAT | No | All the stop offsets. If not supplied default is 0.0 and 1.0. |
+| Dali::Toolkit::GradientVisual::Property::STOP_COLOR | stopColor | ARRAY of VECTOR4 | Yes | The color at those stop offsets. At least 2 required to show a gradient. |
+| Dali::Toolkit::GradientVisual::Property::UNITS | units | INTEGER or STRING | No | Defines the coordinate system. [More info](@ref gradient-visual-units) |
+| Dali::Toolkit::GradientVisual::Property::SPREAD_METHOD | spreadMethod | INTEGER or STRING | No | Indicates what happens if gradient starts or ends inside bounds. [More info](@ref gradient-visual-spread-method) |
+
+If the *stopOffset* and *stopColor* arrays do not have the same number of elements, then the minimum of the two is used as the stop points.
+
+### Units {#gradient-visual-units}
+
+Defines the coordinate system for the attributes:
+ + Start (x1, y1) and End (x2 and y2) points of a line if using a linear gradient.
+ + Center point (cx, cy) and radius (r) of a circle if using a radial gradient.
+
+| Enumeration | String | Description |
+|-----------------------------------------------------------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
+| Dali::Toolkit::GradientVisual::Units::OBJECT_BOUNDING_BOX | OBJECT_BOUNDING_BOX | *Default*. Uses the normals for the start, end & center points, i.e. top-left is (-0.5, -0.5) and bottom-right is (0.5, 0.5). |
+| Dali::Toolkit::GradientVisual::Units::USER_SPACE | USER_SPACE | Uses the user coordinates for the start, end & center points, i.e. in a 200 by 200 control, top-left is (0, 0) and bottom-right is (200, 200). |
+
+### Spread Method {#gradient-visual-spread-method}
+
+Indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.
+
+| Enumeration | String | Description |
+|------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------|
+| Dali::Toolkit::GradientVisual::SpreadMethod::PAD | PAD | *Default*. Uses the terminal colors of the gradient to fill the remainder of the quad. |
+| Dali::Toolkit::GradientVisual::SpreadMethod::REFLECT | REFLECT | Reflect the gradient pattern start-to-end, end-to-start, start-to-end etc. until the quad is filled. |
+| Dali::Toolkit::GradientVisual::SpreadMethod::REPEAT | REPEAT | Repeat the gradient pattern start-to-end, start-to-end, start-to-end etc. until the quad is filled. |
+
+### Usage
+
+**Linear:**
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::GRADIENT;
+map[ GradientVisual::Property::START_POSITION ] = Vector2( 0.5f, 0.5f );
+map[ GradientVisual::Property::END_POSITION ] = Vector2( -0.5f, -0.5f );
+
+Dali::Property::Array stopOffsets;
+stopOffsets.PushBack( 0.0f );
+stopOffsets.PushBack( 0.3f );
+stopOffsets.PushBack( 0.6f );
+stopOffsets.PushBack( 0.8f );
+stopOffsets.PushBack( 1.f );
+map[ GradientVisual::Property::STOP_OFFSET ] = stopOffsets;
+
+Dali::Property::Array stopColors;
+stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
+stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
+stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
+stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
+stopColors.PushBack( Color::YELLOW );
+map[ GradientVisual::Property::STOP_COLOR ] = stopColors;
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+~~~{.js}
+// JavaScript
+var control = new dali.Control( "Control" );
+
+control.background =
+{
+ visualType : "GRADIENT",
+ startPosition : [ 0.5, 0.5 ],
+ endPosition : [ -0.5, -0.5 ],
+ stopOffset : [ 0.0, 0.3, 0.6, 0.8, 1.0 ],
+ stopColor : [
+ [ 129 / 255, 198 / 255, 193 / 255, 255 / 255 ],
+ [ 196 / 255, 198 / 255, 71 / 255, 122 / 255 ],
+ [ 214 / 255, 37 / 255, 139 / 255, 191 / 255 ],
+ [ 129 / 255, 198 / 255, 193 / 255, 150 / 255 ],
+ dali.COLOR_YELLOW
+ ]
+};
+~~~
+
+**Radial:**
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::GRADIENT;
+map[ GradientVisual::Property::CENTER ] = Vector2( 0.5f, 0.5f );
+map[ GradientVisual::Property::RADIUS ] = 1.414f;
+
+Dali::Property::Array stopOffsets;
+stopOffsets.PushBack( 0.0f );
+stopOffsets.PushBack( 0.3f );
+stopOffsets.PushBack( 0.6f );
+stopOffsets.PushBack( 0.8f );
+stopOffsets.PushBack( 1.f );
+map[ GradientVisual::Property::STOP_OFFSET ] = stopOffsets;
+
+Dali::Property::Array stopColors;
+stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
+stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
+stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
+stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
+stopColors.PushBack( Color::YELLOW );
+map[ GradientVisual::Property::STOP_COLOR ] = stopColors;
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+~~~{.js}
+// JavaScript
+var control = new dali.Control( "Control" );
+
+control.background =
+{
+ visualType : "GRADIENT",
+ center : [ 0.5, 0.5 ],
+ radius : 1.414,
+ stopOffset : [ 0.0, 0.3, 0.6, 0.8, 1.0 ],
+ stopColor : [
+ [ 129 / 255, 198 / 255, 193 / 255, 255 / 255 ],
+ [ 196 / 255, 198 / 255, 71 / 255, 122 / 255 ],
+ [ 214 / 255, 37 / 255, 139 / 255, 191 / 255 ],
+ [ 129 / 255, 198 / 255, 193 / 255, 150 / 255 ],
+ dali.COLOR_YELLOW
+ ]
+};
+~~~
+___________________________________________________________________________________________________
+
+## Image Visual {#image-visuals}
+
+Renders an image into the control's quad.
+
+Depending on the extension of the image, a different visual is provided to render the image onto the screen.
+
+ + [Normal (Quad)](@ref image-visual)
+ + [N-Patch](@ref n-patch-visual)
+ + [SVG](@ref svg-visual)
+
+___________________________
+
+### Normal {#image-visual}
+
+Renders a raster image ( jpg, png etc.) into the control's quad.
+
+![ ](../assets/img/visuals/image-visual.png)
+![ ](visuals/image-visual.png)
+
+#### Properties Supported
+
+**VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
+
+| Property | String | Type | Required | Description |
+|------------------------------------------------------|---------------|:-----------------:|:--------:|--------------------------------------------------------------------------------------------------------------------------|
+| Dali::Toolkit::ImageVisual::Property::URL | url | STRING | Yes | The URL of the image. |
+| Dali::Toolkit::ImageVisual::Property::FITTING_MODE | fittingMode | INTEGER or STRING | No | Fitting options, used when resizing images to fit desired dimensions. [More info](@ref resourceimagescaling-fittingmode) |
+| Dali::Toolkit::ImageVisual::Property::SAMPLING_MODE | samplingMode | INTEGER or STRING | No | Filtering options, used when resizing images to sample original pixels. [More info](@ref resourceimagescaling-scaling) |
+| Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH | desiredWidth | INT | No | The desired image width. Will use actual image width if not specified. |
+| Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT | desiredHeight | INT | No | The desired image height. Will use actual image height if not specified. |
+
+#### Usage
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::IMAGE;
+map[ ImageVisual::Property::URL ] = "path-to-image.jpg";
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+~~~{.js}
+// JavaScript
+var control = new dali.Control( "Control" );
+
+control.background =
+{
+ visualType : "IMAGE",
+ url : "path-to-image.jpg"
+};
+~~~
+___________________________________________________________________________________________________
+
+### N-Patch {#n-patch-visual}
+
+Renders an n-patch or a 9-patch image into the control's quad.
+
+![ ](../assets/img/visuals/n-patch-visual.png)
+![ ](visuals/n-patch-visual.png)
+
+#### Properties Supported
+
+**VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
+
+| Property | String | Type | Required | Description |
+|---------------------------------------------------|---------------|:-------:|:--------:|----------------------------------|
+| Dali::Toolkit::ImageVisual::Property::URL | url | STRING | Yes | The URL of the n-patch image. |
+| Dali::Toolkit::ImageVisual::Property::BORDER_ONLY | borderOnly | BOOLEAN | No | If true, only draws the borders. |
+
+#### Usage
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::IMAGE;
+map[ Dali::Toolkit::ImageVisual::Property::URL ] = "path-to-image.9.png";
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+~~~{.js}
+// JavaScript
+var control = new dali.Control( "Control" );
+
+control.background =
+{
+ visualType : "IMAGE",
+ url : "path-to-image.9.png"
+};
+~~~
+
+___________________________________________________________________________________________________
+
+### SVG {#svg-visual}
+
+Renders a svg image into the control's quad.
+
+#### Features: SVG Tiny 1.2 specification
+
+**supported:**
+
+ * basic shapes
+ * paths
+ * solid color fill
+ * gradient color fill
+ * solid color stroke
+
+**not supported:**
+
+ * gradient color stroke
+ * dash array stroke
+ * view box
+ * text
+ * clip path
+
+<div style="width:300px">
+
+![ ](../assets/img/visuals/svg-visual.svg)
+
+</div>
+
+<div style="width:300px">
+
+![ ](visuals/svg-visual.svg)
+
+</div>
+
+
+#### Properties Supported
+
+**VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
+
+| Property | String | Type | Required | Description |
+|-------------------------------------------|--------|:-------:|:--------:|----------------------------------|
+| Dali::Toolkit::ImageVisual::Property::URL | url | STRING | Yes | The URL of the SVG image. |
+
+#### Usage
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::IMAGE;
+map[ Dali::Toolkit::ImageVisual::Property::URL ] = "path-to-image.svg";
+
+control.SetSize( 200.f, 200.f );
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+~~~{.js}
+// JavaScript
+var control = new dali.Control( "Control" );
+
+control.background =
+{
+ visualType : "IMAGE",
+ url : "path-to-image.svg"
+};
+~~~
+___________________________________________________________________________________________________
+
+## Border Visual {#border-visual}
+
+Renders a solid color as an internal border to the control's quad.
+
+![ ](../assets/img/visuals/border-visual.png)
+![ ](visuals/border-visual.png)
+
+### Properties Supported
+
+**VisualType:** Dali::Toolkit::Visual::BORDER, "BORDER"
+
+| Property | String | Type | Required | Description |
+|------------------------------------------------------|---------------|:-------:|:--------:|--------------------------------------------------|
+| Dali::Toolkit::BorderVisual::Property::COLOR | borderColor | VECTOR4 | Yes | The color of the border. |
+| Dali::Toolkit::BorderVisual::Property::SIZE | borderSize | FLOAT | Yes | The width of the border (in pixels). |
+| Dali::Toolkit::BorderVisual::Property::ANTI_ALIASING | antiAliasing | BOOLEAN | No | Whether anti-aliasing of the border is required. |
+
+### Usage
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::BORDER;
+map[ BorderVisual::Property::COLOR ] = Color::BLUE;
+map[ BorderVisual::Property::SIZE ] = 5.0f;
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+~~~{.js}
+// JavaScript
+var control = new dali.Control( "Control" );
+
+control.background =
+{
+ visualType : "BORDER",
+ borderColor : dali.COLOR_BLUE,
+ borderSize = 5
+};
+~~~
+
+___________________________________________________________________________________________________
+
+## Mesh Visual {#mesh-visual}
+
+Renders a mesh using a .obj file, optionally with textures provided by a mtl file. Scaled to fit the control.
+
+![ ](../assets/img/visuals/mesh-visual.png)
+![ ](visuals/mesh-visual.png)
+
+### Properties Supported
+
+**VisualType:** Dali::Toolkit::Visual::MESH, "MESH"
+
+| Property | String | Type | Required | Description |
+|-------------------------------------------------------|----------------|:------------------:|:-----------------:|--------------------------------------------------------------------------------------------------|
+| Dali::Toolkit::MeshVisual::Property::OBJECT_URL | objectUrl | STRING | Yes | The location of the ".obj" file. |
+| Dali::Toolkit::MeshVisual::Property::MATERIAL_URL | materialUrl | STRING | No | The location of the ".mtl" file. Leave blank for a textureless object. |
+| Dali::Toolkit::MeshVisual::Property::TEXTURES_PATH | texturesPath | STRING | If using material | Path to the directory the textures (including gloss and normal) are stored in. |
+| Dali::Toolkit::MeshVisual::Property::SHADING_MODE | shadingMode | INTEGER or STRING | No | Sets the type of shading mode that the mesh will use. [More info](@ref mesh-visual-shading-mode) |
+| Dali::Toolkit::MeshVisual::Property::USE_MIPMAPPING | useMipmapping | BOOLEAN | No | Flag for whether to use mipmaps for textures or not. Default true. |
+| Dali::Toolkit::MeshVisual::Property::USE_SOFT_NORMALS | useSoftNormals | BOOLEAN | No | Flag for whether to average normals at each point to smooth textures or not. Default true. |
+| Dali::Toolkit::MeshVisual::Property::LIGHT_POSITION | lightPosition | VECTOR3 | No | The position, in stage space, of the point light that applies lighting to the model. |
+
+### Shading Mode {#mesh-visual-shading-mode}
+
+When specifying the shading mode, if anything the mode requires is missing, a simpler mode that can be handled with what has been supplied will be used instead.
+
+**Possible values:**
+
+| Enumeration | String | Description |
+|---------------------------------------------------------------------------------|------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
+| Dali::Toolkit::MeshVisual::ShaderType::TEXTURELESS_WITH_DIFFUSE_LIGHTING | TEXTURELESS_WITH_DIFFUSE_LIGHTING | *Simplest*. One color that is lit by ambient and diffuse lighting. |
+| Dali::Toolkit::MeshVisual::ShaderType::TEXTURED_WITH_SPECULAR_LIGHTING | TEXTURED_WITH_SPECULAR_LIGHTING | Uses only the visual image textures provided with specular lighting in addition to ambient and diffuse lighting. |
+| Dali::Toolkit::MeshVisual::ShaderType::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING | TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING | Uses all textures provided including a gloss, normal and texture map along with specular, ambient and diffuse lighting. |
+
+### Usage
+
+~~~{.cpp}
+// C++
+Dali::Stage stage = Dali::Stage::GetCurrent();
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::MESH;
+map[ MeshVisual::Property::OBJECT_URL ] = "home/models/Dino.obj";
+map[ MeshVisual::Property::MATERIAL_URL ] = "home/models/Dino.mtl";
+map[ MeshVisual::Property::TEXTURES_PATH ] = "home/images/";
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+___________________________________________________________________________________________________
+
+## Primitive Visual {#primitive-visual}
+
+Renders a simple 3D shape, such as a cube or sphere. Scaled to fit the control.
+
+The shapes are generated with clockwise winding and back-face culling on by default.
+
+![ ](../assets/img/visuals/cube.png)
+![ ](visuals/cube.png)
+
+### Properties Supported
+
+**VisualType:** Dali::Toolkit::Visual::PRIMITIVE, "PRIMITIVE"
+
+| Property | String | Type | Description | Default Value | Range |
+|---------------------------------------------------------------|-------------------|:------------------:|-----------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------:|:------------------------------:|
+| Dali::Toolkit::PrimitiveVisual::Property::SHAPE | shape | INTEGER or STRING | The specific shape to render. [More info](@ref shape-details) | Dali::Toolkit::PrimitiveVisual::Shape::SPHERE, "SPHERE" | [See list](@ref shape-details) |
+| Dali::Toolkit::PrimitiveVisual::Property::COLOR | shapeColor | VECTOR4 | The color of the shape. | (0.5, 0.5, 0.5, 1.0) | 0.0 - 1.0 for each |
+| Dali::Toolkit::PrimitiveVisual::Property::SLICES | slices | INTEGER | The number of slices as you go around the shape. [More info](@ref slices-details) | 128 | 1 - 255 |
+| Dali::Toolkit::PrimitiveVisual::Property::STACKS | stacks | INTEGER | The number of stacks as you go down the shape. [More info](@ref stacks-details) | 128 | 1 - 255 |
+| Dali::Toolkit::PrimitiveVisual::Property::SCALE_TOP_RADIUS | scaleTopRadius | FLOAT | The scale of the radius of the top circle of a conical frustrum. | 1.0 | ≥ 0.0 |
+| Dali::Toolkit::PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS | scaleBottomRadius | FLOAT | The scale of the radius of the bottom circle of a conical frustrum. | 1.5 | ≥ 0.0 |
+| Dali::Toolkit::PrimitiveVisual::Property::SCALE_HEIGHT | scaleHeight | FLOAT | The scale of the height of a conic. | 3.0 | > 0.0 |
+| Dali::Toolkit::PrimitiveVisual::Property::SCALE_RADIUS | scaleRadius | FLOAT | The scale of the radius of a cylinder. | 1.0 | > 0.0 |
+| Dali::Toolkit::PrimitiveVisual::Property::SCALE_DIMENSIONS | scaleDimensions | VECTOR3 | The dimensions of a cuboid. Scales in the same fashion as a 9-patch image. | Vector3::ONE | > 0.0 for each |
+| Dali::Toolkit::PrimitiveVisual::Property::BEVEL_PERCENTAGE | bevelPercentage | FLOAT | Determines how bevelled the cuboid should be, based off the smallest dimension. [More info](@ref bevel-details) | 0.0 (no bevel) | 0.0 - 1.0 |
+| Dali::Toolkit::PrimitiveVisual::Property::BEVEL_SMOOTHNESS | bevelSmoothness | FLOAT | Defines how smooth the bevelled edges should be. | 0.0 (sharp edges) | 0.0 - 1.0 |
+| Dali::Toolkit::PrimitiveVisual::Property::LIGHT_POSITION | lightPosition | VECTOR3 | The position, in stage space, of the point light that applies lighting to the model. | (Offset outwards from the center of the screen.) | Unlimited |
+
+### Shapes {#shape-details}
+
+There are six shapes that can be chosen, some of which are simplified specialisations of another.
+
+| Enumeration | String | Description | Parameters |
+|---------------------------------------------------------|------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------|
+| Dali::Toolkit::PrimitiveVisual::Shape::SPHERE | SPHERE | *Default*. | color, slices, stacks |
+| Dali::Toolkit::PrimitiveVisual::Shape::CONICAL_FRUSTRUM | CONICAL_FRUSTRUM | The area bound between two circles, i.e. a cone with the tip removed. | color, scaleTopRadius, scaleBottomRadius, scaleHeight, slices |
+| Dali::Toolkit::PrimitiveVisual::Shape::CONE | CONE | Equivalent to a conical frustrum with top radius of zero. | color, scaleBottomRadius, scaleHeight, slices |
+| Dali::Toolkit::PrimitiveVisual::Shape::CYLINDER | CYLINDER | Equivalent to a conical frustrum with equal radii for the top and bottom circles. | color, scaleRadius, scaleHeight, slices |
+| Dali::Toolkit::PrimitiveVisual::Shape::CUBE | CUBE | Equivalent to a bevelled cube with a bevel percentage of zero. | color, scaleDimensions |
+| Dali::Toolkit::PrimitiveVisual::Shape::OCTAHEDRON | OCTAHEDRON | Equivalent to a bevelled cube with a bevel percentage of one. | color, scaleDimensions |
+| Dali::Toolkit::PrimitiveVisual::Shape::BEVELLED_CUBE | BEVELLED_CUBE | A cube/cuboid with all edges flattened to some degree. | color, scaleDimensions, bevelPercentage, bevelSmoothness |
+
+#### Examples below:
+
+**sphere:**
+
+![ ](../assets/img/visuals/sphere.png)
+![ ](visuals/sphere.png)
+
+**conics:**
+
+| Frustrum | Cone | Cylinder |
+|----------|------|----------|
+| ![ ](../assets/img/visuals/conical-frustrum.png) ![ ](visuals/conical-frustrum.png) | ![ ](../assets/img/visuals/cone.png) ![ ](visuals/cone.png) | ![ ](../assets/img/visuals/cylinder.png) ![ ](visuals/cylinder.png) |
+
+### Bevel {#bevel-details}
+
+Bevel percentage ranges from 0.0 to 1.0. It affects the ratio of the outer face widths to the width of the overall cube, as shown:
+
+| 0.0 ( cube) | 0.3 | 0.7 | 1.0 (octahedron) |
+|-------------|-----|-----|------------------|
+| ![ ](../assets/img/visuals/cube.png) ![ ](visuals/cube.png) | ![ ](../assets/img/visuals/bevelled-cube-low.png) ![ ](visuals/bevelled-cube-low.png) | ![ ](../assets/img/visuals/bevelled-cube-high.png) ![ ](visuals/bevelled-cube-high.png) | ![ ](../assets/img/visuals/octahedron.png) ![ ](visuals/octahedron.png) |
+
+### Slices {#slices-details}
+
+For spheres and conical frustrums, 'slices' determines how many divisions there are as you go around the object.
+
+![ ](../assets/img/visuals/slices.png)
+![ ](visuals/slices.png)
+
+### Stacks {#stacks-details}
+
+For spheres, 'stacks' determines how many layers there are as you go down the object.
+
+![ ](../assets/img/visuals/stacks.png)
+![ ](visuals/stacks.png)
+
+### Usage
+
+**sphere**
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
+map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::SPHERE;
+map[ PrimitiveVisual::Property::COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+**conical frustrum**
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
+map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::CONICAL_FRUSTRUM;
+map[ PrimitiveVisual::Property::COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+map[ PrimitiveVisual::Property::SCALE_TOP_RADIUS ] = 1.0f;
+map[ PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS ] = 1.5f;
+map[ PrimitiveVisual::Property::SCALE_HEIGHT ] = 3.0f;
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+**bevelled cube**
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
+map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::BEVELLED_CUBE;
+map[ PrimitiveVisual::Property::COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+map[ PrimitiveVisual::Property::BEVEL_PERCENTAGE ] = 0.4f;
+
+control.SetProperty( Control::Property::BACKGROUND, map );
+~~~
+
+@class _Guide_Control_Visuals
+
+*/
geometry.addVertexBuffer( pentagonVertices );
geometry.addVertexBuffer( pentacleVertices );
geometry.setIndexBuffer( indexDataArray, 10 );
- geometry.setGeometryType( dali.GEOMETRY_LINES );
+ geometry.setType( dali.GEOMETRY_LINES );
var renderer = new dali.Renderer(geometry, shader);
renderer.depthIndex = 0;
// Create geometry
var geometry = new dali.Geometry();
geometry.addVertexBuffer( polyhedraVertices );
- geometry.setGeometryType( dali.GEOMETRY_POINTS );
+ geometry.setType( dali.GEOMETRY_POINTS );
var renderer = new dali.Renderer(geometry, shader);
renderer.setTextures(textureSet);
"type":"ImageView",
"image":
{
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url": "{icon_path}"
},
"position":[20.0, 0.0, 0.0],
"type":"ImageView",
"image":
{
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url": "{icon_path}"
},
"position":[0.0, -10.0, 0.0],
"type":"ImageView",
"image":
{
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url": "{icon_path}"
},
"position":[20.0, 0.0, 0.0],
"type":"ImageView",
"image":
{
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url": "{icon_path}"
},
"position":[0.0, -10.0, 0.0],
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.1.44
+Version: 1.1.45
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT
# Applications or dali-addon will decide which one they will use.
BuildRequires: dali-adaptor-devel
+#need libtzplatform-config for directory if tizen version is 3.x
+
+%if "%{tizen_version_major}" == "3"
+BuildRequires: pkgconfig(libtzplatform-config)
+%endif
+
#############################
# profile setup
#############################
##############################
%prep
%setup -q
+
+#Use TZ_PATH when tizen version is 3.x
+
+%if "%{tizen_version_major}" == "2"
%define dali_data_rw_dir /opt/usr/share/dali/
%define dali_data_ro_dir /usr/share/dali/
+%else
+%define dali_data_rw_dir %TZ_SYS_SHARE/dali/
+%define dali_data_ro_dir %TZ_SYS_RO_SHARE/dali/
+%endif
+
%define dali_toolkit_image_files %{dali_data_ro_dir}/toolkit/images/
%define dali_toolkit_sound_files %{dali_data_ro_dir}/toolkit/sounds/
%define dali_toolkit_style_files %{dali_data_ro_dir}/toolkit/styles/
// 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
+ // [ "OUTPUT_IS_TRANSPARENT", // Might generate transparent alpha from opaque inputs
+ // "MODIFIES_GEOMETRY" ]; // Might change position of vertices, this option disables any culling optimizations
var shader = {
"fragmentShader": fragShader,
- "hints" : "outputIsTransparent"
+ "hints" : "OUTPUT_IS_TRANSPARENT"
};
return shader;
var shader = createColorShiftAndZoomEffect();
var image = {
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url" : getImageDirectory()+"gallery-medium-50.jpg",
"shader" : shader
};
// 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
+// [ "OUTPUT_IS_TRANSPARENT", // Might generate transparent alpha from opaque inputs
+// "MODIFIES_GEOMETRY" ]; // Might change position of vertices, this option disables any culling optimizations
var shader = {
"vertexShader": myVertexShader,
dali.stage.add( imageView );
var image = {
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url" : "myImage.jpg",
"desiredWidth" : desiredWidth, // The desired image width while loading (optional but preferable to set for efficiency)
"desiredHeight" : desiredHeight, // The desired image height while loading (optional but preferable to set for efficiency)
"type":"ImageView",
"image":
{
- "rendererType" : "IMAGE",
+ "visualType" : "IMAGE",
"url": "{icon_path}"
},
"position":[20.0, 0.0, 0.0],
/**
* Set the type of primitives this geometry contains
*
- * @method setGeometryType
+ * @method setType
* @for Geometry
* @param {integer} geometryType Type of primitives this geometry contains
* @example
* dali.GEOMETRY_TRIANGLE_FAN
* dali.GEOMETRY_TRIANGLE_STRIP
*
- * geometry.SetGeometryType( dali.GEOMETRY_LINES );
+ * geometry.SetType( dali.GEOMETRY_LINES );
*/
-void GeometryApi::SetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args )
+void GeometryApi::SetType( const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
}
else
{
- geometry.SetGeometryType(static_cast<Geometry::GeometryType>(geometryType));
+ geometry.SetType(static_cast<Geometry::Type>(geometryType));
}
}
/**
* Get the type of primitives this geometry contains
*
- * @method getGeometryType
+ * @method getType
* @for Geometry
* @return {integer} Type of primitives this geometry contains
* @example
* dali.GEOMETRY_TRIANGLE_FAN
* dali.GEOMETRY_TRIANGLE_STRIP
*/
-void GeometryApi::GetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args )
+void GeometryApi::GetType( const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
Geometry geometry = GetGeometry( isolate, args );
- args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.GetGeometryType() ) );
+ args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.GetType() ) );
}
} // namespace V8Plugin
void GetNumberOfVertexBuffers( const v8::FunctionCallbackInfo< v8::Value >& args );
void RemoveVertexBuffer( const v8::FunctionCallbackInfo< v8::Value >& args );
void SetIndexBuffer( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetType( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetType( const v8::FunctionCallbackInfo< v8::Value >& args );
}; // namespace GeometryApi
{ "GetNumberOfVertexBuffers" , GeometryApi::GetNumberOfVertexBuffers },
{ "RemoveVertexBuffer" , GeometryApi::RemoveVertexBuffer },
{ "SetIndexBuffer" , GeometryApi::SetIndexBuffer },
- { "SetGeometryType" , GeometryApi::SetGeometryType },
- { "GetGeometryType" , GeometryApi::GetGeometryType },
+ { "SetType" , GeometryApi::SetType },
+ { "GetType" , GeometryApi::GetType },
};
const unsigned int GeometryFunctionTableCount = sizeof(GeometryFunctionTable)/sizeof(GeometryFunctionTable[0]);
struct ShaderHintPair
{
const char* name;
- Shader::ShaderHints hint;
+ Shader::Hint::Value hint;
};
const ShaderHintPair ShaderHintTable[]=
{
- {"outputIsTransparent", Shader::HINT_OUTPUT_IS_TRANSPARENT },
- {"modifiesGeometry", Shader::HINT_MODIFIES_GEOMETRY },
+ {"outputIsTransparent", Shader::Hint::OUTPUT_IS_TRANSPARENT },
+ {"modifiesGeometry", Shader::Hint::MODIFIES_GEOMETRY },
};
const unsigned int ShaderHintTableCount = sizeof(ShaderHintTable)/sizeof(ShaderHintTable[0]);
struct ShaderParameters
{
ShaderParameters()
- : mHints( Shader::HINT_NONE )
+ : mHints( Shader::Hint::NONE )
{
}
- Shader::ShaderHints GetShaderHint( const std::string& hint )
+ Shader::Hint::Value GetShaderHint( const std::string& hint )
{
for( unsigned int i = 0 ; i < ShaderHintTableCount; ++i )
{
return ShaderHintTable[i].hint;
}
}
- return Shader::HINT_NONE;
+ return Shader::Hint::NONE;
}
void ProcessHintsArray( const HintsArray& hintsArray )
{
for( HintsArray::const_iterator iter = hintsArray.begin(); iter != hintsArray.end() ; ++iter )
{
- mHints= static_cast<Shader::ShaderHints>( mHints | GetShaderHint( *iter ) );
+ mHints= static_cast<Shader::Hint::Value>( mHints | GetShaderHint( *iter ) );
}
}
std::string mVertex;
std::string mFragment;
- Shader::ShaderHints mHints;
+ Shader::Hint::Value mHints;
};
} // unnamed space