| 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/fxge/include/fx_ge.h" | 7 #include "core/fxge/include/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 ASSERT(pSource && !pSource->IsAlphaMask() && pSrcRect); | 48 ASSERT(pSource && !pSource->IsAlphaMask() && pSrcRect); |
| 49 ASSERT(blend_type == FXDIB_BLEND_NORMAL); | 49 ASSERT(blend_type == FXDIB_BLEND_NORMAL); |
| 50 if (pSource->HasAlpha()) | 50 if (pSource->HasAlpha()) |
| 51 return FALSE; | 51 return FALSE; |
| 52 | 52 |
| 53 CFX_DIBExtractor temp(pSource); | 53 CFX_DIBExtractor temp(pSource); |
| 54 CFX_DIBitmap* pBitmap = temp; | 54 CFX_DIBitmap* pBitmap = temp; |
| 55 if (!pBitmap) | 55 if (!pBitmap) |
| 56 return FALSE; | 56 return FALSE; |
| 57 | 57 |
| 58 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, nullptr); | 58 return GDI_SetDIBits(pBitmap, pSrcRect, left, top); |
| 59 } | 59 } |
| 60 | 60 |
| 61 FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, | 61 FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, |
| 62 uint32_t color, | 62 uint32_t color, |
| 63 int dest_left, | 63 int dest_left, |
| 64 int dest_top, | 64 int dest_top, |
| 65 int dest_width, | 65 int dest_width, |
| 66 int dest_height, | 66 int dest_height, |
| 67 const FX_RECT* pClipRect, | 67 const FX_RECT* pClipRect, |
| 68 uint32_t flags, | 68 uint32_t flags, |
| 69 int blend_type) { | 69 int blend_type) { |
| 70 if (pSource->IsAlphaMask()) { | 70 if (pSource->IsAlphaMask()) { |
| 71 int alpha = FXARGB_A(color); | 71 int alpha = FXARGB_A(color); |
| 72 if (pSource->GetBPP() != 1 || alpha != 255) | 72 if (pSource->GetBPP() != 1 || alpha != 255) |
| 73 return FALSE; | 73 return FALSE; |
| 74 | 74 |
| 75 if (dest_width < 0 || dest_height < 0) { | 75 if (dest_width < 0 || dest_height < 0) { |
| 76 std::unique_ptr<CFX_DIBitmap> pFlipped( | 76 std::unique_ptr<CFX_DIBitmap> pFlipped( |
| 77 pSource->FlipImage(dest_width < 0, dest_height < 0)); | 77 pSource->FlipImage(dest_width < 0, dest_height < 0)); |
| 78 if (!pFlipped) | 78 if (!pFlipped) |
| 79 return FALSE; | 79 return FALSE; |
| 80 | 80 |
| 81 if (dest_width < 0) | 81 if (dest_width < 0) |
| 82 dest_left += dest_width; | 82 dest_left += dest_width; |
| 83 if (dest_height < 0) | 83 if (dest_height < 0) |
| 84 dest_top += dest_height; | 84 dest_top += dest_height; |
| 85 | 85 |
| 86 return GDI_StretchBitMask(pFlipped.get(), dest_left, dest_top, | 86 return GDI_StretchBitMask(pFlipped.get(), dest_left, dest_top, |
| 87 abs(dest_width), abs(dest_height), color, flags, | 87 abs(dest_width), abs(dest_height), color, |
| 88 0, nullptr); | 88 flags); |
| 89 } | 89 } |
| 90 | 90 |
| 91 CFX_DIBExtractor temp(pSource); | 91 CFX_DIBExtractor temp(pSource); |
| 92 CFX_DIBitmap* pBitmap = temp; | 92 CFX_DIBitmap* pBitmap = temp; |
| 93 if (!pBitmap) | 93 if (!pBitmap) |
| 94 return FALSE; | 94 return FALSE; |
| 95 return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, | 95 return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, |
| 96 dest_height, color, flags, 0, nullptr); | 96 dest_height, color, flags); |
| 97 } | 97 } |
| 98 | 98 |
| 99 if (pSource->HasAlpha()) | 99 if (pSource->HasAlpha()) |
| 100 return FALSE; | 100 return FALSE; |
| 101 | 101 |
| 102 if (dest_width < 0 || dest_height < 0) { | 102 if (dest_width < 0 || dest_height < 0) { |
| 103 std::unique_ptr<CFX_DIBitmap> pFlipped( | 103 std::unique_ptr<CFX_DIBitmap> pFlipped( |
| 104 pSource->FlipImage(dest_width < 0, dest_height < 0)); | 104 pSource->FlipImage(dest_width < 0, dest_height < 0)); |
| 105 if (!pFlipped) | 105 if (!pFlipped) |
| 106 return FALSE; | 106 return FALSE; |
| 107 | 107 |
| 108 if (dest_width < 0) | 108 if (dest_width < 0) |
| 109 dest_left += dest_width; | 109 dest_left += dest_width; |
| 110 if (dest_height < 0) | 110 if (dest_height < 0) |
| 111 dest_top += dest_height; | 111 dest_top += dest_height; |
| 112 | 112 |
| 113 return GDI_StretchDIBits(pFlipped.get(), dest_left, dest_top, | 113 return GDI_StretchDIBits(pFlipped.get(), dest_left, dest_top, |
| 114 abs(dest_width), abs(dest_height), flags, nullptr); | 114 abs(dest_width), abs(dest_height), flags); |
| 115 } | 115 } |
| 116 | 116 |
| 117 CFX_DIBExtractor temp(pSource); | 117 CFX_DIBExtractor temp(pSource); |
| 118 CFX_DIBitmap* pBitmap = temp; | 118 CFX_DIBitmap* pBitmap = temp; |
| 119 if (!pBitmap) | 119 if (!pBitmap) |
| 120 return FALSE; | 120 return FALSE; |
| 121 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, | 121 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, |
| 122 dest_height, flags, nullptr); | 122 dest_height, flags); |
| 123 } | 123 } |
| 124 | 124 |
| 125 FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource, | 125 FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource, |
| 126 int bitmap_alpha, | 126 int bitmap_alpha, |
| 127 uint32_t color, | 127 uint32_t color, |
| 128 const CFX_Matrix* pMatrix, | 128 const CFX_Matrix* pMatrix, |
| 129 uint32_t render_flags, | 129 uint32_t render_flags, |
| 130 void*& handle, | 130 void*& handle, |
| 131 int blend_type) { | 131 int blend_type) { |
| 132 if (bitmap_alpha < 255 || pSource->HasAlpha() || | 132 if (bitmap_alpha < 255 || pSource->HasAlpha() || |
| (...skipping 20 matching lines...) Expand all Loading... |
| 153 return FALSE; | 153 return FALSE; |
| 154 | 154 |
| 155 return StretchDIBits(pTransformed.get(), color, full_rect.left, | 155 return StretchDIBits(pTransformed.get(), color, full_rect.left, |
| 156 full_rect.top, full_rect.Width(), full_rect.Height(), | 156 full_rect.top, full_rect.Width(), full_rect.Height(), |
| 157 nullptr, 0, blend_type); | 157 nullptr, 0, blend_type); |
| 158 } | 158 } |
| 159 return FALSE; | 159 return FALSE; |
| 160 } | 160 } |
| 161 | 161 |
| 162 #endif | 162 #endif |
| OLD | NEW |