More work on Cairo bindings
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package lime.graphics; #if (cpp || neko || nodejs)
|
||||
package lime.graphics;
|
||||
|
||||
|
||||
import lime.system.System;
|
||||
import lime.graphics.cairo.Cairo;
|
||||
|
||||
|
||||
class CairoRenderContext {
|
||||
@@ -25,56 +25,18 @@ class CairoRenderContext {
|
||||
|
||||
|
||||
|
||||
private function get_version ():Int {
|
||||
private inline function get_version ():Int {
|
||||
|
||||
return lime_cairo_version ();
|
||||
return Cairo.version;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_versionString ():String {
|
||||
|
||||
return lime_cairo_version_string ();
|
||||
return Cairo.versionString;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Native Methods
|
||||
|
||||
|
||||
|
||||
|
||||
private var lime_cairo_version = System.load ("lime", "lime_cairo_version", 0);
|
||||
private var lime_cairo_version_string = System.load ("lime", "lime_cairo_version_string", 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
class CairoRenderContext {
|
||||
|
||||
|
||||
public var version (get, null):Int;
|
||||
public var versionString (get, null):String;
|
||||
|
||||
|
||||
public function new () {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_version ():Int { return 0; }
|
||||
private function get_versionString ():String { return ""; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#end
|
||||
}
|
||||
@@ -13,7 +13,7 @@ enum RenderContext {
|
||||
CANVAS (context:CanvasRenderContext);
|
||||
DOM (element:DOMRenderContext);
|
||||
FLASH (stage:FlashRenderContext);
|
||||
CAIRO (context:CairoRenderContext);
|
||||
CAIRO (cairo:CairoRenderContext);
|
||||
CONSOLE (context:ConsoleRenderContext);
|
||||
CUSTOM (data:Dynamic);
|
||||
|
||||
|
||||
66
lime/graphics/cairo/Cairo.hx
Normal file
66
lime/graphics/cairo/Cairo.hx
Normal file
@@ -0,0 +1,66 @@
|
||||
package lime.graphics.cairo;
|
||||
|
||||
|
||||
import lime.system.System;
|
||||
|
||||
|
||||
class Cairo {
|
||||
|
||||
|
||||
public static var version (get, null):Int;
|
||||
public static var versionString (get, null):String;
|
||||
|
||||
|
||||
public static function imageSurfaceCreate (format:CairoFormat, width:Int, height:Int):CairoSurface {
|
||||
|
||||
#if sys
|
||||
return lime_cairo_image_surface_create (format, width, height);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Get & Set Methods
|
||||
|
||||
|
||||
|
||||
|
||||
private static function get_version ():Int {
|
||||
|
||||
#if sys
|
||||
return lime_cairo_version ();
|
||||
#else
|
||||
return 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static function get_versionString ():String {
|
||||
|
||||
#if sys
|
||||
return lime_cairo_version_string ();
|
||||
#else
|
||||
return "";
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Native Methods
|
||||
|
||||
|
||||
|
||||
|
||||
#if sys
|
||||
private static var lime_cairo_image_surface_create = System.load ("lime", "lime_cairo_image_surface_create", 3);
|
||||
private static var lime_cairo_version = System.load ("lime", "lime_cairo_version", 0);
|
||||
private static var lime_cairo_version_string = System.load ("lime", "lime_cairo_version_string", 0);
|
||||
#end
|
||||
|
||||
|
||||
}
|
||||
14
lime/graphics/cairo/CairoFormat.hx
Normal file
14
lime/graphics/cairo/CairoFormat.hx
Normal file
@@ -0,0 +1,14 @@
|
||||
package lime.graphics.cairo;
|
||||
|
||||
|
||||
@:enum abstract CairoFormat(Int) from Int to Int {
|
||||
|
||||
public var INVALID = -1;
|
||||
public var ARGB32 = 0;
|
||||
public var RGB24 = 1;
|
||||
public var A8 = 2;
|
||||
public var A1 = 3;
|
||||
public var RGB16_565 = 4;
|
||||
public var RGB30 = 5;
|
||||
|
||||
}
|
||||
14
lime/graphics/cairo/CairoSurface.hx
Normal file
14
lime/graphics/cairo/CairoSurface.hx
Normal file
@@ -0,0 +1,14 @@
|
||||
package lime.graphics.cairo;
|
||||
|
||||
|
||||
abstract CairoSurface(Dynamic) {
|
||||
|
||||
|
||||
public function new (handle) {
|
||||
|
||||
this = handle;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,6 +5,13 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
value lime_cairo_image_surface_create (value format, value width, value height) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_image_surface_create ((cairo_format_t)val_int (format), val_int (width), val_int (height)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_version () {
|
||||
|
||||
return alloc_int (cairo_version ());
|
||||
@@ -19,6 +26,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
DEFINE_PRIM (lime_cairo_image_surface_create, 3);
|
||||
DEFINE_PRIM (lime_cairo_version, 0);
|
||||
DEFINE_PRIM (lime_cairo_version_string, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user