Gnash  0.8.11dev
Renderer_agg.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software 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
18 
19 
20 #ifndef BACKEND_RENDER_HANDLER_AGG_H
21 #define BACKEND_RENDER_HANDLER_AGG_H
22 
23 #include "dsodefs.h"
24 #include "Renderer.h"
25 
26 namespace gnash {
27 
28 // Base class to shield GUIs from AGG's pixelformat classes
30 {
31 private:
32 
33  unsigned char *_testBuffer; // buffer used by initTestBuffer() only
34 
35 public:
36 
37  Renderer_agg_base() : _testBuffer(0) { }
38 
39  // virtual classes should have virtual destructors
40  virtual ~Renderer_agg_base() {}
41 
42  // these methods need to be accessed from outside:
43  virtual void init_buffer(unsigned char *mem, int size, int x, int y,
44  int rowstride) = 0;
45 
46  virtual unsigned int getBytesPerPixel() const = 0;
47 
48  unsigned int getBitsPerPixel() const { return getBytesPerPixel()*8; }
49 
50  virtual bool initTestBuffer(unsigned width, unsigned height) {
51  int size = width * height * getBytesPerPixel();
52 
53  _testBuffer = static_cast<unsigned char *>(realloc(_testBuffer, size));
54  memset(_testBuffer, 0, size);
55  printf("Renderer Test memory at: %p\n", _testBuffer);
56 
57  init_buffer(_testBuffer, size, width, height, width * getBytesPerPixel());
58 
59  return true;
60  }
61 };
62 
64 //
68 DSOEXPORT Renderer_agg_base *create_Renderer_agg(const char *pixelformat);
69 
74 DSOEXPORT const char *agg_detect_pixel_format(unsigned int rofs,
75  unsigned int rsize,
76  unsigned int gofs,
77  unsigned int gsize,
78  unsigned int bofs,
79  unsigned int bsize,
80  unsigned int bpp);
81 
82 
83 } // namespace gnash
84 
85 #endif // BACKEND_RENDER_HANDLER_AGG_H
86 
87 // Local Variables:
88 // mode: C++
89 // indent-tabs-mode: nil
90 // End: