| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ | 5 #ifndef UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ |
| 6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ | 6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <unordered_set> | 10 #include <unordered_set> |
| 11 | 11 |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "cc/resources/scoped_ui_resource.h" | 13 #include "cc/resources/scoped_ui_resource.h" |
| 14 #include "third_party/skia/include/core/SkColor.h" |
| 14 #include "ui/android/resources/crushed_sprite_resource.h" | 15 #include "ui/android/resources/crushed_sprite_resource.h" |
| 15 #include "ui/android/ui_android_export.h" | 16 #include "ui/android/ui_android_export.h" |
| 16 #include "ui/gfx/geometry/insets_f.h" | 17 #include "ui/gfx/geometry/insets_f.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
| 19 | 20 |
| 20 namespace ui { | 21 namespace ui { |
| 21 | 22 |
| 22 class UIResourceProvider; | 23 class UIResourceProvider; |
| 23 | 24 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 58 |
| 58 // Return a handle to the resource specified by |res_type| and |res_id|. | 59 // Return a handle to the resource specified by |res_type| and |res_id|. |
| 59 // If the resource has not been loaded, loading will be performed | 60 // If the resource has not been loaded, loading will be performed |
| 60 // synchronously, blocking until the load completes. | 61 // synchronously, blocking until the load completes. |
| 61 // If load fails, a null handle will be returned and it is up to the caller | 62 // If load fails, a null handle will be returned and it is up to the caller |
| 62 // to react appropriately. | 63 // to react appropriately. |
| 63 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; | 64 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; |
| 64 | 65 |
| 65 // Return a handle to a static resource specified by |res_id| that has a tint | 66 // Return a handle to a static resource specified by |res_id| that has a tint |
| 66 // of |tint_color| applied to it. | 67 // of |tint_color| applied to it. |
| 67 virtual Resource* GetStaticResourceWithTint(int res_id, int tint_color) = 0; | 68 virtual Resource* GetStaticResourceWithTint(int res_id, |
| 69 SkColor tint_color) = 0; |
| 68 | 70 |
| 69 // Remove tints that were unused in the current frame being built. This | 71 // Remove tints that were unused in the current frame being built. This |
| 70 // function takes a set |used_tints| and removes all the tints not in the set | 72 // function takes a set |used_tints| and removes all the tints not in the set |
| 71 // from the cache. | 73 // from the cache. |
| 72 virtual void RemoveUnusedTints(const std::unordered_set<int>& used_tints) = 0; | 74 virtual void RemoveUnusedTints(const std::unordered_set<int>& used_tints) = 0; |
| 73 | 75 |
| 74 // Trigger asynchronous loading of the resource specified by |res_type| and | 76 // Trigger asynchronous loading of the resource specified by |res_type| and |
| 75 // |res_id|, if it has not yet been loaded. | 77 // |res_id|, if it has not yet been loaded. |
| 76 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; | 78 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; |
| 77 | 79 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 89 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; | 91 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; |
| 90 } | 92 } |
| 91 | 93 |
| 92 protected: | 94 protected: |
| 93 virtual ~ResourceManager() {} | 95 virtual ~ResourceManager() {} |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 } // namespace ui | 98 } // namespace ui |
| 97 | 99 |
| 98 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ | 100 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ |
| OLD | NEW |