summaryrefslogtreecommitdiffstats
path: root/minui/include
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-10-23 19:06:35 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-10-23 19:06:35 +0200
commit66a576b79c6cf629c439f02a37b824a1ec35ec19 (patch)
tree516cc6ee57b32a0354a9895e85d7238e6496b7fd /minui/include
parentMerge "Recovery now expects public keys in zipfile" (diff)
parentminui: Move GRSurface into a class. (diff)
downloadandroid_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.gz
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.bz2
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.lz
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.xz
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.zst
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.zip
Diffstat (limited to 'minui/include')
-rw-r--r--minui/include/minui/minui.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index fa13ecdff..e9bd1c4f1 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-#ifndef _MINUI_H_
-#define _MINUI_H_
+#pragma once
+#include <stdint.h>
#include <sys/types.h>
#include <functional>
+#include <memory>
#include <string>
#include <vector>
@@ -27,12 +28,31 @@
// Graphics.
//
-struct GRSurface {
+class GRSurface {
+ public:
+ GRSurface() = default;
+ virtual ~GRSurface();
+
+ // Creates and returns a GRSurface instance for the given data_size. The starting address of the
+ // surface data is aligned to SURFACE_DATA_ALIGNMENT. Returns the created GRSurface instance (in
+ // std::unique_ptr), or nullptr on error.
+ static std::unique_ptr<GRSurface> Create(size_t data_size);
+
+ virtual uint8_t* data() {
+ return data_;
+ }
+
+ const uint8_t* data() const {
+ return const_cast<const uint8_t*>(const_cast<GRSurface*>(this)->data());
+ }
+
int width;
int height;
int row_bytes;
int pixel_bytes;
- unsigned char* data;
+
+ private:
+ uint8_t* data_{ nullptr };
};
struct GRFont {
@@ -75,7 +95,7 @@ void gr_clear();
void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
void gr_fill(int x1, int y1, int x2, int y2);
-void gr_texticon(int x, int y, GRSurface* icon);
+void gr_texticon(int x, int y, const GRSurface* icon);
const GRFont* gr_sys_font();
int gr_init_font(const char* name, GRFont** dest);
@@ -85,7 +105,7 @@ int gr_measure(const GRFont* font, const char* s);
// Returns -1 if font is nullptr.
int gr_font_size(const GRFont* font, int* x, int* y);
-void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy);
+void gr_blit(const GRSurface* source, int sx, int sy, int w, int h, int dx, int dy);
unsigned int gr_get_width(const GRSurface* surface);
unsigned int gr_get_height(const GRSurface* surface);
@@ -165,5 +185,3 @@ std::vector<std::string> get_locales_in_png(const std::string& png_name);
// Free a surface allocated by any of the res_create_*_surface()
// functions.
void res_free_surface(GRSurface* surface);
-
-#endif