Kaydet (Commit) f18ad613 authored tarafından Armin Le Grand's avatar Armin Le Grand

i122985 Various speedups for graphic object swapping to enhance user experience

üst 74626079
......@@ -474,14 +474,38 @@ void JPEGReader::FillBitmap()
for( long nY = 0L; nY < nHeight; nY++ )
{
pTmp = (sal_uInt8*) pBuffer + nY * nAlignedWidth;
// #122985# Added fast-lane implementations using CopyScanline with direct supported mem formats
static bool bCheckOwnReader(true);
for( long nX = 0L; nX < nWidth; nX++ )
if(bCheckOwnReader)
{
// #122985# Trying to copy the RGB data from jpeg import to make things faster. Unfortunately
// it has no GBR format, so RGB three-byte groups need to be 'flipped' to GBR first,
// then CopyScanline can use a memcpy to do the data transport. CopyScanline can also
// do the needed conversion from BMP_FORMAT_24BIT_TC_RGB (and it works well), but this
// is not faster that the old loop below using SetPixel.
sal_uInt8* aSource((sal_uInt8*)pBuffer + nY * nAlignedWidth);
sal_uInt8* aEnd(aSource + (nWidth * 3));
for(sal_uInt8* aTmp(aSource); aTmp < aEnd; aTmp += 3)
{
::std::swap(*aTmp, *(aTmp + 2));
}
pAcc->CopyScanline(nY, aSource, BMP_FORMAT_24BIT_TC_BGR, nWidth * 3);
}
else
{
aColor.SetRed( *pTmp++ );
aColor.SetGreen( *pTmp++ );
aColor.SetBlue( *pTmp++ );
pAcc->SetPixel( nY, nX, aColor );
// old version: WritePixel
pTmp = (sal_uInt8*) pBuffer + nY * nAlignedWidth;
for( long nX = 0L; nX < nWidth; nX++ )
{
aColor.SetRed( *pTmp++ );
aColor.SetGreen( *pTmp++ );
aColor.SetBlue( *pTmp++ );
pAcc->SetPixel( nY, nX, aColor );
}
}
}
}
......
......@@ -335,10 +335,12 @@ public:
class SVX_DLLPUBLIC SdrUndoDelObj : public SdrUndoRemoveObj
{
private:
void TryToFlushGraphicContent();
public:
SdrUndoDelObj(SdrObject& rNewObj, FASTBOOL bOrdNumDirect=sal_False)
: SdrUndoRemoveObj(rNewObj,bOrdNumDirect) { SetOwner(sal_True); }
virtual ~SdrUndoDelObj() {}
SdrUndoDelObj(SdrObject& rNewObj, FASTBOOL bOrdNumDirect=sal_False);
virtual ~SdrUndoDelObj();
virtual void Undo();
virtual void Redo();
......
......@@ -69,6 +69,7 @@
#include <vos/mutex.hxx>
#include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
#include <unotools/cacheoptions.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::io;
......@@ -80,6 +81,37 @@ using namespace ::com::sun::star::io;
#define GRAFSTREAMPOS_INVALID 0xffffffff
#define SWAPGRAPHIC_TIMEOUT 5000
// #122985# it is not correct to se the swap-timeout to a hard-coded 5000ms as it was before.
// Added code and experimented what to do as a good compromize, see description
sal_uInt32 getCacheTimeInMs()
{
static bool bSetAtAll(true);
if(bSetAtAll)
{
static bool bSetToPreferenceTime(true);
if(bSetToPreferenceTime)
{
const SvtCacheOptions aCacheOptions;
const sal_Int32 nSeconds(aCacheOptions.GetGraphicManagerObjectReleaseTime());
// the default is 10 minutes. The minimum is one minute, thus 60 seconds. When the minimum
// should match to the former hard-coded 5 seconds, we have a divisor of 12 to use. For the
// default of 10 minutes this would mean 50 seconds. Compared to before this is ten times
// more (would allow better navigation by switching through pages) and is controllable
// by the user by setting the tools/options/memory/Remove_from_memory_after setting. Seems
// to be a good compromize to me.
return nSeconds * 1000 / 12;
}
else
{
return SWAPGRAPHIC_TIMEOUT;
}
}
return 0;
}
// ------------------
// - SdrGraphicLink -
......@@ -375,7 +407,7 @@ SdrGrafObj::SdrGrafObj()
{
pGraphic = new GraphicObject;
mpReplacementGraphic = 0;
pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
onGraphicChanged();
// #i118485# Shear allowed and possible now
......@@ -402,7 +434,7 @@ SdrGrafObj::SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect)
{
pGraphic = new GraphicObject( rGrf );
mpReplacementGraphic = 0;
pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
onGraphicChanged();
// #i118485# Shear allowed and possible now
......@@ -429,7 +461,7 @@ SdrGrafObj::SdrGrafObj( const Graphic& rGrf )
{
pGraphic = new GraphicObject( rGrf );
mpReplacementGraphic = 0;
pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
onGraphicChanged();
// #i118485# Shear allowed and possible now
......@@ -463,7 +495,7 @@ void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj )
*pGraphic = rGrfObj;
delete mpReplacementGraphic;
mpReplacementGraphic = 0;
pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
pGraphic->SetUserData();
mbIsPreview = sal_False;
SetChanged();
......
......@@ -42,8 +42,9 @@
#include <svx/svdocapt.hxx>
#include <svl/whiter.hxx>
#include <svx/e3dsceneupdater.hxx>
#include "svx/svdviter.hxx"
#include <svx/svdviter.hxx>
#include <svx/svdograf.hxx>
#include <svx/sdr/contact/viewcontactofgraphic.hxx>
////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -882,6 +883,38 @@ void SdrUndoInsertObj::Redo()
////////////////////////////////////////////////////////////////////////////////////////////////////
void SdrUndoDelObj::TryToFlushGraphicContent()
{
SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
if(pSdrGrafObj)
{
sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&pSdrGrafObj->GetViewContact());
if(pVC)
{
pVC->flushViewObjectContacts();
pVC->flushGraphicObjects();
}
pSdrGrafObj->ForceSwapOut();
}
}
SdrUndoDelObj::SdrUndoDelObj(SdrObject& rNewObj, FASTBOOL bOrdNumDirect)
: SdrUndoRemoveObj(rNewObj,bOrdNumDirect)
{
SetOwner(sal_True);
// #122985# if graphic object is deleted (but goes to undo) flush it's graphic content
// since it is potentially no longer needed
TryToFlushGraphicContent();
}
SdrUndoDelObj::~SdrUndoDelObj()
{
}
void SdrUndoDelObj::Undo()
{
SdrUndoRemoveObj::Undo();
......@@ -894,6 +927,10 @@ void SdrUndoDelObj::Redo()
SdrUndoRemoveObj::Redo();
DBG_ASSERT(!IsOwner(),"RedoDeleteObj: pObj gehoert bereits der UndoAction");
SetOwner(sal_True);
// #122985# if graphic object is deleted (but goes to undo) flush it's graphic content
// since it is potentially no longer needed
TryToFlushGraphicContent();
}
XubString SdrUndoDelObj::GetComment() const
......
This diff is collapsed.
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