| 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 <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 int dest_height, | 101 int dest_height, |
| 102 const FX_RECT* pClipRect, | 102 const FX_RECT* pClipRect, |
| 103 uint32_t flags, | 103 uint32_t flags, |
| 104 int blend_type) { | 104 int blend_type) { |
| 105 if (pSource->IsAlphaMask()) { | 105 if (pSource->IsAlphaMask()) { |
| 106 int alpha = FXARGB_A(color); | 106 int alpha = FXARGB_A(color); |
| 107 if (pSource->GetBPP() != 1 || alpha != 255) | 107 if (pSource->GetBPP() != 1 || alpha != 255) |
| 108 return false; | 108 return false; |
| 109 | 109 |
| 110 if (dest_width < 0 || dest_height < 0) { | 110 if (dest_width < 0 || dest_height < 0) { |
| 111 std::unique_ptr<CFX_DIBitmap> pFlipped( | 111 std::unique_ptr<CFX_DIBitmap> pFlipped = |
| 112 pSource->FlipImage(dest_width < 0, dest_height < 0)); | 112 pSource->FlipImage(dest_width < 0, dest_height < 0); |
| 113 if (!pFlipped) | 113 if (!pFlipped) |
| 114 return false; | 114 return false; |
| 115 | 115 |
| 116 if (dest_width < 0) | 116 if (dest_width < 0) |
| 117 dest_left += dest_width; | 117 dest_left += dest_width; |
| 118 if (dest_height < 0) | 118 if (dest_height < 0) |
| 119 dest_top += dest_height; | 119 dest_top += dest_height; |
| 120 | 120 |
| 121 return GDI_StretchBitMask(pFlipped.get(), dest_left, dest_top, | 121 return GDI_StretchBitMask(pFlipped.get(), dest_left, dest_top, |
| 122 abs(dest_width), abs(dest_height), color, | 122 abs(dest_width), abs(dest_height), color, |
| 123 flags); | 123 flags); |
| 124 } | 124 } |
| 125 | 125 |
| 126 CFX_DIBExtractor temp(pSource); | 126 CFX_DIBExtractor temp(pSource); |
| 127 CFX_DIBitmap* pBitmap = temp.GetBitmap(); | 127 CFX_DIBitmap* pBitmap = temp.GetBitmap(); |
| 128 if (!pBitmap) | 128 if (!pBitmap) |
| 129 return false; | 129 return false; |
| 130 return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, | 130 return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, |
| 131 dest_height, color, flags); | 131 dest_height, color, flags); |
| 132 } | 132 } |
| 133 | 133 |
| 134 if (pSource->HasAlpha()) | 134 if (pSource->HasAlpha()) |
| 135 return false; | 135 return false; |
| 136 | 136 |
| 137 if (dest_width < 0 || dest_height < 0) { | 137 if (dest_width < 0 || dest_height < 0) { |
| 138 std::unique_ptr<CFX_DIBitmap> pFlipped( | 138 std::unique_ptr<CFX_DIBitmap> pFlipped = |
| 139 pSource->FlipImage(dest_width < 0, dest_height < 0)); | 139 pSource->FlipImage(dest_width < 0, dest_height < 0); |
| 140 if (!pFlipped) | 140 if (!pFlipped) |
| 141 return false; | 141 return false; |
| 142 | 142 |
| 143 if (dest_width < 0) | 143 if (dest_width < 0) |
| 144 dest_left += dest_width; | 144 dest_left += dest_width; |
| 145 if (dest_height < 0) | 145 if (dest_height < 0) |
| 146 dest_top += dest_height; | 146 dest_top += dest_height; |
| 147 | 147 |
| 148 return GDI_StretchDIBits(pFlipped.get(), dest_left, dest_top, | 148 return GDI_StretchDIBits(pFlipped.get(), dest_left, dest_top, |
| 149 abs(dest_width), abs(dest_height), flags); | 149 abs(dest_width), abs(dest_height), flags); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 177 return StretchDIBits(pSource, color, | 177 return StretchDIBits(pSource, color, |
| 178 bFlipX ? full_rect.right : full_rect.left, | 178 bFlipX ? full_rect.right : full_rect.left, |
| 179 bFlipY ? full_rect.bottom : full_rect.top, | 179 bFlipY ? full_rect.bottom : full_rect.top, |
| 180 bFlipX ? -full_rect.Width() : full_rect.Width(), | 180 bFlipX ? -full_rect.Width() : full_rect.Width(), |
| 181 bFlipY ? -full_rect.Height() : full_rect.Height(), | 181 bFlipY ? -full_rect.Height() : full_rect.Height(), |
| 182 nullptr, 0, blend_type); | 182 nullptr, 0, blend_type); |
| 183 } | 183 } |
| 184 if (FXSYS_fabs(pMatrix->a) >= 0.5f || FXSYS_fabs(pMatrix->d) >= 0.5f) | 184 if (FXSYS_fabs(pMatrix->a) >= 0.5f || FXSYS_fabs(pMatrix->d) >= 0.5f) |
| 185 return false; | 185 return false; |
| 186 | 186 |
| 187 std::unique_ptr<CFX_DIBitmap> pTransformed( | 187 std::unique_ptr<CFX_DIBitmap> pTransformed = |
| 188 pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0)); | 188 pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0); |
| 189 if (!pTransformed) | 189 if (!pTransformed) |
| 190 return false; | 190 return false; |
| 191 | 191 |
| 192 return StretchDIBits(pTransformed.get(), color, full_rect.left, full_rect.top, | 192 return StretchDIBits(pTransformed.get(), color, full_rect.left, full_rect.top, |
| 193 full_rect.Width(), full_rect.Height(), nullptr, 0, | 193 full_rect.Width(), full_rect.Height(), nullptr, 0, |
| 194 blend_type); | 194 blend_type); |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool CGdiPrinterDriver::DrawDeviceText(int nChars, | 197 bool CGdiPrinterDriver::DrawDeviceText(int nChars, |
| 198 const FXTEXT_CHARPOS* pCharPos, | 198 const FXTEXT_CHARPOS* pCharPos, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return false; | 319 return false; |
| 320 | 320 |
| 321 // Try to get the font and draw again. | 321 // Try to get the font and draw again. |
| 322 g_pdfium_typeface_accessible_func(&lf, wsText.c_str(), nChars); | 322 g_pdfium_typeface_accessible_func(&lf, wsText.c_str(), nChars); |
| 323 return !!ExtTextOutW(m_hDC, 0, 0, ETO_GLYPH_INDEX, nullptr, wsText.c_str(), | 323 return !!ExtTextOutW(m_hDC, 0, 0, ETO_GLYPH_INDEX, nullptr, wsText.c_str(), |
| 324 nChars, nChars > 1 ? &spacing[1] : nullptr); | 324 nChars, nChars > 1 ? &spacing[1] : nullptr); |
| 325 #else | 325 #else |
| 326 return false; | 326 return false; |
| 327 #endif | 327 #endif |
| 328 } | 328 } |
| OLD | NEW |