+++ /dev/null
-/*\r
- * GPAC - Multimedia Framework C SDK\r
- *\r
- * Copyright (c) Jean Le Feuvre 2000-2005\r
- * All rights reserved\r
- *\r
- * This file is part of GPAC / modules interfaces\r
- *\r
- * GPAC is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU Lesser General Public License as published by\r
- * the Free Software Foundation; either version 2, or (at your option)\r
- * any later version.\r
- * \r
- * GPAC is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU Lesser General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; see the file COPYING. If not, write to\r
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
- *\r
- */\r
-\r
-\r
-#ifndef _GF_MODULE_RASTER2D_H_\r
-#define _GF_MODULE_RASTER2D_H_\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#include <gpac/path2d.h>\r
-#include <gpac/module.h>\r
-#include <gpac/color.h>\r
-\r
-\r
-/*stencil types*/\r
-typedef enum\r
-{\r
- /*solid color stencil*/\r
- GF_STENCIL_SOLID = 0,\r
- /*linear color gradient stencil*/\r
- GF_STENCIL_LINEAR_GRADIENT,\r
- /*radial color gradient stencil*/\r
- GF_STENCIL_RADIAL_GRADIENT,\r
- /*texture stencil*/\r
- GF_STENCIL_VERTEX_GRADIENT,\r
- /*texture stencil*/\r
- GF_STENCIL_TEXTURE,\r
-} GF_StencilType;\r
-\r
-\r
-/*gradient filling modes*/\r
-typedef enum\r
-{\r
- /*edge colors are repeated until path is filled*/\r
- GF_GRADIENT_MODE_PAD,\r
- /*pattern is inversed each time it's repeated*/\r
- GF_GRADIENT_MODE_SPREAD,\r
- /*pattern is repeated to fill path*/\r
- GF_GRADIENT_MODE_REPEAT\r
-} GF_GradientMode;\r
-\r
-\r
-/*texture tiling flags*/\r
-typedef enum\r
-{\r
- /*texture is repeated in its horizontal direction*/\r
- GF_TEXTURE_REPEAT_S = (1<<1),\r
- /*texture is repeated in its horizontal direction*/\r
- GF_TEXTURE_REPEAT_T = (1<<2),\r
- /*texture is fliped vertically*/\r
- GF_TEXTURE_FLIP = (1<<3),\r
-} GF_TextureTiling;\r
-\r
-/*filter levels for texturing - up to the graphics engine but the following levels are used by\r
-the client*/\r
-typedef enum\r
-{\r
- /*high speed mapping (ex, no filtering applied)*/\r
- GF_TEXTURE_FILTER_HIGH_SPEED,\r
- /*compromise between speed and quality (ex, filter to nearest pixel)*/\r
- GF_TEXTURE_FILTER_MID,\r
- /*high quality mapping (ex, bi-linear/bi-cubic interpolation)*/\r
- GF_TEXTURE_FILTER_HIGH_QUALITY\r
-} GF_TextureFilter;\r
-\r
-/* rasterizer antialiasing depending on the graphics engine*/\r
-typedef enum\r
-{\r
- /*raster should use fastest mode possible (eg, no antialiasing)*/\r
- GF_RASTER_HIGH_SPEED,\r
- /*raster should use fast mode and good quality if possible*/\r
- GF_RASTER_MID,\r
- /*raster should use antialiasing*/\r
- GF_RASTER_HIGH_QUALITY\r
-} GF_RasterLevel;\r
-\r
-\r
-/*user routines for raserizer. common syntaxes:\r
- @cbk: user defined callback\r
- @x, y: first pixel position of the run, in device memory (top-left) coordinates\r
- @run_h_len: number of pixels to fill on line\r
- @color: color to fill pixel with. USER MUST IGNORE THE ALPHA COMPONENT OF THIS COLOR, the final \r
- alpha is computed by the lib\r
- @alpha: blending amount (0->0xFF) for the pixels\r
-*/\r
-typedef struct\r
-{\r
- void *cbk;\r
- /*fills line pixels without any blending operation*/\r
- void (*fill_run_no_alpha)(void *cbk, u32 x, u32 y, u32 run_h_len, GF_Color color);\r
- /*fills line pixels without blending operation - alpha combines both fill color and anti-aliasing blending*/\r
- void (*fill_run_alpha)(void *cbk, u32 x, u32 y, u32 run_h_len, GF_Color color, u32 alpha);\r
-} GF_RasterCallback;\r
-\r
-\r
-\r
-/*opaque handler for all stencils*/\r
-typedef void *GF_STENCIL;\r
-\r
-/*visual surface handler*/\r
-typedef void *GF_SURFACE;\r
-\r
-/*interface name and version for raster2D*/\r
-#define GF_RASTER_2D_INTERFACE GF_4CC('G','R','2', 0x02)\r
-\r
-/*graphics driver*/\r
-typedef struct _raster2d_interface\r
-{\r
- /* interface declaration*/\r
- GF_DECL_MODULE_INTERFACE\r
-\r
- GF_STENCIL (*stencil_new) (struct _raster2d_interface *, GF_StencilType type);\r
- /*common destructor for all stencils*/\r
- void (*stencil_delete) (GF_STENCIL _this);\r
- /*set stencil transformation matrix*/\r
- GF_Err (*stencil_set_matrix) (GF_STENCIL _this, GF_Matrix2D *mat);\r
- /*solid brush - set brush color*/\r
- GF_Err (*stencil_set_brush_color) (GF_STENCIL _this, GF_Color c);\r
- /*gradient brushes*/\r
- /*sets gradient repeat mode - return GF_NOT_SUPPORTED if driver doesn't support this to let the app compute repeat patterns\r
- this may be called before the gradient is setup*/\r
- GF_Err (*stencil_set_gradient_mode) (GF_STENCIL _this, GF_GradientMode mode);\r
- /*set linear gradient. line is defined by start and end, and you can give interpolation colors at specified positions*/\r
- GF_Err (*stencil_set_linear_gradient) (GF_STENCIL _this, Fixed start_x, Fixed start_y, Fixed end_x, Fixed end_y);\r
- /*radial gradient brush center point, focal point and radius - colors can only be set through set_interpolation */\r
- GF_Err (*stencil_set_radial_gradient) (GF_STENCIL _this, Fixed cx, Fixed cy, Fixed fx, Fixed fy, Fixed x_radius, Fixed y_radius);\r
- /*radial and linear gradient (not used with vertex) - set color interpolation at given points, \r
- @pos[i]: distance from (center for radial, start for linear) expressed between 0 and 1 (1 being the gradient bounds)\r
- @col[i]: associated color\r
- NOTE 1: the colors at 0 and 1.0 MUST be provided\r
- NOTE 2: colors shall be fed in order from 0 to 1\r
- NOTE 3: this overrides the colors provided for linear gradient\r
- */\r
- GF_Err (*stencil_set_gradient_interpolation) (GF_STENCIL _this, Fixed *pos, GF_Color *col, u32 count);\r
-\r
- /*vertex gradient : set limit path */\r
- GF_Err (*stencil_set_vertex_path) (GF_STENCIL _this, GF_Path *path);\r
- /*set the center of the gradient*/\r
- GF_Err (*stencil_set_vertex_center) (GF_STENCIL _this, Fixed cx, Fixed cy, u32 color);\r
- /*set the center of the gradient*/\r
- GF_Err (*stencil_set_vertex_colors) (GF_STENCIL _this, u32 *colors, u32 nbCol);\r
- \r
- /*sets global alpha blending level for stencil (texture and gradients)\r
- the alpha channel shall be combined with the color matrix if any*/\r
- GF_Err (*stencil_set_alpha) (GF_STENCIL _this, u8 alpha);\r
- \r
- /*set stencil texture\r
- @pixels: texture data, from top to bottom\r
- @width, @height: texture size\r
- @stride: texture horizontal pitch (bytes to skip to get to next row)\r
- @pixelFormat: texture pixel format as defined in file constants.h\r
- @destination_format_hint: this is the current pixel format of the destination surface, and is given\r
- as a hint in case the texture needs to be converted by the stencil\r
- @no_copy: if set, specifies the texture data shall not be cached by the module (eg it must be able\r
- to directly modify the given memory\r
- NOTE: this stencil acts as a data wrapper, the pixel data is not required to be locally copied\r
- data is not required to be available for texturing until the stencil is used in a draw operation\r
- */\r
- GF_Err (*stencil_set_texture) (GF_STENCIL _this, char *pixels, u32 width, u32 height, u32 stride, GF_PixelFormat pixelFormat, GF_PixelFormat destination_format_hint, Bool no_copy);\r
- /*creates internal texture - pixel data is owned by texture brush - set to NULL if not supported - this is used to \r
- cope with engines that don't support random strides (ex: Gdiplus needs stride to be a multiple of 4) \r
- if not set the compositor will create its own mem texture and pass it through set_texture - pixel format shall \r
- be respected as far as Alpha is concerned (eg alpha info shall be kept and used in blit) */\r
- GF_Err (*stencil_create_texture) (GF_STENCIL _this, u32 width, u32 height, GF_PixelFormat pixelFormat);\r
- /*signals the texture has been modified (internal texture only)*/\r
- void (*stencil_texture_modified) (GF_STENCIL _this);\r
-\r
- /*sets texture tile mode*/\r
- GF_Err (*stencil_set_tiling) (GF_STENCIL _this, GF_TextureTiling mode);\r
- /*sets texture filtering mode*/\r
- GF_Err (*stencil_set_filter) (GF_STENCIL _this, GF_TextureFilter filter_mode);\r
- /*set stencil color matrix - texture stencils only. If matrix is NULL, resets current color matrix*/\r
- GF_Err (*stencil_set_color_matrix) (GF_STENCIL _this, GF_ColorMatrix *cmat);\r
-\r
- /*creates surface object*/\r
- /* @center_coords: true indicates mathematical-like coord system, \r
- false indicates computer-like coord system */\r
- GF_SURFACE (*surface_new) (struct _raster2d_interface *, Bool center_coords);\r
- /* delete surface object */\r
- void (*surface_delete) (GF_SURFACE _this);\r
-\r
- /* attach surface object to device object (Win32: HDC) width and height are target surface size*/\r
- GF_Err (*surface_attach_to_device) (GF_SURFACE _this, void *os_handle, u32 width, u32 height);\r
- /* attach surface object to stencil object*/\r
- GF_Err (*surface_attach_to_texture) (GF_SURFACE _this, GF_STENCIL sten);\r
- /* attach surface object to memory buffer if supported\r
- @pixels: texture data\r
- @width, @height: texture size\r
- @stride: texture horizontal pitch (bytes to skip to get to next row)\r
- @pixelFormat: texture pixel format\r
- */\r
- GF_Err (*surface_attach_to_buffer) (GF_SURFACE _this, char *pixels, u32 width, u32 height, u32 stride, GF_PixelFormat pixelFormat);\r
-\r
- GF_Err (*surface_attach_to_callbacks) (GF_SURFACE _this, GF_RasterCallback *callbacks, u32 width, u32 height);\r
-\r
- /* detach surface object */\r
- void (*surface_detach) (GF_SURFACE _this);\r
-\r
- /*sets rasterizer precision */\r
- GF_Err (*surface_set_raster_level) (GF_SURFACE _this, GF_RasterLevel RasterSetting);\r
- /* set the given matrix as the current transformations for all drawn paths\r
- if NULL reset the current transformation */\r
- GF_Err (*surface_set_matrix) (GF_SURFACE _this, GF_Matrix2D *mat);\r
- /* set the given rectangle as a clipper - nothing will be drawn outside this clipper\r
- if the clipper is NULL then no clipper is set\r
- NB: the clipper is not affected by the surface matrix and is given in pixels\r
- CF ABOVE NOTE ON CLIPPERS*/\r
- GF_Err (*surface_set_clipper) (GF_SURFACE _this, GF_IRect *rc);\r
-\r
- /*sets the given path as the current one for drawing - the surface transform is NEVER changed between\r
- setting the path and filling, only the clipper may change*/\r
- GF_Err (*surface_set_path) (GF_SURFACE _this, GF_Path *path);\r
- /*fills the current path using the given stencil - can be called several times with the same current path*/\r
- GF_Err (*surface_fill) (GF_SURFACE _this, GF_STENCIL stencil);\r
-\r
- /*flushes to surface*/\r
- GF_Err (*surface_flush) (GF_SURFACE _this);\r
-\r
- /*clears given pixel rect on the surface with the given color - REQUIRED\r
- the given rect is formatted as a clipper - CF ABOVE NOTE ON CLIPPERS*/\r
- GF_Err (*surface_clear)(GF_SURFACE _this, GF_IRect *rc, GF_Color col);\r
-\r
-/*private:*/\r
- void *internal;\r
-} GF_Raster2D;\r
-\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /*_GF_MODULE_RASTER2D_H_*/\r
-\r