Merge "[3.0] Rename color property of primitive visual to mixColor." into tizen
authorTaeyoon Lee <taeyoon0.lee@samsung.com>
Fri, 2 Sep 2016 09:11:17 +0000 (02:11 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 2 Sep 2016 09:11:17 +0000 (02:11 -0700)
1  2 
automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp
dali-toolkit/internal/visuals/primitive/primitive-visual.cpp

@@@ -1366,7 -1366,7 +1366,7 @@@ int UtcDaliVisualFactoryGetPrimitiveVis
    Property::Map propertyMap;
    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::MIX_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 );
@@@ -1395,7 -1395,7 +1395,7 @@@ int UtcDaliVisualFactoryGetPrimitiveVis
    Property::Map propertyMap;
    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::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
    propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
    propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
  
@@@ -1417,7 -1417,7 +1417,7 @@@ int UtcDaliVisualFactoryGetPrimitiveVis
    Property::Map propertyMap;
    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::MIX_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 );
@@@ -1441,7 -1441,7 +1441,7 @@@ int UtcDaliVisualFactoryGetPrimitiveVis
    Property::Map propertyMap;
    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::MIX_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.
@@@ -1462,7 -1462,7 +1462,7 @@@ int UtcDaliVisualFactoryGetPrimitiveVis
    Property::Map propertyMap;
    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 ) );
+   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
  
    //Test to see if shape loads correctly.
    TestPrimitiveVisualWithProperties( propertyMap, application );
@@@ -1482,7 -1482,7 +1482,7 @@@ int UtcDaliVisualFactoryGetPrimitiveVis
    Property::Map propertyMap;
    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::MIX_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 );
@@@ -1505,7 -1505,7 +1505,7 @@@ int UtcDaliVisualFactoryGetPrimitiveVis
    Property::Map propertyMap;
    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::MIX_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.
    END_TEST;
  }
  
 +//Test if primitive shape loads correctly when told to use too many slices.
 +int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual9:  Request primitive visual with above-cap slices." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 1000000 ) );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
 +//Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
 +int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual10:  Request primitive visual with too few slices." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 2 ) );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
 +//Test if primitive shape loads correctly when told to use too many stacks.
 +int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual11:  Request primitive visual with too many stacks." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1000000 ) );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
 +//Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
 +int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual12:  Request primitive visual with too few stacks." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1 ) );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
 +//Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
 +int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual13:  Request primitive visual with invalid scale dimensions." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
 +//Test if primitive shape loads correctly when told to use too low a bevel percentage.
 +int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual14:  Request primitive visual with too low a bevel percentage." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( -1.0f ) );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
 +//Test if primitive shape loads correctly when told to use too high a bevel percentage.
 +int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual15:  Request primitive visual with too high a bevel percentage." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( 2.0f ) );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
 +//Test if primitive shape loads correctly when told to use too low a bevel smoothness.
 +int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual16:  Request primitive visual with too low a bevel smoothness." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( -1.0f ) );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
 +//Test if primitive shape loads correctly when told to use too high a bevel smoothness.
 +int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
 +{
 +  //Set up test application first, so everything else can be handled.
 +  ToolkitTestApplication application;
 +
 +  tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual17:  Request primitive visual with too high a bevel smoothness." );
 +
 +  //Set up visual properties.
 +  Property::Map propertyMap;
 +  propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
 +  propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
 +  propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( 2.0f ) );
 +
 +  //Test to see if shape loads correctly.
 +  TestPrimitiveVisualWithProperties( propertyMap, application );
 +
 +  END_TEST;
 +}
 +
  //Test if primitive shape renderer handles the case of not being passed a specific shape to use.
  int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
  {
@@@ -53,7 -53,7 +53,7 @@@ DALI_ENUM_TO_STRING_TABLE_END( SHAPE_TY
  
  //Property names
  const char * const PRIMITIVE_SHAPE( "shape" );
- const char * const SHAPE_COLOR( "shapeColor" );
+ const char * const SHAPE_COLOR( "mixColor" );
  const char * const SLICES( "slices" );
  const char * const STACKS( "stacks" );
  const char * const SCALE_TOP_RADIUS( "scaleTopRadius" );
@@@ -74,11 -74,11 +74,11 @@@ const float   DEFAULT_SCALE_HEIGHT 
  const float   DEFAULT_SCALE_RADIUS =        1.0; ///< For cylinders
  const float   DEFAULT_BEVEL_PERCENTAGE =    0.0; ///< For bevelled cubes
  const float   DEFAULT_BEVEL_SMOOTHNESS =    0.0; ///< For bevelled cubes
 -const Vector4 DEFAULT_COLOR =               Vector4( 0.5, 0.5, 0.5, 0.0 ); ///< Grey, for all.
 +const Vector4 DEFAULT_COLOR =               Vector4( 0.5, 0.5, 0.5, 1.0 ); ///< Grey, for all.
  
  //Property limits
 -const int   MIN_SLICES =           1;   ///< Minimum number of slices for spheres and conics
 -const int   MIN_STACKS =           1;   ///< Minimum number of stacks for spheres and conics
 +const int   MIN_SLICES =           3;   ///< Minimum number of slices for spheres and conics
 +const int   MIN_STACKS =           2;   ///< Minimum number of stacks for spheres and conics
  const int   MAX_PARTITIONS =       255; ///< Maximum number of slices or stacks for spheres and conics
  const float MIN_BEVEL_PERCENTAGE = 0.0; ///< Minimum bevel percentage for bevelled cubes
  const float MAX_BEVEL_PERCENTAGE = 1.0; ///< Maximum bevel percentage for bevelled cubes
@@@ -96,7 -96,7 +96,7 @@@ const char * const BEVELLED_CUBE_LABEL
  
  //Shader properties
  const char * const OBJECT_MATRIX_UNIFORM_NAME( "uObjectMatrix" );
 -const char * const COLOR_UNIFORM_NAME( "uColor" );
 +const char * const COLOR_UNIFORM_NAME( "mixColor" );
  const char * const OBJECT_DIMENSIONS_UNIFORM_NAME( "uObjectDimensions" );
  const char * const STAGE_OFFSET_UNIFORM_NAME( "uStageOffset" );
  
@@@ -151,12 -151,10 +151,12 @@@ const char* FRAGMENT_SHADER = DALI_COMP
    precision mediump float;\n
    varying   mediump vec3  vIllumination;\n
    uniform   lowp    vec4  uColor;\n
 +  uniform   lowp    vec4  mixColor;\n
  
    void main()\n
    {\n
 -    gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a );\n
 +    vec4 baseColor = mixColor * uColor;\n
 +    gl_FragColor = vec4( vIllumination.rgb * baseColor.rgb, baseColor.a );\n
    }\n
  );
  
@@@ -197,7 -195,7 +197,7 @@@ void PrimitiveVisual::DoInitialize( Act
  
    //Read in other potential properties.
  
-   Property::Value* color = propertyMap.Find( Toolkit::PrimitiveVisual::Property::COLOR, SHAPE_COLOR );
+   Property::Value* color = propertyMap.Find( Toolkit::PrimitiveVisual::Property::MIX_COLOR, SHAPE_COLOR );
    if( color && !color->Get( mColor ) )
    {
      DALI_LOG_ERROR( "Invalid type for color in PrimitiveVisual.\n" );
        if( mSlices > MAX_PARTITIONS )
        {
          mSlices = MAX_PARTITIONS;
 +        DALI_LOG_WARNING( "Value for slices clamped.\n" );
        }
        else if ( mSlices < MIN_SLICES )
        {
          mSlices = MIN_SLICES;
 +        DALI_LOG_WARNING( "Value for slices clamped.\n" );
        }
      }
      else
        if( mStacks > MAX_PARTITIONS )
        {
          mStacks = MAX_PARTITIONS;
 +        DALI_LOG_WARNING( "Value for stacks clamped.\n" );
        }
        else if ( mStacks < MIN_STACKS )
        {
          mStacks = MIN_STACKS;
 +        DALI_LOG_WARNING( "Value for stacks clamped.\n" );
        }
      }
      else
        if( mScaleDimensions.x <= 0.0 )
        {
          mScaleDimensions.x = 1.0;
 +        DALI_LOG_WARNING( "Value for scale dimensions clamped. Must be greater than zero.\n" );
        }
        if( mScaleDimensions.y <= 0.0 )
        {
          mScaleDimensions.y = 1.0;
 +        DALI_LOG_WARNING( "Value for scale dimensions clamped. Must be greater than zero.\n" );
        }
        if( mScaleDimensions.z <= 0.0 )
        {
          mScaleDimensions.z = 1.0;
 +        DALI_LOG_WARNING( "Value for scale dimensions clamped. Must be greater than zero.\n" );
        }
      }
      else
        if( mBevelPercentage < MIN_BEVEL_PERCENTAGE )
        {
          mBevelPercentage = MIN_BEVEL_PERCENTAGE;
 +        DALI_LOG_WARNING( "Value for bevel percentage clamped.\n" );
        }
        else if( mBevelPercentage > MAX_BEVEL_PERCENTAGE )
        {
          mBevelPercentage = MAX_BEVEL_PERCENTAGE;
 +        DALI_LOG_WARNING( "Value for bevel percentage clamped.\n" );
        }
      }
      else
        if( mBevelSmoothness < MIN_SMOOTHNESS )
        {
          mBevelSmoothness = MIN_SMOOTHNESS;
 +        DALI_LOG_WARNING( "Value for bevel smoothness clamped.\n" );
        }
        else if( mBevelSmoothness > MAX_SMOOTHNESS )
        {
          mBevelSmoothness = MAX_SMOOTHNESS;
 +        DALI_LOG_WARNING( "Value for bevel smoothness clamped.\n" );
        }
      }
      else
@@@ -402,7 -389,7 +402,7 @@@ void PrimitiveVisual::DoCreatePropertyM
    map.Clear();
    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::MIX_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 );
@@@ -1154,17 -1141,16 +1154,17 @@@ void PrimitiveVisual::ComputeBevelledCu
    int normalIndex = 0;  //Track progress through normals, as vertices are calculated per face.
  
    float minDimension = std::min( std::min( dimensions.x, dimensions.y ), dimensions.z );
 -  float bevelScale = 1.0 - bevelPercentage;
 -  float bevelAmount = 0.5 * bevelScale * minDimension;
 +  float bevelAmount = 0.5 * std::min( bevelPercentage, minDimension ); //Cap bevel amount if necessary.
  
 +  //Distances from centre to outer edge points.
    float outerX = 0.5 * dimensions.x;
    float outerY = 0.5 * dimensions.y;
    float outerZ = 0.5 * dimensions.z;
  
 -  float bevelX = outerX - ( 0.5 * minDimension - bevelAmount );
 -  float bevelY = outerY - ( 0.5 * minDimension - bevelAmount );
 -  float bevelZ = outerZ - ( 0.5 * minDimension - bevelAmount );
 +  //Distances from centre to bevelled points.
 +  float bevelX = outerX - bevelAmount;
 +  float bevelY = outerY - bevelAmount;
 +  float bevelZ = outerZ - bevelAmount;
  
    Vector<Vector3> positions;  //Holds object points, to be shared between vertexes.
    positions.Resize( numPositions );