Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fxcrt/include/fx_system.h" | 7 #include "core/fxcrt/include/fx_system.h" |
| 8 #include "core/fxge/include/fx_ge.h" | 8 #include "core/fxge/include/fx_ge.h" |
| 9 | 9 |
| 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) | 24 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) |
| 25 ->m_quartz2d; | 25 ->m_quartz2d; |
| 26 m_pPlatformGraphics = quartz2d.createGraphics(m_pBitmap); | 26 m_pPlatformGraphics = quartz2d.createGraphics(m_pBitmap); |
| 27 } | 27 } |
| 28 void CFX_AggDeviceDriver::DestroyPlatform() { | 28 void CFX_AggDeviceDriver::DestroyPlatform() { |
| 29 CQuartz2D& quartz2d = | 29 CQuartz2D& quartz2d = |
| 30 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) | 30 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) |
| 31 ->m_quartz2d; | 31 ->m_quartz2d; |
| 32 if (m_pPlatformGraphics) { | 32 if (m_pPlatformGraphics) { |
| 33 quartz2d.destroyGraphics(m_pPlatformGraphics); | 33 quartz2d.destroyGraphics(m_pPlatformGraphics); |
| 34 m_pPlatformGraphics = NULL; | 34 m_pPlatformGraphics = nullptr; |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 void CFX_FaceCache::InitPlatform() {} | 37 void CFX_FaceCache::InitPlatform() {} |
| 38 void CFX_FaceCache::DestroyPlatform() {} | 38 void CFX_FaceCache::DestroyPlatform() {} |
| 39 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext( | 39 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext( |
| 40 CFX_Font* pFont, | 40 CFX_Font* pFont, |
| 41 uint32_t glyph_index, | 41 uint32_t glyph_index, |
| 42 const CFX_Matrix* pMatrix, | 42 const CFX_Matrix* pMatrix, |
| 43 int dest_width, | 43 int dest_width, |
| 44 int anti_alias) { | 44 int anti_alias) { |
| 45 return NULL; | 45 return nullptr; |
| 46 } | 46 } |
| 47 static FX_BOOL _CGDrawGlyphRun(CGContextRef pContext, | 47 static FX_BOOL _CGDrawGlyphRun(CGContextRef pContext, |
| 48 int nChars, | 48 int nChars, |
| 49 const FXTEXT_CHARPOS* pCharPos, | 49 const FXTEXT_CHARPOS* pCharPos, |
| 50 CFX_Font* pFont, | 50 CFX_Font* pFont, |
| 51 CFX_FontCache* pCache, | 51 CFX_FontCache* pCache, |
| 52 const CFX_Matrix* pObject2Device, | 52 const CFX_Matrix* pObject2Device, |
| 53 FX_FLOAT font_size, | 53 FX_FLOAT font_size, |
| 54 uint32_t argb, | 54 uint32_t argb, |
| 55 int alpha_flag, | 55 int alpha_flag, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 } | 93 } |
| 94 if (bNegSize) { | 94 if (bNegSize) { |
| 95 new_matrix.a = -new_matrix.a; | 95 new_matrix.a = -new_matrix.a; |
| 96 } else { | 96 } else { |
| 97 new_matrix.b = -new_matrix.b; | 97 new_matrix.b = -new_matrix.b; |
| 98 new_matrix.d = -new_matrix.d; | 98 new_matrix.d = -new_matrix.d; |
| 99 } | 99 } |
| 100 quartz2d.setGraphicsTextMatrix(pContext, &new_matrix); | 100 quartz2d.setGraphicsTextMatrix(pContext, &new_matrix); |
| 101 return quartz2d.drawGraphicsString(pContext, pFont->GetPlatformFont(), | 101 return quartz2d.drawGraphicsString(pContext, pFont->GetPlatformFont(), |
| 102 font_size, glyph_indices, glyph_positions, | 102 font_size, glyph_indices, glyph_positions, |
| 103 nChars, argb, NULL); | 103 nChars, argb, nullptr); |
| 104 } | 104 } |
| 105 static void _DoNothing(void* info, const void* data, size_t size) {} | 105 static void _DoNothing(void* info, const void* data, size_t size) {} |
| 106 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, | 106 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, |
| 107 const FXTEXT_CHARPOS* pCharPos, | 107 const FXTEXT_CHARPOS* pCharPos, |
| 108 CFX_Font* pFont, | 108 CFX_Font* pFont, |
| 109 CFX_FontCache* pCache, | 109 CFX_FontCache* pCache, |
| 110 const CFX_Matrix* pObject2Device, | 110 const CFX_Matrix* pObject2Device, |
| 111 FX_FLOAT font_size, | 111 FX_FLOAT font_size, |
| 112 uint32_t argb, | 112 uint32_t argb, |
| 113 int alpha_flag, | 113 int alpha_flag, |
| 114 void* pIccTransform) { | 114 void* pIccTransform) { |
| 115 if (!pFont) { | 115 if (!pFont) { |
| 116 return FALSE; | 116 return FALSE; |
| 117 } | 117 } |
| 118 FX_BOOL bBold = pFont->IsBold(); | 118 FX_BOOL bBold = pFont->IsBold(); |
| 119 if (!bBold && pFont->GetSubstFont() && | 119 if (!bBold && pFont->GetSubstFont() && |
| 120 pFont->GetSubstFont()->m_Weight >= 500 && | 120 pFont->GetSubstFont()->m_Weight >= 500 && |
| 121 pFont->GetSubstFont()->m_Weight <= 600) { | 121 pFont->GetSubstFont()->m_Weight <= 600) { |
| 122 return FALSE; | 122 return FALSE; |
| 123 } | 123 } |
| 124 for (int i = 0; i < nChars; i++) { | 124 for (int i = 0; i < nChars; i++) { |
| 125 if (pCharPos[i].m_bGlyphAdjust) { | 125 if (pCharPos[i].m_bGlyphAdjust) { |
| 126 return FALSE; | 126 return FALSE; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 CGContextRef ctx = CGContextRef(m_pPlatformGraphics); | 129 CGContextRef ctx = CGContextRef(m_pPlatformGraphics); |
| 130 if (NULL == ctx) { | 130 if (nullptr == ctx) { |
|
Tom Sepez
2016/06/02 20:09:49
nit: !ctx
Lei Zhang
2016/06/07 07:33:24
Done.
| |
| 131 return FALSE; | 131 return FALSE; |
| 132 } | 132 } |
| 133 CGContextSaveGState(ctx); | 133 CGContextSaveGState(ctx); |
| 134 CGContextSetTextDrawingMode(ctx, kCGTextFillClip); | 134 CGContextSetTextDrawingMode(ctx, kCGTextFillClip); |
| 135 CGRect rect_cg; | 135 CGRect rect_cg; |
| 136 CGImageRef pImageCG = NULL; | 136 CGImageRef pImageCG = nullptr; |
| 137 if (m_pClipRgn) { | 137 if (m_pClipRgn) { |
| 138 rect_cg = | 138 rect_cg = |
| 139 CGRectMake(m_pClipRgn->GetBox().left, m_pClipRgn->GetBox().top, | 139 CGRectMake(m_pClipRgn->GetBox().left, m_pClipRgn->GetBox().top, |
| 140 m_pClipRgn->GetBox().Width(), m_pClipRgn->GetBox().Height()); | 140 m_pClipRgn->GetBox().Width(), m_pClipRgn->GetBox().Height()); |
| 141 const CFX_DIBitmap* pClipMask = m_pClipRgn->GetMask(); | 141 const CFX_DIBitmap* pClipMask = m_pClipRgn->GetMask(); |
| 142 if (pClipMask) { | 142 if (pClipMask) { |
| 143 CGDataProviderRef pClipMaskDataProvider = CGDataProviderCreateWithData( | 143 CGDataProviderRef pClipMaskDataProvider = CGDataProviderCreateWithData( |
| 144 NULL, pClipMask->GetBuffer(), | 144 nullptr, pClipMask->GetBuffer(), |
| 145 pClipMask->GetPitch() * pClipMask->GetHeight(), _DoNothing); | 145 pClipMask->GetPitch() * pClipMask->GetHeight(), _DoNothing); |
| 146 CGFloat decode_f[2] = {255.f, 0.f}; | 146 CGFloat decode_f[2] = {255.f, 0.f}; |
| 147 pImageCG = CGImageMaskCreate( | 147 pImageCG = CGImageMaskCreate( |
| 148 pClipMask->GetWidth(), pClipMask->GetHeight(), 8, 8, | 148 pClipMask->GetWidth(), pClipMask->GetHeight(), 8, 8, |
| 149 pClipMask->GetPitch(), pClipMaskDataProvider, decode_f, FALSE); | 149 pClipMask->GetPitch(), pClipMaskDataProvider, decode_f, FALSE); |
| 150 CGDataProviderRelease(pClipMaskDataProvider); | 150 CGDataProviderRelease(pClipMaskDataProvider); |
| 151 } | 151 } |
| 152 } else { | 152 } else { |
| 153 rect_cg = CGRectMake(0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight()); | 153 rect_cg = CGRectMake(0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight()); |
| 154 } | 154 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 166 } | 166 } |
| 167 CGContextRestoreGState(ctx); | 167 CGContextRestoreGState(ctx); |
| 168 return ret; | 168 return ret; |
| 169 } | 169 } |
| 170 void CFX_Font::ReleasePlatformResource() { | 170 void CFX_Font::ReleasePlatformResource() { |
| 171 if (m_pPlatformFont) { | 171 if (m_pPlatformFont) { |
| 172 CQuartz2D& quartz2d = | 172 CQuartz2D& quartz2d = |
| 173 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) | 173 static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData()) |
| 174 ->m_quartz2d; | 174 ->m_quartz2d; |
| 175 quartz2d.DestroyFont(m_pPlatformFont); | 175 quartz2d.DestroyFont(m_pPlatformFont); |
| 176 m_pPlatformFont = NULL; | 176 m_pPlatformFont = nullptr; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 180 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| OLD | NEW |