ui: Add constness to Draw- functions.
These functions take the given GRSurface instances as inputs, which shouldn't be altered. Test: mmma -j bootable/recovery Test: Run recovery_unit_test. Test: `Run graphics test` on marlin. Change-Id: I51bf408e85faae2b497d4f148ab1dec22dd16c93
This commit is contained in:
parent
66a576b79c
commit
65815b6d3a
5 changed files with 21 additions and 19 deletions
|
@ -600,7 +600,7 @@ int ScreenRecoveryUI::ScreenHeight() const {
|
||||||
return gr_fb_height();
|
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 {
|
int dy) const {
|
||||||
gr_blit(surface, sx, sy, w, h, dx, dy);
|
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);
|
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);
|
gr_texticon(x, y, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,14 @@ class DrawInterface {
|
||||||
virtual int DrawTextLine(int x, int y, const std::string& line, bool bold) const = 0;
|
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).
|
// 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;
|
int dy) const = 0;
|
||||||
|
|
||||||
// Draws rectangle at (x, y) - (x + w, y + h).
|
// Draws rectangle at (x, y) - (x + w, y + h).
|
||||||
virtual void DrawFill(int x, int y, int w, int h) const = 0;
|
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).
|
// 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.
|
// 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;
|
virtual int DrawTextLines(int x, int y, const std::vector<std::string>& lines) const = 0;
|
||||||
|
@ -299,9 +299,10 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
|
||||||
void SetColor(UIElement e) const override;
|
void SetColor(UIElement e) const override;
|
||||||
void DrawHighlightBar(int x, int y, int width, int height) const override;
|
void DrawHighlightBar(int x, int y, int width, int height) const override;
|
||||||
int DrawHorizontalRule(int y) 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 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 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 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;
|
int DrawWrappedTextLines(int x, int y, const std::vector<std::string>& lines) const override;
|
||||||
|
|
|
@ -42,26 +42,26 @@ static const std::vector<std::string> ITEMS{ "item1", "item2", "item3", "item4",
|
||||||
class MockDrawFunctions : public DrawInterface {
|
class MockDrawFunctions : public DrawInterface {
|
||||||
void SetColor(UIElement /* element */) const override {}
|
void SetColor(UIElement /* element */) const override {}
|
||||||
void DrawHighlightBar(int /* x */, int /* y */, int /* width */,
|
void DrawHighlightBar(int /* x */, int /* y */, int /* width */,
|
||||||
int /* height */) const override {};
|
int /* height */) const override {}
|
||||||
int DrawHorizontalRule(int /* y */) const override {
|
int DrawHorizontalRule(int /* y */) const override {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
int DrawTextLine(int /* x */, int /* y */, const std::string& /* line */,
|
int DrawTextLine(int /* x */, int /* y */, const std::string& /* line */,
|
||||||
bool /* bold */) const override {
|
bool /* bold */) const override {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
void DrawSurface(GRSurface* /* surface */, int /* sx */, int /* sy */, int /* w */, int /* h */,
|
void DrawSurface(const GRSurface* /* surface */, int /* sx */, int /* sy */, int /* w */,
|
||||||
int /* dx */, int /* dy */) const override {};
|
int /* h */, int /* dx */, int /* dy */) const override {}
|
||||||
void DrawFill(int /* x */, int /* y */, int /* w */, int /* h */) 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 DrawTextLines(int /* x */, int /* y */,
|
int DrawTextLines(int /* x */, int /* y */,
|
||||||
const std::vector<std::string>& /* lines */) const override {
|
const std::vector<std::string>& /* lines */) const override {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
int DrawWrappedTextLines(int /* x */, int /* y */,
|
int DrawWrappedTextLines(int /* x */, int /* y */,
|
||||||
const std::vector<std::string>& /* lines */) const override {
|
const std::vector<std::string>& /* lines */) const override {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScreenUITest : public testing::Test {
|
class ScreenUITest : public testing::Test {
|
||||||
|
|
|
@ -34,13 +34,13 @@ int VrRecoveryUI::ScreenHeight() const {
|
||||||
return gr_fb_height();
|
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 {
|
int dy) const {
|
||||||
gr_blit(surface, sx, sy, w, h, dx + stereo_offset_, dy);
|
gr_blit(surface, sx, sy, w, h, dx + stereo_offset_, dy);
|
||||||
gr_blit(surface, sx, sy, w, h, dx - stereo_offset_ + ScreenWidth(), 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_, y, surface);
|
||||||
gr_texticon(x - stereo_offset_ + ScreenWidth(), y, surface);
|
gr_texticon(x - stereo_offset_ + ScreenWidth(), y, surface);
|
||||||
}
|
}
|
||||||
|
|
5
vr_ui.h
5
vr_ui.h
|
@ -33,11 +33,12 @@ class VrRecoveryUI : public ScreenRecoveryUI {
|
||||||
int ScreenWidth() const override;
|
int ScreenWidth() const override;
|
||||||
int ScreenHeight() 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;
|
int DrawHorizontalRule(int y) const override;
|
||||||
void DrawHighlightBar(int x, int y, int width, int height) 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 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 DrawTextLine(int x, int y, const std::string& line, bool bold) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue