2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 Free Software Foundation, Inc
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.
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.
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
21 #include "gnashconfig.h"
24 #include "Qt4GlueAgg.h"
26 #include "Renderer_agg.h"
27 #include "GnashException.h"
35 Qt4AggGlue::Qt4AggGlue()
43 Qt4AggGlue::~Qt4AggGlue()
48 Qt4AggGlue::init(int /* argc */, char *** /* argv */)
55 Qt4AggGlue::prepDrawingArea(DrawingWidget
*drawing_area
)
57 _drawing_area
= drawing_area
;
62 Qt4AggGlue::initBuffer(int width
, int height
)
64 if (!_renderer
) return;
70 int depth_bytes
= _bpp
/ 8;
72 assert(_bpp
% 8 == 0);
74 #define CHUNK_SIZE (100 * 100 * depth_bytes)
76 int bufsize
= (width
* height
* depth_bytes
/ CHUNK_SIZE
+ 1) * CHUNK_SIZE
;
78 _offscreenbuf
.reset(new unsigned char[bufsize
]);
80 Renderer_agg_base
* renderer
=
81 static_cast<Renderer_agg_base
*>(_renderer
);
83 renderer
->init_buffer(_offscreenbuf
.get(), bufsize
, _width
, _height
,
86 _image
.reset(new QImage(_offscreenbuf
.get(), _width
, _height
, QImage::Format_RGB32
));
93 QRect
r(0, 0, _width
, _height
);
99 Qt4AggGlue::render(const QRect
& updateRect
)
101 QPainter
p(_drawing_area
);
103 p
.drawImage(updateRect
, *_image
, updateRect
);
109 Qt4AggGlue::createRenderHandler()
111 _renderer
= create_Renderer_agg("BGRA32");
115 throw GnashException(_("Could not create AGG renderer with pixelformat ABGR32"));
121 Qt4AggGlue::resize(int width
, int height
)
123 initBuffer(width
, height
);
126 // end of namespace gnash