/*
- * 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 "atlas-packer.h"
// EXTERNAL HEADER
-#include <stdlib.h> // For abs()
+#include <cstdlib> // For abs()
#include <dali/integration-api/debug.h>
namespace Dali
bool ApproximatelyEqual( uint32_t a, uint32_t b )
{
- return abs( a-b ) <= 1;
+ return std::abs( static_cast<int32_t>( a - b ) ) <= 1;
}
uint16_t MaxDimension( const Uint16Pair& dimensions )
firstFit = InsertNode( mRoot->child[1], blockWidth, blockHeight );
}
- if( firstFit != NULL )
- {
- firstFit->occupied = true;
- packPositionX = firstFit->rectArea.x;
- packPositionY = firstFit->rectArea.y;
- }
+ DALI_ASSERT_ALWAYS( firstFit != NULL && "It should never happen!")
+
+ firstFit->occupied = true;
+ packPositionX = firstFit->rectArea.x;
+ packPositionY = firstFit->rectArea.y;
}
void AtlasPacker::GrowNode( SizeType blockWidth, SizeType blockHeight )
bool shouldGrowRight = canGrowRight && mRoot->rectArea.height >= mRoot->rectArea.width+blockWidth;
bool shouldGrowDown = canGrowDown && mRoot->rectArea.width >= mRoot->rectArea.height+blockHeight;
- if( canGrowRight && canGrowRight )
+ if( canGrowRight && canGrowDown )
{
shouldGrowRight = mRoot->rectArea.width+blockWidth <= mRoot->rectArea.height+blockHeight;
shouldGrowDown = !shouldGrowRight;