Gnash  0.8.11dev
Renderer_cairo.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 
20 #ifndef BACKEND_RENDER_HANDLER_CAIRO_H
21 #define BACKEND_RENDER_HANDLER_CAIRO_H
22 
23 #include <vector>
24 #include <cairo/cairo.h>
25 #include "Renderer.h"
26 #include "Geometry.h"
27 
28 namespace gnash {
29  class Transform;
30  class SWFCxForm;
31 }
32 
33 namespace gnash {
34 
35  typedef std::vector<Path> PathVec;
36  typedef std::vector<const Path*> PathPtrVec;
37 
39 {
40 
41 public:
43  ~Renderer_cairo();
44 
45  std::string description() const { return "Cairo"; }
46 
47  CachedBitmap* createCachedBitmap(std::unique_ptr<image::GnashImage> im);
48 
49  void drawVideoFrame(image::GnashImage* baseframe, const Transform& xform,
50  const SWFRect* bounds, bool smooth);
51 
52  virtual geometry::Range2d<int> world_to_pixel(const SWFRect& worldbounds)
53  const;
54 
55  virtual point pixel_to_world(int x, int y) const;
56 
57  void set_color(const rgba& c);
58 
59  void set_invalidated_regions(const InvalidatedRanges& ranges);
60 
62  return nullptr;
63  }
64 
65  virtual void endInternalRender() {}
66 
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);
70 
71  virtual void end_display();
72 
73  void set_scale(float xscale, float yscale);
74 
75  void set_translation(float xoff, float yoff);
76 
77  void drawLine(const std::vector<point>& coords, const rgba& color,
78  const SWFMatrix& mat);
79 
80  void draw_poly(const std::vector<point>& corners,
81  const rgba& fill, const rgba& outline,
82  const SWFMatrix& mat, bool masked);
83 
84  void set_antialiased(bool enable);
85 
86  void begin_submit_mask();
87  void end_submit_mask();
88  void disable_mask();
89 
90  void add_path(cairo_t* cr, const Path& cur_path);
91 
92  void apply_line_style(const LineStyle& style, const SWFCxForm& cx,
93  const SWFMatrix& mat);
94 
95  void draw_outlines(const PathVec& path_vec,
96  const std::vector<LineStyle>& line_styles,
97  const SWFCxForm& cx,
98  const SWFMatrix& mat);
99 
100  std::vector<PathVec::const_iterator> find_subshapes(const PathVec& path_vec);
101 
102  void draw_subshape(const PathVec& path_vec,
103  const SWFMatrix& mat, const SWFCxForm& cx,
104  const std::vector<FillStyle>& FillStyles,
105  const std::vector<LineStyle>& line_styles);
106 
107  void draw_mask(const PathVec& path_vec);
108 
109  void add_paths(const PathVec& path_vec);
110 
111  void apply_matrix_to_paths(std::vector<Path>& paths, const SWFMatrix& mat);
112 
113  void drawShape(const SWF::ShapeRecord& shape, const Transform& xform);
114 
115  void drawGlyph(const SWF::ShapeRecord& rec, const rgba& color,
116  const SWFMatrix& mat);
117 
118  void set_context(cairo_t* context);
119 
120  unsigned int getBitsPerPixel() const;
121 
122  bool getPixel(rgba& color_return, int x, int y) const;
123 
124  bool initTestBuffer(unsigned width, unsigned height);
125 
126 private:
128  cairo_t* _cr;
129  std::unique_ptr<std::uint8_t[]> _video_buffer;
130  std::vector<PathVec> _masks;
131  size_t _video_bufsize;
132  bool _drawing_mask;
133  InvalidatedRanges _invalidated_ranges;
134  cairo_matrix_t _stage_mat;
135 };
136 
137 
138 
139 namespace renderer {
140 
142 namespace cairo {
143 
146 
148 void set_context(Renderer* handler, cairo_t* context);
149 
150 } // namespace gnash::renderer::cairo
151 } // namespace gnash::renderer
152 } // namespace gnash
153 
154 #endif // BACKEND_RENDER_HANDLER_CAIRO_H
Renderer * create_handler(const char *pixelformat)
Definition: Renderer_DirectFB.cpp:267
DSOEXPORT void set_context(Renderer *handler, cairo_t *context)
Make sure to call this before starting display.
Definition: Renderer_cairo.cpp:1143
VGPaint fill
Definition: testr_gtk.cpp:86
Definition: SWFMatrix.h:53
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
std::string description() const
Return a description of this renderer.
Definition: Renderer_cairo.h:45
Definition: klash_part.cpp:329
2D Point class
Definition: Point2d.h:38
Definition: GnashKey.h:149
Color transformation record.
Definition: SWFCxForm.h:34
Base class for render handlers.
Definition: Renderer.h:188
virtual Renderer * startInternalRender(image::GnashImage &)
Setup the renderer to draw to an internal buffer.
Definition: Renderer_cairo.h:61
const VGfloat color[4]
Definition: testr_gtk.cpp:82
Definition: klash_part.cpp:329
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:166
Definition: Renderer_cairo.h:38
std::int32_t x
Definition: BitmapData_as.cpp:434
virtual void endInternalRender()
Finish internal rendering.
Definition: Renderer_cairo.h:65
#define DSOEXPORT
Definition: dsodefs.h:55
std::vector< const Path * > PathPtrVec
Definition: Renderer_cairo.h:36
For the outside of outline shapes, or just bare lines.
Definition: LineStyle.h:50
std::vector< Path > PathVec
Definition: Renderer_cairo.h:35
std::int32_t y
Definition: BitmapData_as.cpp:435
Base class for different types of bitmaps.
Definition: GnashImage.h:77
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:37
Holds information needed to draw a shape.
Definition: ShapeRecord.h:126
The Transform class expresses a stage in a cumulative transformation.
Definition: Transform.h:33
A basic RGBA type.
Definition: RGBA.h:35