move static bitmap into a svapp member

so it won't crash on exit when its dtor uses stuff destroyed by deinitvcl
already.

also fix comparisons, i.e. presumably
aLastColorTopLeft == aLastColorTopLeft etc
should have been aLastColorTopLeft == aColorTopLeft

Change-Id: I1f3dc47504c5add113b3a8bcadf010ca3b9f4c31
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 86b0d7a9..a929165 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -284,6 +284,26 @@ struct ImplSVNWFData
    bool                    mbDDListBoxNoTextArea:1;
};

struct BlendFrameCache
{
    Size m_aLastSize;
    sal_uInt8 m_nLastAlpha;
    Color m_aLastColorTopLeft;
    Color m_aLastColorTopRight;
    Color m_aLastColorBottomRight;
    Color m_aLastColorBottomLeft;
    BitmapEx m_aLastResult;

    BlendFrameCache()
        : m_aLastSize(0, 0)
        , m_nLastAlpha(0)
        , m_aLastColorTopLeft(COL_BLACK)
        , m_aLastColorTopRight(COL_BLACK)
        , m_aLastColorBottomRight(COL_BLACK)
        , m_aLastColorBottomLeft(COL_BLACK)
    {
    }
};

struct ImplSVData
{
@@ -312,6 +332,7 @@ struct ImplSVData
    UnoWrapperBase*         mpUnoWrapper;
    Window*                 mpIntroWindow;      // the splash screen
    DockingManager*         mpDockingManager;
    BlendFrameCache*        mpBlendFrameCache;
    sal_Bool                mbIsTestTool;

    oslThreadIdentifier                     mnMainThreadId;
@@ -330,6 +351,7 @@ Window*     ImplGetDefaultWindow();
VCL_PLUGIN_PUBLIC ResMgr*     ImplGetResMgr();
VCL_PLUGIN_PUBLIC ResId VclResId( sal_Int32 nId ); // throws std::bad_alloc if no res mgr
DockingManager*     ImplGetDockingManager();
BlendFrameCache*    ImplGetBlendFrameCache();
void        ImplWindowAutoMnemonic( Window* pWindow );

void        ImplUpdateSystemProcessWindow();
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index feec982..2a7bc93 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -256,6 +256,15 @@ DockingManager* ImplGetDockingManager()
    return pSVData->mpDockingManager;
}

BlendFrameCache* ImplGetBlendFrameCache()
{
    ImplSVData* pSVData = ImplGetSVData();
    if ( !pSVData->mpBlendFrameCache)
        pSVData->mpBlendFrameCache= new BlendFrameCache();

    return pSVData->mpBlendFrameCache;
}

class AccessBridgeCurrentContext: public cppu::WeakImplHelper1< com::sun::star::uno::XCurrentContext >
{
public:
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 21a351b..9104be9 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -540,6 +540,9 @@ void DeInitVCL()
    if ( pSVData->maAppData.mpFirstEventHook )
        ImplFreeEventHookData();

    if (pSVData->mpBlendFrameCache)
        delete pSVData->mpBlendFrameCache, pSVData->mpBlendFrameCache = NULL;

    ImplDeletePrnQueueList();
    delete pSVData->maGDIData.mpScreenFontList;
    pSVData->maGDIData.mpScreenFontList = NULL;
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index 7a3ca96..227e630 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -1252,31 +1252,25 @@ BitmapEx VCL_DLLPUBLIC createBlendFrame(
    Color aColorBottomRight,
    Color aColorBottomLeft)
{
    static Size aLastSize(0, 0);
    static sal_uInt8 nLastAlpha(0);
    static Color aLastColorTopLeft(COL_BLACK);
    static Color aLastColorTopRight(COL_BLACK);
    static Color aLastColorBottomRight(COL_BLACK);
    static Color aLastColorBottomLeft(COL_BLACK);
    static BitmapEx aLastResult;
    BlendFrameCache* pBlendFrameCache = ImplGetBlendFrameCache();

    if(aLastSize == rSize
        && nLastAlpha == nAlpha
        && aLastColorTopLeft == aLastColorTopLeft
        && aLastColorTopRight == aLastColorTopRight
        && aLastColorBottomRight == aLastColorBottomRight
        && aLastColorBottomLeft == aLastColorBottomLeft)
    if(pBlendFrameCache->m_aLastSize == rSize
        && pBlendFrameCache->m_nLastAlpha == nAlpha
        && pBlendFrameCache->m_aLastColorTopLeft == aColorTopLeft
        && pBlendFrameCache->m_aLastColorTopRight == aColorTopRight
        && pBlendFrameCache->m_aLastColorBottomRight == aColorBottomRight
        && pBlendFrameCache->m_aLastColorBottomLeft == aColorBottomLeft)
    {
        return aLastResult;
        return pBlendFrameCache->m_aLastResult;
    }

    aLastSize = rSize;
    nLastAlpha = nAlpha;
    aLastColorTopLeft = aLastColorTopLeft;
    aLastColorTopRight = aLastColorTopRight;
    aLastColorBottomRight = aLastColorBottomRight;
    aLastColorBottomLeft = aLastColorBottomLeft;
    aLastResult.Clear();
    pBlendFrameCache->m_aLastSize = rSize;
    pBlendFrameCache->m_nLastAlpha = nAlpha;
    pBlendFrameCache->m_aLastColorTopLeft = aColorTopLeft;
    pBlendFrameCache->m_aLastColorTopRight = aColorTopRight;
    pBlendFrameCache->m_aLastColorBottomRight = aColorBottomRight;
    pBlendFrameCache->m_aLastColorBottomLeft = aColorBottomLeft;
    pBlendFrameCache->m_aLastResult.Clear();

    const long nW(rSize.Width());
    const long nH(rSize.Height());
@@ -1348,7 +1342,7 @@ BitmapEx VCL_DLLPUBLIC createBlendFrame(
            aContent.ReleaseAccess(pContent);
            aAlpha.ReleaseAccess(pAlpha);

            aLastResult = BitmapEx(aContent, aAlpha);
            pBlendFrameCache->m_aLastResult = BitmapEx(aContent, aAlpha);
        }
        else
        {
@@ -1364,7 +1358,7 @@ BitmapEx VCL_DLLPUBLIC createBlendFrame(
        }
    }

    return aLastResult;
    return pBlendFrameCache->m_aLastResult;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */