From: Adeel Kazmi Date: Mon, 18 Jul 2016 12:36:12 +0000 (+0100) Subject: Change enumeration values to uppercase for Mesh & Gradient Renderer X-Git-Tag: dali_1.1.44~9 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=8d57a46c918cd6a824dbe6f93884e8e453c35e26 Change enumeration values to uppercase for Mesh & Gradient Renderer Change-Id: I69b630f0afb5ff3531f6b4c74532716b34e2051d --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp index 3518778..fdb576e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp @@ -361,9 +361,9 @@ int UtcDaliControlRendererGetPropertyMap3(void) 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("startPosition", start); + propertyMap.Insert("endPosition", end); + propertyMap.Insert("spreadMethod", "REPEAT"); propertyMap.Insert("stopOffset", Vector2(0.2f, 0.8f)); @@ -384,11 +384,11 @@ int UtcDaliControlRendererGetPropertyMap3(void) value = resultMap.Find( "units", Property::STRING ); DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == "objectBoundingBox" ); + DALI_TEST_CHECK( value->Get() == "OBJECT_BOUNDING_BOX" ); value = resultMap.Find( "spreadMethod", Property::STRING ); DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == "repeat" ); + DALI_TEST_CHECK( value->Get() == "REPEAT" ); value = resultMap.Find( "startPosition", Property::VECTOR2 ); DALI_TEST_CHECK( value ); @@ -428,7 +428,7 @@ int UtcDaliControlRendererGetPropertyMap4(void) Vector2 center(100.f, 100.f); float radius = 100.f; - propertyMap.Insert("units", "userSpace"); + propertyMap.Insert("units", "USER_SPACE"); propertyMap.Insert("center", center); propertyMap.Insert("radius", radius); propertyMap.Insert("stopOffset", Vector3(0.1f, 0.3f, 1.1f)); @@ -452,11 +452,11 @@ int UtcDaliControlRendererGetPropertyMap4(void) value = resultMap.Find( "units", Property::STRING ); DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == "userSpace" ); + DALI_TEST_CHECK( value->Get() == "USER_SPACE" ); value = resultMap.Find( "spreadMethod", Property::STRING ); DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == "pad" ); + DALI_TEST_CHECK( value->Get() == "PAD" ); value = resultMap.Find( "center", Property::VECTOR2 ); DALI_TEST_CHECK( value ); @@ -655,7 +655,7 @@ int UtcDaliControlRendererGetPropertyMap8(void) propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME ); propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME ); propertyMap.Insert( "texturesPath", TEST_RESOURCE_LOCATION ); - propertyMap.Insert( "shaderType", "textureless" ); + propertyMap.Insert( "shaderType", "TEXTURELESS" ); ControlRenderer meshRenderer = factory.CreateControlRenderer( propertyMap ); Property::Map resultMap; @@ -680,7 +680,7 @@ int UtcDaliControlRendererGetPropertyMap8(void) value = resultMap.Find( "shaderType", Property::STRING ); DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == "textureless" ); + DALI_TEST_CHECK( value->Get() == "TEXTURELESS" ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-DebugRenderer.cpp b/automated-tests/src/dali-toolkit/utc-Dali-DebugRenderer.cpp index 3092aff..82ffc09 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-DebugRenderer.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-DebugRenderer.cpp @@ -93,17 +93,17 @@ int UtcDaliDebugRendererGetRenderer1(void) propertyMap3.Insert("rendererType", "gradient"); Vector2 start(-1.f, -1.f); Vector2 end(1.f, 1.f); - propertyMap3.Insert("gradientStartPosition", start); - propertyMap3.Insert("gradientEndPosition", end); - propertyMap3.Insert("gradientSpreadMethod", "repeat"); + 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("gradientStopOffset", stopOffsets); + propertyMap3.Insert("stopOffset", stopOffsets); Property::Array stopColors; stopColors.PushBack( Color::RED ); stopColors.PushBack( Color::GREEN ); - propertyMap3.Insert("gradientStopColor", stopColors); + propertyMap3.Insert("stopColor", stopColors); ControlRenderer gradientRenderer = factory.CreateControlRenderer(propertyMap3); DALI_TEST_CHECK( gradientRenderer ); DALI_TEST_CHECK( IsDebugRenderer( gradientRenderer ) ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-RendererFactory.cpp b/automated-tests/src/dali-toolkit/utc-Dali-RendererFactory.cpp index aef0a65..8b6a072 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-RendererFactory.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-RendererFactory.cpp @@ -460,19 +460,19 @@ int UtcDaliRendererFactoryGetLinearGradientRenderer(void) 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("startPosition", start); + propertyMap.Insert("endPosition", end); + propertyMap.Insert("spreadMethod", "REPEAT"); Property::Array stopOffsets; stopOffsets.PushBack( 0.2f ); stopOffsets.PushBack( 0.8f ); - propertyMap.Insert("stopOffset", stopOffsets); + propertyMap.Insert("stopOffset", stopOffsets); Property::Array stopColors; stopColors.PushBack( Color::RED ); stopColors.PushBack( Color::GREEN ); - propertyMap.Insert("stopColor", stopColors); + propertyMap.Insert("stopColor", stopColors); ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap); DALI_TEST_CHECK( controlRenderer ); @@ -500,7 +500,7 @@ int UtcDaliRendererFactoryGetRadialGradientRenderer(void) Vector2 center(100.f, 100.f); float radius = 100.f; - propertyMap.Insert("units", "userSpace"); + propertyMap.Insert("units", "USER_SPACE"); propertyMap.Insert("center", center); propertyMap.Insert("radius", radius); @@ -545,14 +545,14 @@ int UtcDaliRendererFactoryDefaultOffsetsGradientRenderer(void) 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("startPosition", start); + propertyMap.Insert("endPosition", end); + propertyMap.Insert("spreadMethod", "REPEAT"); Property::Array stopColors; stopColors.PushBack( Color::RED ); stopColors.PushBack( Color::GREEN ); - propertyMap.Insert("stopColor", stopColors); + propertyMap.Insert("stopColor", stopColors); ControlRenderer controlRenderer = factory.CreateControlRenderer(propertyMap); DALI_TEST_CHECK( controlRenderer ); diff --git a/dali-toolkit/internal/controls/renderers/gradient/gradient-renderer.cpp b/dali-toolkit/internal/controls/renderers/gradient/gradient-renderer.cpp index 952bd3b..5923bb5 100644 --- a/dali-toolkit/internal/controls/renderers/gradient/gradient-renderer.cpp +++ b/dali-toolkit/internal/controls/renderers/gradient/gradient-renderer.cpp @@ -59,11 +59,11 @@ const char * const UNITS_NAME("units"); // Property::String "userSpaceOnUse | o const char * const SPREAD_METHOD_NAME("spreadMethod"); // Property::String "pad | reflect | repeat" // string values -const char * const UNIT_USER_SPACE("userSpace"); -const char * const UNIT_BOUNDING_BOX("objectBoundingBox"); -const char * const SPREAD_PAD("pad"); -const char * const SPREAD_REFLECT("reflect"); -const char * const SPREAD_REPEAT("repeat"); +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"); // uniform names const char * const UNIFORM_ALIGNMENT_MATRIX_NAME( "uAlignmentMatrix" ); @@ -196,7 +196,7 @@ void GradientRenderer::DoInitialize( Actor& actor, const Property::Map& property 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' + // Only need to set new units if 'USER_SPACE' if( unitsValue && unitsValue->Get( units ) && units == UNIT_USER_SPACE ) { gradientUnits = Gradient::USER_SPACE_ON_USE; diff --git a/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.cpp b/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.cpp index dd52948..f6186d3 100644 --- a/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.cpp +++ b/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.cpp @@ -87,6 +87,10 @@ const char * const RENDERER_TYPE_VALUE( "mesh" ); //String label for which type 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" ); + //Shaders //If a shader requires certain textures, they must be listed in order, //as detailed in the TextureIndex enum documentation. @@ -313,23 +317,27 @@ void MeshRenderer::DoInitialize( Actor& actor, const Property::Map& propertyMap } Property::Value* shaderType = propertyMap.Find( SHADER_TYPE ); - if( shaderType && shaderType->Get( mShaderTypeString ) ) + if( shaderType ) { - if( mShaderTypeString == "textureless" ) - { - mShaderType = TEXTURELESS; - } - else if( mShaderTypeString == "diffuseTexture" ) - { - mShaderType = DIFFUSE_TEXTURE; - } - else if( mShaderTypeString == "allTextures" ) - { - mShaderType = ALL_TEXTURES; - } - else + std::string shaderTypeString; + if( shaderType->Get( shaderTypeString ) ) { - DALI_LOG_ERROR( "Unknown shader type provided to the MeshRenderer object.\n"); + 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"); + } } } } @@ -365,7 +373,29 @@ void MeshRenderer::DoCreatePropertyMap( Property::Map& map ) const map.Insert( OBJECT_URL, mObjectUrl ); map.Insert( MATERIAL_URL, mMaterialUrl ); map.Insert( TEXTURES_PATH, mTexturesPath ); - map.Insert( SHADER_TYPE, mShaderTypeString ); + + 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 ); } void MeshRenderer::InitializeRenderer() diff --git a/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h b/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h index e5aaee5..30d032b 100644 --- a/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h +++ b/dali-toolkit/internal/controls/renderers/mesh/mesh-renderer.h @@ -184,8 +184,6 @@ private: std::string mGlossTextureUrl; std::string mTexturesPath; - std::string mShaderTypeString; - Shader mShader; Geometry mGeometry; TextureSet mTextureSet; diff --git a/docs/content/shared-javascript-and-cpp-documentation/control-renderers.md b/docs/content/shared-javascript-and-cpp-documentation/control-renderers.md index 6930b03..91793bc 100644 --- a/docs/content/shared-javascript-and-cpp-documentation/control-renderers.md +++ b/docs/content/shared-javascript-and-cpp-documentation/control-renderers.md @@ -76,16 +76,16 @@ Both Linear and Radial gradients are 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 | -| [gradientUnits](@ref gradient-renderer-units) | STRING | No | *objectBoundingBox* or *userSpace*. Default: *objectBoundingBox*. | -| [gradientSpreadMethod](@ref gradient-renderer-spread-method) | STRING | No | *pad*, *repeat* or *reflect*. Default: *pad* | +| 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. @@ -95,10 +95,10 @@ 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 | -|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------| -| objectBoundingBox | *Default*. Uses the normals for the start, end & center points, i.e. top-left is (-0.5, -0.5) and bottom-right it (0.5, 0.5). | -| userSpace | 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). | +| 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} @@ -106,9 +106,9 @@ Indicates what happens if the gradient starts or ends inside the bounds of the t | 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 until the quad is filled. | +| 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 @@ -234,13 +234,13 @@ Renders a raster image ( jpg, png etc.) into the control's quad. **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_FILTERr* 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. | +| 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 @@ -437,12 +437,24 @@ Renders a mesh using a .obj file, optionally with textures provided by a mtl fil **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 textures (including gloss and normal) are stored in. | -| shaderType | STRING | No | Sets the type of shader to be used with the mesh. Note that if anything the shader requires is missing, it will use a simpler one that it can handle with what has been supplied.\n Possible values: "textureless", "diffuseTexture", "allTextures". | +| 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