Merge branch 'next' of https://github.com/openfl/lime into text-harfbuzz
Conflicts: lime/graphics/Font.hx project/include/graphics/Font.h project/src/ExternalInterface.cpp project/src/graphics/Font.cpp
This commit is contained in:
@@ -10,20 +10,18 @@
|
||||
#include <hx/CFFI.h>
|
||||
#include <app/Application.h>
|
||||
#include <app/UpdateEvent.h>
|
||||
#ifdef LIME_FREETYPE
|
||||
#include <audio/format/OGG.h>
|
||||
#include <audio/format/WAV.h>
|
||||
#include <audio/AudioBuffer.h>
|
||||
#include <graphics/format/JPEG.h>
|
||||
#include <graphics/format/PNG.h>
|
||||
#include <graphics/Font.h>
|
||||
#ifdef LIME_HARFBUZZ
|
||||
#include <graphics/Text.h>
|
||||
#endif // LIME_HARFBUZZ
|
||||
#endif // LIME_FREETYPE
|
||||
#include <graphics/ImageBuffer.h>
|
||||
#include <graphics/Renderer.h>
|
||||
#include <graphics/RenderEvent.h>
|
||||
#include <media/format/JPEG.h>
|
||||
#include <media/format/OGG.h>
|
||||
#include <media/format/PNG.h>
|
||||
#include <media/format/WAV.h>
|
||||
#include <media/AudioBuffer.h>
|
||||
#include <media/Image.h>
|
||||
#include <system/System.h>
|
||||
#include <ui/KeyEvent.h>
|
||||
#include <ui/MouseEvent.h>
|
||||
@@ -97,7 +95,7 @@ namespace lime {
|
||||
|
||||
value lime_image_load (value data) {
|
||||
|
||||
Image image;
|
||||
ImageBuffer imageBuffer;
|
||||
Resource resource;
|
||||
|
||||
if (val_is_string (data)) {
|
||||
@@ -112,17 +110,17 @@ namespace lime {
|
||||
}
|
||||
|
||||
#ifdef LIME_PNG
|
||||
if (PNG::Decode (&resource, &image)) {
|
||||
if (PNG::Decode (&resource, &imageBuffer)) {
|
||||
|
||||
return image.Value ();
|
||||
return imageBuffer.Value ();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LIME_JPEG
|
||||
if (JPEG::Decode (&resource, &image)) {
|
||||
if (JPEG::Decode (&resource, &imageBuffer)) {
|
||||
|
||||
return image.Value ();
|
||||
return imageBuffer.Value ();
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -184,7 +182,7 @@ namespace lime {
|
||||
value lime_font_create_image (value fontHandle) {
|
||||
|
||||
#ifdef LIME_FREETYPE
|
||||
Image image;
|
||||
ImageBuffer image;
|
||||
Font *font = (Font*)(intptr_t)val_float (fontHandle);
|
||||
value data = alloc_empty_object ();
|
||||
alloc_field (data, val_id ("glyphs"), font->RenderToImage (&image));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <media/AudioBuffer.h>
|
||||
#include <audio/AudioBuffer.h>
|
||||
|
||||
|
||||
namespace lime {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <media/format/OGG.h>
|
||||
#include <audio/format/OGG.h>
|
||||
#include <utils/FileIO.h>
|
||||
#include <vorbis/vorbisfile.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <media/format/WAV.h>
|
||||
#include <audio/format/WAV.h>
|
||||
#include <utils/FileIO.h>
|
||||
|
||||
|
||||
@@ -22,18 +22,6 @@ namespace lime {
|
||||
|
||||
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER);
|
||||
|
||||
#ifdef HX_MACOS
|
||||
// set working directory for OS X
|
||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL (CFBundleGetMainBundle ());
|
||||
char path[PATH_MAX];
|
||||
if (CFURLGetFileSystemRepresentation (resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) {
|
||||
|
||||
chdir(path);
|
||||
|
||||
}
|
||||
CFRelease(resourcesURL);
|
||||
#endif
|
||||
|
||||
currentUpdate = 0;
|
||||
lastUpdate = 0;
|
||||
nextUpdate = 0;
|
||||
@@ -45,6 +33,19 @@ namespace lime {
|
||||
UpdateEvent updateEvent;
|
||||
WindowEvent windowEvent;
|
||||
|
||||
#ifdef HX_MACOS
|
||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL (CFBundleGetMainBundle ());
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (CFURLGetFileSystemRepresentation (resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) {
|
||||
|
||||
chdir (path);
|
||||
|
||||
}
|
||||
|
||||
CFRelease (resourcesURL);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <graphics/Font.h>
|
||||
#include <media/Image.h>
|
||||
#include <graphics/ImageBuffer.h>
|
||||
#include <algorithm>
|
||||
|
||||
// from http://stackoverflow.com/questions/2948308/how-do-i-read-utf-8-characters-via-a-pointer
|
||||
@@ -258,7 +258,7 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
value Font::RenderToImage (Image *image) {
|
||||
value Font::RenderToImage (ImageBuffer *image) {
|
||||
|
||||
if (!init) {
|
||||
|
||||
@@ -370,7 +370,7 @@ namespace lime {
|
||||
alloc_field (offset, id_y, alloc_int (face->glyph->bitmap_top));
|
||||
alloc_field (v, id_offset, offset);
|
||||
|
||||
alloc_field (v, id_codepoint, alloc_int ((*it).codepoint));
|
||||
alloc_field (v, id_codepoint, alloc_int ((*it).index));
|
||||
alloc_field (v, id_size, alloc_int ((*it).size));
|
||||
val_array_set_i (rects, rectsIndex++, v);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <media/Image.h>
|
||||
#include <graphics/ImageBuffer.h>
|
||||
|
||||
|
||||
namespace lime {
|
||||
@@ -11,7 +11,7 @@ namespace lime {
|
||||
static bool init = false;
|
||||
|
||||
|
||||
Image::Image () {
|
||||
ImageBuffer::ImageBuffer () {
|
||||
|
||||
width = 0;
|
||||
height = 0;
|
||||
@@ -21,14 +21,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
Image::~Image () {
|
||||
ImageBuffer::~ImageBuffer () {
|
||||
|
||||
delete data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Image::Blit (const unsigned char *data, int x, int y, int width, int height) {
|
||||
void ImageBuffer::Blit (const unsigned char *data, int x, int y, int width, int height) {
|
||||
|
||||
if (x < 0 || x + width > this->width || y < 0 || y + height > this->height) {
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void Image::Resize (int width, int height, int bpp) {
|
||||
void ImageBuffer::Resize (int width, int height, int bpp) {
|
||||
|
||||
this->bpp = bpp;
|
||||
this->width = width;
|
||||
@@ -58,7 +58,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value Image::Value () {
|
||||
value ImageBuffer::Value () {
|
||||
|
||||
if (!init) {
|
||||
|
||||
@@ -7,7 +7,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <media/format/JPEG.h>
|
||||
#include <graphics/format/JPEG.h>
|
||||
#include <utils/FileIO.h>
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace lime {
|
||||
};
|
||||
|
||||
|
||||
bool JPEG::Decode (Resource *resource, Image* image) {
|
||||
bool JPEG::Decode (Resource *resource, ImageBuffer* imageBuffer) {
|
||||
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
|
||||
@@ -168,10 +168,10 @@ namespace lime {
|
||||
|
||||
jpeg_start_decompress (&cinfo);
|
||||
int components = cinfo.num_components;
|
||||
image->Resize (cinfo.output_width, cinfo.output_height);
|
||||
imageBuffer->Resize (cinfo.output_width, cinfo.output_height);
|
||||
|
||||
unsigned char *bytes = image->data->Bytes ();
|
||||
unsigned char *scanline = new unsigned char [image->width * image->height * components];
|
||||
unsigned char *bytes = imageBuffer->data->Bytes ();
|
||||
unsigned char *scanline = new unsigned char [imageBuffer->width * imageBuffer->height * components];
|
||||
|
||||
while (cinfo.output_scanline < cinfo.output_height) {
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace lime {
|
||||
|
||||
// convert 24-bit scanline to 32-bit
|
||||
const unsigned char *line = scanline;
|
||||
const unsigned char *const end = line + image->width * components;
|
||||
const unsigned char *const end = line + imageBuffer->width * components;
|
||||
|
||||
while (line != end) {
|
||||
|
||||
@@ -7,7 +7,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <media/format/PNG.h>
|
||||
#include <graphics/format/PNG.h>
|
||||
#include <utils/FileIO.h>
|
||||
#include <utils/QuickVec.h>
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace lime {
|
||||
void user_flush_data (png_structp png_ptr) {}
|
||||
|
||||
|
||||
bool PNG::Decode (Resource *resource, Image *image) {
|
||||
bool PNG::Decode (Resource *resource, ImageBuffer *imageBuffer) {
|
||||
|
||||
unsigned char png_sig[PNG_SIG_SIZE];
|
||||
png_structp png_ptr;
|
||||
@@ -160,9 +160,9 @@ namespace lime {
|
||||
|
||||
int bpp = 4;
|
||||
const unsigned int stride = width * bpp;
|
||||
image->Resize (width, height, bpp);
|
||||
imageBuffer->Resize (width, height, bpp);
|
||||
|
||||
unsigned char *bytes = image->data->Bytes ();
|
||||
unsigned char *bytes = imageBuffer->data->Bytes ();
|
||||
|
||||
int number_of_passes = png_set_interlace_handling (png_ptr);
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
static bool Encode (Image *image, ByteArray *bytes) {
|
||||
static bool Encode (ImageBuffer *imageBuffer, ByteArray *bytes) {
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user