summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorAkash Jain <akash96j@gmail.com>2016-06-14 13:46:18 +0530
committerKhaled Hosny <khaledhosny@eglug.org>2016-10-18 20:41:29 +0200
commit73308f05c18012327731fc5722f89707048e9aba (patch)
tree65bdd65fd1e8d51e828eb56a48d458b52f8e20c8 /vcl/win
parente58cd34b81f2072520ef9e11cd90b4072d5ca799 (diff)
GSoC: Move code from winlayout.cxx to winlayout.hxx
WinFontInstance definition moved to winlayout.hxx. It has to be used in the new layout class. Code and headers which WinFontInstance depends on also moved to winlayout.hxx Change-Id: Idc8f87e6601c220d504398671326b1f23d1779a3
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/winlayout.cxx184
1 files changed, 0 insertions, 184 deletions
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index e7196f6d7e04..2c41b8f5bd10 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -26,7 +26,6 @@
#include <opengl/texture.hxx>
#include <opengl/win/gdiimpl.hxx>
-#include "opengl/PackedTextureAtlas.hxx"
#include <vcl/opengl/OpenGLHelper.hxx>
#include <win/salgdi.h>
@@ -50,193 +49,10 @@
#include <unordered_map>
#include <unordered_set>
-// Graphite headers
-#include <config_graphite.h>
-#if ENABLE_GRAPHITE
-#include <i18nlangtag/languagetag.hxx>
-#include <graphite_features.hxx>
-#if ENABLE_GRAPHITE_DWRITE
-#include <d2d1.h>
-#include <dwrite.h>
-#endif
-#endif
-
-// This needs to come after any includes for d2d1.h, otherwise we get lots of errors
-#include "glyphy/demo.hxx"
-
-
#define DROPPED_OUTGLYPH 0xFFFF
-namespace
-{
-// Extra space at the top and bottom of the glyph in total = tmHeight / GLYPH_SPACE_RATIO;
-const int GLYPH_SPACE_RATIO = 8;
-// Border size at the top of the glyph = tmHeight / GLYPH_OFFSET_RATIO;
-const int GLYPH_OFFSET_RATIO = GLYPH_SPACE_RATIO * 2;
-}
-
-struct OpenGLGlyphDrawElement
-{
- Rectangle maLocation;
- int maLeftOverhangs;
- OpenGLTexture maTexture;
- int mnBaselineOffset;
- int mnHeight;
- bool mbVertical;
- bool mbRealGlyphIndices;
-
- int getExtraSpace() const
- {
- return std::max(mnHeight / GLYPH_SPACE_RATIO, 4);
- }
-
- int getExtraOffset() const
- {
- return std::max(mnHeight / GLYPH_OFFSET_RATIO, 2);
- }
-};
-
-class GlyphCache;
-
-struct GlobalGlyphCache
-{
- GlobalGlyphCache()
- : maPackedTextureAtlas(2048, 2048)
- {}
-
- PackedTextureAtlasManager maPackedTextureAtlas;
- std::unordered_set<GlyphCache*> maGlyphCaches;
-};
-
-class GlyphCache
-{
-private:
- static std::unique_ptr<GlobalGlyphCache> gGlobalGlyphCache;
- std::unordered_map<int, OpenGLGlyphDrawElement> maOpenGLTextureCache;
-
-public:
- GlyphCache()
- {
- gGlobalGlyphCache.get()->maGlyphCaches.insert(this);
- }
-
- ~GlyphCache()
- {
- gGlobalGlyphCache.get()->maGlyphCaches.erase(this);
- }
-
- static bool ReserveTextureSpace(OpenGLGlyphDrawElement& rElement, int nWidth, int nHeight)
- {
- GlobalGlyphCache* pGlobalGlyphCache = gGlobalGlyphCache.get();
- rElement.maTexture = pGlobalGlyphCache->maPackedTextureAtlas.Reserve(nWidth, nHeight);
- if (!rElement.maTexture)
- return false;
- std::vector<GLuint> aTextureIDs = pGlobalGlyphCache->maPackedTextureAtlas.ReduceTextureNumber(8);
- if (!aTextureIDs.empty())
- {
- for (auto& pGlyphCache: pGlobalGlyphCache->maGlyphCaches)
- {
- pGlyphCache->RemoveTextures(aTextureIDs);
- }
- }
- return true;
- }
-
- void RemoveTextures(std::vector<GLuint>& rTextureIDs)
- {
- auto it = maOpenGLTextureCache.begin();
-
- while (it != maOpenGLTextureCache.end())
- {
- GLuint nTextureID = it->second.maTexture.Id();
-
- if (std::find(rTextureIDs.begin(), rTextureIDs.end(), nTextureID) != rTextureIDs.end())
- {
- it = maOpenGLTextureCache.erase(it);
- }
- else
- {
- ++it;
- }
- }
- }
-
- void PutDrawElementInCache(const OpenGLGlyphDrawElement& rElement, int nGlyphIndex)
- {
- assert(!IsGlyphCached(nGlyphIndex));
- maOpenGLTextureCache[nGlyphIndex] = OpenGLGlyphDrawElement(rElement);
- }
-
- OpenGLGlyphDrawElement& GetDrawElement(int nGlyphIndex)
- {
- assert(IsGlyphCached(nGlyphIndex));
- return maOpenGLTextureCache[nGlyphIndex];
- }
-
- bool IsGlyphCached(int nGlyphIndex) const
- {
- return maOpenGLTextureCache.find(nGlyphIndex) != maOpenGLTextureCache.end();
- }
-};
-
// static initialization
std::unique_ptr<GlobalGlyphCache> GlyphCache::gGlobalGlyphCache(new GlobalGlyphCache);
-
-// win32 specific physical font instance
-class WinFontInstance : public LogicalFontInstance
-{
-public:
- explicit WinFontInstance( FontSelectPattern& );
- virtual ~WinFontInstance() override;
- void setupGLyphy(HDC hDC);
-
-private:
- // TODO: also add HFONT??? Watch out for issues with too many active fonts...
-
-public:
- bool HasKernData() const;
- void SetKernData( int, const KERNINGPAIR* );
- int GetKerning( sal_Unicode, sal_Unicode ) const;
-
-private:
- KERNINGPAIR* mpKerningPairs;
- int mnKerningPairs;
-
-public:
- SCRIPT_CACHE& GetScriptCache() const
- { return maScriptCache; }
-private:
- mutable SCRIPT_CACHE maScriptCache;
-
-public:
- int GetCachedGlyphWidth( int nCharCode ) const;
- void CacheGlyphWidth( int nCharCode, int nCharWidth );
-
- bool InitKashidaHandling( HDC );
- int GetMinKashidaWidth() const { return mnMinKashidaWidth; }
- int GetMinKashidaGlyph() const { return mnMinKashidaGlyph; }
-
- static GLuint mnGLyphyProgram;
- demo_atlas_t* mpGLyphyAtlas;
- demo_font_t* mpGLyphyFont;
-
-private:
- GlyphCache maGlyphCache;
-public:
- bool CacheGlyphToAtlas(bool bRealGlyphIndices, int nGlyphIndex, const WinLayout& rLayout, SalGraphics& rGraphics);
-
- GlyphCache& GetGlyphCache()
- {
- return maGlyphCache;
- }
-
-private:
- std::unordered_map<int, int> maWidthMap;
- mutable int mnMinKashidaWidth;
- mutable int mnMinKashidaGlyph;
- bool mbGLyphySetupCalled;
-};
-
GLuint WinFontInstance::mnGLyphyProgram = 0;
class TextOutRenderer