void Qt4AggGlue::initBuffer(int width, int height) { if (!_renderer) return; _width = width; _height = height; int _bpp = 32; int depth_bytes = _bpp / 8; assert(_bpp % 8 == 0); #define CHUNK_SIZE (100 * 100 * depth_bytes) int bufsize = (width * height * depth_bytes / CHUNK_SIZE + 1) * CHUNK_SIZE; _offscreenbuf.reset(new unsigned char[bufsize]); Renderer_agg_base * renderer = static_cast<Renderer_agg_base *>(_renderer); renderer->init_buffer(_offscreenbuf.get(), bufsize, _width, _height, width*((_bpp+7)/8)); _image.reset(new QImage(_offscreenbuf.get(), _width, _height, QImage::Format_RGB32)); }
void FltkAggGlue::initBuffer(int width, int height) { assert(_renderer); int _bpp = 24; int depth_bytes = _bpp / 8; // TODO: <Udo> is this correct? Gives 1 for 15 bit modes! assert(_bpp % 8 == 0); _stride = width * depth_bytes; #define CHUNK_SIZE (100 * 100 * depth_bytes) int bufsize = (width * height * depth_bytes / CHUNK_SIZE + 1) * CHUNK_SIZE; _offscreenbuf = new unsigned char[bufsize]; // Only the AGG renderer has the function init_buffer, which is *not* part of // the renderer api. It allows us to change the renderers movie size (and buffer // address) during run-time. Renderer_agg_base * renderer = static_cast<Renderer_agg_base *>(_renderer); renderer->init_buffer(_offscreenbuf, bufsize, width, height, width*((_bpp+7)/8)); _width = width; _height = height; _validbounds.setTo(0, 0, _width-1, _height-1); _drawbounds = _validbounds; }
bool HaikuAggGlue::prepDrawingArea(int width, int height, boost::uint32_t sdl_flags) { (void) sdl_flags; assert(width > 0); assert(height > 0); if (_width == width && _height == height) QQ(1); //return true; int depth_bytes = _bpp / 8; // TODO: <Udo> is this correct? Gives 1 for 15 bit modes! assert(_bpp % 8 == 0); boost::uint32_t rmask, gmask, bmask, amask; switch(_bpp) { case 32: // RGBA32 // BGRA32? rmask = 0xFF; gmask = 0xFF << 8; bmask = 0xFF << 16; amask = 0xFF << 24; break; case 24: // RGB24 rmask = 0xFF; gmask = 0xFF << 8; bmask = 0xFF << 16; amask = 0; break; case 16: // RGB565: 5 bits for red, 6 bits for green, and 5 bits for blue rmask = 0x1F << 11; gmask = 0x3F << 5; bmask = 0x1F; amask = 0; break; default: abort(); } #define CHUNK_SIZE (100 * 100 * depth_bytes) int bufsize = static_cast<int>(width * height * depth_bytes / CHUNK_SIZE + 1) * CHUNK_SIZE; if (_xid != 0) { int pagesize = getpagesize(); bufsize = ((bufsize + pagesize - 1) / pagesize) * pagesize; } if (_bufsize != (unsigned)bufsize) { if (_xid != 0 && _bufsize != 0) { if (msync(_sharebuf, _bufsize, MS_INVALIDATE) != 0) perror("msync"); if (munmap(_sharebuf, _bufsize) != 0) perror("munmap"); } delete [] _offscreenbuf; _bufsize = bufsize; _offscreenbuf = new unsigned char[bufsize]; //BlankScreen(); if (_xid != 0) { if (ftruncate(_sharefd, _bufsize) != 0) perror("ftruncate"); _sharebuf = static_cast<unsigned char*>( mmap( (caddr_t)0, _bufsize, PROT_READ|PROT_WRITE, MAP_SHARED, _sharefd, 0 )); if (_sharebuf == (void*) -1) { perror("mmap"); exit(1); } memset(_sharebuf, 0xcc, _bufsize); } log_debug (_("SDL-AGG: %i byte offscreen buffer allocated"), bufsize); } _width = width; _height = height; // Only the AGG renderer has the function init_buffer, which is *not* part of // the renderer api. It allows us to change the renderers movie size (and buffer // address) during run-time. Renderer_agg_base * renderer = static_cast<Renderer_agg_base *>(_agg_renderer); renderer->init_buffer(_offscreenbuf, bufsize, width, height, width*((_bpp+7)/8)); if (_view != NULL) ViewNeeded(); _validbounds.setTo(0, 0, width-1, height-1); return true; }