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

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

Issue 1337703002: [Contextual Search] Add support for crushed sprites and animate the search provider icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO's for other planned tests Created 5 years, 2 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 "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "cc/resources/scoped_ui_resource.h" 11 #include "cc/resources/scoped_ui_resource.h"
12 #include "ui/android/resources/crushed_sprite_resource.h"
11 #include "ui/android/ui_android_export.h" 13 #include "ui/android/ui_android_export.h"
12 #include "ui/gfx/geometry/insets_f.h" 14 #include "ui/gfx/geometry/insets_f.h"
13 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
15 17
16 namespace ui { 18 namespace ui {
17 19
18 class UIResourceProvider; 20 class UIResourceProvider;
19 21
20 // A Java counterpart will be generated for this enum. 22 // A Java counterpart will be generated for this enum.
21 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources 23 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources
22 enum AndroidResourceType { 24 enum AndroidResourceType {
23 ANDROID_RESOURCE_TYPE_STATIC = 0, 25 ANDROID_RESOURCE_TYPE_STATIC = 0,
24 ANDROID_RESOURCE_TYPE_DYNAMIC, 26 ANDROID_RESOURCE_TYPE_DYNAMIC,
25 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, 27 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP,
26 ANDROID_RESOURCE_TYPE_SYSTEM, 28 ANDROID_RESOURCE_TYPE_SYSTEM,
29 ANDROID_RESOURCE_TYPE_CRUSHED_SPRITE,
27 30
28 ANDROID_RESOURCE_TYPE_COUNT, 31 ANDROID_RESOURCE_TYPE_COUNT,
29 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC, 32 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC,
30 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_SYSTEM, 33 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_CRUSHED_SPRITE,
31 }; 34 };
32 35
33 // The ResourceManager serves as a cache for resources obtained through Android 36 // The ResourceManager serves as a cache for resources obtained through Android
34 // APIs and consumed by the compositor. 37 // APIs and consumed by the compositor.
35 class UI_ANDROID_EXPORT ResourceManager { 38 class UI_ANDROID_EXPORT ResourceManager {
36 public: 39 public:
37 struct Resource { 40 struct Resource {
38 public: 41 public:
39 Resource(); 42 Resource();
40 ~Resource(); 43 ~Resource();
(...skipping 13 matching lines...) Expand all
54 // If the resource has not been loaded, loading will be performed 57 // If the resource has not been loaded, loading will be performed
55 // synchronously, blocking until the load completes. 58 // synchronously, blocking until the load completes.
56 // 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
57 // to react appropriately. 60 // to react appropriately.
58 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; 61 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0;
59 62
60 // Trigger asynchronous loading of the resource specified by |res_type| and 63 // Trigger asynchronous loading of the resource specified by |res_type| and
61 // |res_id|, if it has not yet been loaded. 64 // |res_id|, if it has not yet been loaded.
62 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; 65 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0;
63 66
67 // 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
69 // 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
71 // appropriately.
72 virtual scoped_refptr<CrushedSpriteResource> GetCrushedSpriteResource(
73 int bitmap_res_id, int metadata_res_id) = 0;
74
75 // Reload the source bitmap for the CrushedSpriteResource specified by
76 // |bitmap_res_id| if the resource has been loaded already. If the resource
77 // hasn't been loaded already, this method does nothing.
78 virtual void ReloadCrushedSpriteResource(int bitmap_res_id) = 0;
79
64 // Convenience wrapper method. 80 // Convenience wrapper method.
65 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) { 81 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) {
66 Resource* resource = GetResource(res_type, res_id); 82 Resource* resource = GetResource(res_type, res_id);
67 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; 83 return resource && resource->ui_resource ? resource->ui_resource->id() : 0;
68 } 84 }
69 85
70 protected: 86 protected:
71 virtual ~ResourceManager() {} 87 virtual ~ResourceManager() {}
72 }; 88 };
73 89
74 } // namespace ui 90 } // namespace ui
75 91
76 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ 92 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698