diff --git a/cmake/ToLua.cmake b/cmake/ToLua.cmake index acb6b45a..b9f1d0ca 100644 --- a/cmake/ToLua.cmake +++ b/cmake/ToLua.cmake @@ -50,6 +50,7 @@ ADD_CUSTOM_COMMAND( OUTPUT ${TOLUA_OUT} ${INCL} COMMAND VERBATIM ) SET_SOURCE_FILES_PROPERTIES(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE) +SET_SOURCE_FILES_PROPERTIES(${${VAR}} PROPERTIES COMPILE_FLAGS "-Wno-bad-function-cast -Wno-unused-parameter -Wno-cast-qual") SET(${VAR} ${${VAR}} PARENT_SCOPE) diff --git a/lua/CMakeLists.txt b/lua/CMakeLists.txt index ddbdedb6..31b4c028 100644 --- a/lua/CMakeLists.txt +++ b/lua/CMakeLists.txt @@ -24,8 +24,14 @@ include(ToLua) add_definitions(-DTOLUA_RELEASE) if(BUILD_X11) + if(BUILD_LUA_CAIRO) include_directories(${luacairo_includes} ${CMAKE_CURRENT_SOURCE_DIR}) + + # Need the directory for -lSM + get_filename_component(X11_SM_LIB_PATH ${X11_SM_LIB} DIRECTORY) + link_directories(${X11_SM_LIB_PATH}) + # cairo_set_dash() needs this special hack to work properly # if you have a better solution, please let me know wrap_tolua(luacairo_src cairo.pkg libcairo.patch) diff --git a/lua/libcairo_imlib2_helper.h b/lua/libcairo_imlib2_helper.h index e8fa1ebc..6e96a2a7 100644 --- a/lua/libcairo_imlib2_helper.h +++ b/lua/libcairo_imlib2_helper.h @@ -31,19 +31,23 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, double scale_x, double scale_y, double *return_scale_w, double *return_scale_h) { + int w, h; + double scaled_w, scaled_h; + Imlib_Image premul; + cairo_surface_t *result; + cairo_t *cr; Imlib_Image *image = imlib_load_image(file); - if (!image) { - return; - } + if (!image) { return; } imlib_context_set_image(image); - int w = imlib_image_get_width(), h = imlib_image_get_height(); + w = imlib_image_get_width(); + h = imlib_image_get_height(); - double scaled_w = *return_scale_w = scale_x * (double)w, - scaled_h = *return_scale_h = scale_y * (double)h; + scaled_w = *return_scale_w = scale_x * (double)w; + scaled_h = *return_scale_h = scale_y * (double)h; /* create temporary image */ - Imlib_Image premul = imlib_create_image(scaled_w, scaled_h); + premul = imlib_create_image(scaled_w, scaled_h); /* FIXME: add error handling */ /* fill with opaque black */ @@ -59,11 +63,11 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, imlib_image_copy_alpha_to_image(image, 0, 0); /* now pass the result to cairo */ - cairo_surface_t *result = cairo_image_surface_create_for_data( + result = cairo_image_surface_create_for_data( (void *)imlib_image_get_data_for_reading_only(), CAIRO_FORMAT_ARGB32, scaled_w, scaled_h, sizeof(DATA32) * scaled_w); - cairo_t *cr = cairo_create(cs); + cr = cairo_create(cs); cairo_set_source_surface(cr, result, x, y); cairo_paint(cr);