Chromium Code Reviews| 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_set> | |
|
aelias_OOO_until_Jul13
2016/09/07 19:34:44
Also <unordered_map>
mdjones
2016/09/08 16:34:44
Done.
| |
| 9 | 10 |
| 10 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 11 #include "cc/resources/scoped_ui_resource.h" | 12 #include "cc/resources/scoped_ui_resource.h" |
| 12 #include "ui/android/resources/crushed_sprite_resource.h" | 13 #include "ui/android/resources/crushed_sprite_resource.h" |
| 13 #include "ui/android/ui_android_export.h" | 14 #include "ui/android/ui_android_export.h" |
| 14 #include "ui/gfx/geometry/insets_f.h" | 15 #include "ui/gfx/geometry/insets_f.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 // Obtain a handle to the Java ResourceManager counterpart. | 54 // Obtain a handle to the Java ResourceManager counterpart. |
| 54 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; | 55 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; |
| 55 | 56 |
| 56 // Return a handle to the resource specified by |res_type| and |res_id|. | 57 // Return a handle to the resource specified by |res_type| and |res_id|. |
| 57 // If the resource has not been loaded, loading will be performed | 58 // If the resource has not been loaded, loading will be performed |
| 58 // synchronously, blocking until the load completes. | 59 // synchronously, blocking until the load completes. |
| 59 // If load fails, a null handle will be returned and it is up to the caller | 60 // If load fails, a null handle will be returned and it is up to the caller |
| 60 // to react appropriately. | 61 // to react appropriately. |
| 61 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; | 62 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; |
| 62 | 63 |
| 64 // Return a handle to a static resource specified by |res_id| that has a tint | |
| 65 // of |tint_color| applied to it. | |
| 66 virtual Resource* GetStaticResourceWithTint(int res_id, int tint_color) = 0; | |
| 67 | |
| 68 // Remove tints that were unused in the current frame being built. This | |
| 69 // function takes a set |used_tints| and removes all the tints not in the set | |
| 70 // from the cache. | |
| 71 virtual void RemoveUnusedTints(const std::unordered_set<int>& used_tints) = 0; | |
| 72 | |
| 63 // Trigger asynchronous loading of the resource specified by |res_type| and | 73 // Trigger asynchronous loading of the resource specified by |res_type| and |
| 64 // |res_id|, if it has not yet been loaded. | 74 // |res_id|, if it has not yet been loaded. |
| 65 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; | 75 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; |
| 66 | 76 |
| 67 // Return a handle to the CrushedSpriteResource specified by |bitmap_res_id| | 77 // Return a handle to the CrushedSpriteResource specified by |bitmap_res_id| |
| 68 // and |metadata_res_id|. If the resource has not been loaded, loading will be | 78 // and |metadata_res_id|. If the resource has not been loaded, loading will be |
| 69 // performed synchronously, blocking until the load completes. If load fails, | 79 // performed synchronously, blocking until the load completes. If load fails, |
| 70 // a null handle will be returned and it is up to the caller to react | 80 // a null handle will be returned and it is up to the caller to react |
| 71 // appropriately. | 81 // appropriately. |
| 72 virtual CrushedSpriteResource* GetCrushedSpriteResource( | 82 virtual CrushedSpriteResource* GetCrushedSpriteResource( |
| 73 int bitmap_res_id, int metadata_res_id) = 0; | 83 int bitmap_res_id, int metadata_res_id) = 0; |
| 74 | 84 |
| 75 // Convenience wrapper method. | 85 // Convenience wrapper method. |
| 76 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) { | 86 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) { |
| 77 Resource* resource = GetResource(res_type, res_id); | 87 Resource* resource = GetResource(res_type, res_id); |
| 78 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; | 88 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; |
| 79 } | 89 } |
| 80 | 90 |
| 81 protected: | 91 protected: |
| 82 virtual ~ResourceManager() {} | 92 virtual ~ResourceManager() {} |
| 83 }; | 93 }; |
| 84 | 94 |
| 85 } // namespace ui | 95 } // namespace ui |
| 86 | 96 |
| 87 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ | 97 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ |
| OLD | NEW |