Go to the documentation of this file.
20 #ifndef BACKEND_RENDER_HANDLER_CAIRO_H
21 #define BACKEND_RENDER_HANDLER_CAIRO_H
24 #include <cairo/cairo.h>
47 CachedBitmap* createCachedBitmap(std::unique_ptr<image::GnashImage> im);
50 const SWFRect* bounds,
bool smooth);
55 virtual point pixel_to_world(
int x,
int y)
const;
57 void set_color(
const rgba&
c);
67 virtual void begin_display(
const rgba& bg_color,
68 int viewport_width,
int viewport_height,
69 float x0,
float x1,
float y0,
float y1);
71 virtual void end_display();
73 void set_scale(
float xscale,
float yscale);
75 void set_translation(
float xoff,
float yoff);
77 void drawLine(
const std::vector<point>& coords,
const rgba&
color,
80 void draw_poly(
const std::vector<point>& corners,
84 void set_antialiased(
bool enable);
86 void begin_submit_mask();
87 void end_submit_mask();
90 void add_path(cairo_t* cr,
const Path& cur_path);
95 void draw_outlines(
const PathVec& path_vec,
96 const std::vector<LineStyle>& line_styles,
102 void draw_subshape(
const PathVec& path_vec,
104 const std::vector<FillStyle>& FillStyles,
105 const std::vector<LineStyle>& line_styles);
107 void draw_mask(
const PathVec& path_vec);
109 void add_paths(
const PathVec& path_vec);
111 void apply_matrix_to_paths(std::vector<Path>& paths,
const SWFMatrix& mat);
120 unsigned int getBitsPerPixel()
const;
122 bool getPixel(
rgba& color_return,
int x,
int y)
const;
124 bool initTestBuffer(
unsigned width,
unsigned height);
129 std::unique_ptr<std::uint8_t[]> _video_buffer;
130 std::vector<PathVec> _masks;
131 size_t _video_bufsize;
134 cairo_matrix_t _stage_mat;
154 #endif // BACKEND_RENDER_HANDLER_CAIRO_H
void draw_poly(const std::vector< point > &corners, const rgba &fill, const rgba &outline, const SWFMatrix &mat, bool masked)
Draw a simple, solid filled polygon with a thin (~1 pixel) outline.
Definition: Renderer_cairo.cpp:719
@ CAP_NONE
Definition: LineStyle.h:39
2d Range template class
Definition: Range2d.h:78
~Renderer_cairo()
Definition: Renderer_cairo.cpp:452
@ RADIAL
Definition: FillStyle.h:162
JoinStyle joinStyle() const
Return the join style.
Definition: LineStyle.h:135
point ap
Start point of the path.
Definition: Geometry.h:179
std::string description() const
Return a description of this renderer.
Definition: Renderer_cairo.h:45
A SolidFill containing one color.
Definition: FillStyle.h:247
@ height
Definition: klash_part.cpp:329
size_t width() const
Get the image's width.
Definition: GnashImage.h:126
void add_paths(const PathVec &path_vec)
Definition: Renderer_cairo.cpp:955
std::vector< Path > PathVec
Definition: Renderer_cairo.h:35
std::uint8_t m_r
Definition: RGBA.h:113
void drawLine(const std::vector< point > &coords, const rgba &color, const SWFMatrix &mat)
Draw a line-strip directly, using a thin, solid line.
Definition: Renderer_cairo.cpp:686
std::vector< PathVec::const_iterator > find_subshapes(const PathVec &path_vec)
@ QUALITY_BEST
Definition: GnashEnums.h:39
void set_context(cairo_t *context)
Definition: Renderer_cairo.cpp:1020
24-bit RGB bitmap
Definition: GnashImage.h:217
@ FILL_CLIPPED_BITMAP_HARD
swf8 (alexis is wrong), non-smoothed / hard edges
Definition: SWF.h:1533
point ap
Definition: Geometry.h:50
T getMaxY() const
Get max Y ordinate.
Definition: Range2d.h:633
void draw_outlines(const PathVec &path_vec, const std::vector< LineStyle > &line_styles, const SWFCxForm &cx, const SWFMatrix &mat)
Definition: Renderer_cairo.cpp:914
std::int32_t get_x_max() const
Get the x coordinate of the right-down corner.
Definition: SWFRect.h:122
geometry::Range2d< std::int32_t > getRange() const
Construct and return a Range2d object.
Definition: SWFRect.h:222
DSOEXPORT void set_context(Renderer *handler, cairo_t *context)
Make sure to call this before starting display.
Definition: Renderer_cairo.cpp:1143
std::int32_t y
Definition: BitmapData_as.cpp:435
@ i
Definition: GnashKey.h:155
#define LOG_ONCE(x)
Definition: log.h:49
A basic RGBA type.
Definition: RGBA.h:36
#define _(String)
Definition: log.h:44
StyleHandler()
Definition: Renderer_agg_style.h:442
const Subshapes & subshapes() const
Definition: ShapeRecord.h:158
@ FILL_TILED_BITMAP
Definition: SWF.h:1526
Renderer_cairo()
Implementation of Renderer_cairo class.
Definition: Renderer_cairo.cpp:444
bool initTestBuffer(unsigned width, unsigned height)
Definition: Renderer_cairo.cpp:1031
FillStyle describes the various fill styles for shapes.
Definition: FillStyle.h:282
bool straight() const
Definition: Geometry.h:77
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
@ FILL_CLIPPED_BITMAP
Definition: SWF.h:1527
T getMaxX() const
Get max X ordinate.
Definition: Range2d.h:613
const SWFRect & getBounds() const
Definition: ShapeRecord.h:166
bool is_null() const
returns true if this is a NULL rectangle
Definition: SWFRect.h:75
@ g
Definition: GnashKey.h:153
std::int32_t get_y_max() const
Get the y coordinate of the right-down corner.
Definition: SWFRect.h:136
Base class for different types of bitmaps.
Definition: GnashImage.h:78
std::uint8_t m_g
Definition: RGBA.h:113
Base class for render handlers.
Definition: Renderer.h:189
virtual geometry::Range2d< int > world_to_pixel(const SWFRect &worldbounds) const
Converts world coordinates to pixel coordinates.
Definition: Renderer_cairo.cpp:575
@ m
Definition: GnashKey.h:159
@ CAP_SQUARE
Definition: LineStyle.h:40
@ start
Definition: klash_part.cpp:330
std::uint8_t ratio
Definition: FillStyle.h:50
@ QUALITY_MEDIUM
Definition: GnashEnums.h:37
T getMinX() const
Get min X ordinate.
Definition: Range2d.h:603
@ JOIN_BEVEL
Definition: LineStyle.h:45
#define __FUNCTION__
Definition: log.h:437
Definition: ShapeRecord.h:41
CapStyle endCapStyle() const
Return the end cap style.
Definition: LineStyle.h:130
void disable_mask()
Definition: Renderer_cairo.cpp:790
#define UNUSED(x)
Definition: utility.h:113
void log_error(StringType msg, Args... args)
Definition: log.h:283
ImageType type() const
Return the ImageType of the image.
Definition: GnashImage.h:91
bool isNull() const
Returns true if this is the NULL Range2d.
Definition: Range2d.h:181
void set_invalidated_regions(const InvalidatedRanges &ranges)
Sets the update region (called prior to begin_display).
Definition: Renderer_cairo.cpp:611
float miterLimitFactor() const
Return the miter limit factor.
Definition: LineStyle.h:140
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:45
virtual void begin_display(const rgba &bg_color, int viewport_width, int viewport_height, float x0, float x1, float y0, float y1)
Bracket the displaying of a frame from a movie.
Definition: Renderer_cairo.cpp:617
const VGfloat color[4]
Definition: testr_gtk.cpp:82
@ r
Definition: GnashKey.h:164
bool isWorld() const
Returns true if this is the WORLD Range2d.
Definition: Range2d.h:200
bool getPixel(rgba &color_return, int x, int y) const
Definition: Renderer_cairo.cpp:1073
VGPaint fill
Definition: testr_gtk.cpp:86
@ FILL_TILED_BITMAP_HARD
swf8 (alexis is wrong), non-smoothed / hard edges
Definition: SWF.h:1530
void draw_subshape(const PathVec &path_vec, const SWFMatrix &mat, const SWFCxForm &cx, const std::vector< FillStyle > &FillStyles, const std::vector< LineStyle > &line_styles)
Definition: Renderer_cairo.cpp:932
void for_each(C &container, R(T::*pmf)(const A &), const A &arg)
Definition: Renderer_ogl.cpp:690
@ a
Definition: GnashKey.h:147
rgba color
Definition: FillStyle.h:51
std::int32_t x
The x coordinate.
Definition: Point2d.h:43
std::int32_t get_x_min() const
Get the x coordinate of the left-up corner.
Definition: SWFRect.h:115
@ CAP_ROUND
Definition: LineStyle.h:38
Quality _quality
Kept in parallel with movie_root's setting.
Definition: Renderer.h:589
void draw_mask(const PathVec &path_vec)
Definition: Renderer_cairo.cpp:944
A GradientFill.
Definition: FillStyle.h:154
void set_color(const rgba &c)
Definition: Renderer_cairo.cpp:604
void transform(geometry::Point2d &p) const
Transform a given point by our SWFMatrix.
Definition: SWFMatrix.cpp:99
T getMinY() const
Get min Y ordinate.
Definition: Range2d.h:623
void drawVideoFrame(image::GnashImage *baseframe, const Transform &xform, const SWFRect *bounds, bool smooth)
Draws a video frame.
Definition: Renderer_cairo.cpp:487
T * get(as_object *o)
Extract the DisplayObject attached to an object.
Definition: as_object.h:842
virtual Renderer * startInternalRender(image::GnashImage &)
Setup the renderer to draw to an internal buffer.
Definition: Renderer_cairo.h:61
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:167
@ h
Definition: GnashKey.h:154
For the outside of outline shapes, or just bare lines.
Definition: LineStyle.h:51
T width() const
Return width this Range2d.
Definition: Range2d.h:374
bool scaleThicknessHorizontally() const
Return true if line thickness should be scaled horizontally.
Definition: LineStyle.h:120
std::int32_t height() const
Return height of this rectangle in TWIPS.
Definition: SWFRect.h:109
bool scaleThicknessVertically() const
Return true if line thickness should be scaled vertically.
Definition: LineStyle.h:115
geometry::Point2d point
Definition: Point2d.h:143
@ _1
Definition: GnashKey.h:95
@ JOIN_ROUND
Definition: LineStyle.h:44
CapStyle startCapStyle() const
Return the start cap style.
Definition: LineStyle.h:125
@ JOIN_MITER
Definition: LineStyle.h:46
GnashImage::iterator scanline(GnashImage &im, size_t row)
Get a pointer to a given row of any image.
Definition: GnashImage.h:392
Definition: SWFMatrix.h:54
2D Point class
Definition: Point2d.h:39
size_type size() const
Returns the number of ranges in the list.
Definition: snappingrange.h:320
void end_submit_mask()
Definition: Renderer_cairo.cpp:771
DSOEXPORT Renderer * create_handler()
Create a render handler.
Definition: Renderer_cairo.cpp:1136
std::uint8_t m_a
Definition: RGBA.h:113
@ QUALITY_HIGH
Definition: GnashEnums.h:38
const rgba & get_color() const
Return line color and alpha.
Definition: LineStyle.h:156
void apply_line_style(const LineStyle &style, const SWFCxForm &cx, const SWFMatrix &mat)
Definition: Renderer_cairo.cpp:842
@ f
Definition: GnashKey.h:152
std::uint16_t getThickness() const
Return thickness of the line, in TWIPS.
Definition: LineStyle.h:110
void drawGlyph(const SWF::ShapeRecord &rec, const rgba &color, const SWFMatrix &mat)
Draws a glyph (font character).
Definition: Renderer_cairo.cpp:996
void set_antialiased(bool enable)
Definition: Renderer_cairo.cpp:756
@ LINEAR
Definition: FillStyle.h:161
T height() const
Return height this Range2dangle.
Definition: Range2d.h:385
CachedBitmap * createCachedBitmap(std::unique_ptr< image::GnashImage > im)
Given an image, returns a pointer to a CachedBitmap class that can later be passed to FillStyleX_bitm...
Definition: Renderer_cairo.cpp:458
void concatenate(const SWFMatrix &m)
Concatenate m's transform onto ours.
Definition: SWFMatrix.cpp:148
@ c
Definition: GnashKey.h:149
@ TYPE_RGB
Definition: GnashImage.h:49
Definition: FillStyle.h:41
@ QUALITY_LOW
Definition: GnashEnums.h:36
void drawShape(const SWF::ShapeRecord &shape, const Transform &xform)
Definition: Renderer_cairo.cpp:974
std::int32_t width() const
Return width of this rectangle in TWIPS.
Definition: SWFRect.h:103
Definition: Renderer_cairo.h:39
point cp
Definition: Geometry.h:49
#define DSOEXPORT
Definition: dsodefs.h:55
PathParser(const std::vector< Path > &paths, size_t num_styles)
Definition: PathParser.cpp:42
std::int32_t y
The y coordinate.
Definition: Point2d.h:46
std::uint8_t m_b
Definition: RGBA.h:113
Holds information needed to draw a shape.
Definition: ShapeRecord.h:127
void apply_matrix_to_paths(std::vector< Path > &paths, const SWFMatrix &mat)
Takes a path and translates it using the given SWFMatrix.
Definition: Renderer_cairo.cpp:965
void set_scale(float xscale, float yscale)
Sets the x/y scale for the movie
Definition: Renderer_cairo.cpp:672
Defines an edge with a control point and an anchor point.
Definition: Geometry.h:45
void transform(const SWFMatrix &mat)
Transform all path coordinates according to the given SWFMatrix.
Definition: Geometry.h:443
const RangeType & getRange(size_type index) const
Returns the range at the specified index.
Definition: snappingrange.h:326
@ width
Definition: klash_part.cpp:329
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
std::vector< Edge > m_edges
Edges forming the path.
Definition: Geometry.h:182
unsigned int getBitsPerPixel() const
Definition: Renderer_cairo.cpp:1052
void begin_submit_mask()
Definition: Renderer_cairo.cpp:762
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:38
std::int32_t x
Definition: BitmapData_as.cpp:434
void set_translation(float xoff, float yoff)
Definition: Renderer_cairo.cpp:679
@ b
Definition: GnashKey.h:148
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
@ e
Definition: GnashKey.h:151
void add_path(cairo_t *cr, const Path &cur_path)
Definition: Renderer_cairo.cpp:799
virtual void end_display()
Definition: Renderer_cairo.cpp:666
virtual void endInternalRender()
Finish internal rendering.
Definition: Renderer_cairo.h:65
@ TYPE_RGBA
Definition: GnashImage.h:50
std::int32_t get_y_min() const
Get the y coordinate of the left-up corner.
Definition: SWFRect.h:129
virtual point pixel_to_world(int x, int y) const
Converts pixel coordinates to world coordinates (TWIPS)
Definition: Renderer_cairo.cpp:591
std::vector< const Path * > PathPtrVec
Definition: Renderer_cairo.h:36
size_t height() const
Get the image's width.
Definition: GnashImage.h:133