summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-20 10:38:52 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-20 10:38:52 -0700
commitec51ac3e4dfa8ee1da3d581b40f0b35af4563c9e (patch)
tree856b76dfb372807aaa984acedecff66984ec84b0 /core/fxge
parent54d027dbbff8a0270531855082e4f61cb457c173 (diff)
downloadpdfium-ec51ac3e4dfa8ee1da3d581b40f0b35af4563c9e.tar.xz
Another round of fx_ge cleanup.
- Clean up CFX_GEModule. - Remove duplicate #defines in fx_ge.h - Remove IsFontStyleFromCharCode() that always returns true. - Mark a FXTEXT_CHARPOS field as Mac only. Review-Url: https://codereview.chromium.org/2075333002
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/ge/fx_ge.cpp59
-rw-r--r--core/fxge/include/fx_ge.h47
2 files changed, 56 insertions, 50 deletions
diff --git a/core/fxge/ge/fx_ge.cpp b/core/fxge/ge/fx_ge.cpp
index 360a4eb417..4ebf812f12 100644
--- a/core/fxge/ge/fx_ge.cpp
+++ b/core/fxge/ge/fx_ge.cpp
@@ -9,52 +9,57 @@
#include "core/fxge/ge/fx_text_int.h"
static CFX_GEModule* g_pGEModule = nullptr;
-CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) {
- m_pFontCache = nullptr;
- m_pFontMgr = nullptr;
- m_FTLibrary = nullptr;
- m_pCodecModule = nullptr;
- m_pPlatformData = nullptr;
- m_pUserFontPaths = pUserFontPaths;
+
+CFX_GEModule::CFX_GEModule(const char** pUserFontPaths,
+ CCodec_ModuleMgr* pCodecModule)
+ : m_FTLibrary(nullptr),
+ m_pFontCache(nullptr),
+ m_pFontMgr(new CFX_FontMgr),
+ m_pCodecModule(pCodecModule),
+ m_pPlatformData(nullptr),
+ m_pUserFontPaths(pUserFontPaths) {
+ InitPlatform();
+ SetTextGamma(2.2f);
}
+
CFX_GEModule::~CFX_GEModule() {
delete m_pFontCache;
- m_pFontCache = nullptr;
- delete m_pFontMgr;
- m_pFontMgr = nullptr;
DestroyPlatform();
}
+
+// static
+void CFX_GEModule::Create(const char** userFontPaths,
+ CCodec_ModuleMgr* pCodecModule) {
+ ASSERT(!g_pGEModule);
+ g_pGEModule = new CFX_GEModule(userFontPaths, pCodecModule);
+}
+
+// static
CFX_GEModule* CFX_GEModule::Get() {
return g_pGEModule;
}
-void CFX_GEModule::Create(const char** userFontPaths) {
- g_pGEModule = new CFX_GEModule(userFontPaths);
- g_pGEModule->m_pFontMgr = new CFX_FontMgr;
- g_pGEModule->InitPlatform();
- g_pGEModule->SetTextGamma(2.2f);
-}
-void CFX_GEModule::Use(CFX_GEModule* pModule) {
- g_pGEModule = pModule;
-}
+
+// static
void CFX_GEModule::Destroy() {
+ ASSERT(g_pGEModule);
delete g_pGEModule;
g_pGEModule = nullptr;
}
+
CFX_FontCache* CFX_GEModule::GetFontCache() {
- if (!m_pFontCache) {
+ if (!m_pFontCache)
m_pFontCache = new CFX_FontCache();
- }
return m_pFontCache;
}
+
void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) {
gammaValue /= 2.2f;
- int i = 0;
- while (i < 256) {
- m_GammaValue[i] =
- (uint8_t)(FXSYS_pow((FX_FLOAT)i / 255, gammaValue) * 255.0f + 0.5f);
- i++;
+ for (int i = 0; i < 256; ++i) {
+ m_GammaValue[i] = static_cast<uint8_t>(
+ FXSYS_pow(static_cast<FX_FLOAT>(i) / 255, gammaValue) * 255.0f + 0.5f);
}
}
-const uint8_t* CFX_GEModule::GetTextGammaTable() {
+
+const uint8_t* CFX_GEModule::GetTextGammaTable() const {
return m_GammaValue;
}
diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h
index 9114b47008..538afdb581 100644
--- a/core/fxge/include/fx_ge.h
+++ b/core/fxge/include/fx_ge.h
@@ -7,6 +7,8 @@
#ifndef CORE_FXGE_INCLUDE_FX_GE_H_
#define CORE_FXGE_INCLUDE_FX_GE_H_
+#include <memory>
+
#include "core/fxge/include/fx_dib.h"
#include "core/fxge/include/fx_font.h"
@@ -16,42 +18,37 @@ class CFX_Font;
class CFX_FontCache;
class CFX_FontMgr;
class CPDF_ShadingPattern;
-class CPSFont;
class IFX_RenderDeviceDriver;
class SkPictureRecorder;
class CFX_GEModule {
public:
- static void Create(const char** pUserFontPaths);
- static void Use(CFX_GEModule* pMgr);
+ static void Create(const char** pUserFontPaths,
+ CCodec_ModuleMgr* pCodecModule);
static CFX_GEModule* Get();
static void Destroy();
CFX_FontCache* GetFontCache();
- CFX_FontMgr* GetFontMgr() { return m_pFontMgr; }
+ CFX_FontMgr* GetFontMgr() { return m_pFontMgr.get(); }
void SetTextGamma(FX_FLOAT gammaValue);
- const uint8_t* GetTextGammaTable();
+ const uint8_t* GetTextGammaTable() const;
- void SetCodecModule(CCodec_ModuleMgr* pCodecModule) {
- m_pCodecModule = pCodecModule;
- }
CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; }
void* GetPlatformData() { return m_pPlatformData; }
FXFT_Library m_FTLibrary;
- protected:
- explicit CFX_GEModule(const char** pUserFontPaths);
+ private:
+ CFX_GEModule(const char** pUserFontPaths, CCodec_ModuleMgr* pCodecModule);
~CFX_GEModule();
void InitPlatform();
void DestroyPlatform();
- private:
uint8_t m_GammaValue[256];
CFX_FontCache* m_pFontCache;
- CFX_FontMgr* m_pFontMgr;
- CCodec_ModuleMgr* m_pCodecModule;
+ std::unique_ptr<CFX_FontMgr> m_pFontMgr;
+ CCodec_ModuleMgr* const m_pCodecModule;
void* m_pPlatformData;
const char** m_pUserFontPaths;
};
@@ -62,14 +59,6 @@ struct FX_PATHPOINT {
int m_Flag;
};
-#define FXPT_CLOSEFIGURE 0x01
-#define FXPT_LINETO 0x02
-#define FXPT_BEZIERTO 0x04
-#define FXPT_MOVETO 0x06
-#define FXPT_TYPE 0x06
-#define FXFILL_ALTERNATE 1
-#define FXFILL_WINDING 2
-
class CFX_ClipRgn {
public:
enum ClipType { RectI, MaskF };
@@ -168,6 +157,13 @@ class CFX_GraphStateData {
#define FXDC_RENDER_CAPS 7
#define FXDC_DISPLAY 1
#define FXDC_PRINTER 2
+
+#define FXPT_CLOSEFIGURE 0x01
+#define FXPT_LINETO 0x02
+#define FXPT_BEZIERTO 0x04
+#define FXPT_MOVETO 0x06
+#define FXPT_TYPE 0x06
+
#define FXRC_GET_BITS 0x01
#define FXRC_BIT_MASK 0x02
#define FXRC_ALPHA_MASK 0x04
@@ -182,6 +178,7 @@ class CFX_GraphStateData {
#define FXRENDER_IMAGE_LOSSY 0x1000
#define FXRC_FILLSTROKE_PATH 0x2000
#define FXRC_SHADING 0x4000
+
#define FXFILL_ALTERNATE 1
#define FXFILL_WINDING 2
#define FXFILL_FULLCOVER 4
@@ -192,6 +189,7 @@ class CFX_GraphStateData {
#define FX_FILL_TEXT_MODE 128
#define FX_ZEROAREA_FILL 256
#define FXFILL_NOPATHSMOOTH 512
+
#define FXTEXT_CLEARTYPE 0x01
#define FXTEXT_BGR_STRIPE 0x02
#define FXTEXT_PRINTGRAPHICTEXT 0x04
@@ -201,12 +199,15 @@ class CFX_GraphStateData {
struct FXTEXT_CHARPOS {
uint32_t m_GlyphIndex;
- FX_FLOAT m_OriginX, m_OriginY;
+ FX_FLOAT m_OriginX;
+ FX_FLOAT m_OriginY;
int m_FontCharWidth;
FX_BOOL m_bGlyphAdjust;
FX_FLOAT m_AdjustMatrix[4];
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
uint32_t m_ExtGID;
- FX_BOOL m_bFontStyle;
+#endif
+ bool m_bFontStyle;
};
class CFX_RenderDevice {