Merge "minui: Use runtime properties instead of build time vars."
am: ebc04d1e7a
Change-Id: Ied0cc8732e0c5d75d1608c4aaa637c04548ecfe6
This commit is contained in:
@@ -41,32 +41,6 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
|
|||||||
|
|
||||||
LOCAL_MODULE := libminui
|
LOCAL_MODULE := libminui
|
||||||
|
|
||||||
# This used to compare against values in double-quotes (which are just
|
|
||||||
# ordinary characters in this context). Strip double-quotes from the
|
|
||||||
# value so that either will work.
|
|
||||||
|
|
||||||
ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),ABGR_8888)
|
|
||||||
LOCAL_CFLAGS += -DRECOVERY_ABGR
|
|
||||||
endif
|
|
||||||
ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBX_8888)
|
|
||||||
LOCAL_CFLAGS += -DRECOVERY_RGBX
|
|
||||||
endif
|
|
||||||
ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888)
|
|
||||||
LOCAL_CFLAGS += -DRECOVERY_BGRA
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_RECOVERY_OVERSCAN_PERCENT),)
|
|
||||||
LOCAL_CFLAGS += -DOVERSCAN_PERCENT=$(TARGET_RECOVERY_OVERSCAN_PERCENT)
|
|
||||||
else
|
|
||||||
LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_RECOVERY_DEFAULT_ROTATION),)
|
|
||||||
LOCAL_CFLAGS += -DDEFAULT_ROTATION=$(TARGET_RECOVERY_DEFAULT_ROTATION)
|
|
||||||
else
|
|
||||||
LOCAL_CFLAGS += -DDEFAULT_ROTATION=ROTATION_NONE
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
# libminui (shared library)
|
# libminui (shared library)
|
||||||
|
|||||||
+28
-11
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <android-base/properties.h>
|
||||||
|
|
||||||
#include "graphics_adf.h"
|
#include "graphics_adf.h"
|
||||||
#include "graphics_drm.h"
|
#include "graphics_drm.h"
|
||||||
#include "graphics_fbdev.h"
|
#include "graphics_fbdev.h"
|
||||||
@@ -31,7 +33,6 @@
|
|||||||
static GRFont* gr_font = nullptr;
|
static GRFont* gr_font = nullptr;
|
||||||
static MinuiBackend* gr_backend = nullptr;
|
static MinuiBackend* gr_backend = nullptr;
|
||||||
|
|
||||||
static int overscan_percent = OVERSCAN_PERCENT;
|
|
||||||
static int overscan_offset_x = 0;
|
static int overscan_offset_x = 0;
|
||||||
static int overscan_offset_y = 0;
|
static int overscan_offset_y = 0;
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ static constexpr uint32_t alpha_mask = 0xff000000;
|
|||||||
// gr_draw is owned by backends.
|
// gr_draw is owned by backends.
|
||||||
static const GRSurface* gr_draw = nullptr;
|
static const GRSurface* gr_draw = nullptr;
|
||||||
static GRRotation rotation = GRRotation::NONE;
|
static GRRotation rotation = GRRotation::NONE;
|
||||||
|
static PixelFormat pixel_format = PixelFormat::UNKNOWN;
|
||||||
|
|
||||||
static bool outside(int x, int y) {
|
static bool outside(int x, int y) {
|
||||||
auto swapped = (rotation == GRRotation::LEFT || rotation == GRRotation::RIGHT);
|
auto swapped = (rotation == GRRotation::LEFT || rotation == GRRotation::RIGHT);
|
||||||
@@ -52,6 +54,10 @@ const GRFont* gr_sys_font() {
|
|||||||
return gr_font;
|
return gr_font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PixelFormat gr_pixel_format() {
|
||||||
|
return pixel_format;
|
||||||
|
}
|
||||||
|
|
||||||
int gr_measure(const GRFont* font, const char* s) {
|
int gr_measure(const GRFont* font, const char* s) {
|
||||||
if (font == nullptr) {
|
if (font == nullptr) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -203,11 +209,11 @@ void gr_texticon(int x, int y, GRSurface* icon) {
|
|||||||
|
|
||||||
void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
|
void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
|
||||||
uint32_t r32 = r, g32 = g, b32 = b, a32 = a;
|
uint32_t r32 = r, g32 = g, b32 = b, a32 = a;
|
||||||
#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
|
if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) {
|
||||||
gr_current = (a32 << 24) | (r32 << 16) | (g32 << 8) | b32;
|
gr_current = (a32 << 24) | (r32 << 16) | (g32 << 8) | b32;
|
||||||
#else
|
} else {
|
||||||
gr_current = (a32 << 24) | (b32 << 16) | (g32 << 8) | r32;
|
gr_current = (a32 << 24) | (b32 << 16) | (g32 << 8) | r32;
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gr_clear() {
|
void gr_clear() {
|
||||||
@@ -335,6 +341,18 @@ void gr_flip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int gr_init() {
|
int gr_init() {
|
||||||
|
// pixel_format needs to be set before loading any resources or initializing backends.
|
||||||
|
std::string format = android::base::GetProperty("ro.recovery.ui.pixel_format", "");
|
||||||
|
if (format == "ABGR_8888") {
|
||||||
|
pixel_format = PixelFormat::ABGR;
|
||||||
|
} else if (format == "RGBX_8888") {
|
||||||
|
pixel_format = PixelFormat::RGBX;
|
||||||
|
} else if (format == "BGRA_8888") {
|
||||||
|
pixel_format = PixelFormat::BGRA;
|
||||||
|
} else {
|
||||||
|
pixel_format = PixelFormat::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
int ret = gr_init_font("font", &gr_font);
|
int ret = gr_init_font("font", &gr_font);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("Failed to init font: %d, continuing graphic backend initialization without font file\n",
|
printf("Failed to init font: %d, continuing graphic backend initialization without font file\n",
|
||||||
@@ -360,6 +378,7 @@ int gr_init() {
|
|||||||
|
|
||||||
gr_backend = backend.release();
|
gr_backend = backend.release();
|
||||||
|
|
||||||
|
int overscan_percent = android::base::GetIntProperty("ro.recovery.ui.overscan_percent", 0);
|
||||||
overscan_offset_x = gr_draw->width * overscan_percent / 100;
|
overscan_offset_x = gr_draw->width * overscan_percent / 100;
|
||||||
overscan_offset_y = gr_draw->height * overscan_percent / 100;
|
overscan_offset_y = gr_draw->height * overscan_percent / 100;
|
||||||
|
|
||||||
@@ -370,17 +389,15 @@ int gr_init() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __STRINGIFY(x) #x
|
std::string rotation_str =
|
||||||
#define STRINGIFY(x) __STRINGIFY(x)
|
android::base::GetProperty("ro.recovery.ui.default_rotation", "ROTATION_NONE");
|
||||||
|
|
||||||
std::string rotation_str(STRINGIFY(DEFAULT_ROTATION));
|
|
||||||
if (rotation_str == "ROTATION_RIGHT") {
|
if (rotation_str == "ROTATION_RIGHT") {
|
||||||
gr_rotate(GRRotation::RIGHT);
|
gr_rotate(GRRotation::RIGHT);
|
||||||
} else if (rotation_str == "ROTATION_DOWN") {
|
} else if (rotation_str == "ROTATION_DOWN") {
|
||||||
gr_rotate(GRRotation::DOWN);
|
gr_rotate(GRRotation::DOWN);
|
||||||
} else if (rotation_str == "ROTATION_LEFT") {
|
} else if (rotation_str == "ROTATION_LEFT") {
|
||||||
gr_rotate(GRRotation::LEFT);
|
gr_rotate(GRRotation::LEFT);
|
||||||
} else { // "ROTATION_NONE"
|
} else { // "ROTATION_NONE" or unknown string
|
||||||
gr_rotate(GRRotation::NONE);
|
gr_rotate(GRRotation::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-9
@@ -104,15 +104,16 @@ int MinuiBackendAdf::DeviceInit(adf_device* dev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GRSurface* MinuiBackendAdf::Init() {
|
GRSurface* MinuiBackendAdf::Init() {
|
||||||
#if defined(RECOVERY_ABGR)
|
PixelFormat pixel_format = gr_pixel_format();
|
||||||
format = DRM_FORMAT_ABGR8888;
|
if (pixel_format == PixelFormat::ABGR) {
|
||||||
#elif defined(RECOVERY_BGRA)
|
format = DRM_FORMAT_ABGR8888;
|
||||||
format = DRM_FORMAT_BGRA8888;
|
} else if (pixel_format == PixelFormat::BGRA) {
|
||||||
#elif defined(RECOVERY_RGBX)
|
format = DRM_FORMAT_BGRA8888;
|
||||||
format = DRM_FORMAT_RGBX8888;
|
} else if (pixel_format == PixelFormat::RGBX) {
|
||||||
#else
|
format = DRM_FORMAT_RGBX8888;
|
||||||
format = DRM_FORMAT_RGB565;
|
} else {
|
||||||
#endif
|
format = DRM_FORMAT_RGB565;
|
||||||
|
}
|
||||||
|
|
||||||
adf_id_t* dev_ids = nullptr;
|
adf_id_t* dev_ids = nullptr;
|
||||||
ssize_t n_dev_ids = adf_devices(&dev_ids);
|
ssize_t n_dev_ids = adf_devices(&dev_ids);
|
||||||
|
|||||||
+10
-9
@@ -116,15 +116,16 @@ GRSurfaceDrm* MinuiBackendDrm::DrmCreateSurface(int width, int height) {
|
|||||||
*surface = {};
|
*surface = {};
|
||||||
|
|
||||||
uint32_t format;
|
uint32_t format;
|
||||||
#if defined(RECOVERY_ABGR)
|
PixelFormat pixel_format = gr_pixel_format();
|
||||||
format = DRM_FORMAT_RGBA8888;
|
if (pixel_format == PixelFormat::ABGR) {
|
||||||
#elif defined(RECOVERY_BGRA)
|
format = DRM_FORMAT_ABGR8888;
|
||||||
format = DRM_FORMAT_ARGB8888;
|
} else if (pixel_format == PixelFormat::BGRA) {
|
||||||
#elif defined(RECOVERY_RGBX)
|
format = DRM_FORMAT_BGRA8888;
|
||||||
format = DRM_FORMAT_XBGR8888;
|
} else if (pixel_format == PixelFormat::RGBX) {
|
||||||
#else
|
format = DRM_FORMAT_RGBX8888;
|
||||||
format = DRM_FORMAT_RGB565;
|
} else {
|
||||||
#endif
|
format = DRM_FORMAT_RGB565;
|
||||||
|
}
|
||||||
|
|
||||||
drm_mode_create_dumb create_dumb = {};
|
drm_mode_create_dumb create_dumb = {};
|
||||||
create_dumb.height = height;
|
create_dumb.height = height;
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ enum class GRRotation : int {
|
|||||||
LEFT = 3,
|
LEFT = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class PixelFormat : int {
|
||||||
|
UNKNOWN = 0,
|
||||||
|
ABGR = 1,
|
||||||
|
RGBX = 2,
|
||||||
|
BGRA = 3,
|
||||||
|
};
|
||||||
|
|
||||||
// Initializes the graphics backend and loads font file. Returns 0 on success, or -1 on error. Note
|
// Initializes the graphics backend and loads font file. Returns 0 on success, or -1 on error. Note
|
||||||
// that the font initialization failure would be non-fatal, as caller may not need to draw any text
|
// that the font initialization failure would be non-fatal, as caller may not need to draw any text
|
||||||
// at all. Caller can check the font initialization result via gr_sys_font() as needed.
|
// at all. Caller can check the font initialization result via gr_sys_font() as needed.
|
||||||
@@ -85,6 +92,9 @@ unsigned int gr_get_height(const GRSurface* surface);
|
|||||||
// Sets rotation, flips gr_fb_width/height if 90 degree rotation difference
|
// Sets rotation, flips gr_fb_width/height if 90 degree rotation difference
|
||||||
void gr_rotate(GRRotation rotation);
|
void gr_rotate(GRRotation rotation);
|
||||||
|
|
||||||
|
// Returns the current PixelFormat being used.
|
||||||
|
PixelFormat gr_pixel_format();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Input events.
|
// Input events.
|
||||||
//
|
//
|
||||||
|
|||||||
+11
-9
@@ -207,9 +207,10 @@ int res_create_display_surface(const char* name, GRSurface** pSurface) {
|
|||||||
return -8;
|
return -8;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
|
PixelFormat pixel_format = gr_pixel_format();
|
||||||
png_set_bgr(png_ptr);
|
if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) {
|
||||||
#endif
|
png_set_bgr(png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
for (png_uint_32 y = 0; y < height; ++y) {
|
for (png_uint_32 y = 0; y < height; ++y) {
|
||||||
std::vector<unsigned char> p_row(width * 4);
|
std::vector<unsigned char> p_row(width * 4);
|
||||||
@@ -278,9 +279,9 @@ int res_create_multi_display_surface(const char* name, int* frames, int* fps,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
|
if (gr_pixel_format() == PixelFormat::ABGR || gr_pixel_format() == PixelFormat::BGRA) {
|
||||||
png_set_bgr(png_ptr);
|
png_set_bgr(png_ptr);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
for (png_uint_32 y = 0; y < height; ++y) {
|
for (png_uint_32 y = 0; y < height; ++y) {
|
||||||
std::vector<unsigned char> p_row(width * 4);
|
std::vector<unsigned char> p_row(width * 4);
|
||||||
@@ -327,9 +328,10 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
|
|||||||
surface->row_bytes = width;
|
surface->row_bytes = width;
|
||||||
surface->pixel_bytes = 1;
|
surface->pixel_bytes = 1;
|
||||||
|
|
||||||
#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
|
PixelFormat pixel_format = gr_pixel_format();
|
||||||
png_set_bgr(png_ptr);
|
if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) {
|
||||||
#endif
|
png_set_bgr(png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
for (png_uint_32 y = 0; y < height; ++y) {
|
for (png_uint_32 y = 0; y < height; ++y) {
|
||||||
unsigned char* p_row = surface->data + y * surface->row_bytes;
|
unsigned char* p_row = surface->data + y * surface->row_bytes;
|
||||||
|
|||||||
Reference in New Issue
Block a user