113
103
_drawbounds.push_back(bounds);
119
108
FBAggGlue::init (int argc, char ***argv)
121
GNASH_REPORT_FUNCTION;
110
// GNASH_REPORT_FUNCTION;
123
112
// The device must be initialized before the renderer. AGG only supports
124
113
// The Raw framebuffer, so we use that.
125
114
_device.reset(new renderer::rawfb::RawFBDevice);
126
115
_device->initDevice(argc, *argv);
117
renderer::rawfb::RawFBDevice *rawfb = reinterpret_cast
118
<renderer::rawfb::RawFBDevice *>(_device.get());
120
// You must pass in the file descriptor to the opened
121
// framebuffer when creating a window.
122
return _device->attachWindow(rawfb->getHandle());
128
124
// Set the renderer for the AGG glue layer
129
125
gnash::Renderer *rend = reinterpret_cast<gnash::Renderer *>
130
126
(createRenderHandler());
132
128
_renderer.reset(rend);
134
log_error("failed to create a render handler for AGG!");
130
log_error(_("failed to create a render handler for AGG!"));
138
#ifdef PIXELFORMAT_LUT8
139
134
// Set grayscale for 8 bit modes
140
renderer::rawfb::RawFBDevice *rawfb = reinterpret_cast
141
<renderer::rawfb::RawFBDevice *>(_device.get());
142
135
if (_varinfo.bits_per_pixel == 8) {
143
136
if (!rawfb->setGrayscaleLUT8())
148
_display.initDevice(0, 0);
150
// You must pass in the file descriptor to the opened
151
// framebuffer when creating a window. Under X11, this is
152
// actually the XID of the created window.
153
return _device->attachWindow(_display.getHandle());
161
146
FBAggGlue::createRenderHandler()
163
GNASH_REPORT_FUNCTION;
148
// GNASH_REPORT_FUNCTION;
166
log_error("No Device layer initialized yet!");
151
log_error(_("No Device layer initialized yet!"));
170
155
const int width = _device->getWidth();
171
156
const int height = _device->getHeight();
172
const int bpp = _device->getDepth();
174
// TODO: should recalculate!
176
Renderer_agg_base *agg_handler;
180
158
_validbounds.setTo(0, 0, width - 1, height - 1);
182
#ifdef ENABLE_DOUBLE_BUFFERING
183
log_debug(_("Double buffering enabled"));
186
log_debug(_("Double buffering disabled"));
187
mem = _device->getFBMemory();
192
160
// choose apropriate pixel format
194
162
renderer::rawfb::RawFBDevice *rawfb = reinterpret_cast
195
163
<renderer::rawfb::RawFBDevice *>(_device.get());
196
log_debug(_("red channel: %d / %d"), rawfb->getRedOffset(),
164
log_debug("red channel: %d / %d", rawfb->getRedOffset(),
197
165
rawfb->getRedSize());
198
log_debug(_("green channel: %d / %d"), rawfb->getGreenOffset(),
166
log_debug("green channel: %d / %d", rawfb->getGreenOffset(),
199
167
rawfb->getGreenSize());
200
log_debug(_("blue channel: %d / %d"), rawfb->getBlueOffset(),
168
log_debug("blue channel: %d / %d", rawfb->getBlueOffset(),
201
169
rawfb->getBlueSize());
202
log_debug(_("Total bits per pixel: %d"), bpp);
170
log_debug("Total bits per pixel: %d", rawfb->getDepth());
204
172
const char* pixelformat = agg_detect_pixel_format(
205
173
rawfb->getRedOffset(), rawfb->getRedSize(),
206
174
rawfb->getGreenOffset(), rawfb->getGreenSize(),
207
175
rawfb->getBlueOffset(), rawfb->getBlueSize(),
178
Renderer_agg_base *agg_handler = 0;
210
179
if (pixelformat) {
211
180
agg_handler = create_Renderer_agg(pixelformat);
213
log_error("The pixel format of your framebuffer could not be detected.");
182
log_error(_("The pixel format of your framebuffer could not be detected."));
217
186
assert(agg_handler != NULL);
219
// This attaches the memory from the framebuffer to the AGG
221
size_t rowsize = width*((bpp+7)/8);
222
agg_handler->init_buffer((unsigned char *)mem, _device->getFBMemSize(),
223
width, height, rowsize);
188
// Get the memory buffer to have AGG render into.
189
boost::uint8_t *mem = 0;
190
if (rawfb->isSingleBuffered()) {
191
log_debug(_("Double buffering disabled"));
192
mem = rawfb->getFBMemory();
194
log_debug(_("Double buffering enabled"));
195
mem = rawfb->getOffscreenBuffer();
198
// This attaches the memory from the device to the AGG renderer
199
agg_handler->init_buffer((unsigned char *)mem, rawfb->getFBMemSize(),
200
width, height, rawfb->getStride());
202
_renderer.reset(agg_handler);
225
204
return (Renderer *)agg_handler;
229
208
FBAggGlue::prepDrawingArea(FbWidget */* drawing_area */)
231
GNASH_REPORT_FUNCTION;
210
// GNASH_REPORT_FUNCTION;
232
211
// nothing to do here, the memory was attached when
233
212
// creating the renderer.
238
FBGlue::render(void * /* region */)
240
GNASH_REPORT_FUNCTION;
245
216
FBAggGlue::render()
247
GNASH_REPORT_FUNCTION;
218
// GNASH_REPORT_FUNCTION;
249
if ( _drawbounds.size() == 0 ) {
220
if (_drawbounds.size() == 0 ) {
221
log_error(_("No Drawbounds set in %s!"), __FUNCTION__);
250
222
return; // nothing to do..
253
#ifdef ENABLE_DOUBLE_BUFFERING
254
// Size of a pixel in bytes
255
// NOTE: +7 to support 15 bpp
256
const unsigned int pixel_size = (var_screeninfo.bits_per_pixel+7)/8;
258
for (unsigned int bno=0; bno < _drawbounds.size(); bno++) {
259
geometry::Range2d<int>& bounds = _drawbounds[bno];
261
assert ( ! bounds.isWorld() );
263
// Size, in bytes, of a row that has to be copied
264
const unsigned int row_size = (bounds.width()+1) * pixel_size;
267
const int minx = bounds.getMinX();
268
const int maxy = bounds.getMaxY();
270
for (int y=bounds.getMinY(); y<=maxy; ++y) {
271
const unsigned int pixel_index = y * _rowsize + minx*pixel_size;
272
memcpy(&(_fbmem[pixel_index]), &buffer[pixel_index], row_size);
225
_device->swapBuffers();
279
227
#ifdef DEBUG_SHOW_FPS