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, *_testBufferTmp; // buffers 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  _testBufferTmp = static_cast<unsigned char *>(realloc(_testBuffer, size));
54  if (_testBufferTmp == NULL) {
55  log_error(_("Memory reallocation error"));
56  return false;
57  } else {
58  _testBuffer = _testBufferTmp;
59  }
60 
61  memset(_testBuffer, 0, size);
62  printf("Renderer Test memory at: %p\n", _testBuffer);
63 
64  init_buffer(_testBuffer, size, width, height, width * getBytesPerPixel());
65 
66  return true;
67  }
68 };
69 
71 //
75 DSOEXPORT Renderer_agg_base *create_Renderer_agg(const char *pixelformat);
76 
81 DSOEXPORT const char *agg_detect_pixel_format(unsigned int rofs,
82  unsigned int rsize,
83  unsigned int gofs,
84  unsigned int gsize,
85  unsigned int bofs,
86  unsigned int bsize,
87  unsigned int bpp);
88 
89 
90 } // namespace gnash
91 
92 #endif // BACKEND_RENDER_HANDLER_AGG_H
93 
94 // Local Variables:
95 // mode: C++
96 // indent-tabs-mode: nil
97 // End: