diff options
author | thestig <thestig@chromium.org> | 2016-06-13 15:02:05 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-13 15:02:05 -0700 |
commit | 2f307669ded2621f87d0b019e508f6663523f1d7 (patch) | |
tree | 035cb0ad851aa008a4f3c27c365c40564ef69859 /core/fxge/apple | |
parent | 868150bd69f0f1f9472affc20deea0a9341bf22b (diff) | |
download | pdfium-2f307669ded2621f87d0b019e508f6663523f1d7.tar.xz |
Remove default arguments from IFX_RenderDeviceDriver.
Review-Url: https://codereview.chromium.org/2059883004
Diffstat (limited to 'core/fxge/apple')
-rw-r--r-- | core/fxge/apple/apple_int.h | 58 | ||||
-rw-r--r-- | core/fxge/apple/fx_apple_platform.cpp | 125 | ||||
-rw-r--r-- | core/fxge/apple/fx_quartz_device.cpp | 194 |
3 files changed, 173 insertions, 204 deletions
diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h index 6afda63ee0..5a3c0756db 100644 --- a/core/fxge/apple/apple_int.h +++ b/core/fxge/apple/apple_int.h @@ -101,36 +101,24 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int alpha_flag = 0, - void* pIccTransform = nullptr, - int blend_type = FXDIB_BLEND_NORMAL) override; - FX_BOOL FillRect(const FX_RECT* pRect, - uint32_t fill_color, - int alpha_flag = 0, - void* pIccTransform = nullptr, - int blend_type = FXDIB_BLEND_NORMAL) override; + int blend_type) override; + FX_BOOL FillRectWithBlend(const FX_RECT* pRect, + uint32_t fill_color, + int blend_type) override; FX_BOOL DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, uint32_t color, - int alpha_flag = 0, - void* pIccTransform = nullptr, - int blend_type = FXDIB_BLEND_NORMAL) override; + int blend_type) override; FX_BOOL GetClipBox(FX_RECT* pRect) override; - FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, - int left, - int top, - void* pIccTransform = nullptr, - FX_BOOL bDEdge = FALSE) override; + FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override; FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, const FX_RECT* pSrcRect, int dest_left, int dest_top, - int blend_type, - int alpha_flag = 0, - void* pIccTransform = nullptr) override; + int blend_type) override; FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, @@ -139,18 +127,14 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int alpha_flag = 0, - void* pIccTransform = nullptr, - int blend_type = FXDIB_BLEND_NORMAL) override; + int blend_type) override; FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t flags, void*& handle, - int alpha_flag = 0, - void* pIccTransform = nullptr, - int blend_type = FXDIB_BLEND_NORMAL) override { + int blend_type) override { return FALSE; } FX_BOOL DrawDeviceText(int nChars, @@ -159,9 +143,7 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { CFX_FontCache* pCache, const CFX_Matrix* pObject2Device, FX_FLOAT font_size, - uint32_t color, - int alpha_flag = 0, - void* pIccTransform = nullptr) override; + uint32_t color) override; void ClearDriver() override; protected: @@ -172,21 +154,19 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { void setPathToContext(const CFX_PathData* pathData); FX_FLOAT getLineWidth(const CFX_GraphStateData* graphState, CGAffineTransform ctm); - FX_BOOL CG_DrawGlypRun(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - const CFX_Matrix* pGlyphMatrix, - const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, - uint32_t argb, - int alpha_flag, - void* pIccTransform); + FX_BOOL CG_DrawGlyphRun(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + const CFX_Matrix* pGlyphMatrix, + const CFX_Matrix* pObject2Device, + FX_FLOAT font_size, + uint32_t argb); void CG_SetImageTransform(int dest_left, int dest_top, int dest_width, int dest_height, - CGRect* rect = nullptr); + CGRect* rect); CGContextRef m_context; CGAffineTransform m_foxitDevice2User; 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 = diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp index 154910b69f..4e1e62d6eb 100644 --- a/core/fxge/apple/fx_quartz_device.cpp +++ b/core/fxge/apple/fx_quartz_device.cpp @@ -340,14 +340,13 @@ static CGBlendMode GetCGBlendMode(int blend_type) { } return mode; } + FX_BOOL CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData, const CFX_Matrix* matrix, const CFX_GraphStateData* graphState, uint32_t fillArgb, uint32_t strokeArgb, int fillMode, - int alpha_flag, - void* pIccTransform, int blend_type) { SaveState(); CGBlendMode mode = GetCGBlendMode(blend_type); @@ -394,11 +393,10 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData, RestoreState(false); return TRUE; } -FX_BOOL CFX_QuartzDeviceDriver::FillRect(const FX_RECT* rect, - FX_ARGB fillArgb, - int alphaFlag, - void* iccTransform, - int blend_type) { + +FX_BOOL CFX_QuartzDeviceDriver::FillRectWithBlend(const FX_RECT* rect, + FX_ARGB fillArgb, + int blend_type) { CGBlendMode mode = GetCGBlendMode(blend_type); if (mode != kCGBlendModeNormal) { CGContextSetBlendMode(m_context, mode); @@ -416,13 +414,12 @@ FX_BOOL CFX_QuartzDeviceDriver::FillRect(const FX_RECT* rect, } return TRUE; } + FX_BOOL CFX_QuartzDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, uint32_t argb, - int alphaFlag, - void* iccTransform, int blend_type) { CGBlendMode mode = GetCGBlendMode(blend_type); if (mode != kCGBlendModeNormal) { @@ -447,6 +444,7 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, } return TRUE; } + FX_BOOL CFX_QuartzDeviceDriver::GetClipBox(FX_RECT* rect) { CGRect r = CGContextGetClipBoundingBox(m_context); r = CGRectApplyAffineTransform(r, m_user2FoxitDevice); @@ -456,20 +454,15 @@ FX_BOOL CFX_QuartzDeviceDriver::GetClipBox(FX_RECT* rect) { rect->bottom = FXSYS_ceil(r.origin.y + r.size.height); return TRUE; } + FX_BOOL CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap, int32_t left, - int32_t top, - void* pIccTransform, - FX_BOOL bDEdge) { - if (FXDC_PRINTER == m_deviceClass) { - return FALSE; - } - if (bitmap->GetBPP() < 32) { - return FALSE; - } - if (!(m_renderCaps | FXRC_GET_BITS)) { + int32_t top) { + if (FXDC_PRINTER == m_deviceClass || bitmap->GetBPP() < 32 || + !(m_renderCaps | FXRC_GET_BITS)) { return FALSE; } + CGPoint pt = CGPointMake(left, top); pt = CGPointApplyAffineTransform(pt, m_foxitDevice2User); CGAffineTransform ctm = CGContextGetCTM(m_context); @@ -481,12 +474,11 @@ FX_BOOL CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap, CGFloat width = (CGFloat)bitmap->GetWidth(); CGFloat height = (CGFloat)bitmap->GetHeight(); - if (width + pt.x > m_width) { + if (width + pt.x > m_width) width -= (width + pt.x - m_width); - } - if (height + pt.y > m_height) { + if (height + pt.y > m_height) height -= (height + pt.y - m_height); - } + CGImageRef subImage = CGImageCreateWithImageInRect( image, CGRectMake(pt.x, pt.y, width, height)); CGContextRef context = createContextWithBitmap(bitmap); @@ -496,29 +488,29 @@ FX_BOOL CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap, CGContextRelease(context); CGImageRelease(subImage); CGImageRelease(image); - if (bitmap->HasAlpha()) { - for (int row = 0; row < bitmap->GetHeight(); row++) { - uint8_t* pScanline = (uint8_t*)bitmap->GetScanline(row); - for (int col = 0; col < bitmap->GetWidth(); col++) { - if (pScanline[3] > 0) { - pScanline[0] = (pScanline[0] * 255.f / pScanline[3] + .5f); - pScanline[1] = (pScanline[1] * 255.f / pScanline[3] + .5f); - pScanline[2] = (pScanline[2] * 255.f / pScanline[3] + .5f); - } - pScanline += 4; + if (!bitmap->HasAlpha()) + return TRUE; + + for (int row = 0; row < bitmap->GetHeight(); row++) { + uint8_t* pScanline = (uint8_t*)bitmap->GetScanline(row); + for (int col = 0; col < bitmap->GetWidth(); col++) { + if (pScanline[3] > 0) { + pScanline[0] = (pScanline[0] * 255.f / pScanline[3] + .5f); + pScanline[1] = (pScanline[1] * 255.f / pScanline[3] + .5f); + pScanline[2] = (pScanline[2] * 255.f / pScanline[3] + .5f); } + pScanline += 4; } } return TRUE; } + FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_ARGB argb, const FX_RECT* srcRect, int dest_left, int dest_top, - int blendType, - int alphaFlag, - void* iccTransform) { + int blendType) { SaveState(); CGFloat src_left, src_top, src_width, src_height; if (srcRect) { @@ -635,6 +627,7 @@ FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, RestoreState(false); return TRUE; } + FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, FX_ARGB argb, int dest_left, @@ -643,8 +636,6 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, int dest_height, const FX_RECT* clipRect, uint32_t flags, - int alphaFlag, - void* iccTransform, int blend_type) { SaveState(); if (clipRect) { @@ -657,21 +648,20 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, } CGRect rect = CGRectMake(dest_left, dest_top, dest_width, dest_height); rect = CGRectApplyAffineTransform(rect, m_foxitDevice2User); - if (FXDIB_BICUBIC_INTERPOL == flags) { + if (FXDIB_BICUBIC_INTERPOL == flags) CGContextSetInterpolationQuality(m_context, kCGInterpolationHigh); - } else if (FXDIB_DOWNSAMPLE == flags) { + else if (FXDIB_DOWNSAMPLE == flags) CGContextSetInterpolationQuality(m_context, kCGInterpolationNone); - } else { + else CGContextSetInterpolationQuality(m_context, kCGInterpolationMedium); - } - CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height); + + CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height, nullptr); CFX_DIBitmap* pBitmap1 = nullptr; if (pBitmap->IsAlphaMask()) { - if (pBitmap->GetBuffer()) { + if (pBitmap->GetBuffer()) pBitmap1 = (CFX_DIBitmap*)pBitmap; - } else { + else pBitmap1 = pBitmap->Clone(); - } if (!pBitmap1) { RestoreState(false); return FALSE; @@ -693,20 +683,19 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, CGImageRelease(pImage); CGColorSpaceRelease(pColorSpace); CGDataProviderRelease(pBitmapProvider); - if (pBitmap1 != pBitmap) { + if (pBitmap1 != pBitmap) delete pBitmap1; - } + RestoreState(false); return TRUE; } if (pBitmap->GetBPP() < 32) { pBitmap1 = pBitmap->CloneConvert(FXDIB_Rgb32); } else { - if (pBitmap->GetBuffer()) { + if (pBitmap->GetBuffer()) pBitmap1 = (CFX_DIBitmap*)pBitmap; - } else { + else pBitmap1 = pBitmap->Clone(); - } } if (!pBitmap1) { RestoreState(false); @@ -735,25 +724,25 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, CGContextDrawImage(m_context, rect, image); CGImageRelease(image); CGContextRelease(ctx); - if (pBitmap1 != pBitmap) { + if (pBitmap1 != pBitmap) delete pBitmap1; - } + RestoreState(false); return TRUE; } -FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - const CFX_Matrix* pGlyphMatrix, - const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, - uint32_t argb, - int alpha_flag, - void* pIccTransform) { - if (nChars == 0) { + +FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlyphRun( + int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + const CFX_Matrix* pGlyphMatrix, + const CFX_Matrix* pObject2Device, + FX_FLOAT font_size, + uint32_t argb) { + if (nChars == 0) return TRUE; - } + CQuartz2D& quartz2d = static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) ->m_quartz2d; @@ -775,9 +764,9 @@ FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars, glyph_positions[i].y = pCharPos[i].m_OriginY; } CFX_Matrix text_matrix; - if (pObject2Device) { + if (pObject2Device) text_matrix.Concat(*pObject2Device); - } + CGAffineTransform matrix_cg = CGAffineTransformMake(text_matrix.a, text_matrix.b, text_matrix.c, text_matrix.d, text_matrix.e, text_matrix.f); @@ -797,9 +786,9 @@ FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars, CGAffineTransform glyph_matrix = CGAffineTransformMake( pGlyphMatrix->a, pGlyphMatrix->b, pGlyphMatrix->c, pGlyphMatrix->d, pGlyphMatrix->e, pGlyphMatrix->f); - if (m_foxitDevice2User.d < 0) { + if (m_foxitDevice2User.d < 0) glyph_matrix = CGAffineTransformInvert(glyph_matrix); - } + CGContextConcatCTM(m_context, glyph_matrix); CGContextTranslateCTM(m_context, -origin.x, -origin.y); } @@ -808,17 +797,17 @@ FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars, RestoreState(false); return TRUE; } + FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, CFX_FontCache* pCache, const CFX_Matrix* pObject2Device, FX_FLOAT font_size, - uint32_t color, - int alpha_flag, - void* pIccTransform) { + uint32_t color) { if (!pFont || !m_context) return FALSE; + FX_BOOL bBold = pFont->IsBold(); if (!bBold && pFont->GetSubstFont() && pFont->GetSubstFont()->m_Weight >= 500 && @@ -832,9 +821,8 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, while (i < nChars) { if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { if (i > 0) { - ret = - CG_DrawGlypRun(i, pCharPos, pFont, pCache, nullptr, pObject2Device, - font_size, color, alpha_flag, pIccTransform); + ret = CG_DrawGlyphRun(i, pCharPos, pFont, pCache, nullptr, + pObject2Device, font_size, color); if (!ret) { RestoreState(false); return ret; @@ -850,9 +838,8 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, char_pos->m_AdjustMatrix[0], char_pos->m_AdjustMatrix[1], char_pos->m_AdjustMatrix[2], char_pos->m_AdjustMatrix[3], 0, 0); } - ret = CG_DrawGlypRun(1, char_pos, pFont, pCache, &glphy_matrix, - pObject2Device, font_size, color, alpha_flag, - pIccTransform); + ret = CG_DrawGlyphRun(1, char_pos, pFont, pCache, &glphy_matrix, + pObject2Device, font_size, color); if (!ret) { RestoreState(false); return ret; @@ -866,12 +853,13 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, } } if (i > 0) { - ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, nullptr, pObject2Device, - font_size, color, alpha_flag, pIccTransform); + ret = CG_DrawGlyphRun(i, pCharPos, pFont, pCache, nullptr, pObject2Device, + font_size, color); } RestoreState(false); return ret; } + void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, FX_ARGB argb, FX_FLOAT lineWidth) { @@ -959,6 +947,7 @@ void CFX_QuartzDeviceDriver::setPathToContext(const CFX_PathData* pathData) { } } } + void CFX_QuartzDeviceDriver::CG_SetImageTransform(int dest_left, int dest_top, int dest_width, @@ -966,29 +955,30 @@ void CFX_QuartzDeviceDriver::CG_SetImageTransform(int dest_left, CGRect* rect) { int flip_y = m_foxitDevice2User.d * dest_height < 0 ? 1 : -1; int flip_x = m_foxitDevice2User.a * dest_width > 0 ? 1 : -1; - if (flip_y < 0 || flip_x < 0) { - if (dest_height < 0) { - dest_height = -dest_height; - dest_top -= dest_height; - } - CGRect rt = CGRectApplyAffineTransform( - CGRectMake(dest_left, dest_top, dest_width, dest_height), - m_foxitDevice2User); - CGFloat offset_x = (rt.origin.x) + rt.size.width / 2.f, - offset_y = (rt.origin.y) + rt.size.height / 2.f; - CGAffineTransform transform = CGAffineTransformIdentity; - transform = CGAffineTransformConcat( - transform, CGAffineTransformMake(1, 0, 0, 1, -offset_x, -offset_y)); - transform = CGAffineTransformConcat( - transform, CGAffineTransformMake(flip_x, 0, 0, flip_y, 0, 0)); - transform = CGAffineTransformConcat( - transform, CGAffineTransformMake(1, 0, 0, 1, offset_x, offset_y)); - CGContextConcatCTM(m_context, transform); - if (rect) { - *rect = CGRectApplyAffineTransform(*rect, transform); - } - } + if (flip_y >= 0 && flip_x >= 0) + return; + + if (dest_height < 0) { + dest_height = -dest_height; + dest_top -= dest_height; + } + CGRect rt = CGRectApplyAffineTransform( + CGRectMake(dest_left, dest_top, dest_width, dest_height), + m_foxitDevice2User); + CGFloat offset_x = (rt.origin.x) + rt.size.width / 2.f, + offset_y = (rt.origin.y) + rt.size.height / 2.f; + CGAffineTransform transform = CGAffineTransformIdentity; + transform = CGAffineTransformConcat( + transform, CGAffineTransformMake(1, 0, 0, 1, -offset_x, -offset_y)); + transform = CGAffineTransformConcat( + transform, CGAffineTransformMake(flip_x, 0, 0, flip_y, 0, 0)); + transform = CGAffineTransformConcat( + transform, CGAffineTransformMake(1, 0, 0, 1, offset_x, offset_y)); + CGContextConcatCTM(m_context, transform); + if (rect) + *rect = CGRectApplyAffineTransform(*rect, transform); } + void CFX_QuartzDeviceDriver::ClearDriver() { if (!m_context) return; |