diff options
Diffstat (limited to 'core/fxge/apple/fx_apple_platform.cpp')
-rw-r--r-- | core/fxge/apple/fx_apple_platform.cpp | 125 |
1 files changed, 62 insertions, 63 deletions
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index 4204e7e6a5..3bddf64280 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -19,54 +19,31 @@ #include "core/fxge/include/fx_freetype.h" #include "core/fxge/include/fx_ge_apple.h" -void CFX_AggDeviceDriver::InitPlatform() { - CQuartz2D& quartz2d = - static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) - ->m_quartz2d; - m_pPlatformGraphics = quartz2d.createGraphics(m_pBitmap); -} -void CFX_AggDeviceDriver::DestroyPlatform() { - CQuartz2D& quartz2d = - static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) - ->m_quartz2d; - if (m_pPlatformGraphics) { - quartz2d.destroyGraphics(m_pPlatformGraphics); - m_pPlatformGraphics = nullptr; - } -} -void CFX_FaceCache::InitPlatform() {} -void CFX_FaceCache::DestroyPlatform() {} -CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext( - CFX_Font* pFont, - uint32_t glyph_index, - const CFX_Matrix* pMatrix, - int dest_width, - int anti_alias) { - return nullptr; -} -static FX_BOOL _CGDrawGlyphRun(CGContextRef pContext, - int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, - uint32_t argb, - int alpha_flag, - void* pIccTransform) { - if (nChars == 0) { +namespace { + +void DoNothing(void* info, const void* data, size_t size) {} + +FX_BOOL CGDrawGlyphRun(CGContextRef pContext, + int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + const CFX_Matrix* pObject2Device, + FX_FLOAT font_size, + uint32_t argb) { + if (nChars == 0) return TRUE; - } + CFX_Matrix new_matrix; FX_BOOL bNegSize = font_size < 0; - if (bNegSize) { + if (bNegSize) font_size = -font_size; - } + FX_FLOAT ori_x = pCharPos[0].m_OriginX, ori_y = pCharPos[0].m_OriginY; new_matrix.Transform(ori_x, ori_y); - if (pObject2Device) { + if (pObject2Device) new_matrix.Concat(*pObject2Device); - } + CQuartz2D& quartz2d = static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) ->m_quartz2d; @@ -76,19 +53,17 @@ static FX_BOOL _CGDrawGlyphRun(CGContextRef pContext, pFont->SetPlatformFont( quartz2d.CreateFont(pFont->GetFontData(), pFont->GetSize())); - if (!pFont->GetPlatformFont()) { + if (!pFont->GetPlatformFont()) return FALSE; - } } CFX_FixedBufGrow<uint16_t, 32> glyph_indices(nChars); CFX_FixedBufGrow<CGPoint, 32> glyph_positions(nChars); for (int i = 0; i < nChars; i++) { glyph_indices[i] = pCharPos[i].m_ExtGID; - if (bNegSize) { + if (bNegSize) glyph_positions[i].x = -pCharPos[i].m_OriginX; - } else { + else glyph_positions[i].x = pCharPos[i].m_OriginX; - } glyph_positions[i].y = pCharPos[i].m_OriginY; } if (bNegSize) { @@ -102,19 +77,45 @@ static FX_BOOL _CGDrawGlyphRun(CGContextRef pContext, font_size, glyph_indices, glyph_positions, nChars, argb, nullptr); } -static void _DoNothing(void* info, const void* data, size_t size) {} + +} // namespace + +void CFX_AggDeviceDriver::InitPlatform() { + CQuartz2D& quartz2d = + static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) + ->m_quartz2d; + m_pPlatformGraphics = quartz2d.createGraphics(m_pBitmap); +} +void CFX_AggDeviceDriver::DestroyPlatform() { + CQuartz2D& quartz2d = + static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) + ->m_quartz2d; + if (m_pPlatformGraphics) { + quartz2d.destroyGraphics(m_pPlatformGraphics); + m_pPlatformGraphics = nullptr; + } +} +void CFX_FaceCache::InitPlatform() {} +void CFX_FaceCache::DestroyPlatform() {} +CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext( + CFX_Font* pFont, + uint32_t glyph_index, + const CFX_Matrix* pMatrix, + int dest_width, + int anti_alias) { + return nullptr; +} + FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, CFX_FontCache* pCache, const CFX_Matrix* pObject2Device, FX_FLOAT font_size, - uint32_t argb, - int alpha_flag, - void* pIccTransform) { - if (!pFont) { + uint32_t argb) { + if (!pFont) return FALSE; - } + FX_BOOL bBold = pFont->IsBold(); if (!bBold && pFont->GetSubstFont() && pFont->GetSubstFont()->m_Weight >= 500 && @@ -122,9 +123,8 @@ FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, return FALSE; } for (int i = 0; i < nChars; i++) { - if (pCharPos[i].m_bGlyphAdjust) { + if (pCharPos[i].m_bGlyphAdjust) return FALSE; - } } CGContextRef ctx = CGContextRef(m_pPlatformGraphics); if (!ctx) @@ -142,7 +142,7 @@ FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, if (pClipMask) { CGDataProviderRef pClipMaskDataProvider = CGDataProviderCreateWithData( nullptr, pClipMask->GetBuffer(), - pClipMask->GetPitch() * pClipMask->GetHeight(), _DoNothing); + pClipMask->GetPitch() * pClipMask->GetHeight(), DoNothing); CGFloat decode_f[2] = {255.f, 0.f}; pImageCG = CGImageMaskCreate( pClipMask->GetWidth(), pClipMask->GetHeight(), 8, 8, @@ -153,20 +153,19 @@ FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, rect_cg = CGRectMake(0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight()); } rect_cg = CGContextConvertRectToDeviceSpace(ctx, rect_cg); - if (pImageCG) { + if (pImageCG) CGContextClipToMask(ctx, rect_cg, pImageCG); - } else { + else CGContextClipToRect(ctx, rect_cg); - } - FX_BOOL ret = - _CGDrawGlyphRun(ctx, nChars, pCharPos, pFont, pCache, pObject2Device, - font_size, argb, alpha_flag, pIccTransform); - if (pImageCG) { + + FX_BOOL ret = CGDrawGlyphRun(ctx, nChars, pCharPos, pFont, pCache, + pObject2Device, font_size, argb); + if (pImageCG) CGImageRelease(pImageCG); - } CGContextRestoreGState(ctx); return ret; } + void CFX_Font::ReleasePlatformResource() { if (m_pPlatformFont) { CQuartz2D& quartz2d = |