Implemented DoBlit().

Some testing on exposure/configure compression.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-03-12 20:45:45 +00:00
parent 9e691f46b2
commit b1633d20d6
2 changed files with 70 additions and 71 deletions

View File

@@ -545,6 +545,7 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
} }
return FALSE; return FALSE;
} }
#if 1
case ResizeRequest: case ResizeRequest:
{ {
/* /*
@@ -559,18 +560,14 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
report = * event; report = * event;
while( XCheckTypedWindowEvent (disp, actualWindow, ResizeRequest, &report)); while( XCheckTypedWindowEvent (disp, actualWindow, ResizeRequest, &report));
if (win) wxSize sz = win->GetSize();
{ wxSizeEvent sizeEvent(sz, win->GetId());
wxSize sz = win->GetSize(); sizeEvent.SetEventObject(win);
wxSizeEvent sizeEvent(sz, win->GetId());
sizeEvent.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent( sizeEvent ); return win->GetEventHandler()->ProcessEvent( sizeEvent );
}
return FALSE;
} }
#endif #endif
#endif
#if wxUSE_NANOX #if wxUSE_NANOX
case GR_EVENT_TYPE_CLOSE_REQ: case GR_EVENT_TYPE_CLOSE_REQ:
{ {
@@ -608,6 +605,7 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
} }
#endif #endif
// Only erase background, paint in idle time.
win->SendEraseEvents(); win->SendEraseEvents();
return TRUE; return TRUE;

View File

@@ -971,7 +971,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
bool is_mono = (bitmap.GetBitmap() != NULL); bool is_mono = (bitmap.GetBitmap() != NULL);
/* scale/translate size and position */ // scale/translate size and position
int xx = XLOG2DEV(x); int xx = XLOG2DEV(x);
int yy = YLOG2DEV(y); int yy = YLOG2DEV(y);
@@ -986,7 +986,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
int ww = XLOG2DEVREL(w); int ww = XLOG2DEVREL(w);
int hh = YLOG2DEVREL(h); int hh = YLOG2DEVREL(h);
/* compare to current clipping region */ // compare to current clipping region
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
{ {
wxRegion tmp( xx,yy,ww,hh ); wxRegion tmp( xx,yy,ww,hh );
@@ -995,7 +995,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
return; return;
} }
/* scale bitmap if required */ // scale bitmap if required
wxBitmap use_bitmap; wxBitmap use_bitmap;
if ((w != ww) || (h != hh)) if ((w != ww) || (h != hh))
{ {
@@ -1013,10 +1013,10 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
use_bitmap = bitmap; use_bitmap = bitmap;
} }
/* apply mask if any */ // apply mask if any
WXPixmap mask = NULL; WXPixmap mask = NULL;
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap(); if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
{
if (useMask && mask) if (useMask && mask)
{ {
WXPixmap new_mask = NULL; WXPixmap new_mask = NULL;
@@ -1061,10 +1061,9 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if (new_mask) if (new_mask)
XFreePixmap( (Display*) m_display, (Pixmap) new_mask ); XFreePixmap( (Display*) m_display, (Pixmap) new_mask );
} }
}
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
drawing a mono-bitmap (XBitmap) we use the current text GC */ // drawing a mono-bitmap (XBitmap) we use the current text GC
if (is_mono) if (is_mono)
XCopyPlane( (Display*) m_display, (Pixmap) use_bitmap.GetBitmap(), (Window) m_window, XCopyPlane( (Display*) m_display, (Pixmap) use_bitmap.GetBitmap(), (Window) m_window,
(GC) m_textGC, 0, 0, w, h, xx, yy, 1 ); (GC) m_textGC, 0, 0, w, h, xx, yy, 1 );
@@ -1072,7 +1071,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_window, XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_window,
(GC) m_penGC, 0, 0, w, h, xx, yy ); (GC) m_penGC, 0, 0, w, h, xx, yy );
/* remove mask again if any */ // remove mask again if any
if (useMask && mask) if (useMask && mask)
{ {
if (is_mono) if (is_mono)
@@ -1095,7 +1094,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
// wxUSE_NANOX/!wxUSE_NANOX // wxUSE_NANOX/!wxUSE_NANOX
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask, wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func, bool useMask,
wxCoord xsrcMask, wxCoord ysrcMask ) wxCoord xsrcMask, wxCoord ysrcMask )
{ {
/* this is the nth try to get this utterly useless function to /* this is the nth try to get this utterly useless function to
@@ -1119,13 +1118,13 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
bool use_bitmap_method = FALSE; bool use_bitmap_method = FALSE;
bool is_mono = FALSE; bool is_mono = FALSE;
/* TODO: use the mask origin when drawing transparently */ // TODO: use the mask origin when drawing transparently
if (xsrcMask == -1 && ysrcMask == -1) if (xsrcMask == -1 && ysrcMask == -1)
{ {
xsrcMask = xsrc; ysrcMask = ysrc; xsrcMask = xsrc;
ysrcMask = ysrc;
} }
#if 0
if (srcDC->m_isMemDC) if (srcDC->m_isMemDC)
{ {
if (!memDC->m_selected.Ok()) return FALSE; if (!memDC->m_selected.Ok()) return FALSE;
@@ -1170,14 +1169,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
CalcBoundingBox( xdest, ydest ); CalcBoundingBox( xdest, ydest );
CalcBoundingBox( xdest + width, ydest + height ); CalcBoundingBox( xdest + width, ydest + height );
/* scale/translate size and position */ // scale/translate size and position
wxCoord xx = XLOG2DEV(xdest); wxCoord xx = XLOG2DEV(xdest);
wxCoord yy = YLOG2DEV(ydest); wxCoord yy = YLOG2DEV(ydest);
wxCoord ww = XLOG2DEVREL(width); wxCoord ww = XLOG2DEVREL(width);
wxCoord hh = YLOG2DEVREL(height); wxCoord hh = YLOG2DEVREL(height);
/* compare to current clipping region */ // compare to current clipping region
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
{ {
wxRegion tmp( xx,yy,ww,hh ); wxRegion tmp( xx,yy,ww,hh );
@@ -1191,14 +1190,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
if (use_bitmap_method) if (use_bitmap_method)
{ {
/* scale/translate bitmap size */ // scale/translate bitmap size
wxCoord bm_width = memDC->m_selected.GetWidth(); wxCoord bm_width = memDC->m_selected.GetWidth();
wxCoord bm_height = memDC->m_selected.GetHeight(); wxCoord bm_height = memDC->m_selected.GetHeight();
wxCoord bm_ww = XLOG2DEVREL( bm_width ); wxCoord bm_ww = XLOG2DEVREL( bm_width );
wxCoord bm_hh = YLOG2DEVREL( bm_height ); wxCoord bm_hh = YLOG2DEVREL( bm_height );
/* scale bitmap if required */ // scale bitmap if required
wxBitmap use_bitmap; wxBitmap use_bitmap;
if ((bm_width != bm_ww) || (bm_height != bm_hh)) if ((bm_width != bm_ww) || (bm_height != bm_hh))
@@ -1206,9 +1205,11 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
wxImage image( memDC->m_selected ); wxImage image( memDC->m_selected );
image = image.Scale( bm_ww, bm_hh ); image = image.Scale( bm_ww, bm_hh );
#if 0
if (is_mono) if (is_mono)
use_bitmap = image.ConvertToMonoBitmap(255,255,255); use_bitmap = image.ConvertToMonoBitmap(255,255,255);
else else
#endif
use_bitmap = image.ConvertToBitmap(); use_bitmap = image.ConvertToBitmap();
} }
else else
@@ -1216,13 +1217,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
use_bitmap = memDC->m_selected; use_bitmap = memDC->m_selected;
} }
/* apply mask if any */ // apply mask if any
GdkBitmap *mask = (GdkBitmap *) NULL; WXPixmap mask = NULL;
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap(); if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
if (useMask && mask) if (useMask && mask)
{ {
GdkBitmap *new_mask = (GdkBitmap*) NULL; WXPixmap new_mask = NULL;
#if 0
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
{ {
GdkColor col; GdkColor col;
@@ -1242,59 +1244,62 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh ); gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh );
gdk_gc_unref( gc ); gdk_gc_unref( gc );
} }
#endif
if (is_mono) if (is_mono)
{ {
if (new_mask) if (new_mask)
gdk_gc_set_clip_mask( m_textGC, new_mask ); XSetClipMask( (Display*) m_display, (GC) m_textGC, (Pixmap) new_mask );
else else
gdk_gc_set_clip_mask( m_textGC, mask ); XSetClipMask( (Display*) m_display, (GC) m_textGC, (Pixmap) mask );
gdk_gc_set_clip_origin( m_textGC, xx, yy ); XSetClipOrigin( (Display*) m_display, (GC) m_textGC, xx, yy );
} }
else else
{ {
if (new_mask) if (new_mask)
gdk_gc_set_clip_mask( m_penGC, new_mask ); XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) new_mask );
else else
gdk_gc_set_clip_mask( m_penGC, mask ); XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) mask );
gdk_gc_set_clip_origin( m_penGC, xx, yy ); XSetClipOrigin( (Display*) m_display, (GC) m_penGC, xx, yy );
} }
if (new_mask) if (new_mask)
gdk_bitmap_unref( new_mask ); XFreePixmap( (Display*) m_display, (Pixmap) new_mask );
} }
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
drawing a mono-bitmap (XBitmap) we use the current text GC */ // drawing a mono-bitmap (XBitmap) we use the current text GC
if (is_mono) if (is_mono)
gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh ); XCopyPlane( (Display*) m_display, (Pixmap) use_bitmap.GetBitmap(), (Window) m_window,
(GC) m_textGC, xsrc, ysrc, width, height, xx, yy, 1 );
else else
gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh ); XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_window,
(GC) m_penGC, xsrc, ysrc, width, height, xx, yy );
/* remove mask again if any */ // remove mask again if any
if (useMask && mask) if (useMask && mask)
{ {
if (is_mono) if (is_mono)
{ {
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL ); XSetClipMask( (Display*) m_display, (GC) m_textGC, None );
gdk_gc_set_clip_origin( m_textGC, 0, 0 ); XSetClipOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 );
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() ); XSetRegion( (Display*) m_display, (GC) m_textGC, (Region) m_currentClippingRegion.GetX11Region() );
} }
else else
{ {
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); XSetClipMask( (Display*) m_display, (GC) m_penGC, None );
gdk_gc_set_clip_origin( m_penGC, 0, 0 ); XSetClipOrigin( (Display*) m_display, (GC) m_penGC, 0, 0 );
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() ); XSetRegion( (Display*) m_display, (GC) m_penGC, (Region) m_currentClippingRegion.GetX11Region() );
} }
} }
} }
else /* use_bitmap_method */ else // use_bitmap_method
{ {
if ((width != ww) || (height != hh)) if ((width != ww) || (height != hh))
{ {
/* draw source window into a bitmap as we cannot scale /* Draw source window into a bitmap as we cannot scale
a window in contrast to a bitmap. this would actually a window in contrast to a bitmap. this would actually
work with memory dcs as well, but we'd lose the mask work with memory dcs as well, but we'd lose the mask
information and waste one step in this process since information and waste one step in this process since
@@ -1309,42 +1314,38 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
wxBitmap bitmap( width, height ); wxBitmap bitmap( width, height );
/* copy including child window contents */ // copy including child window contents
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, IncludeInferiors );
gdk_window_copy_area( bitmap.GetPixmap(), m_penGC, 0, 0, XCopyArea( (Display*) m_display, (Window) srcDC->GetWindow(), (Window) bitmap.GetPixmap(),
srcDC->GetWindow(), (GC) m_penGC, xsrc, ysrc, width, height, 0, 0 );
xsrc, ysrc, width, height ); XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren );
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
/* scale image */ // scale image
wxImage image( bitmap ); wxImage image( bitmap );
image = image.Scale( ww, hh ); image = image.Scale( ww, hh );
/* convert to bitmap */ // convert to bitmap
bitmap = image.ConvertToBitmap(); bitmap = image.ConvertToBitmap();
/* draw scaled bitmap */ // draw scaled bitmap
gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 ); XCopyArea( (Display*) m_display, (Window) bitmap.GetPixmap(), (Window) m_window,
(GC) m_penGC, 0, 0, width, height, xx, yy );
} }
else else
{ {
/* No scaling and not a memory dc with a mask either */ // No scaling and not a memory dc with a mask either
/* copy including child window contents */ // copy including child window contents
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, IncludeInferiors );
gdk_window_copy_area( m_window, m_penGC, xx, yy, XCopyArea( (Display*) m_display, (Window) srcDC->GetWindow(), (Window) m_window,
srcDC->GetWindow(), (GC) m_penGC, xsrc, ysrc, width, height, xx, yy );
xsrc, ysrc, width, height ); XSetSubwindowMode( (Display*) m_display, (GC) m_penGC, ClipByChildren );
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
} }
} }
SetLogicalFunction( old_logical_func ); SetLogicalFunction( old_logical_func );
return TRUE; return TRUE;
#endif
return FALSE;
} }
void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )