mirror of https://github.com/odrling/Aegisub
So apparently it's called "c"airo and not "C"airo...
Originally committed to SVN as r1484.
This commit is contained in:
parent
17f235515e
commit
43149f9276
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Lua interface for the Cairo graphics library
|
* Lua interface for the cairo graphics library
|
||||||
*
|
*
|
||||||
|
|
||||||
Copyright 2007 Niels Martin Hansen
|
Copyright 2007 Niels Martin Hansen
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
#define CALLABLE_REG2(func,name) AddCallable(lua_ ## func, # name)
|
#define CALLABLE_REG2(func,name) AddCallable(lua_ ## func, # name)
|
||||||
|
|
||||||
|
|
||||||
// Maps from strings to various Cairo enum types
|
// Maps from strings to various cairo enum types
|
||||||
|
|
||||||
static const char *status_names_list[] = {
|
static const char *status_names_list[] = {
|
||||||
"success",
|
"success",
|
||||||
|
@ -235,7 +235,7 @@ CALLABLE_IMPL(LuaCairoContext, get_source)
|
||||||
{
|
{
|
||||||
LuaCairoContext *ctx = GetObjPointer(L, lua_upvalueindex(1));
|
LuaCairoContext *ctx = GetObjPointer(L, lua_upvalueindex(1));
|
||||||
cairo_pattern_t *pat = cairo_get_source(ctx->context);
|
cairo_pattern_t *pat = cairo_get_source(ctx->context);
|
||||||
// The pattern is owned by Cairo here, so creating the Lua object will create the needed reference from Lua
|
// The pattern is owned by cairo here, so creating the Lua object will create the needed reference from Lua
|
||||||
new LuaCairoPattern(L, pat);
|
new LuaCairoPattern(L, pat);
|
||||||
// Meaning that calling pattern_destroy here would be wrong
|
// Meaning that calling pattern_destroy here would be wrong
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1123,7 +1123,7 @@ CALLABLE_IMPL(LuaCairoSurface, create_context)
|
||||||
cairo_t *context = cairo_create(surf->surface);
|
cairo_t *context = cairo_create(surf->surface);
|
||||||
|
|
||||||
if (!context || cairo_status(context) != CAIRO_STATUS_SUCCESS) {
|
if (!context || cairo_status(context) != CAIRO_STATUS_SUCCESS) {
|
||||||
lua_pushliteral(L, "Failed creating Cairo context");
|
lua_pushliteral(L, "Failed creating cairo context");
|
||||||
lua_error(L);
|
lua_error(L);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Lua interface for the Cairo graphics library
|
* Lua interface for the cairo graphics library
|
||||||
*
|
*
|
||||||
|
|
||||||
Copyright 2007 Niels Martin Hansen
|
Copyright 2007 Niels Martin Hansen
|
||||||
|
@ -331,8 +331,8 @@ private:
|
||||||
CALLABLE(reference);
|
CALLABLE(reference);
|
||||||
CALLABLE(status);
|
CALLABLE(status);
|
||||||
|
|
||||||
// Create Cairo context for this surface
|
// Create cairo context for this surface
|
||||||
// This deviates from the regular Cairo API
|
// This deviates from the regular cairo API
|
||||||
CALLABLE(create_context);
|
CALLABLE(create_context);
|
||||||
|
|
||||||
CALLABLE(finish);
|
CALLABLE(finish);
|
||||||
|
@ -504,7 +504,7 @@ private:
|
||||||
CALLABLE(transform_distance);
|
CALLABLE(transform_distance);
|
||||||
CALLABLE(transform_point);
|
CALLABLE(transform_point);
|
||||||
|
|
||||||
// Pointwise arithmetic on matrices - not part of Cairo API
|
// Pointwise arithmetic on matrices - not part of cairo API
|
||||||
CALLABLE(op_add);
|
CALLABLE(op_add);
|
||||||
CALLABLE(op_sub);
|
CALLABLE(op_sub);
|
||||||
CALLABLE(op_mul);
|
CALLABLE(op_mul);
|
||||||
|
@ -513,7 +513,7 @@ private:
|
||||||
// Equality operator
|
// Equality operator
|
||||||
CALLABLE(op_eq);
|
CALLABLE(op_eq);
|
||||||
|
|
||||||
// Not in Cairo API
|
// Not in cairo API
|
||||||
CALLABLE(copy);
|
CALLABLE(copy);
|
||||||
|
|
||||||
void RegMatrixCallables(lua_State *L);
|
void RegMatrixCallables(lua_State *L);
|
||||||
|
@ -545,8 +545,8 @@ class LuaCairoPath : public LuaCairoBase<LuaCairoPath> {
|
||||||
private:
|
private:
|
||||||
cairo_path_t *path;
|
cairo_path_t *path;
|
||||||
|
|
||||||
// Specifies whether the memory for the cairo_path_t object is owned by the Cairo library.
|
// Specifies whether the memory for the cairo_path_t object is owned by the cairo library.
|
||||||
// If Cairo owns it we cannot add/remove elements from the path.
|
// If cairo owns it we cannot add/remove elements from the path.
|
||||||
bool cairo_owns_memory;
|
bool cairo_owns_memory;
|
||||||
|
|
||||||
// Number of path elemts we have allocated memory for. Undefined if cairo_owns_memory.
|
// Number of path elemts we have allocated memory for. Undefined if cairo_owns_memory.
|
||||||
|
@ -582,7 +582,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
// Create object with new path - we will own the memory
|
// Create object with new path - we will own the memory
|
||||||
LuaCairoPath(lua_State *L);
|
LuaCairoPath(lua_State *L);
|
||||||
// Create object based on path - does not copy path, and lets Cairo own the memory
|
// Create object based on path - does not copy path, and lets cairo own the memory
|
||||||
LuaCairoPath(lua_State *L, cairo_path_t *_path);
|
LuaCairoPath(lua_State *L, cairo_path_t *_path);
|
||||||
// Destructor
|
// Destructor
|
||||||
virtual ~LuaCairoPath();
|
virtual ~LuaCairoPath();
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
Documentation for the Cairo interface provided in OverLua
|
Documentation for the cairo interface provided in OverLua
|
||||||
=========================================================
|
=========================================================
|
||||||
|
|
||||||
First, this file will mostly attempt to describe the differences between the
|
First, this file will mostly attempt to describe the differences between the
|
||||||
Cairo C API and the provided Lua API. If you want more general and in-depth
|
cairo C API and the provided Lua API. If you want more general and in-depth
|
||||||
information on Cairo, please see the documentation for the C API:
|
information on cairo, please see the documentation for the C API:
|
||||||
|
|
||||||
<http://cairographics.org/manual/>
|
<http://cairographics.org/manual/>
|
||||||
|
|
||||||
|
|
||||||
Note that almost all of the *_reference functions are unimplemented currently.
|
Note that almost all of the *_reference functions are unimplemented currently.
|
||||||
They should not be explicitly needed since Lua does its own management on
|
They should not be explicitly needed since Lua does its own management on
|
||||||
objects as well, you can just copy and keep a Lua Cairo object and be
|
objects as well, you can just copy and keep a Lua cairo object and be
|
||||||
guaranteed the underlying Cairo object won't be deleted until all Lua objects
|
guaranteed the underlying cairo object won't be deleted until all Lua objects
|
||||||
referring to it are gone.
|
referring to it are gone.
|
||||||
There are no *_destroy and *_get_reference_count functions either,
|
There are no *_destroy and *_get_reference_count functions either,
|
||||||
for this reason.
|
for this reason.
|
||||||
|
@ -43,7 +43,7 @@ For matrix operations you might also see "matR", this is "result matrix".
|
||||||
More "OO-like" syntax
|
More "OO-like" syntax
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
This Lua Cairo API provides a more common "OO-like" syntax for calls.
|
This Lua cairo API provides a more common "OO-like" syntax for calls.
|
||||||
For example, the cairo_set_source_surface(ctx, surf, x, y) function maps to
|
For example, the cairo_set_source_surface(ctx, surf, x, y) function maps to
|
||||||
ctx.set_source_surface(surf, x, y).
|
ctx.set_source_surface(surf, x, y).
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ Create various kinds of pattern objects.
|
||||||
|
|
||||||
ctx = surf.create_context()
|
ctx = surf.create_context()
|
||||||
|
|
||||||
Not strictly an "initial object", but Cairo context objects are important
|
Not strictly an "initial object", but cairo context objects are important
|
||||||
enough to explicitly list here. They are created by calling the
|
enough to explicitly list here. They are created by calling the
|
||||||
create_context() method in a surface object. This will create a context
|
create_context() method in a surface object. This will create a context
|
||||||
object that draws to the surface it was created with.
|
object that draws to the surface it was created with.
|
||||||
|
@ -242,7 +242,7 @@ surf.set_pixel() is not implemented yet.
|
||||||
|
|
||||||
matR = mat.copy()
|
matR = mat.copy()
|
||||||
|
|
||||||
Duplicate a matrix. Not in Cairo C API.
|
Duplicate a matrix. Not in cairo C API.
|
||||||
|
|
||||||
|
|
||||||
mat.xx, mat.yx, mat.xy, mat.yy, mat.x0, mat.y0
|
mat.xx, mat.yx, mat.xy, mat.yy, mat.x0, mat.y0
|
||||||
|
|
|
@ -100,14 +100,14 @@ Using a table constructor as shown is recommended.
|
||||||
|
|
||||||
surface = frame.create_cairo_surface()
|
surface = frame.create_cairo_surface()
|
||||||
|
|
||||||
Create a Cairo rgb24 surface from the video frame. Drawing to the surface
|
Create a cairo rgb24 surface from the video frame. Drawing to the surface
|
||||||
will _not_ affect the video frame. If you want the changes to the surface
|
will _not_ affect the video frame. If you want the changes to the surface
|
||||||
visible on the video you will need to overlay this surface on the video.
|
visible on the video you will need to overlay this surface on the video.
|
||||||
|
|
||||||
|
|
||||||
frame.overlay_cairo_surface(surface, x, y)
|
frame.overlay_cairo_surface(surface, x, y)
|
||||||
|
|
||||||
Overlay the given Cairo surface at the video frame such that the upper,
|
Overlay the given cairo surface at the video frame such that the upper,
|
||||||
left corner of the surface is positioned at pixel (x, y) on the video.
|
left corner of the surface is positioned at pixel (x, y) on the video.
|
||||||
Only argb32 and rgb24 type surfaces are supported.
|
Only argb32 and rgb24 type surfaces are supported.
|
||||||
Proper alpha blending is used for argb32 surfaces.
|
Proper alpha blending is used for argb32 surfaces.
|
||||||
|
@ -123,7 +123,7 @@ ie. (0, 0, 0).
|
||||||
Vector graphics interface
|
Vector graphics interface
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
OverLua uses the Cairo library for all vector graphics handling, including
|
OverLua uses the cairo library for all vector graphics handling, including
|
||||||
text handling.
|
text handling.
|
||||||
|
|
||||||
See lua-cairo.txt for details.
|
See lua-cairo.txt for details.
|
||||||
|
@ -135,7 +135,7 @@ Raster graphics processing interface
|
||||||
A raster graphics processing interface is also provided, to post-process
|
A raster graphics processing interface is also provided, to post-process
|
||||||
the graphics produced by the vector graphics interface.
|
the graphics produced by the vector graphics interface.
|
||||||
|
|
||||||
The raster graphics interface operates directly on Cairo surfaces.
|
The raster graphics interface operates directly on cairo surfaces.
|
||||||
|
|
||||||
|
|
||||||
raster.gaussian_blur(surface, sigma)
|
raster.gaussian_blur(surface, sigma)
|
||||||
|
|
|
@ -41,8 +41,8 @@ using namespace cimg_library;
|
||||||
// Type of images processed
|
// Type of images processed
|
||||||
typedef CImg<unsigned char> Img;
|
typedef CImg<unsigned char> Img;
|
||||||
|
|
||||||
// Make an Img representing the image of a Cairo image surface
|
// Make an Img representing the image of a cairo image surface
|
||||||
// from the Lua wrapper of Cairo.
|
// from the Lua wrapper of cairo.
|
||||||
static inline Img ImgFromSurf(lua_State *L, int idx)
|
static inline Img ImgFromSurf(lua_State *L, int idx)
|
||||||
{
|
{
|
||||||
LuaCairoSurface *surfobj = LuaCairoSurface::GetObjPointer(L, idx);
|
LuaCairoSurface *surfobj = LuaCairoSurface::GetObjPointer(L, idx);
|
||||||
|
|
|
@ -5,7 +5,7 @@ is currently primarily programmers.
|
||||||
The name is intended as a pun on Overlay and Lua.
|
The name is intended as a pun on Overlay and Lua.
|
||||||
|
|
||||||
To help produce overlay graphics, OverLua provides an interface to the
|
To help produce overlay graphics, OverLua provides an interface to the
|
||||||
Cairo vector graphics library. A library of functions to do raster-based
|
cairo vector graphics library. A library of functions to do raster-based
|
||||||
graphics processing is also included.
|
graphics processing is also included.
|
||||||
|
|
||||||
Curerently the only known-working plugin interface to OverLua is the Avisynth
|
Curerently the only known-working plugin interface to OverLua is the Avisynth
|
||||||
|
@ -33,7 +33,7 @@ if you attempt to use it on a computer without SSE2 support.
|
||||||
Finally, the DLL is built with OpenMP optimisations enabled, which means it
|
Finally, the DLL is built with OpenMP optimisations enabled, which means it
|
||||||
will take advantage of multi-core and other SMP systems if available. The
|
will take advantage of multi-core and other SMP systems if available. The
|
||||||
OpenMP optimisations are only in the raster image filtering and the
|
OpenMP optimisations are only in the raster image filtering and the
|
||||||
Cairo surface/video frame interaction functions. If you do not use the raster
|
cairo surface/video frame interaction functions. If you do not use the raster
|
||||||
graphics operations much you won't see much gain from this SMP support either.
|
graphics operations much you won't see much gain from this SMP support either.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ badtable:
|
||||||
// Always RGB24 format since we don't support video with alpha
|
// Always RGB24 format since we don't support video with alpha
|
||||||
cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_RGB24, (*ud)->width, (*ud)->height);
|
cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_RGB24, (*ud)->width, (*ud)->height);
|
||||||
if (!surf || cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) {
|
if (!surf || cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) {
|
||||||
lua_pushliteral(L, "Unable to create Cairo surface from video frame");
|
lua_pushliteral(L, "Unable to create cairo surface from video frame");
|
||||||
lua_error(L);
|
lua_error(L);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ badtable:
|
||||||
MyType **ud = (MyType**)lua_touserdata(L, lua_upvalueindex(1));
|
MyType **ud = (MyType**)lua_touserdata(L, lua_upvalueindex(1));
|
||||||
LuaCairoSurface *surfwrap = LuaCairoSurface::GetObjPointer(L, 1);
|
LuaCairoSurface *surfwrap = LuaCairoSurface::GetObjPointer(L, 1);
|
||||||
if (!surfwrap) {
|
if (!surfwrap) {
|
||||||
lua_pushliteral(L, "Argument to frame.overlay_cairo_surface is not a Cairo surface");
|
lua_pushliteral(L, "Argument to frame.overlay_cairo_surface is not a cairo surface");
|
||||||
lua_error(L);
|
lua_error(L);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ badtable:
|
||||||
// More argument checks
|
// More argument checks
|
||||||
cairo_surface_t *surf = surfwrap->GetSurface();
|
cairo_surface_t *surf = surfwrap->GetSurface();
|
||||||
if (cairo_surface_get_type(surf) != CAIRO_SURFACE_TYPE_IMAGE) {
|
if (cairo_surface_get_type(surf) != CAIRO_SURFACE_TYPE_IMAGE) {
|
||||||
lua_pushliteral(L, "Argument to frame.overlay_cairo_surface is not a Cairo image surface");
|
lua_pushliteral(L, "Argument to frame.overlay_cairo_surface is not a cairo image surface");
|
||||||
lua_error(L);
|
lua_error(L);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue