OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_H_ | 5 #ifndef UI_ANDROID_RESOURCES_RESOURCE_H_ |
6 #define UI_ANDROID_RESOURCES_RESOURCE_H_ | 6 #define UI_ANDROID_RESOURCES_RESOURCE_H_ |
7 | 7 |
8 #include "cc/resources/scoped_ui_resource.h" | 8 #include "cc/resources/scoped_ui_resource.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.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 Resource { | 15 class UI_ANDROID_EXPORT Resource { |
16 public: | 16 public: |
17 enum class Type { BITMAP, NINE_PATCH_BITMAP }; | 17 enum class Type { BITMAP, NINE_PATCH_BITMAP, TOOLBAR }; |
18 | 18 |
19 Resource(); | 19 Resource(); |
20 virtual ~Resource(); | 20 virtual ~Resource(); |
21 | 21 |
22 virtual std::unique_ptr<Resource> CreateForCopy(); | 22 virtual std::unique_ptr<Resource> CreateForCopy(); |
23 void SetUIResource(std::unique_ptr<cc::ScopedUIResource> ui_resource, | 23 void SetUIResource(std::unique_ptr<cc::ScopedUIResource> ui_resource, |
24 const gfx::Size& size_in_px); | 24 const gfx::Size& size_in_px); |
25 size_t EstimateMemoryUsage() const; | 25 size_t EstimateMemoryUsage() const; |
26 | 26 |
27 cc::ScopedUIResource* ui_resource() const { return ui_resource_.get(); } | 27 cc::ScopedUIResource* ui_resource() const { return ui_resource_.get(); } |
28 gfx::Size size() const { return size_; } | 28 gfx::Size size() const { return size_; } |
29 Type type() const { return type_; } | 29 Type type() const { return type_; } |
30 | 30 |
31 protected: | 31 protected: |
32 Resource(Type type); | 32 Resource(Type type); |
33 | 33 |
34 private: | 34 private: |
35 const Type type_; | 35 const Type type_; |
36 | 36 |
37 // Size of the bitmap in physical pixels. | 37 // Size of the bitmap in physical pixels. |
38 gfx::Size size_; | 38 gfx::Size size_; |
39 std::unique_ptr<cc::ScopedUIResource> ui_resource_; | 39 std::unique_ptr<cc::ScopedUIResource> ui_resource_; |
40 }; | 40 }; |
41 | 41 |
42 } // namespace ui | 42 } // namespace ui |
43 | 43 |
44 #endif // UI_ANDROID_RESOURCES_RESOURCE_H_ | 44 #endif // UI_ANDROID_RESOURCES_RESOURCE_H_ |
OLD | NEW |