This commit is contained in:
Oleg Korshul
2018-04-13 19:00:52 +03:00
parent 33bf2df39d
commit 322bc72ad1
5 changed files with 118 additions and 13 deletions

View File

@ -847,7 +847,7 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
if (NULL != m_pCache)
{
pCacheImage = m_pCache->Lock(m_oBrush.TexturePath);
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
}
@ -905,7 +905,7 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
if (NULL != m_pCache)
{
pCacheImage = m_pCache->Lock(m_oBrush.TexturePath);
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
}
@ -1050,7 +1050,7 @@ HRESULT CGraphicsRenderer::DrawImageFromFile(const std::wstring& bstrVal, const
CCacheImage* pCacheImage = NULL;
if (NULL != m_pCache)
{
pCacheImage = m_pCache->Lock(bstrVal);
pCacheImage = (CCacheImage*)m_pCache->Lock(bstrVal);
}
else
{

View File

@ -43,7 +43,9 @@
#undef GetTempPath
#endif
class CCacheImage
#include "../graphics/pro/Image.h"
class CCacheImage : public NSImages::ICacheImage
{
private:
Aggplus::CImage m_oImage;
@ -82,12 +84,16 @@ public:
m_lRef = 1;
}
LONG AddRef()
virtual ~CCacheImage()
{
}
virtual LONG AddRef()
{
++m_lRef;
return m_lRef;
}
LONG Release()
virtual LONG Release()
{
--m_lRef;
@ -128,13 +134,13 @@ public:
m_oCS.InitializeCriticalSection();
}
~CImageFilesCache()
virtual ~CImageFilesCache()
{
Clear();
m_oCS.DeleteCriticalSection();
}
void Clear()
virtual void Clear()
{
CTemporaryCS oCS(&m_oCS);
@ -146,7 +152,7 @@ public:
m_mapImages.clear();
}
CCacheImage* Lock(const std::wstring& strFile)
virtual NSImages::ICacheImage* Lock(const std::wstring& strFile)
{
CTemporaryCS oCS(&m_oCS);
@ -182,12 +188,12 @@ public:
return pImage;
}
LONG AddRef()
virtual LONG AddRef()
{
++m_lRef;
return m_lRef;
}
LONG Release()
virtual LONG Release()
{
m_oCS.Enter();
--m_lRef;
@ -203,7 +209,7 @@ public:
return m_lRef;
}
void SetApplicationFonts(CApplicationFonts* pApplicationFonts)
virtual void SetApplicationFonts(CApplicationFonts* pApplicationFonts)
{
m_pApplicationFonts = pApplicationFonts;
}

View File

@ -0,0 +1,56 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../ImageFilesCache.h"
namespace NSImages
{
namespace NSCacheImage
{
ICacheImage* Create(NSFonts::IApplicationFonts* pFonts, const std::wstring& sFile)
{
if (sFile.empty())
return new CCacheImage((CApplicationFonts*)pFonts);
return new CCacheImage((CApplicationFonts*)pFonts, sFile);
}
}
namespace NSFilesCache
{
IImageFilesCache* Create(NSFonts::IApplicationFonts* pFonts)
{
return new CImageFilesCache((CApplicationFonts*)pFonts);
}
}
}
#endif // _GRAPHICS_EXPORTS_IMAGE_H_

View File

@ -32,4 +32,46 @@
#ifndef _GRAPHICS_EXPORTS_IMAGE_H_
#define _GRAPHICS_EXPORTS_IMAGE_H_
#include "../../common/Types.h"
#include "./Fonts.h"
namespace NSImages
{
class ICacheImage
{
public:
ICacheImage() {}
virtual ~ICacheImage() {}
virtual LONG AddRef() = 0;
virtual LONG Release() = 0;
};
namespace NSCacheImage
{
ICacheImage* Create(NSFonts::IApplicationFonts* pFonts, const std::wstring& sFile = L"");
}
class IImageFilesCache
{
public:
IImageFilesCache() {}
virtual ~IImageFilesCache() {}
virtual void Clear() = 0;
virtual ICacheImage* Lock(const std::wstring& strFile) = 0;
virtual LONG AddRef() = 0;
virtual LONG Release() = 0;
void SetApplicationFonts(NSFonts::IApplicationFonts* pApplicationFonts);
};
namespace NSFilesCache
{
IImageFilesCache* Create(NSFonts::IApplicationFonts* pFonts);
}
}
#endif // _GRAPHICS_EXPORTS_IMAGE_H_

View File

@ -116,7 +116,8 @@ SOURCES += \
./../../fontengine/FontPath.cpp \
./../../fontengine/GlyphString.cpp \
\
./Fonts.cpp
./Fonts.cpp \
./Image.cpp
SOURCES += $$PWD/graphics_pri.cpp