void mnit_android_png_read_data(png_structp png_ptr,
png_bytep data, png_size_t length)
{
- struct AAsset *recv = png_get_io_ptr(png_ptr);
- int read = AAsset_read(recv, data, length);
+ struct AAsset *self = png_get_io_ptr(png_ptr);
+ int read = AAsset_read(self, data, length);
}
void mnit_android_png_error_fn(png_structp png_ptr,
png_const_charp error_msg)
fun read(count: Int): nullable String is extern import String.as nullable, NativeString.to_s `{
char *buffer = malloc(sizeof(char) * (count+1));
- int read = AAsset_read(recv, buffer, count);
+ int read = AAsset_read(self, buffer, count);
if (read != count)
return null_String();
else
`}
fun length: Int is extern `{
- return AAsset_getLength(recv);
+ return AAsset_getLength(self);
`}
fun to_fd: Int is extern `{
off_t start;
off_t length;
- int fd = AAsset_openFileDescriptor(recv, &start, &length);
+ int fd = AAsset_openFileDescriptor(self, &start, &length);
return fd;
`}
fun close is extern `{
- AAsset_close(recv);
+ AAsset_close(self);
`}
end
end
protected fun load_asset_from_apk(path: String): nullable AndroidAsset is extern import String.to_cstring, AndroidAsset.as nullable, native_app_glue `{
- struct android_app *native_app_glue = App_native_app_glue(recv);
+ struct android_app *native_app_glue = App_native_app_glue(self);
struct AAsset* a = AAssetManager_open(native_app_glue->activity->assetManager, String_to_cstring(path), AASSET_MODE_BUFFER);
if (a == NULL)
{
redef class Opengles1Image
# Read a png from a zipped stream
new from_android_asset(asset: AndroidAsset) import Int.next_pow `{
- struct mnit_opengles_Texture *recv = NULL;
+ struct mnit_opengles_Texture *self = NULL;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
for (i = 0; i < height; i++)
memcpy(pixels + (row_bytes_pow2*i), row_pointers[i], row_bytes);
- recv = mnit_opengles_load_image((const uint_least32_t *)pixels,
+ self = mnit_opengles_load_image((const uint_least32_t *)pixels,
width, height, width_pow2, height_pow2, has_alpha);
// Calculate the size of the client-side memory allocated and freed
}
close_stream:
- return recv;
+ return self;
`}
end
# The first power of `exp` greater or equal to `self`
private fun next_pow(exp: Int): Int
do
- var p = 0
+ var p = 1
while p < self do p = p*exp
return p
end