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 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Obtain a handle to the Java ResourceManager counterpart. | 53 // Obtain a handle to the Java ResourceManager counterpart. |
54 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; | 54 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; |
55 | 55 |
56 // Return a handle to the resource specified by |res_type| and |res_id|. | 56 // 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 | 57 // If the resource has not been loaded, loading will be performed |
58 // synchronously, blocking until the load completes. | 58 // synchronously, blocking until the load completes. |
59 // If load fails, a null handle will be returned and it is up to the caller | 59 // If load fails, a null handle will be returned and it is up to the caller |
60 // to react appropriately. | 60 // to react appropriately. |
61 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; | 61 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; |
62 | 62 |
| 63 // Return a handle to a static resource specified by |res_id| that has a tint |
| 64 // of |tint_color| applied to it. |default_color| is used if the cache becomes |
| 65 // too large. |
| 66 virtual Resource* GetStaticResourceWithTint( |
| 67 int res_id, int tint_color, int default_color) = 0; |
| 68 |
63 // Trigger asynchronous loading of the resource specified by |res_type| and | 69 // Trigger asynchronous loading of the resource specified by |res_type| and |
64 // |res_id|, if it has not yet been loaded. | 70 // |res_id|, if it has not yet been loaded. |
65 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; | 71 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; |
66 | 72 |
67 // Return a handle to the CrushedSpriteResource specified by |bitmap_res_id| | 73 // 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 | 74 // 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, | 75 // 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 | 76 // a null handle will be returned and it is up to the caller to react |
71 // appropriately. | 77 // appropriately. |
72 virtual CrushedSpriteResource* GetCrushedSpriteResource( | 78 virtual CrushedSpriteResource* GetCrushedSpriteResource( |
73 int bitmap_res_id, int metadata_res_id) = 0; | 79 int bitmap_res_id, int metadata_res_id) = 0; |
74 | 80 |
75 // Convenience wrapper method. | 81 // Convenience wrapper method. |
76 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) { | 82 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) { |
77 Resource* resource = GetResource(res_type, res_id); | 83 Resource* resource = GetResource(res_type, res_id); |
78 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; | 84 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; |
79 } | 85 } |
80 | 86 |
81 protected: | 87 protected: |
82 virtual ~ResourceManager() {} | 88 virtual ~ResourceManager() {} |
83 }; | 89 }; |
84 | 90 |
85 } // namespace ui | 91 } // namespace ui |
86 | 92 |
87 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ | 93 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ |
OLD | NEW |