| 1 | // Aseprite Document Library |
| 2 | // Copyright (C) 2019 Igara Studio S.A. |
| 3 | // |
| 4 | // This file is released under the terms of the MIT license. |
| 5 | // Read LICENSE.txt for more information. |
| 6 | |
| 7 | #ifndef DOC_IMAGES_MAP_H_INCLUDED |
| 8 | #define DOC_IMAGES_MAP_H_INCLUDED |
| 9 | #pragma once |
| 10 | |
| 11 | #include "doc/image.h" |
| 12 | #include "doc/image_ref.h" |
| 13 | #include "doc/primitives.h" |
| 14 | |
| 15 | #include <unordered_map> |
| 16 | |
| 17 | namespace doc { |
| 18 | namespace details { |
| 19 | |
| 20 | struct image_hash { |
| 21 | size_t operator()(const ImageRef& i) const { |
| 22 | return calculate_image_hash(i.get(), i->bounds()); |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | struct image_eq { |
| 27 | bool operator()(const ImageRef& a, const ImageRef& b) const { |
| 28 | return is_same_image(a.get(), b.get()); |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | } |
| 33 | |
| 34 | // A hash table used to match Image pixels data <-> an index |
| 35 | typedef std::unordered_map<ImageRef, |
| 36 | uint32_t, |
| 37 | details::image_hash, |
| 38 | details::image_eq> ImagesMap; |
| 39 | |
| 40 | } // namespace doc |
| 41 | |
| 42 | #endif |
| 43 | |