Gnash
0.8.10
|
00001 // 00002 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 00003 // Free Software Foundation, Inc 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 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 virtual geometry::Range2d<int> world_to_pixel(const SWFRect& worldbounds) 00054 const; 00055 00056 virtual point pixel_to_world(int x, int y) const; 00057 00058 void set_color(const rgba& c); 00059 00060 void set_invalidated_regions(const InvalidatedRanges& ranges); 00061 00062 virtual Renderer* startInternalRender(image::GnashImage& /*im*/) { 00063 return 0; 00064 } 00065 00066 virtual void endInternalRender() {} 00067 00068 virtual void begin_display(const rgba& bg_color, 00069 int viewport_width, int viewport_height, 00070 float x0, float x1, float y0, float y1); 00071 00072 virtual void end_display(); 00073 00074 void set_scale(float xscale, float yscale); 00075 00076 void set_translation(float xoff, float yoff); 00077 00078 void drawLine(const std::vector<point>& coords, const rgba& color, 00079 const SWFMatrix& mat); 00080 00081 void draw_poly(const std::vector<point>& corners, 00082 const rgba& fill, const rgba& outline, 00083 const SWFMatrix& mat, bool masked); 00084 00085 void set_antialiased(bool enable); 00086 00087 void begin_submit_mask(); 00088 void end_submit_mask(); 00089 void disable_mask(); 00090 00091 void add_path(cairo_t* cr, const Path& cur_path); 00092 00093 void apply_line_style(const LineStyle& style, const SWFCxForm& cx, 00094 const SWFMatrix& mat); 00095 00096 void draw_outlines(const PathVec& path_vec, 00097 const std::vector<LineStyle>& line_styles, 00098 const SWFCxForm& cx, 00099 const SWFMatrix& mat); 00100 00101 std::vector<PathVec::const_iterator> find_subshapes(const PathVec& path_vec); 00102 00103 void draw_subshape(const PathVec& path_vec, 00104 const SWFMatrix& mat, const SWFCxForm& cx, 00105 const std::vector<FillStyle>& FillStyles, 00106 const std::vector<LineStyle>& line_styles); 00107 00108 void draw_mask(const PathVec& path_vec); 00109 00110 void add_paths(const PathVec& path_vec); 00111 00112 void apply_matrix_to_paths(std::vector<Path>& paths, const SWFMatrix& mat); 00113 00114 void drawShape(const SWF::ShapeRecord& shape, const Transform& xform); 00115 00116 void drawGlyph(const SWF::ShapeRecord& rec, const rgba& color, 00117 const SWFMatrix& mat); 00118 00119 void set_context(cairo_t* context); 00120 00121 unsigned int getBitsPerPixel() const; 00122 00123 bool getPixel(rgba& color_return, int x, int y) const; 00124 00125 bool initTestBuffer(unsigned width, unsigned height); 00126 00127 private: 00129 cairo_t* _cr; 00130 boost::scoped_array<boost::uint8_t> _video_buffer; 00131 std::vector<PathVec> _masks; 00132 size_t _video_bufsize; 00133 bool _drawing_mask; 00134 InvalidatedRanges _invalidated_ranges; 00135 cairo_matrix_t _stage_mat; 00136 }; 00137 00138 00139 00140 namespace renderer { 00141 00143 namespace cairo { 00144 00146 gnash::Renderer* create_handler(); 00147 00149 void set_context(Renderer* handler, cairo_t* context); 00150 00151 } // namespace gnash::renderer::cairo 00152 } // namespace gnash::renderer 00153 } // namespace gnash 00154 00155 #endif // BACKEND_RENDER_HANDLER_CAIRO_H