[Libreoffice-commits] .: Branch 'feature/gtk3' - basebmp/inc basebmp/source vcl/inc vcl/unx
Michael Meeks
michael at kemper.freedesktop.org
Wed Jun 22 05:30:11 PDT 2011
basebmp/inc/basebmp/bitmapdevice.hxx | 5 ++
basebmp/source/bitmapdevice.cxx | 52 +++++++++++++++++++++++------
vcl/inc/unx/gtk/gtkframe.hxx | 1
vcl/unx/gtk/window/gtkframe.cxx | 62 +++++++++++++++++++++++------------
4 files changed, 89 insertions(+), 31 deletions(-)
New commits:
commit af42b1adaf6214cc5e8e45f3afbd8efbede34508
Author: Michael Meeks <michael.meeks at novell.com>
Date: Wed Jun 22 13:28:47 2011 +0100
gtk3: clean up debug, ensure damage is propagated to clones / subsets
diff --git a/basebmp/inc/basebmp/bitmapdevice.hxx b/basebmp/inc/basebmp/bitmapdevice.hxx
index f6b13a5..addecb1 100644
--- a/basebmp/inc/basebmp/bitmapdevice.hxx
+++ b/basebmp/inc/basebmp/bitmapdevice.hxx
@@ -113,6 +113,8 @@ public:
*/
RawMemorySharedArray getBuffer() const;
+ BitmapDeviceDamageTracker *getDamageTracker() const;
+
/** Get pointer to palette
The returned pointer is const on purpose, since the
@@ -546,7 +548,8 @@ protected:
sal_Int32 nScanlineStride,
sal_uInt8* pFirstScanline,
const RawMemorySharedArray& rMem,
- const PaletteMemorySharedVector& rPalette );
+ const PaletteMemorySharedVector& rPalette,
+ BitmapDeviceDamageTracker* pDamage = NULL );
virtual ~BitmapDevice();
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 206f5d9..9aea436 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -274,7 +274,8 @@ namespace
dest_iterator_type maBegin;
typename accessor_traits::color_lookup maColorLookup;
BitmapDeviceDamageTracker *mpDamage;
- to_uint32_functor maToUInt32Converter;
+ basegfx::B2IRange maBounds; // for subsets
+ to_uint32_functor maToUInt32Converter;
dest_accessor_type maAccessor;
colorblend_accessor_type maColorBlendAccessor;
colorblend_generic_accessor_type maGenericColorBlendAccessor;
@@ -303,10 +304,12 @@ namespace
const PaletteMemorySharedVector& rPalette,
BitmapDeviceDamageTracker* pDamage ) :
BitmapDevice( rBounds, nScanlineFormat,
- nScanlineStride, pFirstScanline, rMem, rPalette ),
+ nScanlineStride, pFirstScanline, rMem, rPalette,
+ pDamage ),
maBegin( begin ),
maColorLookup(),
mpDamage( pDamage ),
+ maBounds( rBounds ),
maToUInt32Converter(),
maAccessor( accessor ),
maColorBlendAccessor( accessor ),
@@ -331,13 +334,23 @@ namespace
mpDamage->damaged( rDamageRect );
}
+ void damagedPointSize( const basegfx::B2IPoint& rPoint,
+ const basegfx::B2IRange& rSize ) const
+ {
+ if( mpDamage ) {
+ basegfx::B2IPoint aLower( rPoint.getX() + rSize.getWidth(),
+ rPoint.getY() + rSize.getHeight() );
+ damaged( basegfx::B2IRange( rPoint, aLower ) );
+ }
+ }
+
void damagedPixel( const basegfx::B2IPoint& rDamagePoint ) const
{
if( !mpDamage )
return;
basegfx::B2IPoint aEnd( rDamagePoint.getX() + 1,
rDamagePoint.getY() + 1 );
- mpDamage->damaged( basegfx::B2IRange( rDamagePoint, aEnd ) );
+ damaged( basegfx::B2IRange( rDamagePoint, aEnd ) );
}
boost::shared_ptr<BitmapRenderer> getCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) const
@@ -619,6 +632,12 @@ namespace
rBounds,
aPoly,
basegfx::FillRule_EVEN_ODD );
+
+ if( mpDamage )
+ {
+ basegfx::B2DRange const aPolyBounds( basegfx::tools::getRange(aPoly) );
+ damaged( basegfx::fround( aPolyBounds ) );
+ }
}
virtual void fillPolyPolygon_i(const basegfx::B2DPolyPolygon& rPoly,
@@ -803,7 +822,7 @@ namespace
maGenericColorBlendAccessor,
rDstPoint) );
}
- // FIXME: damaged( rDstRect ); ?
+ damagedPointSize( rDstPoint, rSrcRect );
}
virtual void drawMaskedColor_i(Color aSrcColor,
@@ -866,7 +885,7 @@ namespace
maGenericMaskedColorBlendAccessor,
rDstPoint) );
}
- // FIXME: damaged( rDstRect );
+ damagedPointSize( rDstPoint, rSrcRect );
}
template< typename Iterator, typename Acc >
@@ -1011,12 +1030,14 @@ namespace
struct ImplBitmapDevice
{
- /** Bitmap memory plus deleter.
+ /** Bitmap memory plus deleter.
Always points to the start of the mem
*/
RawMemorySharedArray mpMem;
+ BitmapDeviceDamageTracker *mpDamage;
+
/// Palette memory plus deleter (might be NULL)
PaletteMemorySharedVector mpPalette;
@@ -1073,10 +1094,12 @@ BitmapDevice::BitmapDevice( const basegfx::B2IRange& rBounds,
sal_Int32 nScanlineStride,
sal_uInt8* pFirstScanline,
const RawMemorySharedArray& rMem,
- const PaletteMemorySharedVector& rPalette ) :
+ const PaletteMemorySharedVector& rPalette,
+ BitmapDeviceDamageTracker* pDamage ) :
mpImpl( new ImplBitmapDevice )
{
mpImpl->mpMem = rMem;
+ mpImpl->mpDamage = pDamage;
mpImpl->mpPalette = rPalette;
mpImpl->maBounds = rBounds;
mpImpl->maLineClipRect = basegfx::B2IRange( rBounds.getMinX(),
@@ -1126,6 +1149,11 @@ PaletteMemorySharedVector BitmapDevice::getPalette() const
return mpImpl->mpPalette;
}
+BitmapDeviceDamageTracker *BitmapDevice::getDamageTracker() const
+{
+ return mpImpl->mpDamage;
+}
+
sal_Int32 BitmapDevice::getPaletteEntryCount() const
{
return mpImpl->mpPalette ? mpImpl->mpPalette->size() : 0;
@@ -1826,7 +1854,7 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
boost::shared_array< sal_uInt8 > pMem,
PaletteMemorySharedVector pPal,
const basegfx::B2IRange* pSubset,
- BitmapDeviceDamageTracker* pDamage = NULL )
+ BitmapDeviceDamageTracker* pDamage )
{
if( nScanlineFormat <= Format::NONE ||
nScanlineFormat > Format::MAX )
@@ -2021,6 +2049,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
nScanlineFormat,
boost::shared_array< sal_uInt8 >(),
rPalette,
+ NULL,
NULL );
}
@@ -2035,6 +2064,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
nScanlineFormat,
rMem,
rPalette,
+ NULL,
NULL );
}
@@ -2046,7 +2076,8 @@ BitmapDeviceSharedPtr subsetBitmapDevice( const BitmapDeviceSharedPtr& rProt
rProto->getScanlineFormat(),
rProto->getBuffer(),
rProto->getPalette(),
- &rSubset );
+ &rSubset,
+ rProto->getDamageTracker() );
}
BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize,
@@ -2057,7 +2088,8 @@ BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize,
rProto->getScanlineFormat(),
boost::shared_array< sal_uInt8 >(),
rProto->getPalette(),
- NULL );
+ NULL,
+ rProto->getDamageTracker() );
}
//----------------------------------------------------------------------------------
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 59efb2e..e60561a 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -179,6 +179,7 @@ class GtkSalFrame : public SalFrame, public basebmp::BitmapDeviceDamageTracker
GtkWidget* m_pWindow;
#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
basebmp::BitmapDeviceSharedPtr m_aFrame;
+ int m_nDuringRender;
#endif
GdkWindow* m_pForeignParent;
GdkNativeWindow m_aForeignParentWindow;
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 493137c..e5285ea 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -336,6 +336,8 @@ GetAlternateKeyCode( const sal_uInt16 nKeyCode )
return aAlternate;
}
+static int queuePureRedraw = 0;
+
void GtkSalFrame::doKeyCallback( guint state,
guint keyval,
guint16 hardware_keycode,
@@ -353,6 +355,18 @@ void GtkSalFrame::doKeyCallback( guint state,
aEvent.mnRepeat = 0;
vcl::DeletionListener aDel( this );
+
+#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
+ // shift-zero forces a re-draw and event is swallowed
+ if (keyval == GDK_0) // && (state & GDK_SHIFT_MASK))
+ {
+ queuePureRedraw += 2;
+ fprintf( stderr, "force re-draw %d\n", queuePureRedraw );
+ gtk_widget_queue_draw (m_pWindow);
+ return;
+ }
+#endif
+
/* #i42122# translate all keys with Ctrl and/or Alt to group 0
* else shortcuts (e.g. Ctrl-o) will not work but be inserted by
* the application
@@ -415,6 +429,9 @@ GtkSalFrame::GtkSalFrame( SalFrame* pParent, sal_uLong nStyle )
{
m_nScreen = getDisplay()->GetDefaultScreenNumber();
getDisplay()->registerFrame( this );
+#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
+ m_nDuringRender = 0;
+#endif
m_bDefaultPos = true;
m_bDefaultSize = ( (nStyle & SAL_FRAME_STYLE_SIZEABLE) && ! pParent );
m_bWindowIsGtkPlug = false;
@@ -1518,12 +1535,12 @@ void GtkSalFrame::AllocateFrame()
aFrameSize.setX( 1 );
if( aFrameSize.getY() == 0 )
aFrameSize.setY( 1 );
- fprintf( stderr, "allocate m_aFrame size of %dx%d\n",
- (int)maGeometry.nWidth, (int)maGeometry.nHeight );
m_aFrame = basebmp::createBitmapDevice( aFrameSize, true,
basebmp::Format::TWENTYFOUR_BIT_TC_MASK,
this );
// basebmp::Format::THIRTYTWO_BIT_TC_MASK_ARGB );
+ fprintf( stderr, "allocate m_aFrame size of %dx%d \n",
+ (int)maGeometry.nWidth, (int)maGeometry.nHeight );
#if OSL_DEBUG_LEVEL > 0
m_aFrame->clear( basebmp::Color( 255, 127, 0 ) );
@@ -2930,11 +2947,13 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi
void GtkSalFrame::damaged (const basegfx::B2IRange& rDamageRect)
{
#if GTK_CHECK_VERSION(3,0,0)
- fprintf (stderr, "bitmap damaged %d %d (%dx%d)\n",
+ if (m_nDuringRender)
+ return;
+ /* fprintf (stderr, "bitmap damaged %d %d (%dx%d)\n",
(int) rDamageRect.getMinX(),
(int) rDamageRect.getMinY(),
(int) rDamageRect.getWidth(),
- (int) rDamageRect.getHeight() );
+ (int) rDamageRect.getHeight() ); */
gtk_widget_queue_draw_area( m_pWindow,
rDamageRect.getMinX(),
rDamageRect.getMinY(),
@@ -2954,13 +2973,21 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame )
double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
- // FIXME: qutie possibly we have some co-ordinate system / translation madness here.
- // pEvent->area.x, pEvent->area.y, pEvent->area.width, pEvent->area.height );
struct SalPaintEvent aEvent( x1, y1, x2 - x1, y2 - y1 );
aEvent.mbImmediateUpdate = true;
GTK_YIELD_GRAB();
- pThis->CallCallback( SALEVENT_PAINT, &aEvent );
+ // FIXME: we quite probably want to stop re-rendering of pieces
+ // that we know are just damaged and hence rendered already ...
+ if (queuePureRedraw <= 0) {
+ pThis->m_nDuringRender++;
+ fprintf (stderr, "paint %d\n", queuePureRedraw);
+ pThis->CallCallback( SALEVENT_PAINT, &aEvent );
+ pThis->m_nDuringRender--;
+ } else {
+ queuePureRedraw--;
+ fprintf (stderr, "signalDraw %d\n", queuePureRedraw);
+ }
#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
if( !pThis->m_aFrame.get() )
@@ -2970,12 +2997,11 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame )
basegfx::B2IVector size = pThis->m_aFrame->getSize();
sal_Int32 nStride = pThis->m_aFrame->getScanlineStride();
- // Get the data from our m_aFrame to cairo ...
- g_warning ("Get pixels from bmpdev to cairo (%g,%g %gx%g) vs %dx%d stride %d",
- x1, y1, x2 - x1, y2 - y1, (int)size.getX(), (int)size.getY(), (int)nStride);
+ // FIXME: this is horribly inefficient ...
+
// ARGB == ARGB32 ... map straight across from bmpdev (?) ...
-#if 1
+#if 0
// Draw flat white rectangle first:
cairo_save( cr );
cairo_set_line_width( cr, 1.0 );
@@ -2990,7 +3016,7 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame )
cairo_save( cr );
int cairo_stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, size.getX());
- // This is incredibly lame ... but so is cairo's insistance on -exactly-
+ // FIXME: This is incredibly lame ... but so is cairo's insistance on -exactly-
// its own stride - neither more nor less - particularly not more aligned
// we like 8byte aligned, it likes 4 - most odd.
unsigned char *p, *src, *mem = (unsigned char *)malloc (32 * cairo_stride * size.getY());
@@ -3012,16 +3038,13 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame )
CAIRO_FORMAT_ARGB32,
size.getX(), size.getY(),
cairo_stride );
- g_warning( "Fixed cairo status %d %d strides: %d vs %d, mask %d\n",
+ /* g_warning( "Fixed cairo status %d %d strides: %d vs %d, mask %d\n",
(int) cairo_status( cr ),
(int) cairo_surface_status( pSurface ),
(int) nStride,
(int) cairo_stride,
- (int) (cairo_stride & (sizeof (uint32_t)-1)) );
+ (int) (cairo_stride & (sizeof (uint32_t)-1)) ); */
#endif
- if (!pSurface)
- g_warning ("null surface!");
- // cairo_scale( cr, x2 - x1, y2 - y1 );
cairo_set_operator( cr, CAIRO_OPERATOR_OVER );
cairo_set_source_surface( cr, pSurface, 0, 0 );
cairo_paint( cr );
@@ -3029,12 +3052,11 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame )
free (mem);
cairo_restore( cr );
-#if 0
+#if 1
cairo_save( cr );
cairo_set_line_width( cr, 1.0 );
cairo_set_source_rgb( cr, 1.0, 1.0, 0 );
- cairo_rectangle( cr, 30, 30, size.getX()/2, size.getY()/2 );
- cairo_fill( cr );
+ cairo_rectangle( cr, x1 + 1, y1 + 1, x2 - x1 - 2, y2 - y1 - 2 );
cairo_stroke( cr );
cairo_restore( cr );
#endif
More information about the Libreoffice-commits
mailing list