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

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: Very small changes from last pedrosimonneti@ review Created 5 years, 1 month 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/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "cc/resources/scoped_ui_resource.h" 10 #include "cc/resources/scoped_ui_resource.h"
11 #include "ui/android/resources/crushed_sprite_resource.h"
11 #include "ui/android/ui_android_export.h" 12 #include "ui/android/ui_android_export.h"
12 #include "ui/gfx/geometry/insets_f.h" 13 #include "ui/gfx/geometry/insets_f.h"
13 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
15 16
16 namespace ui { 17 namespace ui {
17 18
18 class UIResourceProvider; 19 class UIResourceProvider;
19 20
20 // A Java counterpart will be generated for this enum. 21 // A Java counterpart will be generated for this enum.
21 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources 22 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources
22 enum AndroidResourceType { 23 enum AndroidResourceType {
23 ANDROID_RESOURCE_TYPE_STATIC = 0, 24 ANDROID_RESOURCE_TYPE_STATIC = 0,
24 ANDROID_RESOURCE_TYPE_DYNAMIC, 25 ANDROID_RESOURCE_TYPE_DYNAMIC,
25 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, 26 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP,
26 ANDROID_RESOURCE_TYPE_SYSTEM, 27 ANDROID_RESOURCE_TYPE_SYSTEM,
28 ANDROID_RESOURCE_TYPE_CRUSHED_SPRITE,
27 29
28 ANDROID_RESOURCE_TYPE_COUNT, 30 ANDROID_RESOURCE_TYPE_COUNT,
29 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC, 31 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC,
30 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_SYSTEM, 32 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_CRUSHED_SPRITE,
31 }; 33 };
32 34
33 // The ResourceManager serves as a cache for resources obtained through Android 35 // The ResourceManager serves as a cache for resources obtained through Android
34 // APIs and consumed by the compositor. 36 // APIs and consumed by the compositor.
35 class UI_ANDROID_EXPORT ResourceManager { 37 class UI_ANDROID_EXPORT ResourceManager {
36 public: 38 public:
37 struct Resource { 39 struct Resource {
38 public: 40 public:
39 Resource(); 41 Resource();
40 ~Resource(); 42 ~Resource();
(...skipping 13 matching lines...) Expand all
54 // If the resource has not been loaded, loading will be performed 56 // If the resource has not been loaded, loading will be performed
55 // synchronously, blocking until the load completes. 57 // synchronously, blocking until the load completes.
56 // If load fails, a null handle will be returned and it is up to the caller 58 // If load fails, a null handle will be returned and it is up to the caller
57 // to react appropriately. 59 // to react appropriately.
58 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0; 60 virtual Resource* GetResource(AndroidResourceType res_type, int res_id) = 0;
59 61
60 // Trigger asynchronous loading of the resource specified by |res_type| and 62 // Trigger asynchronous loading of the resource specified by |res_type| and
61 // |res_id|, if it has not yet been loaded. 63 // |res_id|, if it has not yet been loaded.
62 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0; 64 virtual void PreloadResource(AndroidResourceType res_type, int res_id) = 0;
63 65
66 // Return a handle to the CrushedSpriteResource specified by |bitmap_res_id|
67 // and |metadata_res_id|. If the resource has not been loaded, loading will be
68 // performed synchronously, blocking until the load completes. If load fails,
69 // a null handle will be returned and it is up to the caller to react
70 // appropriately.
71 virtual CrushedSpriteResource* GetCrushedSpriteResource(
72 int bitmap_res_id, int metadata_res_id) = 0;
73
64 // Convenience wrapper method. 74 // Convenience wrapper method.
65 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) { 75 cc::UIResourceId GetUIResourceId(AndroidResourceType res_type, int res_id) {
66 Resource* resource = GetResource(res_type, res_id); 76 Resource* resource = GetResource(res_type, res_id);
67 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; 77 return resource && resource->ui_resource ? resource->ui_resource->id() : 0;
68 } 78 }
69 79
70 protected: 80 protected:
71 virtual ~ResourceManager() {} 81 virtual ~ResourceManager() {}
72 }; 82 };
73 83
74 } // namespace ui 84 } // namespace ui
75 85
76 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ 86 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698