Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: ui/android/resources/resource_manager.h

Issue 2293573002: Add tinted static UI resource cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
10 #include <unordered_set>
9 11
10 #include "base/android/jni_android.h" 12 #include "base/android/jni_android.h"
11 #include "cc/resources/scoped_ui_resource.h" 13 #include "cc/resources/scoped_ui_resource.h"
12 #include "ui/android/resources/crushed_sprite_resource.h" 14 #include "ui/android/resources/crushed_sprite_resource.h"
13 #include "ui/android/ui_android_export.h" 15 #include "ui/android/ui_android_export.h"
14 #include "ui/gfx/geometry/insets_f.h" 16 #include "ui/gfx/geometry/insets_f.h"
15 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/geometry/size.h" 18 #include "ui/gfx/geometry/size.h"
17 19
18 namespace ui { 20 namespace ui {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Obtain a handle to the Java ResourceManager counterpart. 55 // Obtain a handle to the Java ResourceManager counterpart.
54 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; 56 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0;
55 57
56 // Return a handle to the resource specified by |res_type| and |res_id|. 58 // 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 59 // If the resource has not been loaded, loading will be performed
58 // synchronously, blocking until the load completes. 60 // synchronously, blocking until the load completes.
59 // If load fails, a null handle will be returned and it is up to the caller 61 // If load fails, a null handle will be returned and it is up to the caller
60 // to react appropriately. 62 // to react appropriately.
61 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; 63 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0;
62 64
65 // Return a handle to a static resource specified by |res_id| that has a tint
66 // of |tint_color| applied to it.
67 virtual Resource* GetStaticResourceWithTint(int res_id, int tint_color) = 0;
68
69 // 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
71 // from the cache.
72 virtual void RemoveUnusedTints(const std::unordered_set<int>& used_tints) = 0;
73
63 // Trigger asynchronous loading of the resource specified by |res_type| and 74 // Trigger asynchronous loading of the resource specified by |res_type| and
64 // |res_id|, if it has not yet been loaded. 75 // |res_id|, if it has not yet been loaded.
65 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; 76 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0;
66 77
67 // Return a handle to the CrushedSpriteResource specified by |bitmap_res_id| 78 // 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 79 // 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, 80 // 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 81 // a null handle will be returned and it is up to the caller to react
71 // appropriately. 82 // appropriately.
72 virtual CrushedSpriteResource* GetCrushedSpriteResource( 83 virtual CrushedSpriteResource* GetCrushedSpriteResource(
73 int bitmap_res_id, int metadata_res_id) = 0; 84 int bitmap_res_id, int metadata_res_id) = 0;
74 85
75 // Convenience wrapper method. 86 // Convenience wrapper method.
76 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) { 87 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) {
77 Resource* resource = GetResource(res_type, res_id); 88 Resource* resource = GetResource(res_type, res_id);
78 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; 89 return resource && resource->ui_resource ? resource->ui_resource->id() : 0;
79 } 90 }
80 91
81 protected: 92 protected:
82 virtual ~ResourceManager() {} 93 virtual ~ResourceManager() {}
83 }; 94 };
84 95
85 } // namespace ui 96 } // namespace ui
86 97
87 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ 98 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
OLDNEW
« no previous file with comments | « ui/android/java/src/org/chromium/ui/resources/ResourceManager.java ('k') | ui/android/resources/resource_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698