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

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

Issue 731133002: Upstream ResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
7
8 #include "base/android/jni_android.h"
9 #include "base/id_map.h"
10 #include "cc/resources/ui_resource_client.h"
11 #include "ui/android/ui_android_export.h"
12 #include "ui/gfx/geometry/rect.h"
13
14 namespace content {
15 class UIResourceProvider;
16 }
17
18 namespace ui {
19
20 class UIResourceAndroid;
21
22 // A Java counterpart will be generated for this enum.
23 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources
24 enum AndroidResourceType {
25 ANDROID_RESOURCE_TYPE_STATIC = 0,
26 ANDROID_RESOURCE_TYPE_DYNAMIC,
27 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP,
28 ANDROID_RESOURCE_TYPE_SYSTEM,
29
30 ANDROID_RESOURCE_TYPE_COUNT,
31 ANDROID_RESOURCE_TYPE_FIRST = ANDROID_RESOURCE_TYPE_STATIC,
32 ANDROID_RESOURCE_TYPE_LAST = ANDROID_RESOURCE_TYPE_SYSTEM,
33 };
34
35 class UI_ANDROID_EXPORT ResourceManager {
36 public:
37 struct Resource {
38 public:
39 Resource();
40 ~Resource();
41 gfx::Rect Border(const gfx::Size& bounds);
42 gfx::Rect Border(const gfx::Size& bounds, const gfx::InsetsF& scale);
43
44 scoped_ptr<UIResourceAndroid> ui_resource;
45 gfx::Size size;
46 gfx::Rect padding;
47 gfx::Rect aperture;
48 };
49
50 static ResourceManager* FromJavaObject(jobject jobj);
51
52 explicit ResourceManager(content::UIResourceProvider* ui_resource_provider);
53 virtual ~ResourceManager();
54
55 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env);
56
57 ResourceManager::Resource* GetResource(AndroidResourceType res_type,
58 int res_id);
59 void PreloadResource(AndroidResourceType res_type, int res_id);
60
61 // Called from Java ----------------------------------------------------------
62 void OnResourceReady(JNIEnv* env,
63 jobject jobj,
64 jint res_type,
65 jint res_id,
66 jobject bitmap,
67 jint padding_left,
68 jint padding_top,
69 jint padding_right,
70 jint padding_bottom,
71 jint aperture_left,
72 jint aperture_top,
73 jint aperture_right,
74 jint aperture_bottom);
75
76 static bool RegisterResourceManager(JNIEnv* env);
77
78 private:
79 typedef IDMap<Resource, IDMapOwnPointer> ResourceMap;
80
81 content::UIResourceProvider* ui_resource_provider_;
82 ResourceMap resources_[ANDROID_RESOURCE_TYPE_COUNT];
83
84 base::android::ScopedJavaGlobalRef<jobject> java_obj_;
85
86 DISALLOW_COPY_AND_ASSIGN(ResourceManager);
87 };
88
89 } // namespace ui
90
91 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698