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_IMPL_H_ | 5 #ifndef UI_ANDROID_RESOURCES_RESOURCE_MANAGER_IMPL_H_ |
6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_IMPL_H_ | 6 #define UI_ANDROID_RESOURCES_RESOURCE_MANAGER_IMPL_H_ |
7 | 7 |
8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
9 #include "ui/android/resources/resource_manager.h" | 9 #include "ui/android/resources/resource_manager.h" |
10 #include "ui/android/ui_android_export.h" | 10 #include "ui/android/ui_android_export.h" |
11 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
15 class UI_ANDROID_EXPORT ResourceManagerImpl : public ResourceManager { | 15 class UI_ANDROID_EXPORT ResourceManagerImpl : public ResourceManager { |
16 public: | 16 public: |
17 static ResourceManagerImpl* FromJavaObject(jobject jobj); | 17 static ResourceManagerImpl* FromJavaObject(jobject jobj); |
18 | 18 |
19 ResourceManagerImpl(); | 19 ResourceManagerImpl(); |
20 ~ResourceManagerImpl() override; | 20 ~ResourceManagerImpl() override; |
21 | 21 |
22 void Init(cc::LayerTreeHost* host); | 22 void Init(cc::LayerTreeHost* host); |
23 | 23 |
24 // ResourceManager implementation. | 24 // ResourceManager implementation. |
25 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override; | 25 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override; |
26 Resource* GetResource(AndroidResourceType res_type, int res_id) override; | 26 Resource* GetResource(AndroidResourceType res_type, int res_id) override; |
27 void PreloadResource(AndroidResourceType res_type, int res_id) override; | 27 void PreloadResource(AndroidResourceType res_type, int res_id) override; |
28 scoped_refptr<CrushedSpriteResource> GetCrushedSpriteResource( | |
29 int bitmap_res_id, int metadata_res_id) override; | |
30 void ReloadCrushedSpriteResource(int bitmap_res_id) override; | |
28 | 31 |
29 // Called from Java | 32 // Called from Java |
30 // ---------------------------------------------------------- | 33 // ---------------------------------------------------------- |
31 void OnResourceReady(JNIEnv* env, | 34 void OnResourceReady(JNIEnv* env, |
32 jobject jobj, | 35 jobject jobj, |
33 jint res_type, | 36 jint res_type, |
34 jint res_id, | 37 jint res_id, |
35 jobject bitmap, | 38 jobject bitmap, |
36 jint padding_left, | 39 jint padding_left, |
37 jint padding_top, | 40 jint padding_top, |
38 jint padding_right, | 41 jint padding_right, |
39 jint padding_bottom, | 42 jint padding_bottom, |
40 jint aperture_left, | 43 jint aperture_left, |
41 jint aperture_top, | 44 jint aperture_top, |
42 jint aperture_right, | 45 jint aperture_right, |
43 jint aperture_bottom); | 46 jint aperture_bottom); |
47 void OnCrushedSpriteResourceReady(JNIEnv* env, | |
48 jobject jobj, | |
49 jint bitmap_res_id, | |
50 jobject bitmap, | |
51 jobjectArray frame_rects, | |
52 jint sprite_size); | |
53 void OnCrushedSpriteResourceReloaded(JNIEnv* env, | |
54 jobject jobj, | |
55 jint bitmap_res_id, | |
56 jobject bitmap); | |
44 | 57 |
45 static bool RegisterResourceManager(JNIEnv* env); | 58 static bool RegisterResourceManager(JNIEnv* env); |
46 | 59 |
47 private: | 60 private: |
48 friend class TestResourceManagerImpl; | 61 friend class TestResourceManagerImpl; |
49 | 62 |
63 struct CrushedSpriteResourceHolder { | |
David Trainor- moved to gerrit
2015/10/15 21:04:58
Hopefully we don't need this if we don't hold onto
Theresa
2015/10/24 00:06:46
That's correct. I only created the struct because
| |
64 public: | |
65 CrushedSpriteResourceHolder(); | |
66 ~CrushedSpriteResourceHolder(); | |
67 | |
68 scoped_refptr<CrushedSpriteResource> resource; | |
69 }; | |
70 | |
50 // Start loading the resource. virtual for testing. | 71 // Start loading the resource. virtual for testing. |
51 virtual void PreloadResourceFromJava(AndroidResourceType res_type, | 72 virtual void PreloadResourceFromJava(AndroidResourceType res_type, |
52 int res_id); | 73 int res_id); |
53 virtual void RequestResourceFromJava(AndroidResourceType res_type, | 74 virtual void RequestResourceFromJava(AndroidResourceType res_type, |
54 int res_id); | 75 int res_id); |
76 virtual void RequestCrushedSpriteResourceFromJava(int bitmap_res_id, | |
77 int metadata_res_id); | |
78 virtual void ReloadCrushedSpriteResourceFromJava(int bitmap_res_id); | |
55 | 79 |
56 typedef IDMap<Resource, IDMapOwnPointer> ResourceMap; | 80 typedef IDMap<Resource, IDMapOwnPointer> ResourceMap; |
81 typedef IDMap<CrushedSpriteResourceHolder, IDMapOwnPointer> | |
82 CrushedSpriteResourceMap; | |
57 | 83 |
58 cc::LayerTreeHost* host_; | 84 cc::LayerTreeHost* host_; |
59 ResourceMap resources_[ANDROID_RESOURCE_TYPE_COUNT]; | 85 ResourceMap resources_[ANDROID_RESOURCE_TYPE_COUNT]; |
86 CrushedSpriteResourceMap crushed_sprite_resources_; | |
60 | 87 |
61 base::android::ScopedJavaGlobalRef<jobject> java_obj_; | 88 base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
62 | 89 |
63 DISALLOW_COPY_AND_ASSIGN(ResourceManagerImpl); | 90 DISALLOW_COPY_AND_ASSIGN(ResourceManagerImpl); |
64 }; | 91 }; |
65 | 92 |
66 } // namespace ui | 93 } // namespace ui |
67 | 94 |
68 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_IMPL_H_ | 95 #endif // UI_ANDROID_RESOURCES_RESOURCE_MANAGER_IMPL_H_ |
OLD | NEW |