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 * Compare two resource types.
34 * @return zero if the types are equal,
35 * less than zero if lhs < rhs or
36 * greater than zero if lhs > rhs
38 int ResourceTypeCompare(const ResourceType& lhs, const ResourceType& rhs)
44 result = lhs.id > rhs.id ? 1 : -1;
46 else // lhs.id == rhs.id
48 // Cast to a derived resource type and compare...
54 // compare bitmap widths & heights
55 const BitmapResourceType& lhsBitmap = static_cast<const BitmapResourceType&>(lhs);
56 const BitmapResourceType& rhsBitmap = static_cast<const BitmapResourceType&>(rhs);
58 if (lhsBitmap.imageAttributes != rhsBitmap.imageAttributes)
60 result = lhsBitmap.imageAttributes < rhsBitmap.imageAttributes ? -1 : 1;
66 case ResourceNativeImage:
68 // compare native image widths & heights
70 const NativeImageResourceType& lhsNativeImage = static_cast<const NativeImageResourceType&>(lhs);
71 const NativeImageResourceType& rhsNativeImage = static_cast<const NativeImageResourceType&>(rhs);
73 if (lhsNativeImage.imageAttributes != rhsNativeImage.imageAttributes)
75 result = lhsNativeImage.imageAttributes < rhsNativeImage.imageAttributes ? -1 : 1;
81 case ResourceTargetImage:
83 // compare bitmap widths & heights
84 const RenderTargetResourceType& lhsImage = static_cast<const RenderTargetResourceType&>(lhs);
85 const RenderTargetResourceType& rhsImage = static_cast<const RenderTargetResourceType&>(rhs);
87 if (lhsImage.imageAttributes != rhsImage.imageAttributes)
89 result = lhsImage.imageAttributes < rhsImage.imageAttributes ? -1 : 1;
97 // compare shader source hashes
98 const ShaderResourceType& lhsShader = static_cast<const ShaderResourceType&>(lhs);
99 const ShaderResourceType& rhsShader = static_cast<const ShaderResourceType&>(rhs);
101 if (lhsShader.hash != rhsShader.hash)
103 result = lhsShader.hash < rhsShader.hash ? -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