• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

Renderer_cairo.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   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     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& /*im*/) {
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 } // namespace gnash::renderer::cairo
00150 } // namespace gnash::renderer
00151 } // namespace gnash
00152 
00153 #endif // BACKEND_RENDER_HANDLER_CAIRO_H

Generated on Thu Sep 2 2010 for Gnash by  doxygen 1.7.1