2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/resources/resource-type-path.h>
21 using namespace Dali::Integration;
33 * @brief Compare two sets of image loading parameters for equality.
35 inline bool AttributesEqual( ImageDimensions aDims, FittingMode::Type aScaling, SamplingMode::Type aSampling, bool aOrient, ImageDimensions bDims, FittingMode::Type bScaling, SamplingMode::Type bSampling, bool bOrient )
37 return aDims == bDims &&
38 aScaling == bScaling &&
39 aSampling == bSampling &&
44 * @brief Compare two sets of image loading parameters
45 * @pre The two sets are not identical.
47 inline bool AttributesLessAssumingNotEqual( ImageDimensions aDims, FittingMode::Type aScaling, SamplingMode::Type aSampling, bool aOrient, ImageDimensions bDims, FittingMode::Type bScaling, SamplingMode::Type bSampling, bool bOrient )
49 return aDims < bDims &&
50 aScaling < bScaling &&
51 aSampling < bSampling &&
56 * Compare two resource types.
57 * @return zero if the types are equal,
58 * less than zero if lhs < rhs or
59 * greater than zero if lhs > rhs
61 int ResourceTypeCompare(const ResourceType& lhs, const ResourceType& rhs)
67 result = lhs.id > rhs.id ? 1 : -1;
69 else // lhs.id == rhs.id
71 // Cast to a derived resource type and compare...
77 // compare bitmap widths & heights
78 const BitmapResourceType& lhsBitmap = static_cast<const BitmapResourceType&>(lhs);
79 const BitmapResourceType& rhsBitmap = static_cast<const BitmapResourceType&>(rhs);
81 if( ! AttributesEqual( lhsBitmap.size, lhsBitmap.scalingMode, lhsBitmap.samplingMode, lhsBitmap.orientationCorrection,
82 rhsBitmap.size, rhsBitmap.scalingMode, rhsBitmap.samplingMode, rhsBitmap.orientationCorrection ) )
84 result = AttributesLessAssumingNotEqual( lhsBitmap.size, lhsBitmap.scalingMode, lhsBitmap.samplingMode, lhsBitmap.orientationCorrection,
85 rhsBitmap.size, rhsBitmap.scalingMode, rhsBitmap.samplingMode, rhsBitmap.orientationCorrection );
91 case ResourceNativeImage:
93 // compare native image widths & heights
95 const NativeImageResourceType& lhsNativeImage = static_cast<const NativeImageResourceType&>(lhs);
96 const NativeImageResourceType& rhsNativeImage = static_cast<const NativeImageResourceType&>(rhs);
98 if (lhsNativeImage.imageDimensions != rhsNativeImage.imageDimensions)
100 result = lhsNativeImage.imageDimensions < rhsNativeImage.imageDimensions ? -1 : 1;
106 case ResourceTargetImage:
108 // compare bitmap widths & heights
109 const RenderTargetResourceType& lhsImage = static_cast<const RenderTargetResourceType&>(lhs);
110 const RenderTargetResourceType& rhsImage = static_cast<const RenderTargetResourceType&>(rhs);
112 if (lhsImage.imageDimensions != rhsImage.imageDimensions)
114 result = lhsImage.imageDimensions < rhsImage.imageDimensions ? -1 : 1;
125 bool ResourceTypePath::operator<(const ResourceTypePath& rhs) const
127 int typeComparison = ResourceTypeCompare(*type, *(rhs.type));
129 if (typeComparison != 0)
131 return (typeComparison < 0);
135 return path < rhs.path;
139 } // namespace Internal