summaryrefslogtreecommitdiffstats
path: root/screen_ui.h
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-11-06 03:04:49 +0100
committerandroid-build-merger <android-build-merger@google.com>2018-11-06 03:04:49 +0100
commit3d855135fe4f582e45b7a5fdb3b5df2aa6f7c2c4 (patch)
tree7d3a18bd3f341ca898092a0645931f128c3f77df /screen_ui.h
parentMerge "updater: Error out on underrun during patching." am: a0404ecd16 am: 2a4e64a351 (diff)
parentMerge "ui: Manage loaded resources with smart pointers." am: 06aea3a894 (diff)
downloadandroid_bootable_recovery-3d855135fe4f582e45b7a5fdb3b5df2aa6f7c2c4.tar
android_bootable_recovery-3d855135fe4f582e45b7a5fdb3b5df2aa6f7c2c4.tar.gz
android_bootable_recovery-3d855135fe4f582e45b7a5fdb3b5df2aa6f7c2c4.tar.bz2
android_bootable_recovery-3d855135fe4f582e45b7a5fdb3b5df2aa6f7c2c4.tar.lz
android_bootable_recovery-3d855135fe4f582e45b7a5fdb3b5df2aa6f7c2c4.tar.xz
android_bootable_recovery-3d855135fe4f582e45b7a5fdb3b5df2aa6f7c2c4.tar.zst
android_bootable_recovery-3d855135fe4f582e45b7a5fdb3b5df2aa6f7c2c4.zip
Diffstat (limited to 'screen_ui.h')
-rw-r--r--screen_ui.h85
1 files changed, 41 insertions, 44 deletions
diff --git a/screen_ui.h b/screen_ui.h
index 2d0d97d8d..ff245a2fb 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -162,32 +162,31 @@ class TextMenu : public Menu {
int char_height_;
};
-// This class uses GRSurfaces* as the menu header and items.
+// This class uses GRSurface's as the menu header and items.
class GraphicMenu : public Menu {
public:
// Constructs a Menu instance with the given |headers|, |items| and properties. Sets the initial
- // selection to |initial_selection|.
- GraphicMenu(GRSurface* graphic_headers, const std::vector<GRSurface*>& graphic_items,
+ // selection to |initial_selection|. |headers| and |items| will be made local copies.
+ GraphicMenu(const GRSurface* graphic_headers, const std::vector<const GRSurface*>& graphic_items,
size_t initial_selection, const DrawInterface& draw_funcs);
int Select(int sel) override;
int DrawHeader(int x, int y) const override;
int DrawItems(int x, int y, int screen_width, bool long_press) const override;
- // Checks if all the header and items are valid GRSurfaces; and that they can fit in the area
+ // Checks if all the header and items are valid GRSurface's; and that they can fit in the area
// defined by |max_width| and |max_height|.
- static bool Validate(size_t max_width, size_t max_height, GRSurface* graphic_headers,
- const std::vector<GRSurface*>& graphic_items);
+ static bool Validate(size_t max_width, size_t max_height, const GRSurface* graphic_headers,
+ const std::vector<const GRSurface*>& graphic_items);
// Returns true if |surface| fits on the screen with a vertical offset |y|.
static bool ValidateGraphicSurface(size_t max_width, size_t max_height, int y,
const GRSurface* surface);
private:
- // Pointers to the menu headers and items in graphic icons. This class does not have the ownership
- // of the these objects.
- GRSurface* graphic_headers_;
- std::vector<GRSurface*> graphic_items_;
+ // Menu headers and items in graphic icons. These are the copies owned by the class instance.
+ std::unique_ptr<GRSurface> graphic_headers_;
+ std::vector<std::unique_ptr<GRSurface>> graphic_items_;
};
// Implementation of RecoveryUI appropriate for devices with a screen
@@ -243,6 +242,7 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
protected:
static constexpr int kMenuIndent = 4;
+
// The margin that we don't want to use for showing texts (e.g. round screen, or screen with
// rounded corners).
const int margin_width_;
@@ -261,8 +261,8 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
// Creates a GraphicMenu with |graphic_header| and |graphic_items|. If the GraphicMenu isn't
// valid or it doesn't fit on the screen; falls back to create a TextMenu instead. If succeeds,
// returns a unique pointer to the created menu; otherwise returns nullptr.
- virtual std::unique_ptr<Menu> CreateMenu(GRSurface* graphic_header,
- const std::vector<GRSurface*>& graphic_items,
+ virtual std::unique_ptr<Menu> CreateMenu(const GRSurface* graphic_header,
+ const std::vector<const GRSurface*>& graphic_items,
const std::vector<std::string>& text_headers,
const std::vector<std::string>& text_items,
size_t initial_selection) const;
@@ -288,8 +288,8 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
virtual void update_screen_locked();
virtual void update_progress_locked();
- GRSurface* GetCurrentFrame() const;
- GRSurface* GetCurrentText() const;
+ const GRSurface* GetCurrentFrame() const;
+ const GRSurface* GetCurrentText() const;
void ProgressThreadLoop();
@@ -299,8 +299,8 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
void ClearText();
void LoadAnimation();
- void LoadBitmap(const char* filename, GRSurface** surface);
- void LoadLocalizedBitmap(const char* filename, GRSurface** surface);
+ std::unique_ptr<GRSurface> LoadBitmap(const std::string& filename);
+ std::unique_ptr<GRSurface> LoadLocalizedBitmap(const std::string& filename);
int PixelsFromDp(int dp) const;
virtual int GetAnimationBaseline() const;
@@ -324,30 +324,34 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
int DrawTextLines(int x, int y, const std::vector<std::string>& lines) const override;
int DrawWrappedTextLines(int x, int y, const std::vector<std::string>& lines) const override;
- Icon currentIcon;
-
// The layout to use.
int layout_;
- GRSurface* error_icon;
-
- GRSurface* erasing_text;
- GRSurface* error_text;
- GRSurface* installing_text;
- GRSurface* no_command_text;
-
- // Graphs for the wipe data menu
- GRSurface* wipe_data_menu_header_text_;
- GRSurface* try_again_text_;
- GRSurface* factory_data_reset_text_;
-
- GRSurface** introFrames;
- GRSurface** loopFrames;
-
- GRSurface* progressBarEmpty;
- GRSurface* progressBarFill;
- GRSurface* stageMarkerEmpty;
- GRSurface* stageMarkerFill;
+ // The images that contain localized texts.
+ std::unique_ptr<GRSurface> erasing_text_;
+ std::unique_ptr<GRSurface> error_text_;
+ std::unique_ptr<GRSurface> installing_text_;
+ std::unique_ptr<GRSurface> no_command_text_;
+
+ // Localized text images for the wipe data menu.
+ std::unique_ptr<GRSurface> wipe_data_menu_header_text_;
+ std::unique_ptr<GRSurface> try_again_text_;
+ std::unique_ptr<GRSurface> factory_data_reset_text_;
+
+ // current_icon_ points to one of the frames in intro_frames_ or loop_frames_, indexed by
+ // current_frame_, or error_icon_.
+ Icon current_icon_;
+ std::unique_ptr<GRSurface> error_icon_;
+ std::vector<std::unique_ptr<GRSurface>> intro_frames_;
+ std::vector<std::unique_ptr<GRSurface>> loop_frames_;
+ size_t current_frame_;
+ bool intro_done_;
+
+ // progress_bar and stage_marker images.
+ std::unique_ptr<GRSurface> progress_bar_empty_;
+ std::unique_ptr<GRSurface> progress_bar_fill_;
+ std::unique_ptr<GRSurface> stage_marker_empty_;
+ std::unique_ptr<GRSurface> stage_marker_fill_;
ProgressType progressBarType;
@@ -377,13 +381,6 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
std::thread progress_thread_;
std::atomic<bool> progress_thread_stopped_{ false };
- // Number of intro frames and loop frames in the animation.
- size_t intro_frames;
- size_t loop_frames;
-
- size_t current_frame;
- bool intro_done;
-
int stage, max_stage;
int char_width_;