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/include/fxge/fx_ge.h" | 7 #include "core/include/fxge/fx_ge.h" |
8 | 8 |
9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ | 9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ |
10 | 10 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 CFX_DIBExtractor temp(pSource); | 130 CFX_DIBExtractor temp(pSource); |
131 CFX_DIBitmap* pBitmap = temp; | 131 CFX_DIBitmap* pBitmap = temp; |
132 if (pBitmap == NULL) { | 132 if (pBitmap == NULL) { |
133 return FALSE; | 133 return FALSE; |
134 } | 134 } |
135 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, | 135 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, |
136 dest_height, flags, pIccTransform); | 136 dest_height, flags, pIccTransform); |
137 } | 137 } |
138 static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc, | 138 static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc, |
139 const CFX_AffineMatrix* pDestMatrix) { | 139 const CFX_Matrix* pDestMatrix) { |
140 ASSERT(pSrc->GetFormat() == FXDIB_1bppRgb || | 140 ASSERT(pSrc->GetFormat() == FXDIB_1bppRgb || |
141 pSrc->GetFormat() == FXDIB_1bppMask || | 141 pSrc->GetFormat() == FXDIB_1bppMask || |
142 pSrc->GetFormat() == FXDIB_1bppCmyk); | 142 pSrc->GetFormat() == FXDIB_1bppCmyk); |
143 CFX_DIBExtractor src_bitmap(pSrc); | 143 CFX_DIBExtractor src_bitmap(pSrc); |
144 CFX_DIBitmap* pSrcBitmap = src_bitmap; | 144 CFX_DIBitmap* pSrcBitmap = src_bitmap; |
145 if (pSrcBitmap == NULL) { | 145 if (pSrcBitmap == NULL) { |
146 return NULL; | 146 return NULL; |
147 } | 147 } |
148 int src_width = pSrcBitmap->GetWidth(), src_height = pSrcBitmap->GetHeight(); | 148 int src_width = pSrcBitmap->GetWidth(), src_height = pSrcBitmap->GetHeight(); |
149 uint8_t* src_buf = pSrcBitmap->GetBuffer(); | 149 uint8_t* src_buf = pSrcBitmap->GetBuffer(); |
150 FX_DWORD src_pitch = pSrcBitmap->GetPitch(); | 150 FX_DWORD src_pitch = pSrcBitmap->GetPitch(); |
151 FX_FLOAT dest_area = pDestMatrix->GetUnitArea(); | 151 FX_FLOAT dest_area = pDestMatrix->GetUnitArea(); |
152 FX_FLOAT area_scale = | 152 FX_FLOAT area_scale = |
153 FXSYS_Div((FX_FLOAT)(src_width * src_height), dest_area); | 153 FXSYS_Div((FX_FLOAT)(src_width * src_height), dest_area); |
154 FX_FLOAT size_scale = FXSYS_sqrt(area_scale); | 154 FX_FLOAT size_scale = FXSYS_sqrt(area_scale); |
155 CFX_AffineMatrix adjusted_matrix(*pDestMatrix); | 155 CFX_Matrix adjusted_matrix(*pDestMatrix); |
156 adjusted_matrix.Scale(size_scale, size_scale); | 156 adjusted_matrix.Scale(size_scale, size_scale); |
157 CFX_FloatRect result_rect_f = adjusted_matrix.GetUnitRect(); | 157 CFX_FloatRect result_rect_f = adjusted_matrix.GetUnitRect(); |
158 FX_RECT result_rect = result_rect_f.GetOutterRect(); | 158 FX_RECT result_rect = result_rect_f.GetOutterRect(); |
159 CFX_AffineMatrix src2result; | 159 CFX_Matrix src2result; |
160 src2result.e = adjusted_matrix.c + adjusted_matrix.e; | 160 src2result.e = adjusted_matrix.c + adjusted_matrix.e; |
161 src2result.f = adjusted_matrix.d + adjusted_matrix.f; | 161 src2result.f = adjusted_matrix.d + adjusted_matrix.f; |
162 src2result.a = adjusted_matrix.a / pSrcBitmap->GetWidth(); | 162 src2result.a = adjusted_matrix.a / pSrcBitmap->GetWidth(); |
163 src2result.b = adjusted_matrix.b / pSrcBitmap->GetWidth(); | 163 src2result.b = adjusted_matrix.b / pSrcBitmap->GetWidth(); |
164 src2result.c = -adjusted_matrix.c / pSrcBitmap->GetHeight(); | 164 src2result.c = -adjusted_matrix.c / pSrcBitmap->GetHeight(); |
165 src2result.d = -adjusted_matrix.d / pSrcBitmap->GetHeight(); | 165 src2result.d = -adjusted_matrix.d / pSrcBitmap->GetHeight(); |
166 src2result.TranslateI(-result_rect.left, -result_rect.top); | 166 src2result.TranslateI(-result_rect.left, -result_rect.top); |
167 CFX_AffineMatrix result2src; | 167 CFX_Matrix result2src; |
168 result2src.SetReverse(src2result); | 168 result2src.SetReverse(src2result); |
169 CPDF_FixedMatrix result2src_fix(result2src, 8); | 169 CPDF_FixedMatrix result2src_fix(result2src, 8); |
170 int result_width = result_rect.Width(); | 170 int result_width = result_rect.Width(); |
171 int result_height = result_rect.Height(); | 171 int result_height = result_rect.Height(); |
172 CFX_DIBitmap* pTempBitmap = new CFX_DIBitmap; | 172 CFX_DIBitmap* pTempBitmap = new CFX_DIBitmap; |
173 if (!pTempBitmap->Create(result_width, result_height, pSrc->GetFormat())) { | 173 if (!pTempBitmap->Create(result_width, result_height, pSrc->GetFormat())) { |
174 delete pTempBitmap; | 174 delete pTempBitmap; |
175 if (pSrcBitmap != src_bitmap) { | 175 if (pSrcBitmap != src_bitmap) { |
176 delete pSrcBitmap; | 176 delete pSrcBitmap; |
177 } | 177 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 217 } |
218 } | 218 } |
219 if (pSrcBitmap != src_bitmap) { | 219 if (pSrcBitmap != src_bitmap) { |
220 delete pSrcBitmap; | 220 delete pSrcBitmap; |
221 } | 221 } |
222 return pTempBitmap; | 222 return pTempBitmap; |
223 } | 223 } |
224 FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource, | 224 FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource, |
225 int bitmap_alpha, | 225 int bitmap_alpha, |
226 FX_DWORD color, | 226 FX_DWORD color, |
227 const CFX_AffineMatrix* pMatrix, | 227 const CFX_Matrix* pMatrix, |
228 FX_DWORD render_flags, | 228 FX_DWORD render_flags, |
229 void*& handle, | 229 void*& handle, |
230 int alpha_flag, | 230 int alpha_flag, |
231 void* pIccTransform, | 231 void* pIccTransform, |
232 int blend_type) { | 232 int blend_type) { |
233 if (bitmap_alpha < 255 || pSource->HasAlpha() || | 233 if (bitmap_alpha < 255 || pSource->HasAlpha() || |
234 (pSource->IsAlphaMask() && (pSource->GetBPP() != 1 || !m_bSupportROP))) { | 234 (pSource->IsAlphaMask() && (pSource->GetBPP() != 1 || !m_bSupportROP))) { |
235 return FALSE; | 235 return FALSE; |
236 } | 236 } |
237 CFX_FloatRect unit_rect = pMatrix->GetUnitRect(); | 237 CFX_FloatRect unit_rect = pMatrix->GetUnitRect(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 368 } |
369 void CPSPrinterDriver::EndRendering() { | 369 void CPSPrinterDriver::EndRendering() { |
370 m_PSRenderer.EndRendering(); | 370 m_PSRenderer.EndRendering(); |
371 } | 371 } |
372 void CPSPrinterDriver::SaveState() { | 372 void CPSPrinterDriver::SaveState() { |
373 m_PSRenderer.SaveState(); | 373 m_PSRenderer.SaveState(); |
374 } | 374 } |
375 void CPSPrinterDriver::RestoreState(FX_BOOL bKeepSaved) { | 375 void CPSPrinterDriver::RestoreState(FX_BOOL bKeepSaved) { |
376 m_PSRenderer.RestoreState(bKeepSaved); | 376 m_PSRenderer.RestoreState(bKeepSaved); |
377 } | 377 } |
378 FX_BOOL CPSPrinterDriver::SetClip_PathFill( | 378 FX_BOOL CPSPrinterDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
379 const CFX_PathData* pPathData, | 379 const CFX_Matrix* pObject2Device, |
380 const CFX_AffineMatrix* pObject2Device, | 380 int fill_mode) { |
381 int fill_mode) { | |
382 m_PSRenderer.SetClip_PathFill(pPathData, pObject2Device, fill_mode); | 381 m_PSRenderer.SetClip_PathFill(pPathData, pObject2Device, fill_mode); |
383 return TRUE; | 382 return TRUE; |
384 } | 383 } |
385 FX_BOOL CPSPrinterDriver::SetClip_PathStroke( | 384 FX_BOOL CPSPrinterDriver::SetClip_PathStroke( |
386 const CFX_PathData* pPathData, | 385 const CFX_PathData* pPathData, |
387 const CFX_AffineMatrix* pObject2Device, | 386 const CFX_Matrix* pObject2Device, |
388 const CFX_GraphStateData* pGraphState) { | 387 const CFX_GraphStateData* pGraphState) { |
389 m_PSRenderer.SetClip_PathStroke(pPathData, pObject2Device, pGraphState); | 388 m_PSRenderer.SetClip_PathStroke(pPathData, pObject2Device, pGraphState); |
390 return TRUE; | 389 return TRUE; |
391 } | 390 } |
392 FX_BOOL CPSPrinterDriver::DrawPath(const CFX_PathData* pPathData, | 391 FX_BOOL CPSPrinterDriver::DrawPath(const CFX_PathData* pPathData, |
393 const CFX_AffineMatrix* pObject2Device, | 392 const CFX_Matrix* pObject2Device, |
394 const CFX_GraphStateData* pGraphState, | 393 const CFX_GraphStateData* pGraphState, |
395 FX_ARGB fill_color, | 394 FX_ARGB fill_color, |
396 FX_ARGB stroke_color, | 395 FX_ARGB stroke_color, |
397 int fill_mode, | 396 int fill_mode, |
398 int alpha_flag, | 397 int alpha_flag, |
399 void* pIccTransform, | 398 void* pIccTransform, |
400 int blend_type) { | 399 int blend_type) { |
401 if (blend_type != FXDIB_BLEND_NORMAL) { | 400 if (blend_type != FXDIB_BLEND_NORMAL) { |
402 return FALSE; | 401 return FALSE; |
403 } | 402 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 if (blend_type != FXDIB_BLEND_NORMAL) { | 436 if (blend_type != FXDIB_BLEND_NORMAL) { |
438 return FALSE; | 437 return FALSE; |
439 } | 438 } |
440 return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top, | 439 return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top, |
441 dest_width, dest_height, flags, alpha_flag, | 440 dest_width, dest_height, flags, alpha_flag, |
442 pIccTransform); | 441 pIccTransform); |
443 } | 442 } |
444 FX_BOOL CPSPrinterDriver::StartDIBits(const CFX_DIBSource* pBitmap, | 443 FX_BOOL CPSPrinterDriver::StartDIBits(const CFX_DIBSource* pBitmap, |
445 int bitmap_alpha, | 444 int bitmap_alpha, |
446 FX_DWORD color, | 445 FX_DWORD color, |
447 const CFX_AffineMatrix* pMatrix, | 446 const CFX_Matrix* pMatrix, |
448 FX_DWORD render_flags, | 447 FX_DWORD render_flags, |
449 void*& handle, | 448 void*& handle, |
450 int alpha_flag, | 449 int alpha_flag, |
451 void* pIccTransform, | 450 void* pIccTransform, |
452 int blend_type) { | 451 int blend_type) { |
453 if (blend_type != FXDIB_BLEND_NORMAL) { | 452 if (blend_type != FXDIB_BLEND_NORMAL) { |
454 return FALSE; | 453 return FALSE; |
455 } | 454 } |
456 if (bitmap_alpha < 255) { | 455 if (bitmap_alpha < 255) { |
457 return FALSE; | 456 return FALSE; |
458 } | 457 } |
459 handle = NULL; | 458 handle = NULL; |
460 return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags, | 459 return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags, |
461 alpha_flag, pIccTransform); | 460 alpha_flag, pIccTransform); |
462 } | 461 } |
463 FX_BOOL CPSPrinterDriver::DrawDeviceText(int nChars, | 462 FX_BOOL CPSPrinterDriver::DrawDeviceText(int nChars, |
464 const FXTEXT_CHARPOS* pCharPos, | 463 const FXTEXT_CHARPOS* pCharPos, |
465 CFX_Font* pFont, | 464 CFX_Font* pFont, |
466 CFX_FontCache* pCache, | 465 CFX_FontCache* pCache, |
467 const CFX_AffineMatrix* pObject2Device, | 466 const CFX_Matrix* pObject2Device, |
468 FX_FLOAT font_size, | 467 FX_FLOAT font_size, |
469 FX_DWORD color, | 468 FX_DWORD color, |
470 int alpha_flag, | 469 int alpha_flag, |
471 void* pIccTransform) { | 470 void* pIccTransform) { |
472 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device, | 471 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device, |
473 font_size, color, alpha_flag, pIccTransform); | 472 font_size, color, alpha_flag, pIccTransform); |
474 } | 473 } |
475 #endif | 474 #endif |
OLD | NEW |