Kaydet (Commit) 3c1b4b6e authored tarafından Thorsten Behrens's avatar Thorsten Behrens

Keep basebmp free of naked ptrs.

Moved the implementation detail that SalFrames lifetime is handled
manually in vcl out of basebmp & into vcl. Added lightweight wrapper
class to decouple damagetracker lifetime from GtkFrame lifetime.
üst 207bcfc5
......@@ -55,15 +55,18 @@ namespace basebmp
// Temporary. Use like the tools color object
class Color;
typedef boost::shared_ptr< class BitmapDevice > BitmapDeviceSharedPtr;
typedef boost::shared_array< sal_uInt8 > RawMemorySharedArray;
typedef boost::shared_ptr< const std::vector<Color> > PaletteMemorySharedVector;
typedef boost::shared_ptr< class BitmapDevice > BitmapDeviceSharedPtr;
typedef boost::shared_ptr< class IBitmapDeviceDamageTracker > IBitmapDeviceDamageTrackerSharedPtr;
typedef boost::shared_array< sal_uInt8 > RawMemorySharedArray;
typedef boost::shared_ptr< const std::vector<Color> > PaletteMemorySharedVector;
struct ImplBitmapDevice;
class BitmapDeviceDamageTracker {
public:
virtual void damaged (const basegfx::B2IRange& rDamageRect) = 0;
/// Interface for getting damage tracking events
struct IBitmapDeviceDamageTracker
{
/// gets called when said region is clobbered
virtual void damaged(const basegfx::B2IRange& rDamageRect) const = 0;
};
/** Definition of BitmapDevice interface
......@@ -114,7 +117,17 @@ public:
*/
RawMemorySharedArray getBuffer() const;
BitmapDeviceDamageTracker *getDamageTracker() const;
/// Query current damage tracking object (if any)
IBitmapDeviceDamageTrackerSharedPtr getDamageTracker() const;
/** Set new damage tracking object
@param rDamage
Object implementing the IBitmapDeviceDamageTracker interface -
everytime some area of the surface gets clobbered, that object
gets notified.
*/
void setDamageTracker( const IBitmapDeviceDamageTrackerSharedPtr& rDamage );
/** Get pointer to palette
......@@ -544,13 +557,12 @@ public:
const BitmapDeviceSharedPtr& rClip );
protected:
BitmapDevice( const basegfx::B2IRange& rBounds,
sal_Int32 nScanlineFormat,
sal_Int32 nScanlineStride,
sal_uInt8* pFirstScanline,
const RawMemorySharedArray& rMem,
const PaletteMemorySharedVector& rPalette,
BitmapDeviceDamageTracker* pDamage = NULL );
BitmapDevice( const basegfx::B2IRange& rBounds,
sal_Int32 nScanlineFormat,
sal_Int32 nScanlineStride,
sal_uInt8* pFirstScanline,
const RawMemorySharedArray& rMem,
const PaletteMemorySharedVector& rPalette );
virtual ~BitmapDevice();
......@@ -641,6 +653,9 @@ private:
DrawMode drawMode,
const BitmapDeviceSharedPtr& rClip ) = 0;
virtual IBitmapDeviceDamageTrackerSharedPtr getDamageTracker_i() const = 0;
virtual void setDamageTracker_i( const IBitmapDeviceDamageTrackerSharedPtr& rDamage ) = 0;
BitmapDeviceSharedPtr getGenericRenderer() const;
boost::scoped_ptr< ImplBitmapDevice > mpImpl;
......@@ -650,8 +665,7 @@ private:
*/
BASEBMP_DLLPUBLIC BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
sal_Int32 nScanlineFormat,
BitmapDeviceDamageTracker* pDamage = NULL );
sal_Int32 nScanlineFormat );
/** Factory method to create a BitmapDevice for given scanline format
with the given palette
......
This diff is collapsed.
......@@ -61,7 +61,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, basebmp::BitmapDeviceDamageTracker
class GtkSalFrame : public SalFrame
{
static const int nMaxGraphics = 2;
......
......@@ -346,6 +346,19 @@ GetAlternateKeyCode( const sal_uInt16 nKeyCode )
#if GTK_CHECK_VERSION(3,0,0)
static int debugQueuePureRedraw = 0;
static int debugRedboxRedraws = 0;
/// Decouple SalFrame lifetime from damagetracker lifetime
struct DamageTracker : public basebmp::IBitmapDeviceDamageTracker
{
DamageTracker(GtkSalFrame& rFrame) : m_rFrame(rFrame)
{}
virtual void damaged(const basegfx::B2IRange& rDamageRect) const
{
m_rFrame.damaged(rDamageRect);
}
GtkSalFrame& m_rFrame;
};
#endif
void GtkSalFrame::doKeyCallback( guint state,
......@@ -1567,9 +1580,9 @@ void GtkSalFrame::AllocateFrame()
if( aFrameSize.getY() == 0 )
aFrameSize.setY( 1 );
m_aFrame = basebmp::createBitmapDevice( aFrameSize, true,
basebmp::Format::TWENTYFOUR_BIT_TC_MASK,
this );
// basebmp::Format::THIRTYTWO_BIT_TC_MASK_ARGB );
basebmp::Format::TWENTYFOUR_BIT_TC_MASK );
m_aFrame->setDamageTracker(
basebmp::IBitmapDeviceDamageTrackerSharedPtr(new DamageTracker(*this)) );
fprintf( stderr, "allocated m_aFrame size of %dx%d \n",
(int)maGeometry.nWidth, (int)maGeometry.nHeight );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment