summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-10-24 02:28:21 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-10-24 02:28:21 +0200
commit47b650b588ba629e9c54a7e108e313bb0c400043 (patch)
treec61ef3a9fd062733e2f24b27146ba2a474798c91
parentMerge "Add a function to construct the GRSurface in test" (diff)
parentui: Add constness to Draw- functions. (diff)
downloadandroid_bootable_recovery-47b650b588ba629e9c54a7e108e313bb0c400043.tar
android_bootable_recovery-47b650b588ba629e9c54a7e108e313bb0c400043.tar.gz
android_bootable_recovery-47b650b588ba629e9c54a7e108e313bb0c400043.tar.bz2
android_bootable_recovery-47b650b588ba629e9c54a7e108e313bb0c400043.tar.lz
android_bootable_recovery-47b650b588ba629e9c54a7e108e313bb0c400043.tar.xz
android_bootable_recovery-47b650b588ba629e9c54a7e108e313bb0c400043.tar.zst
android_bootable_recovery-47b650b588ba629e9c54a7e108e313bb0c400043.zip
Diffstat (limited to '')
-rw-r--r--screen_ui.cpp4
-rw-r--r--screen_ui.h9
-rw-r--r--tests/unit/screen_ui_test.cpp18
-rw-r--r--vr_ui.cpp4
-rw-r--r--vr_ui.h5
5 files changed, 21 insertions, 19 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index c538815b5..2db27d6a7 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -600,7 +600,7 @@ int ScreenRecoveryUI::ScreenHeight() const {
return gr_fb_height();
}
-void ScreenRecoveryUI::DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx,
+void ScreenRecoveryUI::DrawSurface(const GRSurface* surface, int sx, int sy, int w, int h, int dx,
int dy) const {
gr_blit(surface, sx, sy, w, h, dx, dy);
}
@@ -618,7 +618,7 @@ void ScreenRecoveryUI::DrawFill(int x, int y, int w, int h) const {
gr_fill(x, y, w, h);
}
-void ScreenRecoveryUI::DrawTextIcon(int x, int y, GRSurface* surface) const {
+void ScreenRecoveryUI::DrawTextIcon(int x, int y, const GRSurface* surface) const {
gr_texticon(x, y, surface);
}
diff --git a/screen_ui.h b/screen_ui.h
index b1be100f9..2d0d97d8d 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -60,14 +60,14 @@ class DrawInterface {
virtual int DrawTextLine(int x, int y, const std::string& line, bool bold) const = 0;
// Draws surface portion (sx, sy, w, h) at screen location (dx, dy).
- virtual void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx,
+ virtual void DrawSurface(const GRSurface* surface, int sx, int sy, int w, int h, int dx,
int dy) const = 0;
// Draws rectangle at (x, y) - (x + w, y + h).
virtual void DrawFill(int x, int y, int w, int h) const = 0;
// Draws given surface (surface->pixel_bytes = 1) as text at (x, y).
- virtual void DrawTextIcon(int x, int y, GRSurface* surface) const = 0;
+ virtual void DrawTextIcon(int x, int y, const GRSurface* surface) const = 0;
// Draws multiple text lines. Returns the offset it should be moving along Y-axis.
virtual int DrawTextLines(int x, int y, const std::vector<std::string>& lines) const = 0;
@@ -316,9 +316,10 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
void SetColor(UIElement e) const override;
void DrawHighlightBar(int x, int y, int width, int height) const override;
int DrawHorizontalRule(int y) const override;
- void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx, int dy) const override;
+ void DrawSurface(const GRSurface* surface, int sx, int sy, int w, int h, int dx,
+ int dy) const override;
void DrawFill(int x, int y, int w, int h) const override;
- void DrawTextIcon(int x, int y, GRSurface* surface) const override;
+ void DrawTextIcon(int x, int y, const GRSurface* surface) const override;
int DrawTextLine(int x, int y, const std::string& line, bool bold) const override;
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;
diff --git a/tests/unit/screen_ui_test.cpp b/tests/unit/screen_ui_test.cpp
index 06a98c742..0014e45f1 100644
--- a/tests/unit/screen_ui_test.cpp
+++ b/tests/unit/screen_ui_test.cpp
@@ -42,26 +42,26 @@ static const std::vector<std::string> ITEMS{ "item1", "item2", "item3", "item4",
class MockDrawFunctions : public DrawInterface {
void SetColor(UIElement /* element */) const override {}
void DrawHighlightBar(int /* x */, int /* y */, int /* width */,
- int /* height */) const override {};
+ int /* height */) const override {}
int DrawHorizontalRule(int /* y */) const override {
return 0;
- };
+ }
int DrawTextLine(int /* x */, int /* y */, const std::string& /* line */,
bool /* bold */) const override {
return 0;
- };
- void DrawSurface(GRSurface* /* surface */, int /* sx */, int /* sy */, int /* w */, int /* h */,
- int /* dx */, int /* dy */) const override {};
- void DrawFill(int /* x */, int /* y */, int /* w */, int /* h */) const override {};
- void DrawTextIcon(int /* x */, int /* y */, GRSurface* /* surface */) const override {};
+ }
+ void DrawSurface(const GRSurface* /* surface */, int /* sx */, int /* sy */, int /* w */,
+ int /* h */, int /* dx */, int /* dy */) const override {}
+ void DrawFill(int /* x */, int /* y */, int /* w */, int /* h */) const override {}
+ void DrawTextIcon(int /* x */, int /* y */, const GRSurface* /* surface */) const override {}
int DrawTextLines(int /* x */, int /* y */,
const std::vector<std::string>& /* lines */) const override {
return 0;
- };
+ }
int DrawWrappedTextLines(int /* x */, int /* y */,
const std::vector<std::string>& /* lines */) const override {
return 0;
- };
+ }
};
class ScreenUITest : public testing::Test {
diff --git a/vr_ui.cpp b/vr_ui.cpp
index a131a27a7..1f0292c30 100644
--- a/vr_ui.cpp
+++ b/vr_ui.cpp
@@ -34,13 +34,13 @@ int VrRecoveryUI::ScreenHeight() const {
return gr_fb_height();
}
-void VrRecoveryUI::DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx,
+void VrRecoveryUI::DrawSurface(const GRSurface* surface, int sx, int sy, int w, int h, int dx,
int dy) const {
gr_blit(surface, sx, sy, w, h, dx + stereo_offset_, dy);
gr_blit(surface, sx, sy, w, h, dx - stereo_offset_ + ScreenWidth(), dy);
}
-void VrRecoveryUI::DrawTextIcon(int x, int y, GRSurface* surface) const {
+void VrRecoveryUI::DrawTextIcon(int x, int y, const GRSurface* surface) const {
gr_texticon(x + stereo_offset_, y, surface);
gr_texticon(x - stereo_offset_ + ScreenWidth(), y, surface);
}
diff --git a/vr_ui.h b/vr_ui.h
index 63c0f2465..2e8ac5921 100644
--- a/vr_ui.h
+++ b/vr_ui.h
@@ -33,11 +33,12 @@ class VrRecoveryUI : public ScreenRecoveryUI {
int ScreenWidth() const override;
int ScreenHeight() const override;
- void DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx, int dy) const override;
+ void DrawSurface(const GRSurface* surface, int sx, int sy, int w, int h, int dx,
+ int dy) const override;
int DrawHorizontalRule(int y) const override;
void DrawHighlightBar(int x, int y, int width, int height) const override;
void DrawFill(int x, int y, int w, int h) const override;
- void DrawTextIcon(int x, int y, GRSurface* surface) const override;
+ void DrawTextIcon(int x, int y, const GRSurface* surface) const override;
int DrawTextLine(int x, int y, const std::string& line, bool bold) const override;
};