OLD | NEW |
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/ui_resource_client.h" | 10 #include "cc/resources/scoped_ui_resource.h" |
11 #include "ui/android/resources/ui_resource_android.h" | |
12 #include "ui/android/ui_android_export.h" | 11 #include "ui/android/ui_android_export.h" |
13 #include "ui/gfx/geometry/insets_f.h" | 12 #include "ui/gfx/geometry/insets_f.h" |
14 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
15 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
16 | 15 |
17 namespace ui { | 16 namespace ui { |
18 | 17 |
19 class UIResourceAndroid; | |
20 class UIResourceProvider; | 18 class UIResourceProvider; |
21 | 19 |
22 // A Java counterpart will be generated for this enum. | 20 // A Java counterpart will be generated for this enum. |
23 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources | 21 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.resources |
24 enum AndroidResourceType { | 22 enum AndroidResourceType { |
25 ANDROID_RESOURCE_TYPE_STATIC = 0, | 23 ANDROID_RESOURCE_TYPE_STATIC = 0, |
26 ANDROID_RESOURCE_TYPE_DYNAMIC, | 24 ANDROID_RESOURCE_TYPE_DYNAMIC, |
27 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, | 25 ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, |
28 ANDROID_RESOURCE_TYPE_SYSTEM, | 26 ANDROID_RESOURCE_TYPE_SYSTEM, |
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_SYSTEM, | 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 struct Resource { | 37 struct Resource { |
40 public: | 38 public: |
41 Resource(); | 39 Resource(); |
42 ~Resource(); | 40 ~Resource(); |
43 gfx::Rect Border(const gfx::Size& bounds) const; | 41 gfx::Rect Border(const gfx::Size& bounds) const; |
44 gfx::Rect Border(const gfx::Size& bounds, const gfx::InsetsF& scale) const; | 42 gfx::Rect Border(const gfx::Size& bounds, const gfx::InsetsF& scale) const; |
45 | 43 |
46 scoped_ptr<UIResourceAndroid> ui_resource; | 44 scoped_ptr<cc::ScopedUIResource> ui_resource; |
47 gfx::Size size; | 45 gfx::Size size; |
48 gfx::Rect padding; | 46 gfx::Rect padding; |
49 gfx::Rect aperture; | 47 gfx::Rect aperture; |
50 }; | 48 }; |
51 | 49 |
52 // Obtain a handle to the Java ResourceManager counterpart. | 50 // Obtain a handle to the Java ResourceManager counterpart. |
53 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; | 51 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; |
54 | 52 |
55 // Return a handle to the resource specified by |res_type| and |res_id|. | 53 // Return a handle to the resource specified by |res_type| and |res_id|. |
56 // If the resource has not been loaded, loading will be performed | 54 // If the resource has not been loaded, loading will be performed |
(...skipping 12 matching lines...) Expand all Loading... |
69 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; | 67 return resource && resource->ui_resource ? resource->ui_resource->id() : 0; |
70 } | 68 } |
71 | 69 |
72 protected: | 70 protected: |
73 virtual ~ResourceManager() {} | 71 virtual ~ResourceManager() {} |
74 }; | 72 }; |
75 | 73 |
76 } // namespace ui | 74 } // namespace ui |
77 | 75 |
78 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ | 76 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_H_ |
OLD | NEW |