[Libreoffice-commits] .: Branch 'feature/gtk3' - basebmp/inc basebmp/source vcl/inc vcl/unx
Michael Meeks
michael at kemper.freedesktop.org
Tue Jun 21 07:47:28 PDT 2011
basebmp/inc/basebmp/bitmapdevice.hxx | 8 ++
basebmp/source/bitmapdevice.cxx | 108 ++++++++++++++++++++++++-----------
vcl/inc/unx/gtk/gtkframe.hxx | 5 +
vcl/unx/gtk/window/gtkframe.cxx | 22 ++++++-
4 files changed, 106 insertions(+), 37 deletions(-)
New commits:
commit 5555eeb5b2f2c0904b8ef64a9ec5d071a8246b7c
Author: Michael Meeks <michael.meeks at novell.com>
Date: Tue Jun 21 14:53:45 2011 +0100
Initial attempt at a gtk3 basebmp damage tracker triggering redraws
diff --git a/basebmp/inc/basebmp/bitmapdevice.hxx b/basebmp/inc/basebmp/bitmapdevice.hxx
index f414989..f6b13a5 100644
--- a/basebmp/inc/basebmp/bitmapdevice.hxx
+++ b/basebmp/inc/basebmp/bitmapdevice.hxx
@@ -60,6 +60,11 @@ typedef boost::shared_ptr< const std::vector<Color> > PaletteMemorySharedVecto
struct ImplBitmapDevice;
+class BitmapDeviceDamageTracker {
+ public:
+ virtual void damaged (const basegfx::B2IRange& rDamageRect) = 0;
+};
+
/** Definition of BitmapDevice interface
Use the createBitmapDevice() factory method to create instances.
@@ -641,7 +646,8 @@ private:
*/
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
- sal_Int32 nScanlineFormat );
+ sal_Int32 nScanlineFormat,
+ BitmapDeviceDamageTracker* pDamage = NULL );
/** Factory method to create a BitmapDevice for given scanline format
with the given palette
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 2cb1447..206f5d9 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -273,6 +273,7 @@ namespace
dest_iterator_type maBegin;
typename accessor_traits::color_lookup maColorLookup;
+ BitmapDeviceDamageTracker *mpDamage;
to_uint32_functor maToUInt32Converter;
dest_accessor_type maAccessor;
colorblend_accessor_type maColorBlendAccessor;
@@ -288,21 +289,24 @@ namespace
raw_maskedxor_accessor_type maRawMaskedXorAccessor;
raw_maskedmask_accessor_type maRawMaskedMaskAccessor;
+
// -------------------------------------------------------
BitmapRenderer( const basegfx::B2IRange& rBounds,
sal_Int32 nScanlineFormat,
sal_Int32 nScanlineStride,
sal_uInt8* pFirstScanline,
- dest_iterator_type begin,
+ dest_iterator_type begin,
raw_accessor_type rawAccessor,
dest_accessor_type accessor,
const RawMemorySharedArray& rMem,
- const PaletteMemorySharedVector& rPalette ) :
- BitmapDevice( rBounds, nScanlineFormat,
+ const PaletteMemorySharedVector& rPalette,
+ BitmapDeviceDamageTracker* pDamage ) :
+ BitmapDevice( rBounds, nScanlineFormat,
nScanlineStride, pFirstScanline, rMem, rPalette ),
maBegin( begin ),
maColorLookup(),
+ mpDamage( pDamage ),
maToUInt32Converter(),
maAccessor( accessor ),
maColorBlendAccessor( accessor ),
@@ -320,6 +324,22 @@ namespace
{}
private:
+
+ void damaged( const basegfx::B2IRange& rDamageRect ) const
+ {
+ if( mpDamage )
+ mpDamage->damaged( rDamageRect );
+ }
+
+ 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 ) );
+ }
+
boost::shared_ptr<BitmapRenderer> getCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) const
{
return boost::dynamic_pointer_cast< BitmapRenderer >( bmp );
@@ -373,6 +393,7 @@ namespace
maColorLookup(
maAccessor,
fillColor) );
+ damaged( rBounds );
}
virtual void setPixel_i( const basegfx::B2IPoint& rPt,
@@ -388,6 +409,7 @@ namespace
else
maAccessor.set( pixelColor,
pixel );
+ damagedPixel(rPt);
}
virtual void setPixel_i( const basegfx::B2IPoint& rPt,
@@ -411,6 +433,7 @@ namespace
else
maMaskedAccessor.set( pixelColor,
aIter );
+ damagedPixel(rPt);
}
virtual Color getPixel_i(const basegfx::B2IPoint& rPt )
@@ -443,6 +466,9 @@ namespace
col,
begin,
rawAcc );
+ // FIXME: perhaps this needs pushing up the stack a bit
+ // to make more complex polygons more efficient ...
+ damaged( basegfx::B2IRange( rPt1, rPt2 ) );
}
template< typename Iterator, typename Accessor, typename RawAcc >
@@ -460,7 +486,7 @@ namespace
begin,
rawAcc );
}
-
+
template< typename Iterator, typename RawAcc, typename XorAcc >
void implDrawLine( const basegfx::B2IPoint& rPt1,
const basegfx::B2IPoint& rPt2,
@@ -648,6 +674,7 @@ namespace
acc,
rDstRect),
rSrcBitmap.get() == this );
+ damaged( rDstRect );
}
template< typename Iterator, typename Acc >
@@ -658,7 +685,7 @@ namespace
const Acc& acc)
{
GenericColorImageAccessor aSrcAcc( rSrcBitmap );
-
+
scaleImage(
srcIterRange(vigra::Diff2D(),
aSrcAcc,
@@ -666,6 +693,7 @@ namespace
destIterRange(begin,
acc,
rDstRect));
+ damaged( rDstRect );
}
virtual void drawBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap,
@@ -695,6 +723,7 @@ namespace
maBegin,
maAccessor);
}
+ damaged( rDstRect );
}
virtual void drawBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap,
@@ -725,6 +754,7 @@ namespace
getMaskedIter(rClip),
maMaskedAccessor);
}
+ damaged( rDstRect );
}
virtual void drawMaskedColor_i(Color aSrcColor,
@@ -773,6 +803,7 @@ namespace
maGenericColorBlendAccessor,
rDstPoint) );
}
+ // FIXME: damaged( rDstRect ); ?
}
virtual void drawMaskedColor_i(Color aSrcColor,
@@ -835,6 +866,7 @@ namespace
maGenericMaskedColorBlendAccessor,
rDstPoint) );
}
+ // FIXME: damaged( rDstRect );
}
template< typename Iterator, typename Acc >
@@ -865,6 +897,7 @@ namespace
FastMask >::type(acc),
rDstRect),
rSrcBitmap.get() == this);
+ damaged( rDstRect );
}
template< typename Iterator, typename Acc >
@@ -898,6 +931,7 @@ namespace
Masks::clipmask_polarity,
NoFastMask >::type(acc),
rDstRect));
+ damaged( rDstRect );
}
virtual void drawMaskedBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap,
@@ -933,6 +967,7 @@ namespace
maBegin,
maAccessor);
}
+ damaged( rDstRect );
}
virtual void drawMaskedBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap,
@@ -969,6 +1004,7 @@ namespace
getMaskedIter(rClip),
maMaskedAccessor);
}
+ damaged( rDstRect );
}
};
} // namespace
@@ -1059,7 +1095,6 @@ BitmapDevice::~BitmapDevice()
basegfx::B2IVector BitmapDevice::getSize() const
{
-
return basegfx::B2IVector(
mpImpl->maBounds.getMaxX() - mpImpl->maBounds.getMinX(),
mpImpl->maBounds.getMaxY() - mpImpl->maBounds.getMinY() );
@@ -1641,8 +1676,8 @@ BitmapDeviceSharedPtr createRenderer(
typename FormatTraits::accessor_selector::template wrap_accessor<
typename FormatTraits::raw_accessor_type>::type const& rAccessor,
boost::shared_array< sal_uInt8 > pMem,
- const PaletteMemorySharedVector& pPal )
-
+ const PaletteMemorySharedVector& pPal,
+ BitmapDeviceDamageTracker* pDamage )
#else
template< class FormatTraits, class MaskTraits, class Accessor >
@@ -1654,7 +1689,8 @@ BitmapDeviceSharedPtr createRenderer(
typename FormatTraits::raw_accessor_type const& rRawAccessor,
Accessor const& rAccessor,
boost::shared_array< sal_uInt8 > pMem,
- const PaletteMemorySharedVector& pPal )
+ const PaletteMemorySharedVector& pPal,
+ BitmapDeviceDamageTracker* pDamage )
#endif
{
@@ -1676,7 +1712,8 @@ BitmapDeviceSharedPtr createRenderer(
rRawAccessor,
rAccessor,
pMem,
- pPal ));
+ pPal,
+ pDamage ));
}
/// Create standard grey level palette
@@ -1707,7 +1744,8 @@ BitmapDeviceSharedPtr createRenderer(
sal_Int32 nScanlineStride,
sal_uInt8* pFirstScanline,
boost::shared_array< sal_uInt8 > pMem,
- const PaletteMemorySharedVector& pPal )
+ const PaletteMemorySharedVector& pPal,
+ BitmapDeviceDamageTracker* pDamage )
{
return createRenderer<FormatTraits,
MaskTraits>(rBounds,
@@ -1719,7 +1757,8 @@ BitmapDeviceSharedPtr createRenderer(
wrap_accessor<
typename FormatTraits::raw_accessor_type>::type(),
pMem,
- pPal);
+ pPal,
+ pDamage);
}
template< class FormatTraits, class MaskTraits >
@@ -1730,7 +1769,8 @@ BitmapDeviceSharedPtr createRenderer(
sal_uInt8* pFirstScanline,
boost::shared_array< sal_uInt8 > pMem,
PaletteMemorySharedVector pPal,
- int nBitsPerPixel )
+ int nBitsPerPixel,
+ BitmapDeviceDamageTracker* pDamage )
{
pPal = createStandardPalette(pPal,
1UL << nBitsPerPixel);
@@ -1748,7 +1788,8 @@ BitmapDeviceSharedPtr createRenderer(
&pPal->at(0),
pPal->size()),
pMem,
- pPal);
+ pPal,
+ pDamage);
}
//----------------------------------------------------------------------------------
@@ -1784,7 +1825,8 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
sal_Int32 nScanlineFormat,
boost::shared_array< sal_uInt8 > pMem,
PaletteMemorySharedVector pPal,
- const basegfx::B2IRange* pSubset )
+ const basegfx::B2IRange* pSubset,
+ BitmapDeviceDamageTracker* pDamage = NULL )
{
if( nScanlineFormat <= Format::NONE ||
nScanlineFormat > Format::MAX )
@@ -1852,24 +1894,24 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
case Format::ONE_BIT_MSB_GREY:
return createRenderer<PixelFormatTraits_GREY1_MSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
case Format::ONE_BIT_LSB_GREY:
return createRenderer<PixelFormatTraits_GREY1_LSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
case Format::ONE_BIT_MSB_PAL:
return createRenderer<PixelFormatTraits_PAL1_MSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
pFirstScanline, pMem, pPal,
- bitsPerPixel[nScanlineFormat] );
+ bitsPerPixel[nScanlineFormat], pDamage );
case Format::ONE_BIT_LSB_PAL:
return createRenderer<PixelFormatTraits_PAL1_LSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
pFirstScanline, pMem, pPal,
- bitsPerPixel[nScanlineFormat] );
+ bitsPerPixel[nScanlineFormat], pDamage );
// ----------------------------------------------------------------------
@@ -1878,24 +1920,24 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
case Format::FOUR_BIT_MSB_GREY:
return createRenderer<PixelFormatTraits_GREY4_MSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
case Format::FOUR_BIT_LSB_GREY:
return createRenderer<PixelFormatTraits_GREY4_LSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
case Format::FOUR_BIT_MSB_PAL:
return createRenderer<PixelFormatTraits_PAL4_MSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
pFirstScanline, pMem, pPal,
- bitsPerPixel[nScanlineFormat] );
+ bitsPerPixel[nScanlineFormat], pDamage );
case Format::FOUR_BIT_LSB_PAL:
return createRenderer<PixelFormatTraits_PAL4_LSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
pFirstScanline, pMem, pPal,
- bitsPerPixel[nScanlineFormat] );
+ bitsPerPixel[nScanlineFormat], pDamage );
// ----------------------------------------------------------------------
@@ -1904,13 +1946,13 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
case Format::EIGHT_BIT_GREY:
return createRenderer<PixelFormatTraits_GREY8,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
case Format::EIGHT_BIT_PAL:
return createRenderer<PixelFormatTraits_PAL8,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
pFirstScanline, pMem, pPal,
- bitsPerPixel[nScanlineFormat] );
+ bitsPerPixel[nScanlineFormat], pDamage );
// ----------------------------------------------------------------------
@@ -1919,12 +1961,12 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
case Format::SIXTEEN_BIT_LSB_TC_MASK:
return createRenderer<PixelFormatTraits_RGB16_565_LSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
case Format::SIXTEEN_BIT_MSB_TC_MASK:
return createRenderer<PixelFormatTraits_RGB16_565_MSB,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
// ----------------------------------------------------------------------
@@ -1932,7 +1974,7 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
case Format::TWENTYFOUR_BIT_TC_MASK:
return createRenderer<PixelFormatTraits_BGR24,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
// ----------------------------------------------------------------------
@@ -1941,12 +1983,12 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
case Format::THIRTYTWO_BIT_TC_MASK:
return createRenderer<PixelFormatTraits_RGB32_888,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
case Format::THIRTYTWO_BIT_TC_MASK_ARGB:
return createRenderer<PixelFormatTraits_BGR32_888,StdMasks>(
aBounds, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal );
+ pFirstScanline, pMem, pPal, pDamage );
}
// TODO(F3): other formats not yet implemented
@@ -1957,14 +1999,16 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& r
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
- sal_Int32 nScanlineFormat )
+ sal_Int32 nScanlineFormat,
+ BitmapDeviceDamageTracker* pDamage )
{
return createBitmapDeviceImpl( rSize,
bTopDown,
nScanlineFormat,
boost::shared_array< sal_uInt8 >(),
PaletteMemorySharedVector(),
- NULL );
+ NULL,
+ pDamage );
}
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 3590fda..59efb2e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -60,7 +60,7 @@ typedef XLIB_Window GdkNativeWindow;
#define gdk_window_foreign_new_for_display(a,b) gdk_x11_window_foreign_new_for_display(a,b)
#endif
-class GtkSalFrame : public SalFrame
+class GtkSalFrame : public SalFrame, public basebmp::BitmapDeviceDamageTracker
{
static const int nMaxGraphics = 2;
@@ -225,6 +225,9 @@ class GtkSalFrame : public SalFrame
void Init( SystemParentData* pSysData );
void InitCommon();
+ // Only used for gtk3 to track damage regions in our bitmapdevice
+ virtual void damaged (const basegfx::B2IRange& rDamageRect);
+
// signals
static gboolean signalButton( GtkWidget*, GdkEventButton*, gpointer );
static void signalStyleSet( GtkWidget*, GtkStyle* pPrevious, gpointer );
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 6aebe22..493137c 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -53,6 +53,7 @@
#include <svids.hrc>
#include <sal/macros.h>
+#include <basegfx/range/b2irange.hxx>
#include <basegfx/vector/b2ivector.hxx>
#include <algorithm>
@@ -1520,7 +1521,8 @@ void GtkSalFrame::AllocateFrame()
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 );
+ basebmp::Format::TWENTYFOUR_BIT_TC_MASK,
+ this );
// basebmp::Format::THIRTYTWO_BIT_TC_MASK_ARGB );
#if OSL_DEBUG_LEVEL > 0
@@ -2925,6 +2927,22 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi
return sal_True;
}
+void GtkSalFrame::damaged (const basegfx::B2IRange& rDamageRect)
+{
+#if GTK_CHECK_VERSION(3,0,0)
+ fprintf (stderr, "bitmap damaged %d %d (%dx%d)\n",
+ (int) rDamageRect.getMinX(),
+ (int) rDamageRect.getMinY(),
+ (int) rDamageRect.getWidth(),
+ (int) rDamageRect.getHeight() );
+ gtk_widget_queue_draw_area( m_pWindow,
+ rDamageRect.getMinX(),
+ rDamageRect.getMinY(),
+ rDamageRect.getWidth(),
+ rDamageRect.getHeight() );
+#endif
+}
+
#if GTK_CHECK_VERSION(3,0,0)
// This is unpleasant: we assume that a draw event was an expose earlier in life ...
// We also hope & pray (for gtk 3.0.0) that the window was realised/mapped before draw
@@ -2969,7 +2987,6 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame )
#endif
#if 1
- if (getenv ("BREAKME")) {
cairo_save( cr );
int cairo_stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, size.getX());
@@ -3011,7 +3028,6 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame )
cairo_surface_destroy( pSurface );
free (mem);
cairo_restore( cr );
- }
#if 0
cairo_save( cr );
More information about the Libreoffice-commits
mailing list