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 <boost/scoped_array.hpp>
25 #include <cairo/cairo.h>
26 #include "Renderer.h"
27 #include "Geometry.h"
28 
29 namespace gnash {
30  class Transform;
31  class SWFCxForm;
32 }
33 
34 namespace gnash {
35 
36  typedef std::vector<Path> PathVec;
37  typedef std::vector<const Path*> PathPtrVec;
38 
40 {
41 
42 public:
44  ~Renderer_cairo();
45 
46  std::string description() const { return "Cairo"; }
47 
48  CachedBitmap* createCachedBitmap(std::auto_ptr<image::GnashImage> im);
49 
50  void drawVideoFrame(image::GnashImage* baseframe, const Transform& xform,
51  const SWFRect* bounds, bool smooth);
52 
53  virtual geometry::Range2d<int> world_to_pixel(const SWFRect& worldbounds)
54  const;
55 
56  virtual point pixel_to_world(int x, int y) const;
57 
58  void set_color(const rgba& c);
59 
60  void set_invalidated_regions(const InvalidatedRanges& ranges);
61 
63  return 0;
64  }
65 
66  virtual void endInternalRender() {}
67 
68  virtual void begin_display(const rgba& bg_color,
69  int viewport_width, int viewport_height,
70  float x0, float x1, float y0, float y1);
71 
72  virtual void end_display();
73 
74  void set_scale(float xscale, float yscale);
75 
76  void set_translation(float xoff, float yoff);
77 
78  void drawLine(const std::vector<point>& coords, const rgba& color,
79  const SWFMatrix& mat);
80 
81  void draw_poly(const std::vector<point>& corners,
82  const rgba& fill, const rgba& outline,
83  const SWFMatrix& mat, bool masked);
84 
85  void set_antialiased(bool enable);
86 
87  void begin_submit_mask();
88  void end_submit_mask();
89  void disable_mask();
90 
91  void add_path(cairo_t* cr, const Path& cur_path);
92 
93  void apply_line_style(const LineStyle& style, const SWFCxForm& cx,
94  const SWFMatrix& mat);
95 
96  void draw_outlines(const PathVec& path_vec,
97  const std::vector<LineStyle>& line_styles,
98  const SWFCxForm& cx,
99  const SWFMatrix& mat);
100 
101  std::vector<PathVec::const_iterator> find_subshapes(const PathVec& path_vec);
102 
103  void draw_subshape(const PathVec& path_vec,
104  const SWFMatrix& mat, const SWFCxForm& cx,
105  const std::vector<FillStyle>& FillStyles,
106  const std::vector<LineStyle>& line_styles);
107 
108  void draw_mask(const PathVec& path_vec);
109 
110  void add_paths(const PathVec& path_vec);
111 
112  void apply_matrix_to_paths(std::vector<Path>& paths, const SWFMatrix& mat);
113 
114  void drawShape(const SWF::ShapeRecord& shape, const Transform& xform);
115 
116  void drawGlyph(const SWF::ShapeRecord& rec, const rgba& color,
117  const SWFMatrix& mat);
118 
119  void set_context(cairo_t* context);
120 
121  unsigned int getBitsPerPixel() const;
122 
123  bool getPixel(rgba& color_return, int x, int y) const;
124 
125  bool initTestBuffer(unsigned width, unsigned height);
126 
127 private:
129  cairo_t* _cr;
130  boost::scoped_array<boost::uint8_t> _video_buffer;
131  std::vector<PathVec> _masks;
132  size_t _video_bufsize;
133  bool _drawing_mask;
134  InvalidatedRanges _invalidated_ranges;
135  cairo_matrix_t _stage_mat;
136 };
137 
138 
139 
140 namespace renderer {
141 
143 namespace cairo {
144 
147 
149 void set_context(Renderer* handler, cairo_t* context);
150 
151 } // namespace gnash::renderer::cairo
152 } // namespace gnash::renderer
153 } // namespace gnash
154 
155 #endif // BACKEND_RENDER_HANDLER_CAIRO_H
DSOEXPORT void set_context(Renderer *handler, cairo_t *context)
Make sure to call this before starting display.
Definition: Renderer_cairo.cpp:1157
DSOEXPORT Renderer * create_handler()
Create a render handler.
Definition: Renderer_cairo.cpp:1150
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
Definition: klash_part.cpp:329
2D Point class
Definition: Point2d.h:38
Definition: GnashKey.h:149
Color transformation record.
Definition: SWFCxForm.h:35
Base class for render handlers.
Definition: Renderer.h:190
virtual Renderer * startInternalRender(image::GnashImage &)
Setup the renderer to draw to an internal buffer.
Definition: Renderer_cairo.h:62
const VGfloat color[4]
Definition: testr_gtk.cpp:82
std::string description() const
Return a description of this renderer.
Definition: Renderer_cairo.h:46
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:39
boost::int32_t x
Definition: BitmapData_as.cpp:434
virtual void endInternalRender()
Finish internal rendering.
Definition: Renderer_cairo.h:66
#define DSOEXPORT
Definition: dsodefs.h:55
std::vector< const Path * > PathPtrVec
Definition: Renderer_cairo.h:37
For the outside of outline shapes, or just bare lines.
Definition: LineStyle.h:49
std::vector< Path > PathVec
Definition: Renderer_cairo.h:36
boost::int32_t y
Definition: BitmapData_as.cpp:435
Base class for different types of bitmaps.
Definition: GnashImage.h:79
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:32
A basic RGBA type.
Definition: RGBA.h:35