| 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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
| 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ | 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #include "../../../include/fxge/fx_ge_win32.h" | 10 #include "../../../include/fxge/fx_ge_win32.h" |
| 11 #include "win32_int.h" | 11 #include "win32_int.h" |
| 12 #include "../../../include/fxge/fx_freetype.h" | 12 #include "../../../include/fxge/fx_freetype.h" |
| 13 #include "../ge/text_int.h" | 13 #include "../ge/text_int.h" |
| 14 #include "../dib/dib_int.h" | 14 #include "../dib/dib_int.h" |
| 15 #define SIZETHRESHOLD 1000 | 15 #define SIZETHRESHOLD 1000 |
| 16 #define OUTPUTPSLEN 4096 | 16 #define OUTPUTPSLEN 4096 |
| 17 CGdiPrinterDriver::CGdiPrinterDriver(HDC hDC) : CGdiDeviceDriver(hDC, FXDC_PRINT
ER) | 17 CGdiPrinterDriver::CGdiPrinterDriver(HDC hDC) : CGdiDeviceDriver(hDC, FXDC_PRINT
ER) |
| 18 { | 18 { |
| 19 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); | 19 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); |
| 20 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); | 20 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); |
| 21 m_bSupportROP = TRUE; | 21 m_bSupportROP = true; |
| 22 } | 22 } |
| 23 int CGdiPrinterDriver::GetDeviceCaps(int caps_id) | 23 int CGdiPrinterDriver::GetDeviceCaps(int caps_id) |
| 24 { | 24 { |
| 25 if (caps_id == FXDC_HORZ_SIZE) { | 25 if (caps_id == FXDC_HORZ_SIZE) { |
| 26 return m_HorzSize; | 26 return m_HorzSize; |
| 27 } | 27 } |
| 28 if (caps_id == FXDC_VERT_SIZE) { | 28 if (caps_id == FXDC_VERT_SIZE) { |
| 29 return m_VertSize; | 29 return m_VertSize; |
| 30 } | 30 } |
| 31 return CGdiDeviceDriver::GetDeviceCaps(caps_id); | 31 return CGdiDeviceDriver::GetDeviceCaps(caps_id); |
| 32 } | 32 } |
| 33 FX_BOOL CGdiPrinterDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD colo
r, const FX_RECT* pSrcRect, int left, int top, int blend_type, | 33 bool CGdiPrinterDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD color,
const FX_RECT* pSrcRect, int left, int top, int blend_type, |
| 34 int alpha_flag, void* pIccTransform) | 34 int alpha_flag, void* pIccTransform) |
| 35 { | 35 { |
| 36 if (pSource->IsAlphaMask()) { | 36 if (pSource->IsAlphaMask()) { |
| 37 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->H
eight()); | 37 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->H
eight()); |
| 38 return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRe
ct->top, pSource->GetWidth(), pSource->GetHeight(), | 38 return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRe
ct->top, pSource->GetWidth(), pSource->GetHeight(), |
| 39 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE
ND_NORMAL); | 39 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE
ND_NORMAL); |
| 40 } | 40 } |
| 41 ASSERT(pSource != NULL && !pSource->IsAlphaMask() && pSrcRect != NULL); | 41 ASSERT(pSource != NULL && !pSource->IsAlphaMask() && pSrcRect != NULL); |
| 42 ASSERT(blend_type == FXDIB_BLEND_NORMAL); | 42 ASSERT(blend_type == FXDIB_BLEND_NORMAL); |
| 43 if (pSource->HasAlpha()) { | 43 if (pSource->HasAlpha()) { |
| 44 return FALSE; | 44 return false; |
| 45 } | 45 } |
| 46 CFX_DIBExtractor temp(pSource); | 46 CFX_DIBExtractor temp(pSource); |
| 47 CFX_DIBitmap* pBitmap = temp; | 47 CFX_DIBitmap* pBitmap = temp; |
| 48 if (pBitmap == NULL) { | 48 if (pBitmap == NULL) { |
| 49 return FALSE; | 49 return false; |
| 50 } | 50 } |
| 51 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); | 51 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); |
| 52 } | 52 } |
| 53 FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD
color, int dest_left, int dest_top, | 53 bool CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD col
or, int dest_left, int dest_top, |
| 54 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag
s, | 54 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag
s, |
| 55 int alpha_flag, void* pIccTransform, int blend_type) | 55 int alpha_flag, void* pIccTransform, int blend_type) |
| 56 { | 56 { |
| 57 if (pSource->IsAlphaMask()) { | 57 if (pSource->IsAlphaMask()) { |
| 58 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha
_flag) : FXARGB_A(color); | 58 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha
_flag) : FXARGB_A(color); |
| 59 if (pSource->GetBPP() != 1 || alpha != 255 || !m_bSupportROP) { | 59 if (pSource->GetBPP() != 1 || alpha != 255 || !m_bSupportROP) { |
| 60 return FALSE; | 60 return false; |
| 61 } | 61 } |
| 62 if (dest_width < 0 || dest_height < 0) { | 62 if (dest_width < 0 || dest_height < 0) { |
| 63 CFX_DIBitmap* pFlipped = pSource->FlipImage(dest_width < 0, dest_hei
ght < 0); | 63 CFX_DIBitmap* pFlipped = pSource->FlipImage(dest_width < 0, dest_hei
ght < 0); |
| 64 if (pFlipped == NULL) { | 64 if (pFlipped == NULL) { |
| 65 return FALSE; | 65 return false; |
| 66 } | 66 } |
| 67 if (dest_width < 0) { | 67 if (dest_width < 0) { |
| 68 dest_left += dest_width; | 68 dest_left += dest_width; |
| 69 } | 69 } |
| 70 if (dest_height < 0) { | 70 if (dest_height < 0) { |
| 71 dest_top += dest_height; | 71 dest_top += dest_height; |
| 72 } | 72 } |
| 73 FX_BOOL ret = GDI_StretchBitMask(pFlipped, dest_left, dest_top, abs(
dest_width), abs(dest_height), color, flags, alpha_flag, pIccTransform); | 73 bool ret = GDI_StretchBitMask(pFlipped, dest_left, dest_top, abs(des
t_width), abs(dest_height), color, flags, alpha_flag, pIccTransform); |
| 74 delete pFlipped; | 74 delete pFlipped; |
| 75 return ret; | 75 return ret; |
| 76 } | 76 } |
| 77 CFX_DIBExtractor temp(pSource); | 77 CFX_DIBExtractor temp(pSource); |
| 78 CFX_DIBitmap* pBitmap = temp; | 78 CFX_DIBitmap* pBitmap = temp; |
| 79 if (pBitmap == NULL) { | 79 if (pBitmap == NULL) { |
| 80 return FALSE; | 80 return false; |
| 81 } | 81 } |
| 82 return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, dest
_height, color, flags, alpha_flag, pIccTransform); | 82 return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width, dest
_height, color, flags, alpha_flag, pIccTransform); |
| 83 } else { | 83 } else { |
| 84 ASSERT(pSource != NULL); | 84 ASSERT(pSource != NULL); |
| 85 if (pSource->HasAlpha()) { | 85 if (pSource->HasAlpha()) { |
| 86 return FALSE; | 86 return false; |
| 87 } | 87 } |
| 88 if (dest_width < 0 || dest_height < 0) { | 88 if (dest_width < 0 || dest_height < 0) { |
| 89 CFX_DIBitmap* pFlipped = pSource->FlipImage(dest_width < 0, dest_hei
ght < 0); | 89 CFX_DIBitmap* pFlipped = pSource->FlipImage(dest_width < 0, dest_hei
ght < 0); |
| 90 if (pFlipped == NULL) { | 90 if (pFlipped == NULL) { |
| 91 return FALSE; | 91 return false; |
| 92 } | 92 } |
| 93 if (dest_width < 0) { | 93 if (dest_width < 0) { |
| 94 dest_left += dest_width; | 94 dest_left += dest_width; |
| 95 } | 95 } |
| 96 if (dest_height < 0) { | 96 if (dest_height < 0) { |
| 97 dest_top += dest_height; | 97 dest_top += dest_height; |
| 98 } | 98 } |
| 99 FX_BOOL ret = GDI_StretchDIBits(pFlipped, dest_left, dest_top, abs(d
est_width), abs(dest_height), flags, pIccTransform); | 99 bool ret = GDI_StretchDIBits(pFlipped, dest_left, dest_top, abs(dest
_width), abs(dest_height), flags, pIccTransform); |
| 100 delete pFlipped; | 100 delete pFlipped; |
| 101 return ret; | 101 return ret; |
| 102 } | 102 } |
| 103 CFX_DIBExtractor temp(pSource); | 103 CFX_DIBExtractor temp(pSource); |
| 104 CFX_DIBitmap* pBitmap = temp; | 104 CFX_DIBitmap* pBitmap = temp; |
| 105 if (pBitmap == NULL) { | 105 if (pBitmap == NULL) { |
| 106 return FALSE; | 106 return false; |
| 107 } | 107 } |
| 108 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_
height, flags, pIccTransform); | 108 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_
height, flags, pIccTransform); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc, const CFX_Af
fineMatrix* pDestMatrix) | 111 static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc, const CFX_Af
fineMatrix* pDestMatrix) |
| 112 { | 112 { |
| 113 ASSERT(pSrc->GetFormat() == FXDIB_1bppRgb || pSrc->GetFormat() == FXDIB_1bpp
Mask || pSrc->GetFormat() == FXDIB_1bppCmyk); | 113 ASSERT(pSrc->GetFormat() == FXDIB_1bppRgb || pSrc->GetFormat() == FXDIB_1bpp
Mask || pSrc->GetFormat() == FXDIB_1bppCmyk); |
| 114 CFX_FloatRect unit_rect = pDestMatrix->GetUnitRect(); | 114 CFX_FloatRect unit_rect = pDestMatrix->GetUnitRect(); |
| 115 FX_RECT full_rect = unit_rect.GetOutterRect(); | 115 FX_RECT full_rect = unit_rect.GetOutterRect(); |
| 116 int full_left = full_rect.left; | 116 int full_left = full_rect.left; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 dest_scan[dest_x / 8] &= ~(1 << (7 - dest_x % 8)); | 185 dest_scan[dest_x / 8] &= ~(1 << (7 - dest_x % 8)); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 if (pSrcBitmap != src_bitmap) { | 189 if (pSrcBitmap != src_bitmap) { |
| 190 delete pSrcBitmap; | 190 delete pSrcBitmap; |
| 191 } | 191 } |
| 192 return pTempBitmap; | 192 return pTempBitmap; |
| 193 } | 193 } |
| 194 FX_BOOL»CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource, int bitmap_
alpha, FX_DWORD color, | 194 bool» CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource, int bitmap_
alpha, FX_DWORD color, |
| 195 const CFX_AffineMatrix* pMatrix, FX_DWORD
render_flags, void*& handle, | 195 const CFX_AffineMatrix* pMatrix, FX_DWORD
render_flags, void*& handle, |
| 196 int alpha_flag, void* pIccTransform, int
blend_type) | 196 int alpha_flag, void* pIccTransform, int
blend_type) |
| 197 { | 197 { |
| 198 if (bitmap_alpha < 255 || pSource->HasAlpha() || (pSource->IsAlphaMask() &&
(pSource->GetBPP() != 1 || !m_bSupportROP))) { | 198 if (bitmap_alpha < 255 || pSource->HasAlpha() || (pSource->IsAlphaMask() &&
(pSource->GetBPP() != 1 || !m_bSupportROP))) { |
| 199 return FALSE; | 199 return false; |
| 200 } | 200 } |
| 201 CFX_FloatRect unit_rect = pMatrix->GetUnitRect(); | 201 CFX_FloatRect unit_rect = pMatrix->GetUnitRect(); |
| 202 FX_RECT full_rect = unit_rect.GetOutterRect(); | 202 FX_RECT full_rect = unit_rect.GetOutterRect(); |
| 203 if (FXSYS_fabs(pMatrix->b) < 0.5f && pMatrix->a != 0 && FXSYS_fabs(pMatrix->
c) < 0.5f && pMatrix->d != 0) { | 203 if (FXSYS_fabs(pMatrix->b) < 0.5f && pMatrix->a != 0 && FXSYS_fabs(pMatrix->
c) < 0.5f && pMatrix->d != 0) { |
| 204 FX_BOOL bFlipX = pMatrix->a < 0; | 204 bool bFlipX = pMatrix->a < 0; |
| 205 FX_BOOL bFlipY = pMatrix->d > 0; | 205 bool bFlipY = pMatrix->d > 0; |
| 206 return StretchDIBits(pSource, color, bFlipX ? full_rect.right : full_rec
t.left, bFlipY ? full_rect.bottom : full_rect.top, | 206 return StretchDIBits(pSource, color, bFlipX ? full_rect.right : full_rec
t.left, bFlipY ? full_rect.bottom : full_rect.top, |
| 207 bFlipX ? -full_rect.Width() : full_rect.Width(), bF
lipY ? -full_rect.Height() : full_rect.Height(), NULL, 0, | 207 bFlipX ? -full_rect.Width() : full_rect.Width(), bF
lipY ? -full_rect.Height() : full_rect.Height(), NULL, 0, |
| 208 alpha_flag, pIccTransform, blend_type); | 208 alpha_flag, pIccTransform, blend_type); |
| 209 } | 209 } |
| 210 if (FXSYS_fabs(pMatrix->a) < 0.5f && FXSYS_fabs(pMatrix->d) < 0.5f) { | 210 if (FXSYS_fabs(pMatrix->a) < 0.5f && FXSYS_fabs(pMatrix->d) < 0.5f) { |
| 211 CFX_DIBitmap* pTransformed = pSource->SwapXY(pMatrix->c > 0, pMatrix->b
< 0); | 211 CFX_DIBitmap* pTransformed = pSource->SwapXY(pMatrix->c > 0, pMatrix->b
< 0); |
| 212 if (pTransformed == NULL) { | 212 if (pTransformed == NULL) { |
| 213 return FALSE; | 213 return false; |
| 214 } | 214 } |
| 215 FX_BOOL ret = StretchDIBits(pTransformed, color, full_rect.left, full_re
ct.top, full_rect.Width(), full_rect.Height(), NULL, 0, | 215 bool ret = StretchDIBits(pTransformed, color, full_rect.left, full_rect.
top, full_rect.Width(), full_rect.Height(), NULL, 0, |
| 216 alpha_flag, pIccTransform, blend_type); | 216 alpha_flag, pIccTransform, blend_type); |
| 217 delete pTransformed; | 217 delete pTransformed; |
| 218 return ret; | 218 return ret; |
| 219 } | 219 } |
| 220 if (pSource->GetBPP() == 1) { | 220 if (pSource->GetBPP() == 1) { |
| 221 CFX_DIBitmap* pTransformed = Transform1bppBitmap(pSource, pMatrix); | 221 CFX_DIBitmap* pTransformed = Transform1bppBitmap(pSource, pMatrix); |
| 222 if (pIccTransform == NULL) { | 222 if (pIccTransform == NULL) { |
| 223 return FALSE; | 223 return false; |
| 224 } | 224 } |
| 225 SaveState(); | 225 SaveState(); |
| 226 CFX_PathData path; | 226 CFX_PathData path; |
| 227 path.AppendRect(0, 0, 1.0f, 1.0f); | 227 path.AppendRect(0, 0, 1.0f, 1.0f); |
| 228 SetClip_PathFill(&path, pMatrix, WINDING); | 228 SetClip_PathFill(&path, pMatrix, WINDING); |
| 229 FX_BOOL ret = StretchDIBits(pTransformed, color, full_rect.left, full_re
ct.top, full_rect.Width(), full_rect.Height(), NULL, 0, | 229 bool ret = StretchDIBits(pTransformed, color, full_rect.left, full_rect.
top, full_rect.Width(), full_rect.Height(), NULL, 0, |
| 230 alpha_flag, pIccTransform, blend_type); | 230 alpha_flag, pIccTransform, blend_type); |
| 231 RestoreState(); | 231 RestoreState(); |
| 232 delete pTransformed; | 232 delete pTransformed; |
| 233 handle = NULL; | 233 handle = NULL; |
| 234 return ret; | 234 return ret; |
| 235 } | 235 } |
| 236 return FALSE; | 236 return false; |
| 237 } | 237 } |
| 238 CPSOutput::CPSOutput(HDC hDC) | 238 CPSOutput::CPSOutput(HDC hDC) |
| 239 { | 239 { |
| 240 m_hDC = hDC; | 240 m_hDC = hDC; |
| 241 m_pBuf = NULL; | 241 m_pBuf = NULL; |
| 242 } | 242 } |
| 243 CPSOutput::~CPSOutput() | 243 CPSOutput::~CPSOutput() |
| 244 { | 244 { |
| 245 if (m_pBuf) { | 245 if (m_pBuf) { |
| 246 FX_Free(m_pBuf); | 246 FX_Free(m_pBuf); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 261 *(FX_WORD*)m_pBuf = send_len; | 261 *(FX_WORD*)m_pBuf = send_len; |
| 262 FXSYS_memcpy(m_pBuf + 2, string + sent_len, send_len); | 262 FXSYS_memcpy(m_pBuf + 2, string + sent_len, send_len); |
| 263 int ret = ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, m_pBuf, 0, NULL); | 263 int ret = ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, m_pBuf, 0, NULL); |
| 264 sent_len += send_len; | 264 sent_len += send_len; |
| 265 len -= send_len; | 265 len -= send_len; |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 CPSPrinterDriver::CPSPrinterDriver() | 268 CPSPrinterDriver::CPSPrinterDriver() |
| 269 { | 269 { |
| 270 m_pPSOutput = NULL; | 270 m_pPSOutput = NULL; |
| 271 m_bCmykOutput = FALSE; | 271 m_bCmykOutput = false; |
| 272 } | 272 } |
| 273 CPSPrinterDriver::~CPSPrinterDriver() | 273 CPSPrinterDriver::~CPSPrinterDriver() |
| 274 { | 274 { |
| 275 EndRendering(); | 275 EndRendering(); |
| 276 delete m_pPSOutput; | 276 delete m_pPSOutput; |
| 277 } | 277 } |
| 278 FX_BOOL CPSPrinterDriver::Init(HDC hDC, int pslevel, FX_BOOL bCmykOutput) | 278 bool CPSPrinterDriver::Init(HDC hDC, int pslevel, bool bCmykOutput) |
| 279 { | 279 { |
| 280 m_hDC = hDC; | 280 m_hDC = hDC; |
| 281 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); | 281 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); |
| 282 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); | 282 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); |
| 283 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); | 283 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); |
| 284 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); | 284 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); |
| 285 m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL); | 285 m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL); |
| 286 m_pPSOutput = new CPSOutput(hDC); | 286 m_pPSOutput = new CPSOutput(hDC); |
| 287 ((CPSOutput*)m_pPSOutput)->Init(); | 287 ((CPSOutput*)m_pPSOutput)->Init(); |
| 288 m_PSRenderer.Init(m_pPSOutput, pslevel, m_Width, m_Height, bCmykOutput); | 288 m_PSRenderer.Init(m_pPSOutput, pslevel, m_Width, m_Height, bCmykOutput); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 300 for (FX_DWORD i = 0; i < pData->rdh.nCount; i ++) { | 300 for (FX_DWORD i = 0; i < pData->rdh.nCount; i ++) { |
| 301 RECT* pRect = (RECT*)(pData->Buffer + pData->rdh.nRgnSize *
i); | 301 RECT* pRect = (RECT*)(pData->Buffer + pData->rdh.nRgnSize *
i); |
| 302 path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bott
om, (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top); | 302 path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bott
om, (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top); |
| 303 } | 303 } |
| 304 m_PSRenderer.SetClip_PathFill(&path, NULL, FXFILL_WINDING); | 304 m_PSRenderer.SetClip_PathFill(&path, NULL, FXFILL_WINDING); |
| 305 } | 305 } |
| 306 FX_Free(pData); | 306 FX_Free(pData); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 ::DeleteObject(hRgn); | 309 ::DeleteObject(hRgn); |
| 310 return TRUE; | 310 return true; |
| 311 } | 311 } |
| 312 int CPSPrinterDriver::GetDeviceCaps(int caps_id) | 312 int CPSPrinterDriver::GetDeviceCaps(int caps_id) |
| 313 { | 313 { |
| 314 switch (caps_id) { | 314 switch (caps_id) { |
| 315 case FXDC_DEVICE_CLASS: | 315 case FXDC_DEVICE_CLASS: |
| 316 return FXDC_PRINTER; | 316 return FXDC_PRINTER; |
| 317 case FXDC_PIXEL_WIDTH: | 317 case FXDC_PIXEL_WIDTH: |
| 318 return m_Width; | 318 return m_Width; |
| 319 case FXDC_PIXEL_HEIGHT: | 319 case FXDC_PIXEL_HEIGHT: |
| 320 return m_Height; | 320 return m_Height; |
| 321 case FXDC_BITS_PIXEL: | 321 case FXDC_BITS_PIXEL: |
| 322 return m_nBitsPerPixel; | 322 return m_nBitsPerPixel; |
| 323 case FXDC_RENDER_CAPS: | 323 case FXDC_RENDER_CAPS: |
| 324 return m_bCmykOutput ? FXRC_BIT_MASK | FXRC_CMYK_OUTPUT : FXRC_BIT_M
ASK; | 324 return m_bCmykOutput ? FXRC_BIT_MASK | FXRC_CMYK_OUTPUT : FXRC_BIT_M
ASK; |
| 325 case FXDC_HORZ_SIZE: | 325 case FXDC_HORZ_SIZE: |
| 326 return m_HorzSize; | 326 return m_HorzSize; |
| 327 case FXDC_VERT_SIZE: | 327 case FXDC_VERT_SIZE: |
| 328 return m_VertSize; | 328 return m_VertSize; |
| 329 } | 329 } |
| 330 return 0; | 330 return 0; |
| 331 } | 331 } |
| 332 FX_BOOL CPSPrinterDriver::StartRendering() | 332 bool CPSPrinterDriver::StartRendering() |
| 333 { | 333 { |
| 334 return m_PSRenderer.StartRendering(); | 334 return m_PSRenderer.StartRendering(); |
| 335 } | 335 } |
| 336 void CPSPrinterDriver::EndRendering() | 336 void CPSPrinterDriver::EndRendering() |
| 337 { | 337 { |
| 338 m_PSRenderer.EndRendering(); | 338 m_PSRenderer.EndRendering(); |
| 339 } | 339 } |
| 340 void CPSPrinterDriver::SaveState() | 340 void CPSPrinterDriver::SaveState() |
| 341 { | 341 { |
| 342 m_PSRenderer.SaveState(); | 342 m_PSRenderer.SaveState(); |
| 343 } | 343 } |
| 344 void CPSPrinterDriver::RestoreState(FX_BOOL bKeepSaved) | 344 void CPSPrinterDriver::RestoreState(bool bKeepSaved) |
| 345 { | 345 { |
| 346 m_PSRenderer.RestoreState(bKeepSaved); | 346 m_PSRenderer.RestoreState(bKeepSaved); |
| 347 } | 347 } |
| 348 FX_BOOL»CPSPrinterDriver::SetClip_PathFill(const CFX_PathData* pPathData, const
CFX_AffineMatrix* pObject2Device, | 348 bool» CPSPrinterDriver::SetClip_PathFill(const CFX_PathData* pPathData, const
CFX_AffineMatrix* pObject2Device, |
| 349 int fill_mode) | 349 int fill_mode) |
| 350 { | 350 { |
| 351 m_PSRenderer.SetClip_PathFill(pPathData, pObject2Device, fill_mode); | 351 m_PSRenderer.SetClip_PathFill(pPathData, pObject2Device, fill_mode); |
| 352 return TRUE; | 352 return true; |
| 353 } | 353 } |
| 354 FX_BOOL»CPSPrinterDriver::SetClip_PathStroke(const CFX_PathData* pPathData, | 354 bool» CPSPrinterDriver::SetClip_PathStroke(const CFX_PathData* pPathData, |
| 355 const CFX_AffineMatrix* pObject2Device, | 355 const CFX_AffineMatrix* pObject2Device, |
| 356 const CFX_GraphStateData* pGraphState) | 356 const CFX_GraphStateData* pGraphState) |
| 357 { | 357 { |
| 358 m_PSRenderer.SetClip_PathStroke(pPathData, pObject2Device, pGraphState); | 358 m_PSRenderer.SetClip_PathStroke(pPathData, pObject2Device, pGraphState); |
| 359 return TRUE; | 359 return true; |
| 360 } | 360 } |
| 361 FX_BOOL»CPSPrinterDriver::DrawPath(const CFX_PathData* pPathData, | 361 bool» CPSPrinterDriver::DrawPath(const CFX_PathData* pPathData, |
| 362 const CFX_AffineMatrix* pObject2Device, | 362 const CFX_AffineMatrix* pObject2Device, |
| 363 const CFX_GraphStateData* pGraphState, FX_ARG
B fill_color, FX_ARGB stroke_color, | 363 const CFX_GraphStateData* pGraphState, FX_ARG
B fill_color, FX_ARGB stroke_color, |
| 364 int fill_mode, int alpha_flag, void* pIccTran
sform, int blend_type) | 364 int fill_mode, int alpha_flag, void* pIccTran
sform, int blend_type) |
| 365 { | 365 { |
| 366 if (blend_type != FXDIB_BLEND_NORMAL) { | 366 if (blend_type != FXDIB_BLEND_NORMAL) { |
| 367 return FALSE; | 367 return false; |
| 368 } | 368 } |
| 369 return m_PSRenderer.DrawPath(pPathData, pObject2Device, pGraphState, fill_co
lor, stroke_color, fill_mode & 3, alpha_flag, pIccTransform); | 369 return m_PSRenderer.DrawPath(pPathData, pObject2Device, pGraphState, fill_co
lor, stroke_color, fill_mode & 3, alpha_flag, pIccTransform); |
| 370 } | 370 } |
| 371 FX_BOOL CPSPrinterDriver::GetClipBox(FX_RECT* pRect) | 371 bool CPSPrinterDriver::GetClipBox(FX_RECT* pRect) |
| 372 { | 372 { |
| 373 *pRect = m_PSRenderer.GetClipBox(); | 373 *pRect = m_PSRenderer.GetClipBox(); |
| 374 return TRUE; | 374 return true; |
| 375 } | 375 } |
| 376 FX_BOOL CPSPrinterDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color
, const FX_RECT* pSrcRect, int left, int top, int blend_type, | 376 bool CPSPrinterDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, c
onst FX_RECT* pSrcRect, int left, int top, int blend_type, |
| 377 int alpha_flag, void* pIccTransform) | 377 int alpha_flag, void* pIccTransform) |
| 378 { | 378 { |
| 379 if (blend_type != FXDIB_BLEND_NORMAL) { | 379 if (blend_type != FXDIB_BLEND_NORMAL) { |
| 380 return FALSE; | 380 return false; |
| 381 } | 381 } |
| 382 return m_PSRenderer.SetDIBits(pBitmap, color, left, top, alpha_flag, pIccTra
nsform); | 382 return m_PSRenderer.SetDIBits(pBitmap, color, left, top, alpha_flag, pIccTra
nsform); |
| 383 } | 383 } |
| 384 FX_BOOL CPSPrinterDriver::StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD c
olor, int dest_left, int dest_top, | 384 bool CPSPrinterDriver::StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD colo
r, int dest_left, int dest_top, |
| 385 int dest_width, int dest_height, const F
X_RECT* pClipRect, FX_DWORD flags, | 385 int dest_width, int dest_height, const F
X_RECT* pClipRect, FX_DWORD flags, |
| 386 int alpha_flag, void* pIccTransform, int
blend_type) | 386 int alpha_flag, void* pIccTransform, int
blend_type) |
| 387 { | 387 { |
| 388 if (blend_type != FXDIB_BLEND_NORMAL) { | 388 if (blend_type != FXDIB_BLEND_NORMAL) { |
| 389 return FALSE; | 389 return false; |
| 390 } | 390 } |
| 391 return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top, dest_
width, dest_height, flags, alpha_flag, pIccTransform); | 391 return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top, dest_
width, dest_height, flags, alpha_flag, pIccTransform); |
| 392 } | 392 } |
| 393 FX_BOOL»CPSPrinterDriver::StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_a
lpha, FX_DWORD color, | 393 bool» CPSPrinterDriver::StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_a
lpha, FX_DWORD color, |
| 394 const CFX_AffineMatrix* pMatrix, FX_DWORD
render_flags, void*& handle, | 394 const CFX_AffineMatrix* pMatrix, FX_DWORD
render_flags, void*& handle, |
| 395 int alpha_flag, void* pIccTransform, int b
lend_type) | 395 int alpha_flag, void* pIccTransform, int b
lend_type) |
| 396 { | 396 { |
| 397 if (blend_type != FXDIB_BLEND_NORMAL) { | 397 if (blend_type != FXDIB_BLEND_NORMAL) { |
| 398 return FALSE; | 398 return false; |
| 399 } | 399 } |
| 400 if (bitmap_alpha < 255) { | 400 if (bitmap_alpha < 255) { |
| 401 return FALSE; | 401 return false; |
| 402 } | 402 } |
| 403 handle = NULL; | 403 handle = NULL; |
| 404 return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags, alpha_
flag, pIccTransform); | 404 return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags, alpha_
flag, pIccTransform); |
| 405 } | 405 } |
| 406 FX_BOOL»CPSPrinterDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pChar
Pos, CFX_Font* pFont, | 406 bool» CPSPrinterDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pChar
Pos, CFX_Font* pFont, |
| 407 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT
font_size, FX_DWORD color, | 407 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT
font_size, FX_DWORD color, |
| 408 int alpha_flag, void* pIccTransform) | 408 int alpha_flag, void* pIccTransform) |
| 409 { | 409 { |
| 410 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device
, font_size, color, alpha_flag, pIccTransform); | 410 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device
, font_size, color, alpha_flag, pIccTransform); |
| 411 } | 411 } |
| 412 #endif | 412 #endif |
| OLD | NEW |