Merge branch 'master' of git://git.sv.gnu.org/gnash
[gnash.git] / librender / Renderer_agg.h
blobaf4a2c7f8b0be423aa2108ae96926502460bce16
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
3 // 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
20 #ifndef BACKEND_RENDER_HANDLER_AGG_H
21 #define BACKEND_RENDER_HANDLER_AGG_H
23 #include "dsodefs.h"
24 #include "Renderer.h"
26 namespace gnash {
28 // Base class to shield GUIs from AGG's pixelformat classes
29 class Renderer_agg_base : public Renderer
31 private:
33 unsigned char *_testBuffer; // buffer used by initTestBuffer() only
35 public:
37 Renderer_agg_base() : _testBuffer(0) { }
39 // virtual classes should have virtual destructors
40 virtual ~Renderer_agg_base() {}
42 // these methods need to be accessed from outside:
43 virtual void init_buffer(unsigned char *mem, int size, int x, int y, int rowstride)=0;
45 virtual unsigned int getBytesPerPixel() const=0;
47 unsigned int getBitsPerPixel() const { return getBytesPerPixel()*8; }
49 virtual bool initTestBuffer(unsigned width, unsigned height) {
50 int size = width * height * getBytesPerPixel();
52 _testBuffer = static_cast<unsigned char *>( realloc(_testBuffer, size) );
54 init_buffer(_testBuffer, size, width, height, width * getBytesPerPixel());
56 return true;
63 /// Create a render handler
65 /// If the given pixelformat is unsupported, or any other error
66 /// occurs, NULL is returned.
67 ///
68 DSOEXPORT Renderer_agg_base*
69 create_Renderer_agg(const char *pixelformat);
71 /// Detect pixel format based on bit mask. If the pixel format is unknown,
72 /// NULL is returned. Note that a successfully detected pixel format does
73 /// not necessarily mean that the pixel format is available (compiled in).
74 /// The bit offsets are assumed to be in host byte order!
75 DSOEXPORT const char* agg_detect_pixel_format(unsigned int rofs, unsigned int rsize,
76 unsigned int gofs, unsigned int gsize,
77 unsigned int bofs, unsigned int bsize,
78 unsigned int bpp);
81 } // namespace gnash
84 #endif // BACKEND_RENDER_HANDLER_CAIRO_H