Merge "use modern construct '= default' for special functions." into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-item.cpp
old mode 100644 (file)
new mode 100755 (executable)
index ffbddf0..5492878
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -45,24 +45,24 @@ RenderItem* RenderItem::New()
 RenderItem::RenderItem()
 : mModelMatrix( false ),
   mModelViewMatrix( false ),
+  mColor( Vector4::ZERO ),
   mSize(),
-  mRenderer( NULL ),
-  mNode( NULL ),
+  mRenderer( nullptr ),
+  mNode( nullptr ),
+  mTextureSet( nullptr ),
   mDepthIndex( 0 ),
-  mIsOpaque( true )
+  mIsOpaque( true ),
+  mIsUpdated( false )
 {
 }
 
-RenderItem::~RenderItem()
-{
-}
+RenderItem::~RenderItem() = default;
 
-
-ClippingBox RenderItem::CalculateViewportSpaceAABB( const int viewportWidth, const int viewportHeight ) const
+ClippingBox RenderItem::CalculateViewportSpaceAABB( const Vector3& size, const int viewportWidth, const int viewportHeight ) const
 {
   // Calculate extent vector of the AABB:
-  const float halfActorX = mSize.x * 0.5f;
-  const float halfActorY = mSize.y * 0.5f;
+  const float halfActorX = size.x * 0.5f;
+  const float halfActorY = size.y * 0.5f;
 
   // To transform the actor bounds to screen-space, We do a fast, 2D version of a matrix multiply optimized for 2D quads.
   // This reduces float multiplications from 64 (16 * 4) to 12 (4 * 3).
@@ -100,13 +100,19 @@ ClippingBox RenderItem::CalculateViewportSpaceAABB( const int viewportWidth, con
   // So without doing min/max branching, we can fetch the min/max values of all the remaining X/Y coords from this one index.
   Vector4 aabb( corners[smallestX].x, corners[( smallestX + 3u ) % 4].y, corners[( smallestX + 2u ) % 4].x, corners[( smallestX + 1u ) % 4].y );
 
-  // Convert maximums to extents.
-  aabb.z -= aabb.x;
-  aabb.w -= aabb.y;
-
   // Return the AABB in screen-space pixels (x, y, width, height).
   // Note: This is a algebraic simplification of: ( viewport.x - aabb.width ) / 2 - ( ( aabb.width / 2 ) + aabb.x ) per axis.
-  return ClippingBox( ( viewportWidth / 2 ) - aabb.z - aabb.x, ( viewportHeight / 2 ) - aabb.w - aabb.y, aabb.z, aabb.w );
+  Vector4 aabbInScreen( static_cast<float>( viewportWidth )  * 0.5f - aabb.z,
+                        static_cast<float>( viewportHeight ) * 0.5f - aabb.w,
+                        static_cast<float>( viewportWidth )  * 0.5f - aabb.x,
+                        static_cast<float>( viewportHeight ) * 0.5f - aabb.y );
+
+  int x = static_cast< int >( floor( aabbInScreen.x ) );
+  int y = static_cast< int >( floor( aabbInScreen.y ) );
+  int z = static_cast< int >( roundf( aabbInScreen.z ) );
+  int w = static_cast< int >( roundf( aabbInScreen.w ) );
+
+  return ClippingBox( x, y, z - x, w - y );
 }
 
 void RenderItem::operator delete( void* ptr )
@@ -114,7 +120,6 @@ void RenderItem::operator delete( void* ptr )
   gRenderItemPool.Free( static_cast<RenderItem*>( ptr ) );
 }
 
-
 } // namespace SceneGraph
 
 } // namespace Internal