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
00031 typedef std::vector<Path> PathVec;
00032 typedef std::vector<const Path*> PathPtrVec;
00033
00034 class DSOEXPORT Renderer_cairo: public Renderer
00035 {
00036
00037 public:
00038 Renderer_cairo();
00039 ~Renderer_cairo();
00040
00041 CachedBitmap* createCachedBitmap(std::auto_ptr<GnashImage> im);
00042
00043 void drawVideoFrame(GnashImage* baseframe, const SWFMatrix* m,
00044 const SWFRect* bounds, bool smooth);
00045
00046 geometry::Range2d<int> world_to_pixel(const SWFRect& worldbounds);
00047 point pixel_to_world(int x, int y);
00048
00049 void set_color(const rgba& c);
00050
00051 void set_invalidated_regions(const InvalidatedRanges& ranges);
00052
00053 void begin_display(const rgba& bg_color,
00054 int viewport_width, int viewport_height,
00055 float x0, float x1, float y0, float y1);
00056
00057 void end_display();
00058
00059 void set_scale(float xscale, float yscale);
00060
00061 void set_translation(float xoff, float yoff);
00062
00063 void drawLine(const std::vector<point>& coords, const rgba& color,
00064 const SWFMatrix& mat);
00065
00066 void draw_poly(const point* corners, size_t corner_count,
00067 const rgba& fill, const rgba& outline,
00068 const SWFMatrix& mat, bool masked);
00069
00070 void set_antialiased(bool enable);
00071
00072 void begin_submit_mask();
00073 void end_submit_mask();
00074 void disable_mask();
00075
00076 void add_path(cairo_t* cr, const Path& cur_path);
00077
00078 void apply_line_style(const LineStyle& style, const cxform& cx,
00079 const SWFMatrix& mat);
00080
00081 void draw_outlines(const PathVec& path_vec,
00082 const std::vector<LineStyle>& line_styles,
00083 const cxform& cx,
00084 const SWFMatrix& mat);
00085
00086 std::vector<PathVec::const_iterator> find_subshapes(const PathVec& path_vec);
00087
00088 void draw_subshape(const PathVec& path_vec,
00089 const SWFMatrix& mat, const cxform& cx,
00090 const std::vector<FillStyle>& FillStyles,
00091 const std::vector<LineStyle>& line_styles);
00092
00093 void draw_mask(const PathVec& path_vec);
00094
00095 void add_paths(const PathVec& path_vec);
00096
00097 void apply_matrix_to_paths(std::vector<Path>& paths, const SWFMatrix& mat);
00098
00099 void drawShape(const SWF::ShapeRecord& shape, const cxform& cx,
00100 const SWFMatrix& mat);
00101
00102 void drawGlyph(const SWF::ShapeRecord& rec, const rgba& color,
00103 const SWFMatrix& mat);
00104
00105 void set_context(cairo_t* context);
00106
00107 unsigned int getBitsPerPixel() const;
00108
00109 bool getPixel(rgba& color_return, int x, int y) const;
00110
00111 bool initTestBuffer(unsigned width, unsigned height);
00112
00113 private:
00115 cairo_t* _cr;
00116 boost::scoped_array<boost::uint8_t> _video_buffer;
00117 std::vector<PathVec> _masks;
00118 size_t _video_bufsize;
00119 bool _drawing_mask;
00120 InvalidatedRanges _invalidated_ranges;
00121 cairo_matrix_t _stage_mat;
00122 };
00123
00124
00125
00126 namespace renderer {
00127
00129 namespace cairo {
00130
00132 gnash::Renderer* create_handler();
00133
00135 void set_context(Renderer* handler, cairo_t* context);
00136
00137 }
00138 }
00139 }
00140
00141 #endif // BACKEND_RENDER_HANDLER_CAIRO_H