Gnash  0.8.10
Renderer_agg.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software 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_AGG_H
00021 #define BACKEND_RENDER_HANDLER_AGG_H
00022 
00023 #include "dsodefs.h"
00024 #include "Renderer.h"
00025 
00026 namespace gnash {
00027 
00028 // Base class to shield GUIs from AGG's pixelformat classes 
00029 class Renderer_agg_base : public Renderer
00030 {
00031 private:
00032     
00033     unsigned char *_testBuffer; // buffer used by initTestBuffer() only
00034     
00035 public:
00036     
00037     Renderer_agg_base() : _testBuffer(0) { }  
00038     
00039     // virtual classes should have virtual destructors
00040     virtual ~Renderer_agg_base() {}
00041     
00042     // these methods need to be accessed from outside:
00043     virtual void init_buffer(unsigned char *mem, int size, int x, int y,
00044                              int rowstride) = 0;
00045     
00046     virtual unsigned int getBytesPerPixel() const = 0;
00047     
00048     unsigned int getBitsPerPixel() const { return getBytesPerPixel()*8; }
00049     
00050     virtual bool initTestBuffer(unsigned width, unsigned height) {
00051         int size = width * height * getBytesPerPixel();
00052         
00053         _testBuffer = static_cast<unsigned char *>(realloc(_testBuffer, size));
00054         memset(_testBuffer, 0, size);
00055         printf("Renderer Test memory at: %p\n", _testBuffer);
00056         
00057         init_buffer(_testBuffer, size, width, height, width * getBytesPerPixel());
00058         
00059         return true;
00060     }    
00061 };
00062 
00064 //
00068 DSOEXPORT Renderer_agg_base *create_Renderer_agg(const char *pixelformat);
00069   
00074 DSOEXPORT const char *agg_detect_pixel_format(unsigned int rofs,
00075                                               unsigned int rsize,
00076                                               unsigned int gofs,
00077                                               unsigned int gsize,
00078                                               unsigned int bofs,
00079                                               unsigned int bsize,
00080                                               unsigned int bpp);
00081   
00082 
00083 } // namespace gnash
00084 
00085 #endif // BACKEND_RENDER_HANDLER_AGG_H
00086 
00087 // Local Variables:
00088 // mode: C++
00089 // indent-tabs-mode: nil
00090 // End: