blob: 40d3c2c88eb47f3e3cf398d3907dcbc97b57a241 [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdlib.h>
Elliott Hughescd3c55a2015-01-29 20:50:08 -080018#include <string.h>
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080019#include <unistd.h>
20
21#include <fcntl.h>
22#include <stdio.h>
23
24#include <sys/ioctl.h>
25#include <sys/mman.h>
26#include <sys/types.h>
27
28#include <linux/fb.h>
29#include <linux/kd.h>
30
Doug Zongker19faefa2009-03-27 17:06:24 -070031#include <png.h>
32
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080033#include "minui.h"
34
Doug Zongker16f97c32014-03-06 16:16:05 -080035#define SURFACE_DATA_ALIGNMENT 8
36
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -070037static GRSurface* malloc_surface(size_t data_size) {
Elliott Hughes07cfb8f2015-04-10 13:12:05 -070038 size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT;
39 unsigned char* temp = reinterpret_cast<unsigned char*>(malloc(size));
Doug Zongker16f97c32014-03-06 16:16:05 -080040 if (temp == NULL) return NULL;
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -070041 GRSurface* surface = reinterpret_cast<GRSurface*>(temp);
Doug Zongker16f97c32014-03-06 16:16:05 -080042 surface->data = temp + sizeof(GRSurface) +
43 (SURFACE_DATA_ALIGNMENT - (sizeof(GRSurface) % SURFACE_DATA_ALIGNMENT));
44 return surface;
Doug Zongker19faefa2009-03-27 17:06:24 -070045}
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080046
Doug Zongkera418aa72014-03-17 12:10:02 -070047static int open_png(const char* name, png_structp* png_ptr, png_infop* info_ptr,
48 png_uint_32* width, png_uint_32* height, png_byte* channels) {
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080049 char resPath[256];
Doug Zongker19faefa2009-03-27 17:06:24 -070050 unsigned char header[8];
Doug Zongkera418aa72014-03-17 12:10:02 -070051 int result = 0;
Elliott Hughes07cfb8f2015-04-10 13:12:05 -070052 int color_type, bit_depth;
53 size_t bytesRead;
Doug Zongker6809c512011-03-01 14:04:34 -080054
Doug Zongker19faefa2009-03-27 17:06:24 -070055 snprintf(resPath, sizeof(resPath)-1, "/res/images/%s.png", name);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080056 resPath[sizeof(resPath)-1] = '\0';
Doug Zongker19faefa2009-03-27 17:06:24 -070057 FILE* fp = fopen(resPath, "rb");
58 if (fp == NULL) {
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080059 result = -1;
60 goto exit;
61 }
Doug Zongker19faefa2009-03-27 17:06:24 -070062
Elliott Hughes07cfb8f2015-04-10 13:12:05 -070063 bytesRead = fread(header, 1, sizeof(header), fp);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080064 if (bytesRead != sizeof(header)) {
65 result = -2;
66 goto exit;
67 }
Doug Zongker19faefa2009-03-27 17:06:24 -070068
69 if (png_sig_cmp(header, 0, sizeof(header))) {
70 result = -3;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080071 goto exit;
72 }
Doug Zongker19faefa2009-03-27 17:06:24 -070073
Doug Zongkera418aa72014-03-17 12:10:02 -070074 *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
75 if (!*png_ptr) {
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080076 result = -4;
77 goto exit;
78 }
Doug Zongker19faefa2009-03-27 17:06:24 -070079
Doug Zongkera418aa72014-03-17 12:10:02 -070080 *info_ptr = png_create_info_struct(*png_ptr);
81 if (!*info_ptr) {
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080082 result = -5;
83 goto exit;
84 }
Doug Zongker19faefa2009-03-27 17:06:24 -070085
Doug Zongkera418aa72014-03-17 12:10:02 -070086 if (setjmp(png_jmpbuf(*png_ptr))) {
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080087 result = -6;
88 goto exit;
89 }
Doug Zongker19faefa2009-03-27 17:06:24 -070090
Doug Zongkera418aa72014-03-17 12:10:02 -070091 png_init_io(*png_ptr, fp);
92 png_set_sig_bytes(*png_ptr, sizeof(header));
93 png_read_info(*png_ptr, *info_ptr);
Doug Zongker19faefa2009-03-27 17:06:24 -070094
Doug Zongkera418aa72014-03-17 12:10:02 -070095 png_get_IHDR(*png_ptr, *info_ptr, width, height, &bit_depth,
John Reck94fd07b2013-08-26 16:45:33 -070096 &color_type, NULL, NULL, NULL);
97
Doug Zongkera418aa72014-03-17 12:10:02 -070098 *channels = png_get_channels(*png_ptr, *info_ptr);
John Reck94fd07b2013-08-26 16:45:33 -070099
Doug Zongkera418aa72014-03-17 12:10:02 -0700100 if (bit_depth == 8 && *channels == 3 && color_type == PNG_COLOR_TYPE_RGB) {
101 // 8-bit RGB images: great, nothing to do.
102 } else if (bit_depth <= 8 && *channels == 1 && color_type == PNG_COLOR_TYPE_GRAY) {
103 // 1-, 2-, 4-, or 8-bit gray images: expand to 8-bit gray.
104 png_set_expand_gray_1_2_4_to_8(*png_ptr);
Doug Zongker577a1302014-03-20 08:27:01 -0700105 } else if (bit_depth <= 8 && *channels == 1 && color_type == PNG_COLOR_TYPE_PALETTE) {
Doug Zongkera418aa72014-03-17 12:10:02 -0700106 // paletted images: expand to 8-bit RGB. Note that we DON'T
107 // currently expand the tRNS chunk (if any) to an alpha
108 // channel, because minui doesn't support alpha channels in
109 // general.
110 png_set_palette_to_rgb(*png_ptr);
111 *channels = 3;
112 } else {
113 fprintf(stderr, "minui doesn't support PNG depth %d channels %d color_type %d\n",
Doug Zongkera388a762014-03-17 16:51:47 -0700114 bit_depth, *channels, color_type);
Doug Zongkera418aa72014-03-17 12:10:02 -0700115 result = -7;
Doug Zongker19faefa2009-03-27 17:06:24 -0700116 goto exit;
117 }
118
Doug Zongkera418aa72014-03-17 12:10:02 -0700119 return result;
Doug Zongker55a36ac2013-03-04 15:49:02 -0800120
Doug Zongkera418aa72014-03-17 12:10:02 -0700121 exit:
122 if (result < 0) {
123 png_destroy_read_struct(png_ptr, info_ptr, NULL);
124 }
125 if (fp != NULL) {
126 fclose(fp);
127 }
128
129 return result;
130}
131
132// "display" surfaces are transformed into the framebuffer's required
133// pixel format (currently only RGBX is supported) at load time, so
134// gr_blit() can be nothing more than a memcpy() for each row. The
135// next two functions are the only ones that know anything about the
136// framebuffer pixel format; they need to be modified if the
137// framebuffer format changes (but nothing else should).
138
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700139// Allocate and return a GRSurface* sufficient for storing an image of
Doug Zongkera418aa72014-03-17 12:10:02 -0700140// the indicated size in the framebuffer pixel format.
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700141static GRSurface* init_display_surface(png_uint_32 width, png_uint_32 height) {
142 GRSurface* surface = malloc_surface(width * height * 4);
Doug Zongkera418aa72014-03-17 12:10:02 -0700143 if (surface == NULL) return NULL;
144
145 surface->width = width;
146 surface->height = height;
147 surface->row_bytes = width * 4;
148 surface->pixel_bytes = 4;
149
150 return surface;
151}
152
153// Copy 'input_row' to 'output_row', transforming it to the
154// framebuffer pixel format. The input format depends on the value of
155// 'channels':
156//
157// 1 - input is 8-bit grayscale
158// 3 - input is 24-bit RGB
159// 4 - input is 32-bit RGBA/RGBX
160//
161// 'width' is the number of pixels in the row.
162static void transform_rgb_to_draw(unsigned char* input_row,
163 unsigned char* output_row,
164 int channels, int width) {
165 int x;
166 unsigned char* ip = input_row;
167 unsigned char* op = output_row;
168
169 switch (channels) {
170 case 1:
171 // expand gray level to RGBX
172 for (x = 0; x < width; ++x) {
173 *op++ = *ip;
174 *op++ = *ip;
175 *op++ = *ip;
176 *op++ = 0xff;
177 ip++;
178 }
179 break;
180
181 case 3:
182 // expand RGBA to RGBX
183 for (x = 0; x < width; ++x) {
184 *op++ = *ip++;
185 *op++ = *ip++;
186 *op++ = *ip++;
187 *op++ = 0xff;
188 }
189 break;
190
191 case 4:
192 // copy RGBA to RGBX
193 memcpy(output_row, input_row, width*4);
194 break;
195 }
196}
197
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700198int res_create_display_surface(const char* name, GRSurface** pSurface) {
199 GRSurface* surface = NULL;
Doug Zongkera418aa72014-03-17 12:10:02 -0700200 int result = 0;
201 png_structp png_ptr = NULL;
202 png_infop info_ptr = NULL;
203 png_uint_32 width, height;
204 png_byte channels;
Elliott Hughes07cfb8f2015-04-10 13:12:05 -0700205 unsigned char* p_row;
206 unsigned int y;
Doug Zongkera418aa72014-03-17 12:10:02 -0700207
208 *pSurface = NULL;
209
210 result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels);
211 if (result < 0) return result;
212
213 surface = init_display_surface(width, height);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800214 if (surface == NULL) {
Doug Zongker19faefa2009-03-27 17:06:24 -0700215 result = -8;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800216 goto exit;
217 }
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800218
Tony Kuofd778e32015-02-05 21:25:56 +0800219#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
220 png_set_bgr(png_ptr);
221#endif
222
Elliott Hughes07cfb8f2015-04-10 13:12:05 -0700223 p_row = reinterpret_cast<unsigned char*>(malloc(width * 4));
Doug Zongkera418aa72014-03-17 12:10:02 -0700224 for (y = 0; y < height; ++y) {
225 png_read_row(png_ptr, p_row, NULL);
226 transform_rgb_to_draw(p_row, surface->data + y * surface->row_bytes, channels, width);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800227 }
Doug Zongkera418aa72014-03-17 12:10:02 -0700228 free(p_row);
Doug Zongker19faefa2009-03-27 17:06:24 -0700229
Doug Zongkera418aa72014-03-17 12:10:02 -0700230 *pSurface = surface;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800231
Doug Zongkera418aa72014-03-17 12:10:02 -0700232 exit:
Doug Zongker19faefa2009-03-27 17:06:24 -0700233 png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
Doug Zongkera418aa72014-03-17 12:10:02 -0700234 if (result < 0 && surface != NULL) free(surface);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800235 return result;
236}
237
Tao Baob723f4f2015-12-11 15:18:51 -0800238int res_create_multi_display_surface(const char* name, int* frames, int* fps,
239 GRSurface*** pSurface) {
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700240 GRSurface** surface = NULL;
Doug Zongker469954f2014-03-07 09:21:25 -0800241 int result = 0;
Doug Zongker469954f2014-03-07 09:21:25 -0800242 png_structp png_ptr = NULL;
243 png_infop info_ptr = NULL;
Doug Zongkera418aa72014-03-17 12:10:02 -0700244 png_uint_32 width, height;
245 png_byte channels;
Elliott Hughes07cfb8f2015-04-10 13:12:05 -0700246 png_textp text;
247 int num_text;
248 unsigned char* p_row;
249 unsigned int y;
Doug Zongker469954f2014-03-07 09:21:25 -0800250
251 *pSurface = NULL;
252 *frames = -1;
253
Doug Zongkera418aa72014-03-17 12:10:02 -0700254 result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels);
255 if (result < 0) return result;
Doug Zongker469954f2014-03-07 09:21:25 -0800256
257 *frames = 1;
Tao Baob723f4f2015-12-11 15:18:51 -0800258 *fps = 20;
Doug Zongker469954f2014-03-07 09:21:25 -0800259 if (png_get_text(png_ptr, info_ptr, &text, &num_text)) {
Tao Baob723f4f2015-12-11 15:18:51 -0800260 for (int i = 0; i < num_text; ++i) {
Doug Zongker469954f2014-03-07 09:21:25 -0800261 if (text[i].key && strcmp(text[i].key, "Frames") == 0 && text[i].text) {
262 *frames = atoi(text[i].text);
Tao Baob723f4f2015-12-11 15:18:51 -0800263 } else if (text[i].key && strcmp(text[i].key, "FPS") == 0 && text[i].text) {
264 *fps = atoi(text[i].text);
Doug Zongker469954f2014-03-07 09:21:25 -0800265 }
266 }
267 printf(" found frames = %d\n", *frames);
Tao Baob723f4f2015-12-11 15:18:51 -0800268 printf(" found fps = %d\n", *fps);
269 }
270
271 if (frames <= 0 || fps <= 0) {
272 printf("bad number of frames (%d) and/or FPS (%d)\n", *frames, *fps);
273 result = -10;
274 goto exit;
Doug Zongker469954f2014-03-07 09:21:25 -0800275 }
276
277 if (height % *frames != 0) {
278 printf("bad height (%d) for frame count (%d)\n", height, *frames);
279 result = -9;
280 goto exit;
281 }
282
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700283 surface = reinterpret_cast<GRSurface**>(malloc(*frames * sizeof(GRSurface*)));
Doug Zongker469954f2014-03-07 09:21:25 -0800284 if (surface == NULL) {
285 result = -8;
286 goto exit;
287 }
Tao Baob723f4f2015-12-11 15:18:51 -0800288 for (int i = 0; i < *frames; ++i) {
Doug Zongkera418aa72014-03-17 12:10:02 -0700289 surface[i] = init_display_surface(width, height / *frames);
290 if (surface[i] == NULL) {
291 result = -8;
292 goto exit;
Doug Zongker469954f2014-03-07 09:21:25 -0800293 }
294 }
295
Tony Kuofd778e32015-02-05 21:25:56 +0800296#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
297 png_set_bgr(png_ptr);
298#endif
299
Elliott Hughes07cfb8f2015-04-10 13:12:05 -0700300 p_row = reinterpret_cast<unsigned char*>(malloc(width * 4));
Doug Zongkera418aa72014-03-17 12:10:02 -0700301 for (y = 0; y < height; ++y) {
302 png_read_row(png_ptr, p_row, NULL);
303 int frame = y % *frames;
304 unsigned char* out_row = surface[frame]->data +
305 (y / *frames) * surface[frame]->row_bytes;
306 transform_rgb_to_draw(p_row, out_row, channels, width);
307 }
308 free(p_row);
309
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700310 *pSurface = reinterpret_cast<GRSurface**>(surface);
Doug Zongker469954f2014-03-07 09:21:25 -0800311
312exit:
313 png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
314
Doug Zongker469954f2014-03-07 09:21:25 -0800315 if (result < 0) {
316 if (surface) {
Tao Baob723f4f2015-12-11 15:18:51 -0800317 for (int i = 0; i < *frames; ++i) {
Doug Zongker469954f2014-03-07 09:21:25 -0800318 if (surface[i]) free(surface[i]);
319 }
320 free(surface);
321 }
322 }
323 return result;
324}
325
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700326int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
327 GRSurface* surface = NULL;
Doug Zongkera418aa72014-03-17 12:10:02 -0700328 int result = 0;
329 png_structp png_ptr = NULL;
330 png_infop info_ptr = NULL;
331 png_uint_32 width, height;
332 png_byte channels;
333
334 *pSurface = NULL;
335
336 result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels);
337 if (result < 0) return result;
338
339 if (channels != 1) {
340 result = -7;
341 goto exit;
342 }
343
344 surface = malloc_surface(width * height);
345 if (surface == NULL) {
346 result = -8;
347 goto exit;
348 }
349 surface->width = width;
350 surface->height = height;
351 surface->row_bytes = width;
352 surface->pixel_bytes = 1;
353
Tony Kuofd778e32015-02-05 21:25:56 +0800354#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
355 png_set_bgr(png_ptr);
356#endif
357
Doug Zongkera418aa72014-03-17 12:10:02 -0700358 unsigned char* p_row;
359 unsigned int y;
360 for (y = 0; y < height; ++y) {
361 p_row = surface->data + y * surface->row_bytes;
362 png_read_row(png_ptr, p_row, NULL);
363 }
364
365 *pSurface = surface;
366
367 exit:
368 png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
369 if (result < 0 && surface != NULL) free(surface);
370 return result;
371}
372
Tianjie Xu2430e292016-04-19 15:02:41 -0700373// This function tests if a locale string stored in PNG (prefix) matches
374// the locale string provided by the system (locale).
375bool matches_locale(const char* prefix, const char* locale) {
376 if (locale == NULL) return false;
Doug Zongker02ec6b82012-08-22 17:26:40 -0700377
Tianjie Xu2430e292016-04-19 15:02:41 -0700378 // Return true if the whole string of prefix matches the top part of
379 // locale. For instance, prefix == "en" matches locale == "en_US";
380 // and prefix == "zh_CN" matches locale == "zh_CN_#Hans".
Doug Zongker02ec6b82012-08-22 17:26:40 -0700381
Tianjie Xu2430e292016-04-19 15:02:41 -0700382 return (strncmp(prefix, locale, strlen(prefix)) == 0);
Doug Zongker02ec6b82012-08-22 17:26:40 -0700383}
384
Doug Zongkera418aa72014-03-17 12:10:02 -0700385int res_create_localized_alpha_surface(const char* name,
386 const char* locale,
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700387 GRSurface** pSurface) {
388 GRSurface* surface = NULL;
Doug Zongker02ec6b82012-08-22 17:26:40 -0700389 int result = 0;
Doug Zongker02ec6b82012-08-22 17:26:40 -0700390 png_structp png_ptr = NULL;
391 png_infop info_ptr = NULL;
Doug Zongkera418aa72014-03-17 12:10:02 -0700392 png_uint_32 width, height;
393 png_byte channels;
Elliott Hughes07cfb8f2015-04-10 13:12:05 -0700394 unsigned char* row;
395 png_uint_32 y;
Doug Zongker02ec6b82012-08-22 17:26:40 -0700396
397 *pSurface = NULL;
398
Doug Zongkera418aa72014-03-17 12:10:02 -0700399 if (locale == NULL) {
400 surface = malloc_surface(0);
401 surface->width = 0;
402 surface->height = 0;
403 surface->row_bytes = 0;
404 surface->pixel_bytes = 1;
Doug Zongker02ec6b82012-08-22 17:26:40 -0700405 goto exit;
406 }
407
Doug Zongkera418aa72014-03-17 12:10:02 -0700408 result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels);
409 if (result < 0) return result;
410
411 if (channels != 1) {
412 result = -7;
Doug Zongker02ec6b82012-08-22 17:26:40 -0700413 goto exit;
414 }
415
Elliott Hughes07cfb8f2015-04-10 13:12:05 -0700416 row = reinterpret_cast<unsigned char*>(malloc(width));
Doug Zongker02ec6b82012-08-22 17:26:40 -0700417 for (y = 0; y < height; ++y) {
418 png_read_row(png_ptr, row, NULL);
419 int w = (row[1] << 8) | row[0];
420 int h = (row[3] << 8) | row[2];
421 int len = row[4];
Doug Zongker469954f2014-03-07 09:21:25 -0800422 char* loc = (char*)row+5;
Doug Zongker02ec6b82012-08-22 17:26:40 -0700423
Doug Zongkera418aa72014-03-17 12:10:02 -0700424 if (y+1+h >= height || matches_locale(loc, locale)) {
Doug Zongker52eeea4f2012-09-04 14:28:25 -0700425 printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y);
426
Doug Zongker16f97c32014-03-06 16:16:05 -0800427 surface = malloc_surface(w*h);
Doug Zongker02ec6b82012-08-22 17:26:40 -0700428 if (surface == NULL) {
429 result = -8;
430 goto exit;
431 }
Doug Zongker02ec6b82012-08-22 17:26:40 -0700432 surface->width = w;
433 surface->height = h;
Doug Zongker16f97c32014-03-06 16:16:05 -0800434 surface->row_bytes = w;
435 surface->pixel_bytes = 1;
Doug Zongker02ec6b82012-08-22 17:26:40 -0700436
437 int i;
438 for (i = 0; i < h; ++i, ++y) {
439 png_read_row(png_ptr, row, NULL);
Doug Zongkera418aa72014-03-17 12:10:02 -0700440 memcpy(surface->data + i*w, row, w);
Doug Zongker02ec6b82012-08-22 17:26:40 -0700441 }
442
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700443 *pSurface = reinterpret_cast<GRSurface*>(surface);
Doug Zongker02ec6b82012-08-22 17:26:40 -0700444 break;
445 } else {
Doug Zongker02ec6b82012-08-22 17:26:40 -0700446 int i;
447 for (i = 0; i < h; ++i, ++y) {
448 png_read_row(png_ptr, row, NULL);
449 }
450 }
451 }
452
453exit:
454 png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
Doug Zongkera418aa72014-03-17 12:10:02 -0700455 if (result < 0 && surface != NULL) free(surface);
Doug Zongker02ec6b82012-08-22 17:26:40 -0700456 return result;
457}
458
Elliott Hughes0a5cb0c2015-04-15 10:58:56 -0700459void res_free_surface(GRSurface* surface) {
Doug Zongker16f97c32014-03-06 16:16:05 -0800460 free(surface);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800461}