diff options
author | weili <weili@chromium.org> | 2016-06-14 17:21:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-14 17:21:14 -0700 |
commit | f4bb580add3824196dc49cd7de2f7d051019ede8 (patch) | |
tree | 15c1db6fb7000330d48c105c66acf1d468ba56bd /core/fxge | |
parent | ee2abec93f22bd10522181dc0362f24d389fc66b (diff) | |
download | pdfium-f4bb580add3824196dc49cd7de2f7d051019ede8.tar.xz |
Make code compile with clang_use_chrome_plugin (part II)
This change contains files in core directory which were not covered
in part I. This is part of the efforts to make PDFium code compilable
by Clang chromium style plugins.
The changes are mainly the following:
-- move inline constructor/destructor of complex class/struct out-of-line;
-- add constructor/destructor of complex class/struct if not
explicitly defined;
-- add explicit out-of-line copy constructor when needed;
-- move inline virtual functions out-of-line;
-- Properly mark virtual functions with 'override';
-- some minor cleanups;
BUG=pdfium:469
Review-Url: https://codereview.chromium.org/2060913003
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/agg/fx_agg_driver.cpp | 94 | ||||
-rw-r--r-- | core/fxge/agg/fx_agg_driver.h | 6 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_device.cpp | 33 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_fontmap.cpp | 17 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_path.cpp | 67 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_text.cpp | 4 | ||||
-rw-r--r-- | core/fxge/ge/fx_text_int.h | 60 | ||||
-rw-r--r-- | core/fxge/include/fx_font.h | 52 | ||||
-rw-r--r-- | core/fxge/include/fx_ge.h | 85 | ||||
-rw-r--r-- | core/fxge/include/fx_ge_win32.h | 25 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 14 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_dib.cpp | 15 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_dwrite.cpp | 81 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 82 | ||||
-rw-r--r-- | core/fxge/win32/win32_int.h | 6 |
15 files changed, 413 insertions, 228 deletions
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 554c79f349..f5d7cbbf4c 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -425,6 +425,88 @@ IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver( bGroupKnockout); } +IFX_RenderDeviceDriver::~IFX_RenderDeviceDriver() {} + +CFX_Matrix IFX_RenderDeviceDriver::GetCTM() const { + return CFX_Matrix(); +} + +FX_BOOL IFX_RenderDeviceDriver::StartRendering() { + return TRUE; +} + +void IFX_RenderDeviceDriver::EndRendering() {} + +FX_BOOL IFX_RenderDeviceDriver::SetClip_PathStroke( + const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState) { + return FALSE; +} + +FX_BOOL IFX_RenderDeviceDriver::SetPixel(int x, int y, uint32_t color) { + return FALSE; +} + +FX_BOOL IFX_RenderDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, + uint32_t fill_color, + int blend_type) { + return FALSE; +} + +FX_BOOL IFX_RenderDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + uint32_t color, + int blend_type) { + return FALSE; +} + +FX_BOOL IFX_RenderDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, + int left, + int top) { + return FALSE; +} +CFX_DIBitmap* IFX_RenderDeviceDriver::GetBackDrop() { + return nullptr; +} + +FX_BOOL IFX_RenderDeviceDriver::ContinueDIBits(void* handle, + IFX_Pause* pPause) { + return FALSE; +} + +void IFX_RenderDeviceDriver::CancelDIBits(void* handle) {} + +FX_BOOL IFX_RenderDeviceDriver::DrawDeviceText(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + const CFX_Matrix* pObject2Device, + FX_FLOAT font_size, + uint32_t color) { + return FALSE; +} + +void* IFX_RenderDeviceDriver::GetPlatformSurface() const { + return nullptr; +} + +int IFX_RenderDeviceDriver::GetDriverType() const { + return 0; +} + +void IFX_RenderDeviceDriver::ClearDriver() {} + +FX_BOOL IFX_RenderDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, + const CFX_Matrix* pMatrix, + const FX_RECT& clip_rect, + int alpha, + FX_BOOL bAlphaMode) { + return false; +} + CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, @@ -452,6 +534,10 @@ uint8_t* CFX_AggDeviceDriver::GetBuffer() const { return m_pBitmap->GetBuffer(); } +const CFX_DIBitmap* CFX_AggDeviceDriver::GetBitmap() const { + return m_pBitmap; +} + #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ void CFX_AggDeviceDriver::InitPlatform() {} @@ -1435,6 +1521,10 @@ class CFX_Renderer { } }; +int CFX_AggDeviceDriver::GetDriverType() const { + return 1; +} + FX_BOOL CFX_AggDeviceDriver::RenderRasterizer( agg::rasterizer_scanline_aa& rasterizer, uint32_t color, @@ -1645,6 +1735,10 @@ FX_BOOL CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, return bRet; } +CFX_DIBitmap* CFX_AggDeviceDriver::GetBackDrop() { + return m_pOriDevice; +} + FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, uint32_t argb, const FX_RECT* pSrcRect, diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index 48d6fae87f..7c2e98047f 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h @@ -59,7 +59,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { int blend_type) override; FX_BOOL GetClipBox(FX_RECT* pRect) override; FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override; - CFX_DIBitmap* GetBackDrop() override { return m_pOriDevice; } + CFX_DIBitmap* GetBackDrop() override; FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, const FX_RECT* pSrcRect, @@ -91,7 +91,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { const CFX_Matrix* pObject2Device, FX_FLOAT font_size, uint32_t color) override; - int GetDriverType() const override { return 1; } + int GetDriverType() const override; FX_BOOL RenderRasterizer(agg::rasterizer_scanline_aa& rasterizer, uint32_t color, @@ -103,7 +103,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { void SetClipMask(agg::rasterizer_scanline_aa& rasterizer); virtual uint8_t* GetBuffer() const; - const CFX_DIBitmap* GetBitmap() const { return m_pBitmap; } + const CFX_DIBitmap* GetBitmap() const; private: CFX_DIBitmap* m_pBitmap; 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_ diff --git a/core/fxge/include/fx_font.h b/core/fxge/include/fx_font.h index b38ecaed33..17adc7ac9c 100644 --- a/core/fxge/include/fx_font.h +++ b/core/fxge/include/fx_font.h @@ -19,7 +19,6 @@ typedef struct FT_FaceRec_* FXFT_Face; typedef void* FXFT_Library; class CFX_FaceCache; -class CFX_FontFaceInfo; class CFX_FontMapper; class CFX_PathData; class CFX_SizeGlyphCache; @@ -65,6 +64,13 @@ using CFX_TypeFace = SkTypeface; #define FXFONT_FW_NORMAL 400 #define FXFONT_FW_BOLD 700 +#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_Font { public: CFX_Font(); @@ -379,6 +385,50 @@ class IFX_SystemFontInfo { virtual void* RetainFont(void* hFont); }; +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; +}; + +class CFX_FontFaceInfo { + public: + CFX_FontFaceInfo(CFX_ByteString filePath, + CFX_ByteString faceName, + CFX_ByteString fontTables, + uint32_t fontOffset, + uint32_t fileSize); + + 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; +}; + class CFX_FolderFontInfo : public IFX_SystemFontInfo { public: CFX_FolderFontInfo(); diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h index b2e2b455e4..9114b47008 100644 --- a/core/fxge/include/fx_ge.h +++ b/core/fxge/include/fx_ge.h @@ -36,9 +36,10 @@ class CFX_GEModule { m_pCodecModule = pCodecModule; } CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; } - FXFT_Library m_FTLibrary; void* GetPlatformData() { return m_pPlatformData; } + FXFT_Library m_FTLibrary; + protected: explicit CFX_GEModule(const char** pUserFontPaths); ~CFX_GEModule(); @@ -71,16 +72,18 @@ struct FX_PATHPOINT { class CFX_ClipRgn { public: + enum ClipType { RectI, MaskF }; + CFX_ClipRgn(int device_width, int device_height); explicit CFX_ClipRgn(const FX_RECT& rect); CFX_ClipRgn(const CFX_ClipRgn& src); ~CFX_ClipRgn(); - enum ClipType { RectI, MaskF }; - void Reset(const FX_RECT& rect); ClipType GetType() const { return m_Type; } const FX_RECT& GetBox() const { return m_Box; } CFX_DIBitmapRef GetMask() const { return m_Mask; } + + void Reset(const FX_RECT& rect); void IntersectRect(const FX_RECT& rect); void IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask); @@ -103,6 +106,7 @@ class CFX_PathData { FX_FLOAT GetPointX(int index) const { return m_pPoints[index].m_PointX; } FX_FLOAT GetPointY(int index) const { return m_pPoints[index].m_PointY; } FX_PATHPOINT* GetPoints() const { return m_pPoints; } + void SetPointCount(int nPoints); void AllocPointCount(int nPoints); void AddPointCount(int addPoints); @@ -131,6 +135,8 @@ class CFX_PathData { class CFX_GraphStateData { public: + enum LineCap { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 }; + CFX_GraphStateData(); CFX_GraphStateData(const CFX_GraphStateData& src); ~CFX_GraphStateData(); @@ -138,7 +144,6 @@ class CFX_GraphStateData { void Copy(const CFX_GraphStateData& src); void SetDashCount(int count); - enum LineCap { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 }; LineCap m_LineCap; int m_DashCount; FX_FLOAT* m_DashArray; @@ -216,6 +221,7 @@ class CFX_RenderDevice { void EndRendering(); void SaveState(); void RestoreState(bool bKeepSaved); + int GetWidth() const { return m_Width; } int GetHeight() const { return m_Height; } int GetDeviceClass() const { return m_DeviceClass; } @@ -308,10 +314,7 @@ class CFX_RenderDevice { int top, int dest_width, int dest_height, - uint32_t color) { - return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height, - color, 0); - } + uint32_t color); FX_BOOL StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, int left, int top, @@ -421,35 +424,29 @@ class CFX_FxgeDevice : public CFX_RenderDevice { class IFX_RenderDeviceDriver { public: + virtual ~IFX_RenderDeviceDriver(); + static IFX_RenderDeviceDriver* CreateFxgeDriver(CFX_DIBitmap* pBitmap, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout); - virtual ~IFX_RenderDeviceDriver() {} virtual int GetDeviceCaps(int caps_id) = 0; - virtual CFX_Matrix GetCTM() const { return CFX_Matrix(); } - - virtual FX_BOOL StartRendering() { return TRUE; } - - virtual void EndRendering() {} + virtual CFX_Matrix GetCTM() const; + virtual FX_BOOL StartRendering(); + virtual void EndRendering(); virtual void SaveState() = 0; - virtual void RestoreState(bool bKeepSaved) = 0; virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device, int fill_mode) = 0; - virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState) { - return FALSE; - } - + const CFX_GraphStateData* pGraphState); virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, @@ -457,38 +454,26 @@ class IFX_RenderDeviceDriver { uint32_t stroke_color, int fill_mode, int blend_type) = 0; - - virtual FX_BOOL SetPixel(int x, int y, uint32_t color) { return FALSE; } - + virtual FX_BOOL SetPixel(int x, int y, uint32_t color); virtual FX_BOOL FillRectWithBlend(const FX_RECT* pRect, uint32_t fill_color, - int blend_type) { - return FALSE; - } - + int blend_type); virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, uint32_t color, - int blend_type) { - return FALSE; - } + int blend_type); virtual FX_BOOL GetClipBox(FX_RECT* pRect) = 0; - - virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { - return FALSE; - } - virtual CFX_DIBitmap* GetBackDrop() { return nullptr; } - + virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top); + virtual CFX_DIBitmap* GetBackDrop(); virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, const FX_RECT* pSrcRect, int dest_left, int dest_top, int blend_type) = 0; - virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, @@ -498,7 +483,6 @@ class IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int blend_type) = 0; - virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, uint32_t color, @@ -506,34 +490,23 @@ class IFX_RenderDeviceDriver { uint32_t flags, void*& handle, int blend_type) = 0; - - virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) { - return FALSE; - } - - virtual void CancelDIBits(void* handle) {} - + virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause); + virtual void CancelDIBits(void* handle); virtual FX_BOOL DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, CFX_FontCache* pCache, const CFX_Matrix* pObject2Device, FX_FLOAT font_size, - uint32_t color) { - return FALSE; - } - - virtual void* GetPlatformSurface() const { return nullptr; } - virtual int GetDriverType() const { return 0; } - virtual void ClearDriver() {} - + uint32_t color); + virtual void* GetPlatformSurface() const; + virtual int GetDriverType() const; + virtual void ClearDriver(); virtual FX_BOOL DrawShading(const CPDF_ShadingPattern* pPattern, const CFX_Matrix* pMatrix, const FX_RECT& clip_rect, int alpha, - FX_BOOL bAlphaMode) { - return false; - } + FX_BOOL bAlphaMode); }; #endif // CORE_FXGE_INCLUDE_FX_GE_H_ diff --git a/core/fxge/include/fx_ge_win32.h b/core/fxge/include/fx_ge_win32.h index e7207a5f70..703093d92f 100644 --- a/core/fxge/include/fx_ge_win32.h +++ b/core/fxge/include/fx_ge_win32.h @@ -25,42 +25,29 @@ typedef struct WINDIB_Open_Args_ { class CFX_WindowsDIB : public CFX_DIBitmap { public: - static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap); + CFX_WindowsDIB(HDC hDC, int width, int height); + ~CFX_WindowsDIB() override; + static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap); static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData); - static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC); - static CFX_DIBitmap* LoadFromDDB(HDC hDC, HBITMAP hBitmap, uint32_t* pPalette = nullptr, uint32_t size = 256); - static CFX_DIBitmap* LoadFromFile(const FX_WCHAR* filename); - - static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename) { - return LoadFromFile(CFX_WideString::FromLocal(filename).c_str()); - } - + static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename); static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); - CFX_WindowsDIB(HDC hDC, int width, int height); - - ~CFX_WindowsDIB(); - HDC GetDC() const { return m_hMemDC; } - HBITMAP GetWindowsBitmap() const { return m_hBitmap; } void LoadFromDevice(HDC hDC, int left, int top); - void SetToDevice(HDC hDC, int left, int top); protected: HDC m_hMemDC; - HBITMAP m_hBitmap; - HBITMAP m_hOldBitmap; }; @@ -69,7 +56,7 @@ class CFX_WindowsDevice : public CFX_RenderDevice { static IFX_RenderDeviceDriver* CreateDriver(HDC hDC); explicit CFX_WindowsDevice(HDC hDC); - ~CFX_WindowsDevice(); + ~CFX_WindowsDevice() override; HDC GetDC() const; }; @@ -77,7 +64,7 @@ class CFX_WindowsDevice : public CFX_RenderDevice { class CFX_WinBitmapDevice : public CFX_RenderDevice { public: CFX_WinBitmapDevice(int width, int height, FXDIB_Format format); - ~CFX_WinBitmapDevice(); + ~CFX_WinBitmapDevice() override; HDC GetDC() { return m_hDC; } diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index c2084f2877..2df5c1c4ce 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -939,6 +939,10 @@ FX_BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect) { return ::GetClipBox(m_hDC, (RECT*)pRect); } +void* CGdiDeviceDriver::GetPlatformSurface() const { + return (void*)m_hDC; +} + void CGdiDeviceDriver::DrawLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, @@ -1363,6 +1367,16 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, dest_height, flags, nullptr); } +FX_BOOL CGdiDisplayDriver::StartDIBits(const CFX_DIBSource* pBitmap, + int bitmap_alpha, + uint32_t color, + const CFX_Matrix* pMatrix, + uint32_t render_flags, + void*& handle, + int blend_type) { + return FALSE; +} + CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { SetDeviceDriver(CreateDriver(hDC)); } diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index 7221d10536..0e79399357 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -51,6 +51,7 @@ CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) { result.ReleaseBuffer(len); return result; } + CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha) { @@ -97,21 +98,25 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, } return pBitmap; } + CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) { return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE); } + HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) { CFX_ByteString info = GetBitmapInfo(pBitmap); return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); } + void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) { BITMAP bmp; GetObject(hBitmap, sizeof bmp, &bmp); w = bmp.bmWidth; h = bmp.bmHeight; } + CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) { CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); @@ -145,6 +150,11 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) { DeleteDC(hDC); return pDIBitmap; } + +CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_CHAR* filename) { + return LoadFromFile(CFX_WideString::FromLocal(filename).c_str()); +} + CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) { CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); @@ -178,6 +188,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) { DeleteDC(hDC); return pDIBitmap; } + CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, HBITMAP hBitmap, uint32_t* pPalette, @@ -259,6 +270,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, } return pDIBitmap; } + CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) { Create(width, height, FXDIB_Rgb, (uint8_t*)1); BITMAPINFOHEADER bmih; @@ -273,14 +285,17 @@ CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) { m_hMemDC = CreateCompatibleDC(hDC); m_hOldBitmap = (HBITMAP)SelectObject(m_hMemDC, m_hBitmap); } + CFX_WindowsDIB::~CFX_WindowsDIB() { SelectObject(m_hMemDC, m_hOldBitmap); DeleteDC(m_hMemDC); DeleteObject(m_hBitmap); } + void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) { ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); } + void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) { ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); } diff --git a/core/fxge/win32/fx_win32_dwrite.cpp b/core/fxge/win32/fx_win32_dwrite.cpp index 5f620cba4c..b3ba28cfc7 100644 --- a/core/fxge/win32/fx_win32_dwrite.cpp +++ b/core/fxge/win32/fx_win32_dwrite.cpp @@ -30,22 +30,29 @@ inline InterfaceType* SafeAcquire(InterfaceType* newObject) { } return newObject; } + class CDwFontFileStream final : public IDWriteFontFileStream { public: explicit CDwFontFileStream(void const* fontFileReferenceKey, UINT32 fontFileReferenceKeySize); - virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, - void** ppvObject); - virtual ULONG STDMETHODCALLTYPE AddRef(); - virtual ULONG STDMETHODCALLTYPE Release(); - virtual HRESULT STDMETHODCALLTYPE + + // IUnknown. + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, + void** ppvObject) override; + ULONG STDMETHODCALLTYPE AddRef() override; + ULONG STDMETHODCALLTYPE Release() override; + + // IDWriteFontFileStream. + HRESULT STDMETHODCALLTYPE ReadFileFragment(void const** fragmentStart, UINT64 fileOffset, UINT64 fragmentSize, - OUT void** fragmentContext); - virtual void STDMETHODCALLTYPE ReleaseFileFragment(void* fragmentContext); - virtual HRESULT STDMETHODCALLTYPE GetFileSize(OUT UINT64* fileSize); - virtual HRESULT STDMETHODCALLTYPE GetLastWriteTime(OUT UINT64* lastWriteTime); + OUT void** fragmentContext) override; + void STDMETHODCALLTYPE ReleaseFileFragment(void* fragmentContext) override; + HRESULT STDMETHODCALLTYPE GetFileSize(OUT UINT64* fileSize) override; + HRESULT STDMETHODCALLTYPE + GetLastWriteTime(OUT UINT64* lastWriteTime) override; + bool IsInitialized() { return !!resourcePtr_; } private: @@ -53,16 +60,20 @@ class CDwFontFileStream final : public IDWriteFontFileStream { void const* resourcePtr_; DWORD resourceSize_; }; + class CDwFontFileLoader final : public IDWriteFontFileLoader { public: - virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, - void** ppvObject); - virtual ULONG STDMETHODCALLTYPE AddRef(); - virtual ULONG STDMETHODCALLTYPE Release(); - virtual HRESULT STDMETHODCALLTYPE + // IUnknown. + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, + void** ppvObject) override; + ULONG STDMETHODCALLTYPE AddRef() override; + ULONG STDMETHODCALLTYPE Release() override; + + // IDWriteFontFileLoader. + HRESULT STDMETHODCALLTYPE CreateStreamFromKey(void const* fontFileReferenceKey, UINT32 fontFileReferenceKeySize, - OUT IDWriteFontFileStream** fontFileStream); + OUT IDWriteFontFileStream** fontFileStream) override; static IDWriteFontFileLoader* GetLoader() { if (!instance_) { @@ -77,10 +88,12 @@ class CDwFontFileLoader final : public IDWriteFontFileLoader { ULONG refCount_; static IDWriteFontFileLoader* instance_; }; + class CDwFontContext { public: CDwFontContext(IDWriteFactory* dwriteFactory); ~CDwFontContext(); + HRESULT Initialize(); private: @@ -89,12 +102,14 @@ class CDwFontContext { HRESULT hr_; IDWriteFactory* dwriteFactory_; }; + class CDwGdiTextRenderer { public: CDwGdiTextRenderer(CFX_DIBitmap* pBitmap, IDWriteBitmapRenderTarget* bitmapRenderTarget, IDWriteRenderingParams* renderingParams); ~CDwGdiTextRenderer(); + HRESULT STDMETHODCALLTYPE DrawGlyphRun(const FX_RECT& text_bbox, __in_opt CFX_ClipRgn* pClipRgn, __in_opt DWRITE_MATRIX const* pMatrix, @@ -109,13 +124,15 @@ class CDwGdiTextRenderer { IDWriteBitmapRenderTarget* pRenderTarget_; IDWriteRenderingParams* pRenderingParams_; }; -CDWriteExt::CDWriteExt() { - m_hModule = nullptr; - m_pDWriteFactory = nullptr; - m_pDwFontContext = nullptr; - m_pDwTextRenderer = nullptr; -} + +CDWriteExt::CDWriteExt() + : m_hModule(nullptr), + m_pDWriteFactory(nullptr), + m_pDwFontContext(nullptr), + m_pDwTextRenderer(nullptr) {} + void CDWriteExt::Load() {} + void CDWriteExt::Unload() { if (m_pDwFontContext) { delete (CDwFontContext*)m_pDwFontContext; @@ -123,9 +140,11 @@ void CDWriteExt::Unload() { } SafeRelease((IDWriteFactory**)&m_pDWriteFactory); } + CDWriteExt::~CDWriteExt() { Unload(); } + LPVOID CDWriteExt::DwCreateFontFaceFromStream(uint8_t* pData, uint32_t size, int simulation_style) { @@ -162,6 +181,7 @@ failed: SafeRelease(&pDwFontFile); return nullptr; } + FX_BOOL CDWriteExt::DwCreateRenderingTarget(CFX_DIBitmap* pBitmap, void** renderTarget) { if (pBitmap->GetFormat() > FXDIB_Argb) { @@ -203,6 +223,7 @@ failed: SafeRelease(&pRenderingParams); return FALSE; } + FX_BOOL CDWriteExt::DwRendingString(void* renderTarget, CFX_ClipRgn* pClipRgn, FX_RECT& stringRect, @@ -245,20 +266,24 @@ FX_BOOL CDWriteExt::DwRendingString(void* renderTarget, RGB(FXARGB_R(text_color), FXARGB_G(text_color), FXARGB_B(text_color))); return SUCCEEDED(hr); } + void CDWriteExt::DwDeleteRenderingTarget(void* renderTarget) { delete (CDwGdiTextRenderer*)renderTarget; } + void CDWriteExt::DwDeleteFont(void* pFont) { if (pFont) { SafeRelease((IDWriteFontFace**)&pFont); } } + CDwFontFileStream::CDwFontFileStream(void const* fontFileReferenceKey, UINT32 fontFileReferenceKeySize) { refCount_ = 0; resourcePtr_ = fontFileReferenceKey; resourceSize_ = fontFileReferenceKeySize; } + HRESULT STDMETHODCALLTYPE CDwFontFileStream::QueryInterface(REFIID iid, void** ppvObject) { if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileStream)) { @@ -269,9 +294,11 @@ HRESULT STDMETHODCALLTYPE CDwFontFileStream::QueryInterface(REFIID iid, *ppvObject = nullptr; return E_NOINTERFACE; } + ULONG STDMETHODCALLTYPE CDwFontFileStream::AddRef() { return InterlockedIncrement((long*)(&refCount_)); } + ULONG STDMETHODCALLTYPE CDwFontFileStream::Release() { ULONG newCount = InterlockedDecrement((long*)(&refCount_)); if (newCount == 0) { @@ -279,6 +306,7 @@ ULONG STDMETHODCALLTYPE CDwFontFileStream::Release() { } return newCount; } + HRESULT STDMETHODCALLTYPE CDwFontFileStream::ReadFileFragment(void const** fragmentStart, UINT64 fileOffset, @@ -295,17 +323,20 @@ CDwFontFileStream::ReadFileFragment(void const** fragmentStart, *fragmentContext = nullptr; return E_FAIL; } + void STDMETHODCALLTYPE CDwFontFileStream::ReleaseFileFragment(void* fragmentContext) {} HRESULT STDMETHODCALLTYPE CDwFontFileStream::GetFileSize(OUT UINT64* fileSize) { *fileSize = resourceSize_; return S_OK; } + HRESULT STDMETHODCALLTYPE CDwFontFileStream::GetLastWriteTime(OUT UINT64* lastWriteTime) { *lastWriteTime = 0; return E_NOTIMPL; } + IDWriteFontFileLoader* CDwFontFileLoader::instance_ = nullptr; CDwFontFileLoader::CDwFontFileLoader() : refCount_(0) {} HRESULT STDMETHODCALLTYPE CDwFontFileLoader::QueryInterface(REFIID iid, @@ -318,9 +349,11 @@ HRESULT STDMETHODCALLTYPE CDwFontFileLoader::QueryInterface(REFIID iid, *ppvObject = nullptr; return E_NOINTERFACE; } + ULONG STDMETHODCALLTYPE CDwFontFileLoader::AddRef() { return InterlockedIncrement((long*)(&refCount_)); } + ULONG STDMETHODCALLTYPE CDwFontFileLoader::Release() { ULONG newCount = InterlockedDecrement((long*)(&refCount_)); if (newCount == 0) { @@ -329,6 +362,7 @@ ULONG STDMETHODCALLTYPE CDwFontFileLoader::Release() { } return newCount; } + HRESULT STDMETHODCALLTYPE CDwFontFileLoader::CreateStreamFromKey( void const* fontFileReferenceKey, UINT32 fontFileReferenceKeySize, @@ -343,14 +377,17 @@ HRESULT STDMETHODCALLTYPE CDwFontFileLoader::CreateStreamFromKey( *fontFileStream = SafeAcquire(stream); return S_OK; } + CDwFontContext::CDwFontContext(IDWriteFactory* dwriteFactory) : hr_(S_FALSE), dwriteFactory_(SafeAcquire(dwriteFactory)) {} + CDwFontContext::~CDwFontContext() { if (dwriteFactory_ && hr_ == S_OK) { dwriteFactory_->UnregisterFontFileLoader(CDwFontFileLoader::GetLoader()); } SafeRelease(&dwriteFactory_); } + HRESULT CDwFontContext::Initialize() { if (hr_ == S_FALSE) { return hr_ = dwriteFactory_->RegisterFontFileLoader( @@ -358,6 +395,7 @@ HRESULT CDwFontContext::Initialize() { } return hr_; } + CDwGdiTextRenderer::CDwGdiTextRenderer( CFX_DIBitmap* pBitmap, IDWriteBitmapRenderTarget* bitmapRenderTarget, @@ -369,6 +407,7 @@ CDwGdiTextRenderer::~CDwGdiTextRenderer() { SafeRelease(&pRenderTarget_); SafeRelease(&pRenderingParams_); } + STDMETHODIMP CDwGdiTextRenderer::DrawGlyphRun( const FX_RECT& text_bbox, __in_opt CFX_ClipRgn* pClipRgn, diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 68b9aaa80e..3de1b5a8d5 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -1258,18 +1258,14 @@ FX_BOOL CGdiplusExt::DrawPath(HDC hDC, CallFunc(GdipDeleteGraphics)(pGraphics); return TRUE; } -class GpStream final : public IStream { - LONG m_RefCount; - int m_ReadPos; - CFX_ByteTextBuf m_InterStream; +class GpStream final : public IStream { public: - GpStream() { - m_RefCount = 1; - m_ReadPos = 0; - } - virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, - void** ppvObject) { + GpStream() : m_RefCount(1), m_ReadPos(0) {} + + // IUnknown + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, + void** ppvObject) override { if (iid == __uuidof(IUnknown) || iid == __uuidof(IStream) || iid == __uuidof(ISequentialStream)) { *ppvObject = static_cast<IStream*>(this); @@ -1278,10 +1274,10 @@ class GpStream final : public IStream { } return E_NOINTERFACE; } - virtual ULONG STDMETHODCALLTYPE AddRef(void) { + ULONG STDMETHODCALLTYPE AddRef(void) override { return (ULONG)InterlockedIncrement(&m_RefCount); } - virtual ULONG STDMETHODCALLTYPE Release(void) { + ULONG STDMETHODCALLTYPE Release(void) override { ULONG res = (ULONG)InterlockedDecrement(&m_RefCount); if (res == 0) { delete this; @@ -1289,10 +1285,10 @@ class GpStream final : public IStream { return res; } - public: - virtual HRESULT STDMETHODCALLTYPE Read(void* Output, - ULONG cb, - ULONG* pcbRead) { + // ISequentialStream + HRESULT STDMETHODCALLTYPE Read(void* Output, + ULONG cb, + ULONG* pcbRead) override { size_t bytes_left; size_t bytes_out; if (pcbRead) { @@ -1310,9 +1306,9 @@ class GpStream final : public IStream { } return S_OK; } - virtual HRESULT STDMETHODCALLTYPE Write(void const* Input, - ULONG cb, - ULONG* pcbWritten) { + HRESULT STDMETHODCALLTYPE Write(void const* Input, + ULONG cb, + ULONG* pcbWritten) override { if (cb <= 0) { if (pcbWritten) { *pcbWritten = 0; @@ -1326,34 +1322,34 @@ class GpStream final : public IStream { return S_OK; } - public: - virtual HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER) { + // IStream + HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE CopyTo(IStream*, - ULARGE_INTEGER, - ULARGE_INTEGER*, - ULARGE_INTEGER*) { + HRESULT STDMETHODCALLTYPE CopyTo(IStream*, + ULARGE_INTEGER, + ULARGE_INTEGER*, + ULARGE_INTEGER*) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE Commit(DWORD) { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE Revert(void) { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER, - ULARGE_INTEGER, - DWORD) { + HRESULT STDMETHODCALLTYPE Commit(DWORD) override { return E_NOTIMPL; } + HRESULT STDMETHODCALLTYPE Revert(void) override { return E_NOTIMPL; } + HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER, + ULARGE_INTEGER, + DWORD) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER, - ULARGE_INTEGER, - DWORD) { + HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER, + ULARGE_INTEGER, + DWORD) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE Clone(IStream** stream) { + HRESULT STDMETHODCALLTYPE Clone(IStream** stream) override { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove, - DWORD dwOrigin, - ULARGE_INTEGER* lpNewFilePointer) { + HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove, + DWORD dwOrigin, + ULARGE_INTEGER* lpNewFilePointer) override { long start = 0; long new_read_position; switch (dwOrigin) { @@ -1381,7 +1377,8 @@ class GpStream final : public IStream { } return S_OK; } - virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag) { + HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, + DWORD grfStatFlag) override { if (!pStatstg) { return STG_E_INVALIDFUNCTION; } @@ -1389,7 +1386,13 @@ class GpStream final : public IStream { pStatstg->cbSize.QuadPart = m_InterStream.GetLength(); return S_OK; } + + private: + LONG m_RefCount; + int m_ReadPos; + CFX_ByteTextBuf m_InterStream; }; + typedef struct { BITMAPINFO* pbmi; int Stride; @@ -1398,6 +1401,7 @@ typedef struct { BitmapData* pBitmapData; GpStream* pStream; } PREVIEW3_DIBITMAP; + static PREVIEW3_DIBITMAP* LoadDIBitmap(WINDIB_Open_Args_ args) { GpBitmap* pBitmap; GpStream* pStream = nullptr; @@ -1477,6 +1481,7 @@ static PREVIEW3_DIBITMAP* LoadDIBitmap(WINDIB_Open_Args_ args) { pInfo->pStream = pStream; return pInfo; } + static void FreeDIBitmap(PREVIEW3_DIBITMAP* pInfo) { CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; @@ -1489,6 +1494,7 @@ static void FreeDIBitmap(PREVIEW3_DIBITMAP* pInfo) { } FX_Free(pInfo); } + CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData, FX_BOOL bAlpha); diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index e0952706fa..b09c4ebbd5 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -137,7 +137,7 @@ class CGdiDeviceDriver : public IFX_RenderDeviceDriver { uint32_t color, int blend_type) override; FX_BOOL GetClipBox(FX_RECT* pRect) override; - void* GetPlatformSurface() const override { return (void*)m_hDC; } + void* GetPlatformSurface() const override; void DrawLine(FX_FLOAT x1, FX_FLOAT y1, @@ -203,9 +203,7 @@ class CGdiDisplayDriver : public CGdiDeviceDriver { const CFX_Matrix* pMatrix, uint32_t render_flags, void*& handle, - int blend_type) override { - return FALSE; - } + int blend_type) override; FX_BOOL UseFoxitStretchEngine(const CFX_DIBSource* pSource, uint32_t color, int dest_left, |