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; // used by initTestBuffer() for testing
34 
35 public:
36 
37  Renderer_agg_base() : _testBuffer(nullptr) { }
38 
39  // virtual classes should have virtual destructors
40  virtual ~Renderer_agg_base() {
41  if ( _testBuffer ) free(_testBuffer);
42  }
43 
44  // these methods need to be accessed from outside:
45  virtual void init_buffer(unsigned char *mem, int size, int x, int y,
46  int rowstride) = 0;
47 
48  virtual unsigned int getBytesPerPixel() const = 0;
49 
50  unsigned int getBitsPerPixel() const { return getBytesPerPixel()*8; }
51 
52  virtual bool initTestBuffer(unsigned width, unsigned height) {
53  int size = width * height * getBytesPerPixel();
54 
55  unsigned char *tmp = static_cast<unsigned char *>(realloc(_testBuffer, size));
56  if (tmp == nullptr) {
57  log_error(_("Memory reallocation error"));
58  return false;
59  } else {
60  _testBuffer = tmp;
61  }
62 
63  memset(_testBuffer, 0, size);
64  printf("Renderer Test memory at: %p\n", _testBuffer);
65 
66  init_buffer(_testBuffer, size, width, height, width * getBytesPerPixel());
67 
68  return true;
69  }
70 };
71 
73 //
77 DSOEXPORT Renderer_agg_base *create_Renderer_agg(const char *pixelformat);
78 
83 DSOEXPORT const char *agg_detect_pixel_format(unsigned int rofs,
84  unsigned int rsize,
85  unsigned int gofs,
86  unsigned int gsize,
87  unsigned int bofs,
88  unsigned int bsize,
89  unsigned int bpp);
90 
91 
92 } // namespace gnash
93 
94 #endif // BACKEND_RENDER_HANDLER_AGG_H
95 
96 // Local Variables:
97 // mode: C++
98 // indent-tabs-mode: nil
99 // End:
virtual unsigned int getBytesPerPixel() const =0
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Definition: klash_part.cpp:329
unsigned int getBitsPerPixel() const
Definition: Renderer_agg.h:50
Base class for render handlers.
Definition: Renderer.h:188
DSOEXPORT const char * agg_detect_pixel_format(unsigned int rofs, unsigned int rsize, unsigned int gofs, unsigned int gsize, unsigned int bofs, unsigned int bsize, unsigned int bpp)
Definition: Renderer_agg.cpp:2108
Definition: klash_part.cpp:329
#define _(String)
Definition: log.h:44
virtual bool initTestBuffer(unsigned width, unsigned height)
Definition: Renderer_agg.h:52
void log_error(StringType msg, Args... args)
Definition: log.h:283
std::int32_t x
Definition: BitmapData_as.cpp:434
Definition: Renderer_agg.h:29
#define DSOEXPORT
Definition: dsodefs.h:55
virtual void init_buffer(unsigned char *mem, int size, int x, int y, int rowstride)=0
std::int32_t y
Definition: BitmapData_as.cpp:435
Renderer_agg_base()
Definition: Renderer_agg.h:37
DSOEXPORT Renderer_agg_base * create_Renderer_agg(const char *pixelformat)
Create a render handler.
Definition: Renderer_agg.cpp:2047
virtual ~Renderer_agg_base()
Definition: Renderer_agg.h:40