summaryrefslogtreecommitdiff
path: root/core/fxge/ge
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge/ge')
-rw-r--r--core/fxge/ge/fx_ge_device.cpp33
-rw-r--r--core/fxge/ge/fx_ge_fontmap.cpp17
-rw-r--r--core/fxge/ge/fx_ge_path.cpp67
-rw-r--r--core/fxge/ge/fx_ge_text.cpp4
-rw-r--r--core/fxge/ge/fx_text_int.h60
5 files changed, 95 insertions, 86 deletions
diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp
index f1f7dc021d..adf68a8749 100644
--- a/core/fxge/ge/fx_ge_device.cpp
+++ b/core/fxge/ge/fx_ge_device.cpp
@@ -6,18 +6,25 @@
#include "core/fxge/include/fx_ge.h"
-CFX_RenderDevice::CFX_RenderDevice() {
- m_pDeviceDriver = nullptr;
- m_pBitmap = nullptr;
-}
+CFX_RenderDevice::CFX_RenderDevice()
+ : m_pBitmap(nullptr),
+ m_Width(0),
+ m_Height(0),
+ m_bpp(0),
+ m_RenderCaps(0),
+ m_DeviceClass(0),
+ m_pDeviceDriver(nullptr) {}
+
CFX_RenderDevice::~CFX_RenderDevice() {
delete m_pDeviceDriver;
}
+
void CFX_RenderDevice::SetDeviceDriver(IFX_RenderDeviceDriver* pDriver) {
delete m_pDeviceDriver;
m_pDeviceDriver = pDriver;
InitDeviceInfo();
}
+
void CFX_RenderDevice::InitDeviceInfo() {
m_Width = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_WIDTH);
m_Height = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_HEIGHT);
@@ -31,12 +38,15 @@ void CFX_RenderDevice::InitDeviceInfo() {
m_ClipBox.bottom = m_Height;
}
}
+
FX_BOOL CFX_RenderDevice::StartRendering() {
return m_pDeviceDriver->StartRendering();
}
+
void CFX_RenderDevice::EndRendering() {
m_pDeviceDriver->EndRendering();
}
+
void CFX_RenderDevice::SaveState() {
m_pDeviceDriver->SaveState();
}
@@ -52,6 +62,7 @@ int CFX_RenderDevice::GetDeviceCaps(int caps_id) const {
CFX_Matrix CFX_RenderDevice::GetCTM() const {
return m_pDeviceDriver->GetCTM();
}
+
FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB,
int width,
int height) const {
@@ -72,6 +83,7 @@ FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB,
width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb);
#endif
}
+
FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode) {
@@ -82,6 +94,7 @@ FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData,
UpdateClipBox();
return TRUE;
}
+
FX_BOOL CFX_RenderDevice::SetClip_PathStroke(
const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
@@ -93,6 +106,7 @@ FX_BOOL CFX_RenderDevice::SetClip_PathStroke(
UpdateClipBox();
return TRUE;
}
+
FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) {
CFX_PathData path;
path.AppendRect(rect.left, rect.bottom, rect.right, rect.top);
@@ -102,6 +116,7 @@ FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) {
UpdateClipBox();
return TRUE;
}
+
void CFX_RenderDevice::UpdateClipBox() {
if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) {
return;
@@ -421,6 +436,16 @@ FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap,
FXDIB_BLEND_NORMAL);
}
+FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap,
+ int left,
+ int top,
+ int dest_width,
+ int dest_height,
+ uint32_t color) {
+ return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height,
+ color, 0);
+}
+
FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap,
int left,
int top,
diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp
index fa53898ecc..81e3137913 100644
--- a/core/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/fxge/ge/fx_ge_fontmap.cpp
@@ -9,8 +9,9 @@
#include <utility>
#include <vector>
+#include "core/fxge/include/fx_font.h"
+
#include "core/fxge/fontdata/chromefontdata/chromefontdata.h"
-#include "core/fxge/ge/fx_text_int.h"
#include "core/fxge/include/fx_freetype.h"
#include "core/fxge/include/fx_ge.h"
#include "third_party/base/stl_util.h"
@@ -1358,7 +1359,21 @@ std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault(
}
#endif
+CFX_FontFaceInfo::CFX_FontFaceInfo(CFX_ByteString filePath,
+ CFX_ByteString faceName,
+ CFX_ByteString fontTables,
+ uint32_t fontOffset,
+ uint32_t fileSize)
+ : m_FilePath(filePath),
+ m_FaceName(faceName),
+ m_FontTables(fontTables),
+ m_FontOffset(fontOffset),
+ m_FileSize(fileSize),
+ m_Styles(0),
+ m_Charsets(0) {}
+
CFX_FolderFontInfo::CFX_FolderFontInfo() {}
+
CFX_FolderFontInfo::~CFX_FolderFontInfo() {
for (const auto& pair : m_FontList) {
delete pair.second;
diff --git a/core/fxge/ge/fx_ge_path.cpp b/core/fxge/ge/fx_ge_path.cpp
index 6eb41d3094..468d80eeec 100644
--- a/core/fxge/ge/fx_ge_path.cpp
+++ b/core/fxge/ge/fx_ge_path.cpp
@@ -8,27 +8,25 @@
#include "core/fxge/include/fx_ge.h"
#include "third_party/base/numerics/safe_math.h"
-CFX_ClipRgn::CFX_ClipRgn(int width, int height) {
- m_Type = RectI;
- m_Box.left = m_Box.top = 0;
- m_Box.right = width;
- m_Box.bottom = height;
-}
-CFX_ClipRgn::CFX_ClipRgn(const FX_RECT& rect) {
- m_Type = RectI;
- m_Box = rect;
-}
+CFX_ClipRgn::CFX_ClipRgn(int width, int height)
+ : m_Type(RectI), m_Box(0, 0, width, height) {}
+
+CFX_ClipRgn::CFX_ClipRgn(const FX_RECT& rect) : m_Type(RectI), m_Box(rect) {}
+
CFX_ClipRgn::CFX_ClipRgn(const CFX_ClipRgn& src) {
m_Type = src.m_Type;
m_Box = src.m_Box;
m_Mask = src.m_Mask;
}
+
CFX_ClipRgn::~CFX_ClipRgn() {}
+
void CFX_ClipRgn::Reset(const FX_RECT& rect) {
m_Type = RectI;
m_Box = rect;
m_Mask.SetNull();
}
+
void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) {
if (m_Type == RectI) {
m_Box.Intersect(rect);
@@ -39,6 +37,7 @@ void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) {
return;
}
}
+
void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect,
FX_RECT mask_rect,
CFX_DIBitmapRef Mask) {
@@ -69,6 +68,7 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect,
}
}
}
+
void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
const CFX_DIBitmap* mask_dib = Mask.GetObject();
ASSERT(mask_dib->GetFormat() == FXDIB_8bppMask);
@@ -112,13 +112,14 @@ void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
}
ASSERT(FALSE);
}
-CFX_PathData::CFX_PathData() {
- m_PointCount = m_AllocCount = 0;
- m_pPoints = nullptr;
-}
+
+CFX_PathData::CFX_PathData()
+ : m_PointCount(0), m_pPoints(nullptr), m_AllocCount(0) {}
+
CFX_PathData::~CFX_PathData() {
FX_Free(m_pPoints);
}
+
void CFX_PathData::SetPointCount(int nPoints) {
m_PointCount = nPoints;
if (m_AllocCount < nPoints) {
@@ -127,6 +128,7 @@ void CFX_PathData::SetPointCount(int nPoints) {
m_AllocCount = nPoints;
}
}
+
void CFX_PathData::AllocPointCount(int nPoints) {
if (m_AllocCount < nPoints) {
FX_PATHPOINT* pNewBuf = FX_Alloc(FX_PATHPOINT, nPoints);
@@ -138,17 +140,20 @@ void CFX_PathData::AllocPointCount(int nPoints) {
m_AllocCount = nPoints;
}
}
+
CFX_PathData::CFX_PathData(const CFX_PathData& src) {
m_PointCount = m_AllocCount = src.m_PointCount;
m_pPoints = FX_Alloc(FX_PATHPOINT, src.m_PointCount);
FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount);
}
+
void CFX_PathData::TrimPoints(int nPoints) {
if (m_PointCount <= nPoints) {
return;
}
SetPointCount(nPoints);
}
+
void CFX_PathData::AddPointCount(int addPoints) {
pdfium::base::CheckedNumeric<int> safe_new_count = m_PointCount;
safe_new_count += addPoints;
@@ -156,6 +161,7 @@ void CFX_PathData::AddPointCount(int addPoints) {
AllocPointCount(new_count);
m_PointCount = new_count;
}
+
void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
int old_count = m_PointCount;
AddPointCount(pSrc->m_PointCount);
@@ -168,12 +174,14 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
}
}
}
+
void CFX_PathData::SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag) {
ASSERT(index < m_PointCount);
m_pPoints[index].m_PointX = x;
m_pPoints[index].m_PointY = y;
m_pPoints[index].m_Flag = flag;
}
+
void CFX_PathData::AppendRect(FX_FLOAT left,
FX_FLOAT bottom,
FX_FLOAT right,
@@ -189,6 +197,7 @@ void CFX_PathData::AppendRect(FX_FLOAT left,
pPoints[1].m_Flag = pPoints[2].m_Flag = pPoints[3].m_Flag = FXPT_LINETO;
pPoints[4].m_Flag = FXPT_LINETO | FXPT_CLOSEFIGURE;
}
+
CFX_FloatRect CFX_PathData::GetBoundingBox() const {
CFX_FloatRect rect;
if (m_PointCount) {
@@ -199,6 +208,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox() const {
}
return rect;
}
+
static void _UpdateLineEndPoints(CFX_FloatRect& rect,
FX_FLOAT start_x,
FX_FLOAT start_y,
@@ -242,6 +252,7 @@ static void _UpdateLineEndPoints(CFX_FloatRect& rect,
rect.UpdateRect(mx - dx1, my + dy1);
rect.UpdateRect(mx + dx1, my - dy1);
}
+
static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
FX_FLOAT start_x,
FX_FLOAT start_y,
@@ -334,6 +345,7 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
FX_FLOAT join_y = (start_k * join_x) + start_outside_c;
rect.UpdateRect(join_x, join_y);
}
+
CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
FX_FLOAT miter_limit) const {
CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f,
@@ -384,6 +396,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
}
return rect;
}
+
void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
if (!pMatrix) {
return;
@@ -392,6 +405,7 @@ void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY);
}
}
+
FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath,
CFX_Matrix* pMatrix,
FX_BOOL& bThin,
@@ -536,6 +550,7 @@ FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath,
}
return TRUE;
}
+
FX_BOOL CFX_PathData::IsRect() const {
if (m_PointCount != 5 && m_PointCount != 4) {
return FALSE;
@@ -563,6 +578,7 @@ FX_BOOL CFX_PathData::IsRect() const {
}
return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE);
}
+
FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
CFX_FloatRect* pRect) const {
if (!pMatrix) {
@@ -613,23 +629,26 @@ FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
}
return TRUE;
}
+
void CFX_PathData::Copy(const CFX_PathData& src) {
SetPointCount(src.m_PointCount);
FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount);
}
-CFX_GraphStateData::CFX_GraphStateData() {
- m_LineCap = LineCapButt;
- m_DashCount = 0;
- m_DashArray = nullptr;
- m_DashPhase = 0;
- m_LineJoin = LineJoinMiter;
- m_MiterLimit = 10 * 1.0f;
- m_LineWidth = 1.0f;
-}
+
+CFX_GraphStateData::CFX_GraphStateData()
+ : m_LineCap(LineCapButt),
+ m_DashCount(0),
+ m_DashArray(nullptr),
+ m_DashPhase(0),
+ m_LineJoin(LineJoinMiter),
+ m_MiterLimit(10 * 1.0f),
+ m_LineWidth(1.0f) {}
+
CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) {
m_DashArray = nullptr;
Copy(src);
}
+
void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) {
m_LineCap = src.m_LineCap;
m_DashCount = src.m_DashCount;
@@ -644,9 +663,11 @@ void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) {
FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT));
}
}
+
CFX_GraphStateData::~CFX_GraphStateData() {
FX_Free(m_DashArray);
}
+
void CFX_GraphStateData::SetDashCount(int count) {
FX_Free(m_DashArray);
m_DashArray = nullptr;
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index 6b456c2eaa..cf349eb9c0 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -933,12 +933,16 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont,
bFontStyle, dest_width, anti_alias);
#endif
}
+
+CFX_SizeGlyphCache::CFX_SizeGlyphCache() {}
+
CFX_SizeGlyphCache::~CFX_SizeGlyphCache() {
for (const auto& pair : m_GlyphMap) {
delete pair.second;
}
m_GlyphMap.clear();
}
+
#define CONTRAST_RAMP_STEP 1
void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) {
FXFT_MM_Var pMasters = nullptr;
diff --git a/core/fxge/ge/fx_text_int.h b/core/fxge/ge/fx_text_int.h
index 2ca23217c7..87a9b3eced 100644
--- a/core/fxge/ge/fx_text_int.h
+++ b/core/fxge/ge/fx_text_int.h
@@ -17,68 +17,12 @@ struct _CFX_UniqueKeyGen {
FX_CHAR m_Key[128];
int m_KeyLen;
};
+
class CFX_SizeGlyphCache {
public:
- CFX_SizeGlyphCache() {}
+ CFX_SizeGlyphCache();
~CFX_SizeGlyphCache();
std::map<uint32_t, CFX_GlyphBitmap*> m_GlyphMap;
};
-class CTTFontDesc {
- public:
- CTTFontDesc() {
- m_Type = 0;
- m_pFontData = nullptr;
- m_RefCount = 0;
- }
- ~CTTFontDesc();
- // ret < 0, releaseface not appropriate for this object.
- // ret == 0, object released
- // ret > 0, object still alive, other referrers.
- int ReleaseFace(FXFT_Face face);
- int m_Type;
- union {
- struct {
- FX_BOOL m_bItalic;
- FX_BOOL m_bBold;
- FXFT_Face m_pFace;
- } m_SingleFace;
- struct {
- FXFT_Face m_pFaces[16];
- } m_TTCFace;
- };
- uint8_t* m_pFontData;
- int m_RefCount;
-};
-
-#define CHARSET_FLAG_ANSI 1
-#define CHARSET_FLAG_SYMBOL 2
-#define CHARSET_FLAG_SHIFTJIS 4
-#define CHARSET_FLAG_BIG5 8
-#define CHARSET_FLAG_GB 16
-#define CHARSET_FLAG_KOREAN 32
-
-class CFX_FontFaceInfo {
- public:
- CFX_FontFaceInfo(CFX_ByteString filePath,
- CFX_ByteString faceName,
- CFX_ByteString fontTables,
- uint32_t fontOffset,
- uint32_t fileSize)
- : m_FilePath(filePath),
- m_FaceName(faceName),
- m_FontTables(fontTables),
- m_FontOffset(fontOffset),
- m_FileSize(fileSize),
- m_Styles(0),
- m_Charsets(0) {}
-
- const CFX_ByteString m_FilePath;
- const CFX_ByteString m_FaceName;
- const CFX_ByteString m_FontTables;
- const uint32_t m_FontOffset;
- const uint32_t m_FileSize;
- uint32_t m_Styles;
- uint32_t m_Charsets;
-};
#endif // CORE_FXGE_GE_FX_TEXT_INT_H_