// drawing public void draw_async(rectangle cliprect, bool clearit = true) { // if the cliprect exceeds our current bitmap dimensions, expand if (cliprect.right() >= m_bitmap.width() || cliprect.bottom() >= m_bitmap.height()) { int new_width = std.max(cliprect.right() + 1, m_bitmap.width()); int new_height = std.max(cliprect.bottom() + 1, m_bitmap.height()); m_bitmap.resize(new_width, new_height, BITMAP_SLOP, BITMAP_SLOP); m_dirty.resize(new_width, new_height); } // clear out the region if (clearit) { clear(cliprect); } // wrap the bitmap, adjusting for x/y origins _BitmapType wrapped = m_bitmapCreator(m_bitmap.pix(0) - m_xorigin - m_yorigin * m_bitmap.rowpixels(), m_xorigin + cliprect.right() + 1, m_yorigin + cliprect.bottom() + 1, m_bitmap.rowpixels()); //_BitmapType wrapped(&m_bitmap.pix(0) - m_xorigin - m_yorigin * m_bitmap.rowpixels(), m_xorigin + cliprect.right() + 1, m_yorigin + cliprect.bottom() + 1, m_bitmap.rowpixels()); // compute adjusted cliprect in source space rectangle adjusted = cliprect; adjusted.offset(m_xorigin, m_yorigin); // render draw(wrapped, adjusted); }