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

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

Issue 2798123002: Remove crushed sprite resource and layer (Closed)
Patch Set: Rebase and fix my nits Created 3 years, 8 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> 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 "third_party/skia/include/core/SkColor.h"
15 #include "ui/android/resources/crushed_sprite_resource.h"
16 #include "ui/android/resources/resource.h" 15 #include "ui/android/resources/resource.h"
17 #include "ui/android/ui_android_export.h" 16 #include "ui/android/ui_android_export.h"
18 17
19 namespace ui { 18 namespace ui {
20 19
21 // A Java counterpart will be generated for this enum. 20 // A Java counterpart will be generated for this enum.
22 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources 21 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources
23 enum AndroidResourceType { 22 enum AndroidResourceType {
24 ANDROID_RESOURCE_TYPE_STATIC = 0, 23 ANDROID_RESOURCE_TYPE_STATIC = 0,
25 ANDROID_RESOURCE_TYPE_DYNAMIC, 24 ANDROID_RESOURCE_TYPE_DYNAMIC,
26 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, 25 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP,
27 ANDROID_RESOURCE_TYPE_SYSTEM, 26 ANDROID_RESOURCE_TYPE_SYSTEM,
28 ANDROID_RESOURCE_TYPE_CRUSHED_SPRITE,
29 27
30 ANDROID_RESOURCE_TYPE_COUNT, 28 ANDROID_RESOURCE_TYPE_COUNT,
31 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC, 29 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC,
32 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_CRUSHED_SPRITE, 30 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_SYSTEM,
33 }; 31 };
34 32
35 // The ResourceManager serves as a cache for resources obtained through Android 33 // The ResourceManager serves as a cache for resources obtained through Android
36 // APIs and consumed by the compositor. 34 // APIs and consumed by the compositor.
37 class UI_ANDROID_EXPORT ResourceManager { 35 class UI_ANDROID_EXPORT ResourceManager {
38 public: 36 public:
39 // Obtain a handle to the Java ResourceManager counterpart. 37 // Obtain a handle to the Java ResourceManager counterpart.
40 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; 38 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0;
41 39
42 // Return a handle to the resource specified by |res_type| and |res_id|. 40 // Return a handle to the resource specified by |res_type| and |res_id|.
(...skipping 10 matching lines...) Expand all
53 51
54 // Remove tints that were unused in the current frame being built. This 52 // Remove tints that were unused in the current frame being built. This
55 // function takes a set |used_tints| and removes all the tints not in the set 53 // function takes a set |used_tints| and removes all the tints not in the set
56 // from the cache. 54 // from the cache.
57 virtual void RemoveUnusedTints(const std::unordered_set<int>& used_tints) = 0; 55 virtual void RemoveUnusedTints(const std::unordered_set<int>& used_tints) = 0;
58 56
59 // Trigger asynchronous loading of the resource specified by |res_type| and 57 // Trigger asynchronous loading of the resource specified by |res_type| and
60 // |res_id|, if it has not yet been loaded. 58 // |res_id|, if it has not yet been loaded.
61 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; 59 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0;
62 60
63 // Return a handle to the CrushedSpriteResource specified by |bitmap_res_id|
64 // and |metadata_res_id|. If the resource has not been loaded, loading will be
65 // performed synchronously, blocking until the load completes. If load fails,
66 // a null handle will be returned and it is up to the caller to react
67 // appropriately.
68 virtual CrushedSpriteResource* GetCrushedSpriteResource(
69 int bitmap_res_id, int metadata_res_id) = 0;
70
71 // Convenience wrapper method. 61 // Convenience wrapper method.
72 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) { 62 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) {
73 Resource* resource = GetResource(res_type, res_id); 63 Resource* resource = GetResource(res_type, res_id);
74 return resource && resource->ui_resource() ? resource->ui_resource()->id() 64 return resource && resource->ui_resource() ? resource->ui_resource()->id()
75 : 0; 65 : 0;
76 } 66 }
77 67
78 protected: 68 protected:
79 virtual ~ResourceManager() {} 69 virtual ~ResourceManager() {}
80 }; 70 };
81 71
82 } // namespace ui 72 } // namespace ui
83 73
84 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ 74 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
OLDNEW
« no previous file with comments | « ui/android/resources/crushed_sprite_resource.cc ('k') | ui/android/resources/resource_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698