X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FGCJ.cc;h=bba04f828c139c616d2137bb88143abfd09a6680;hb=ce1cf6a710c67eb2ef06835fffdaed7c41c85b24;hp=9efbe82fccc33048a5490c13a6627e5c16812990;hpb=798082a9cf2856f50f91483da37b5d9661355f00;p=org.ibex.core.git diff --git a/src/org/xwt/plat/GCJ.cc b/src/org/xwt/plat/GCJ.cc index 9efbe82..bba04f8 100644 --- a/src/org/xwt/plat/GCJ.cc +++ b/src/org/xwt/plat/GCJ.cc @@ -5,32 +5,36 @@ #include #include extern "C" { + +// hack for broken Solaris headers +#define _WCHAR_T + #include #include #include #include "jpeglib.h" } -#include +#include +#include #include #include #include #include #include -#include // builtin.xwar ///////////////////////////////////////////////////////// -extern unsigned char builtin_xwar[]; -extern int builtin_xwar_length; +extern unsigned char builtin_bytes[]; +extern int builtin_length; java::io::InputStream* org::xwt::plat::GCJ::_getBuiltinInputStream() { - jbyteArray ret = JvNewByteArray(builtin_xwar_length); - memcpy(elements(ret), builtin_xwar, builtin_xwar_length); + jbyteArray ret = JvNewByteArray(builtin_length); + memcpy(elements(ret), builtin_bytes, builtin_length); return new java::io::ByteArrayInputStream(ret); } - + // JPEG //////////////////////////////////////////////////////////////// @@ -39,7 +43,9 @@ java::io::InputStream* org::xwt::plat::GCJ::_getBuiltinInputStream() { typedef struct { struct jpeg_source_mgr pub; + /* FIXME org::xwt::plat::GCJ$JPEG* myself; + */ } source_manager; void jpeg_error_handler (j_common_ptr cinfo) { @@ -51,6 +57,7 @@ void term_source (j_decompress_ptr cinfo) { } void init_source (j_decompress_ptr cinfo) { } boolean fill_input_buffer (j_decompress_ptr cinfo) { + /* FIXME source_manager* src = (source_manager*)cinfo->src; jint nbytes = src->myself->is->read(src->myself->buffer, 0, INPUT_BUF_SIZE); if (nbytes <= 0) { @@ -61,6 +68,7 @@ boolean fill_input_buffer (j_decompress_ptr cinfo) { } src->pub.next_input_byte = (JOCTET*)elements(src->myself->buffer); src->pub.bytes_in_buffer = nbytes; + */ return 1; } @@ -76,8 +84,11 @@ void skip_input_data (j_decompress_ptr cinfo, long num_bytes) { } } -void org::xwt::plat::GCJ$JPEG::nativeDecompress() { +org::xwt::Picture* org::xwt::plat::GCJ::_decodeJPEG(java::io::InputStream* is, jstring name) { struct jpeg_decompress_struct cinfo; + jintArray data; + jint width; + jint height; // set up our error handler struct jpeg_error_mgr error_handler; @@ -87,14 +98,18 @@ void org::xwt::plat::GCJ$JPEG::nativeDecompress() { jpeg_create_decompress(&cinfo); try { source_manager src; + /* buffer = JvNewByteArray(INPUT_BUF_SIZE); + */ src.pub.init_source = init_source; src.pub.fill_input_buffer = fill_input_buffer; src.pub.skip_input_data = skip_input_data; src.pub.resync_to_restart = jpeg_resync_to_restart; src.pub.term_source = term_source; + /* src.myself = this; src.pub.next_input_byte = (JOCTET*)elements(buffer); + */ src.pub.bytes_in_buffer = 0; cinfo.src = (jpeg_source_mgr*)&src; @@ -120,5 +135,11 @@ void org::xwt::plat::GCJ$JPEG::nativeDecompress() { throw t; } jpeg_destroy_decompress(&cinfo); + return org::xwt::Platform::createPicture(data, width, height); } +// C++ new/delete operators (JvMalloc never fails) +void* operator new(size_t size) { return JvMalloc(size); } +void* operator new[](size_t size) { return JvMalloc(size);} +void operator delete(void *p) { JvFree(p); } +void operator delete[](void *p) { JvFree(p); }