Gnash 0.8.10dev
Renderer_agg.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
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, int rowstride)=0;
00044 
00045   virtual unsigned int getBytesPerPixel() const=0;
00046 
00047   unsigned int getBitsPerPixel() const { return getBytesPerPixel()*8; }
00048   
00049   virtual bool initTestBuffer(unsigned width, unsigned height) {
00050     int size = width * height * getBytesPerPixel();
00051     
00052     _testBuffer = static_cast<unsigned char *>( realloc(_testBuffer, size) );
00053     
00054     init_buffer(_testBuffer, size, width, height, width * getBytesPerPixel());
00055     
00056     return true;
00057   }
00058   
00059   
00060 };
00061 
00062 
00064 //
00068 DSOEXPORT Renderer_agg_base*
00069   create_Renderer_agg(const char *pixelformat);
00070   
00075 DSOEXPORT const char* agg_detect_pixel_format(unsigned int rofs, unsigned int rsize,
00076   unsigned int gofs, unsigned int gsize,
00077   unsigned int bofs, unsigned int bsize,
00078   unsigned int bpp);
00079   
00080 
00081 } // namespace gnash
00082 
00083 
00084 #endif // BACKEND_RENDER_HANDLER_CAIRO_H