From 557fa1f45e413777a31b1bb2db4eee826c3ee486 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 7 Feb 2017 12:51:00 -0800 Subject: minui: Move graphics_{adf,drm,fbdev} into classes. This CL defines minui_backend as an interface, and expresses the three backends (adf, drm and fbdev) as subclasses to the interface. Test: 'Run graphics test' on N9, Pixel C and N5X. Change-Id: I0e23951c7b2e2ff918957a8d9fc8b0085b6e5952 --- minui/graphics.h | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'minui/graphics.h') diff --git a/minui/graphics.h b/minui/graphics.h index 1eaafc75a..3c45a406b 100644 --- a/minui/graphics.h +++ b/minui/graphics.h @@ -19,25 +19,20 @@ #include "minui/minui.h" -// TODO: lose the function pointers. -struct minui_backend { - // Initializes the backend and returns a GRSurface* to draw into. - GRSurface* (*init)(minui_backend*); +class MinuiBackend { + public: + // Initializes the backend and returns a GRSurface* to draw into. + virtual GRSurface* Init() = 0; - // Causes the current drawing surface (returned by the most recent - // call to flip() or init()) to be displayed, and returns a new - // drawing surface. - GRSurface* (*flip)(minui_backend*); + // Causes the current drawing surface (returned by the most recent call to Flip() or Init()) to + // be displayed, and returns a new drawing surface. + virtual GRSurface* Flip() = 0; - // Blank (or unblank) the screen. - void (*blank)(minui_backend*, bool); + // Blank (or unblank) the screen. + virtual void Blank(bool) = 0; - // Device cleanup when drawing is done. - void (*exit)(minui_backend*); + // Device cleanup when drawing is done. + virtual ~MinuiBackend() {}; }; -minui_backend* open_fbdev(); -minui_backend* open_adf(); -minui_backend* open_drm(); - -#endif +#endif // _GRAPHICS_H_ -- cgit v1.2.3