aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2015-04-15 12:58:56 -0500
committerElliott Hughes2015-04-15 12:58:56 -0500
commit0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9 (patch)
tree625c21a7688ed613dd22fc9fc9e6c68cec7c44bc /minui/resources.cpp
parent6e435abfeb7256b5ea82ca37166acf36e3f98085 (diff)
downloadplatform-bootable-recovery-0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9.tar.gz
platform-bootable-recovery-0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9.tar.xz
platform-bootable-recovery-0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9.zip
Don't use typedefs that hide *s.
gr_surface was causing confusion for no good reason. Change-Id: If7120187f9a00dd16297877fc49352185a4d4ea6
Diffstat (limited to 'minui/resources.cpp')
-rw-r--r--minui/resources.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/minui/resources.cpp b/minui/resources.cpp
index fa413b60..5e478927 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -36,11 +36,11 @@ extern char* locale;
36 36
37#define SURFACE_DATA_ALIGNMENT 8 37#define SURFACE_DATA_ALIGNMENT 8
38 38
39static gr_surface malloc_surface(size_t data_size) { 39static GRSurface* malloc_surface(size_t data_size) {
40 size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT; 40 size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT;
41 unsigned char* temp = reinterpret_cast<unsigned char*>(malloc(size)); 41 unsigned char* temp = reinterpret_cast<unsigned char*>(malloc(size));
42 if (temp == NULL) return NULL; 42 if (temp == NULL) return NULL;
43 gr_surface surface = (gr_surface) temp; 43 GRSurface* surface = reinterpret_cast<GRSurface*>(temp);
44 surface->data = temp + sizeof(GRSurface) + 44 surface->data = temp + sizeof(GRSurface) +
45 (SURFACE_DATA_ALIGNMENT - (sizeof(GRSurface) % SURFACE_DATA_ALIGNMENT)); 45 (SURFACE_DATA_ALIGNMENT - (sizeof(GRSurface) % SURFACE_DATA_ALIGNMENT));
46 return surface; 46 return surface;
@@ -138,12 +138,10 @@ static int open_png(const char* name, png_structp* png_ptr, png_infop* info_ptr,
138// framebuffer pixel format; they need to be modified if the 138// framebuffer pixel format; they need to be modified if the
139// framebuffer format changes (but nothing else should). 139// framebuffer format changes (but nothing else should).
140 140
141// Allocate and return a gr_surface sufficient for storing an image of 141// Allocate and return a GRSurface* sufficient for storing an image of
142// the indicated size in the framebuffer pixel format. 142// the indicated size in the framebuffer pixel format.
143static gr_surface init_display_surface(png_uint_32 width, png_uint_32 height) { 143static GRSurface* init_display_surface(png_uint_32 width, png_uint_32 height) {
144 gr_surface surface; 144 GRSurface* surface = malloc_surface(width * height * 4);
145
146 surface = malloc_surface(width * height * 4);
147 if (surface == NULL) return NULL; 145 if (surface == NULL) return NULL;
148 146
149 surface->width = width; 147 surface->width = width;
@@ -199,8 +197,8 @@ static void transform_rgb_to_draw(unsigned char* input_row,
199 } 197 }
200} 198}
201 199
202int res_create_display_surface(const char* name, gr_surface* pSurface) { 200int res_create_display_surface(const char* name, GRSurface** pSurface) {
203 gr_surface surface = NULL; 201 GRSurface* surface = NULL;
204 int result = 0; 202 int result = 0;
205 png_structp png_ptr = NULL; 203 png_structp png_ptr = NULL;
206 png_infop info_ptr = NULL; 204 png_infop info_ptr = NULL;
@@ -239,8 +237,8 @@ int res_create_display_surface(const char* name, gr_surface* pSurface) {
239 return result; 237 return result;
240} 238}
241 239
242int res_create_multi_display_surface(const char* name, int* frames, gr_surface** pSurface) { 240int res_create_multi_display_surface(const char* name, int* frames, GRSurface*** pSurface) {
243 gr_surface* surface = NULL; 241 GRSurface** surface = NULL;
244 int result = 0; 242 int result = 0;
245 png_structp png_ptr = NULL; 243 png_structp png_ptr = NULL;
246 png_infop info_ptr = NULL; 244 png_infop info_ptr = NULL;
@@ -275,7 +273,7 @@ int res_create_multi_display_surface(const char* name, int* frames, gr_surface**
275 goto exit; 273 goto exit;
276 } 274 }
277 275
278 surface = reinterpret_cast<gr_surface*>(malloc(*frames * sizeof(gr_surface))); 276 surface = reinterpret_cast<GRSurface**>(malloc(*frames * sizeof(GRSurface*)));
279 if (surface == NULL) { 277 if (surface == NULL) {
280 result = -8; 278 result = -8;
281 goto exit; 279 goto exit;
@@ -302,7 +300,7 @@ int res_create_multi_display_surface(const char* name, int* frames, gr_surface**
302 } 300 }
303 free(p_row); 301 free(p_row);
304 302
305 *pSurface = (gr_surface*) surface; 303 *pSurface = reinterpret_cast<GRSurface**>(surface);
306 304
307exit: 305exit:
308 png_destroy_read_struct(&png_ptr, &info_ptr, NULL); 306 png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -318,8 +316,8 @@ exit:
318 return result; 316 return result;
319} 317}
320 318
321int res_create_alpha_surface(const char* name, gr_surface* pSurface) { 319int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
322 gr_surface surface = NULL; 320 GRSurface* surface = NULL;
323 int result = 0; 321 int result = 0;
324 png_structp png_ptr = NULL; 322 png_structp png_ptr = NULL;
325 png_infop info_ptr = NULL; 323 png_infop info_ptr = NULL;
@@ -384,8 +382,8 @@ static int matches_locale(const char* loc, const char* locale) {
384 382
385int res_create_localized_alpha_surface(const char* name, 383int res_create_localized_alpha_surface(const char* name,
386 const char* locale, 384 const char* locale,
387 gr_surface* pSurface) { 385 GRSurface** pSurface) {
388 gr_surface surface = NULL; 386 GRSurface* surface = NULL;
389 int result = 0; 387 int result = 0;
390 png_structp png_ptr = NULL; 388 png_structp png_ptr = NULL;
391 png_infop info_ptr = NULL; 389 png_infop info_ptr = NULL;
@@ -440,7 +438,7 @@ int res_create_localized_alpha_surface(const char* name,
440 memcpy(surface->data + i*w, row, w); 438 memcpy(surface->data + i*w, row, w);
441 } 439 }
442 440
443 *pSurface = (gr_surface) surface; 441 *pSurface = reinterpret_cast<GRSurface*>(surface);
444 break; 442 break;
445 } else { 443 } else {
446 int i; 444 int i;
@@ -456,6 +454,6 @@ exit:
456 return result; 454 return result;
457} 455}
458 456
459void res_free_surface(gr_surface surface) { 457void res_free_surface(GRSurface* surface) {
460 free(surface); 458 free(surface);
461} 459}