From 322bc72ad1b3d7ba130486de2f8a67ab210faf1c Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Fri, 13 Apr 2018 19:00:52 +0300 Subject: [PATCH] 15 --- DesktopEditor/graphics/GraphicsRenderer.cpp | 6 +-- DesktopEditor/graphics/ImageFilesCache.h | 24 +++++---- DesktopEditor/graphics/pro/Image.cpp | 56 +++++++++++++++++++++ DesktopEditor/graphics/pro/Image.h | 42 ++++++++++++++++ DesktopEditor/graphics/pro/graphics.pro | 3 +- 5 files changed, 118 insertions(+), 13 deletions(-) create mode 100644 DesktopEditor/graphics/pro/Image.cpp diff --git a/DesktopEditor/graphics/GraphicsRenderer.cpp b/DesktopEditor/graphics/GraphicsRenderer.cpp index 631314ad0f..f0b589099f 100644 --- a/DesktopEditor/graphics/GraphicsRenderer.cpp +++ b/DesktopEditor/graphics/GraphicsRenderer.cpp @@ -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 { diff --git a/DesktopEditor/graphics/ImageFilesCache.h b/DesktopEditor/graphics/ImageFilesCache.h index 3968f96283..6d64f36b1d 100644 --- a/DesktopEditor/graphics/ImageFilesCache.h +++ b/DesktopEditor/graphics/ImageFilesCache.h @@ -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; } diff --git a/DesktopEditor/graphics/pro/Image.cpp b/DesktopEditor/graphics/pro/Image.cpp new file mode 100644 index 0000000000..2fa847eb73 --- /dev/null +++ b/DesktopEditor/graphics/pro/Image.cpp @@ -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_ diff --git a/DesktopEditor/graphics/pro/Image.h b/DesktopEditor/graphics/pro/Image.h index fc63d7c0df..1ec4c9e11a 100644 --- a/DesktopEditor/graphics/pro/Image.h +++ b/DesktopEditor/graphics/pro/Image.h @@ -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_ diff --git a/DesktopEditor/graphics/pro/graphics.pro b/DesktopEditor/graphics/pro/graphics.pro index 38f57cc7e9..5778c16abf 100644 --- a/DesktopEditor/graphics/pro/graphics.pro +++ b/DesktopEditor/graphics/pro/graphics.pro @@ -116,7 +116,8 @@ SOURCES += \ ./../../fontengine/FontPath.cpp \ ./../../fontengine/GlyphString.cpp \ \ - ./Fonts.cpp + ./Fonts.cpp \ + ./Image.cpp SOURCES += $$PWD/graphics_pri.cpp