Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef BACKEND_RENDER_HANDLER_CAIRO_H
00021 #define BACKEND_RENDER_HANDLER_CAIRO_H
00022
00023 #include <vector>
00024 #include <boost/scoped_array.hpp>
00025 #include <cairo/cairo.h>
00026 #include "Renderer.h"
00027 #include "Geometry.h"
00028
00029 namespace gnash {
00030 class Transform;
00031 class SWFCxForm;
00032 }
00033
00034 namespace gnash {
00035
00036 typedef std::vector<Path> PathVec;
00037 typedef std::vector<const Path*> PathPtrVec;
00038
00039 class DSOEXPORT Renderer_cairo: public Renderer
00040 {
00041
00042 public:
00043 Renderer_cairo();
00044 ~Renderer_cairo();
00045
00046 std::string description() const { return "Cairo"; }
00047
00048 CachedBitmap* createCachedBitmap(std::auto_ptr<image::GnashImage> im);
00049
00050 void drawVideoFrame(image::GnashImage* baseframe, const Transform& xform,
00051 const SWFRect* bounds, bool smooth);
00052
00053 geometry::Range2d<int> world_to_pixel(const SWFRect& worldbounds);
00054 point pixel_to_world(int x, int y);
00055
00056 void set_color(const rgba& c);
00057
00058 void set_invalidated_regions(const InvalidatedRanges& ranges);
00059
00060 virtual Renderer* startInternalRender(image::GnashImage& ) {
00061 return 0;
00062 }
00063
00064 virtual void endInternalRender() {}
00065
00066 virtual void begin_display(const rgba& bg_color,
00067 int viewport_width, int viewport_height,
00068 float x0, float x1, float y0, float y1);
00069
00070 virtual void end_display();
00071
00072 void set_scale(float xscale, float yscale);
00073
00074 void set_translation(float xoff, float yoff);
00075
00076 void drawLine(const std::vector<point>& coords, const rgba& color,
00077 const SWFMatrix& mat);
00078
00079 void draw_poly(const point* corners, size_t corner_count,
00080 const rgba& fill, const rgba& outline,
00081 const SWFMatrix& mat, bool masked);
00082
00083 void set_antialiased(bool enable);
00084
00085 void begin_submit_mask();
00086 void end_submit_mask();
00087 void disable_mask();
00088
00089 void add_path(cairo_t* cr, const Path& cur_path);
00090
00091 void apply_line_style(const LineStyle& style, const SWFCxForm& cx,
00092 const SWFMatrix& mat);
00093
00094 void draw_outlines(const PathVec& path_vec,
00095 const std::vector<LineStyle>& line_styles,
00096 const SWFCxForm& cx,
00097 const SWFMatrix& mat);
00098
00099 std::vector<PathVec::const_iterator> find_subshapes(const PathVec& path_vec);
00100
00101 void draw_subshape(const PathVec& path_vec,
00102 const SWFMatrix& mat, const SWFCxForm& cx,
00103 const std::vector<FillStyle>& FillStyles,
00104 const std::vector<LineStyle>& line_styles);
00105
00106 void draw_mask(const PathVec& path_vec);
00107
00108 void add_paths(const PathVec& path_vec);
00109
00110 void apply_matrix_to_paths(std::vector<Path>& paths, const SWFMatrix& mat);
00111
00112 void drawShape(const SWF::ShapeRecord& shape, const Transform& xform);
00113
00114 void drawGlyph(const SWF::ShapeRecord& rec, const rgba& color,
00115 const SWFMatrix& mat);
00116
00117 void set_context(cairo_t* context);
00118
00119 unsigned int getBitsPerPixel() const;
00120
00121 bool getPixel(rgba& color_return, int x, int y) const;
00122
00123 bool initTestBuffer(unsigned width, unsigned height);
00124
00125 private:
00127 cairo_t* _cr;
00128 boost::scoped_array<boost::uint8_t> _video_buffer;
00129 std::vector<PathVec> _masks;
00130 size_t _video_bufsize;
00131 bool _drawing_mask;
00132 InvalidatedRanges _invalidated_ranges;
00133 cairo_matrix_t _stage_mat;
00134 };
00135
00136
00137
00138 namespace renderer {
00139
00141 namespace cairo {
00142
00144 gnash::Renderer* create_handler();
00145
00147 void set_context(Renderer* handler, cairo_t* context);
00148
00149 }
00150 }
00151 }
00152
00153 #endif // BACKEND_RENDER_HANDLER_CAIRO_H