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_ | 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include "../../../include/fxge/fx_ge_win32.h" | 10 #include "../../../include/fxge/fx_ge_win32.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 src2result.a = adjusted_matrix.a / pSrcBitmap->GetWidth(); | 136 src2result.a = adjusted_matrix.a / pSrcBitmap->GetWidth(); |
137 src2result.b = adjusted_matrix.b / pSrcBitmap->GetWidth(); | 137 src2result.b = adjusted_matrix.b / pSrcBitmap->GetWidth(); |
138 src2result.c = -adjusted_matrix.c / pSrcBitmap->GetHeight(); | 138 src2result.c = -adjusted_matrix.c / pSrcBitmap->GetHeight(); |
139 src2result.d = -adjusted_matrix.d / pSrcBitmap->GetHeight(); | 139 src2result.d = -adjusted_matrix.d / pSrcBitmap->GetHeight(); |
140 src2result.TranslateI(-result_rect.left, -result_rect.top); | 140 src2result.TranslateI(-result_rect.left, -result_rect.top); |
141 CFX_AffineMatrix result2src; | 141 CFX_AffineMatrix result2src; |
142 result2src.SetReverse(src2result); | 142 result2src.SetReverse(src2result); |
143 CPDF_FixedMatrix result2src_fix(result2src, 8); | 143 CPDF_FixedMatrix result2src_fix(result2src, 8); |
144 int result_width = result_rect.Width(); | 144 int result_width = result_rect.Width(); |
145 int result_height = result_rect.Height(); | 145 int result_height = result_rect.Height(); |
146 CFX_DIBitmap* pTempBitmap = FX_NEW CFX_DIBitmap; | 146 CFX_DIBitmap* pTempBitmap = new CFX_DIBitmap; |
147 if (!pTempBitmap) { | |
148 if (pSrcBitmap != src_bitmap) { | |
149 delete pSrcBitmap; | |
150 } | |
151 return NULL; | |
152 } | |
153 if (!pTempBitmap->Create(result_width, result_height, pSrc->GetFormat())) { | 147 if (!pTempBitmap->Create(result_width, result_height, pSrc->GetFormat())) { |
154 delete pTempBitmap; | 148 delete pTempBitmap; |
155 if (pSrcBitmap != src_bitmap) { | 149 if (pSrcBitmap != src_bitmap) { |
156 delete pSrcBitmap; | 150 delete pSrcBitmap; |
157 } | 151 } |
158 return NULL; | 152 return NULL; |
159 } | 153 } |
160 pTempBitmap->CopyPalette(pSrc->GetPalette()); | 154 pTempBitmap->CopyPalette(pSrc->GetPalette()); |
161 FX_LPBYTE dest_buf = pTempBitmap->GetBuffer(); | 155 FX_LPBYTE dest_buf = pTempBitmap->GetBuffer(); |
162 int dest_pitch = pTempBitmap->GetPitch(); | 156 int dest_pitch = pTempBitmap->GetPitch(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 } | 278 } |
285 } | 279 } |
286 FX_BOOL CPSPrinterDriver::Init(HDC hDC, int pslevel, FX_BOOL bCmykOutput) | 280 FX_BOOL CPSPrinterDriver::Init(HDC hDC, int pslevel, FX_BOOL bCmykOutput) |
287 { | 281 { |
288 m_hDC = hDC; | 282 m_hDC = hDC; |
289 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); | 283 m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); |
290 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); | 284 m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); |
291 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); | 285 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); |
292 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); | 286 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); |
293 m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL); | 287 m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL); |
294 m_pPSOutput = FX_NEW CPSOutput(hDC); | 288 m_pPSOutput = new CPSOutput(hDC); |
295 if (!m_pPSOutput) { | |
296 return FALSE; | |
297 } | |
298 ((CPSOutput*)m_pPSOutput)->Init(); | 289 ((CPSOutput*)m_pPSOutput)->Init(); |
299 m_PSRenderer.Init(m_pPSOutput, pslevel, m_Width, m_Height, bCmykOutput); | 290 m_PSRenderer.Init(m_pPSOutput, pslevel, m_Width, m_Height, bCmykOutput); |
300 m_bCmykOutput = bCmykOutput; | 291 m_bCmykOutput = bCmykOutput; |
301 HRGN hRgn = ::CreateRectRgn(0, 0, 1, 1); | 292 HRGN hRgn = ::CreateRectRgn(0, 0, 1, 1); |
302 int ret = ::GetClipRgn(hDC, hRgn); | 293 int ret = ::GetClipRgn(hDC, hRgn); |
303 if (ret == 1) { | 294 if (ret == 1) { |
304 ret = ::GetRegionData(hRgn, 0, NULL); | 295 ret = ::GetRegionData(hRgn, 0, NULL); |
305 if (ret) { | 296 if (ret) { |
306 RGNDATA* pData = (RGNDATA*)FX_Alloc(FX_BYTE, ret); | 297 RGNDATA* pData = (RGNDATA*)FX_Alloc(FX_BYTE, ret); |
307 if (!pData) { | 298 if (!pData) { |
308 return FALSE; | 299 return FALSE; |
309 } | 300 } |
310 ret = ::GetRegionData(hRgn, ret, pData); | 301 ret = ::GetRegionData(hRgn, ret, pData); |
311 if (ret) { | 302 if (ret) { |
312 CFX_PathData path; | 303 CFX_PathData path; |
313 path.AllocPointCount(pData->rdh.nCount * 5); | 304 path.AllocPointCount(pData->rdh.nCount * 5); |
314 for (FX_DWORD i = 0; i < pData->rdh.nCount; i ++) { | 305 for (FX_DWORD i = 0; i < pData->rdh.nCount; i ++) { |
315 RECT* pRect = (RECT*)(pData->Buffer + pData->rdh.nRgnSize * i); | 306 RECT* pRect = (RECT*)(pData->Buffer + pData->rdh.nRgnSize * i); |
316 path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bott om, (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top); | 307 path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bott om, (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top); |
317 } | 308 } |
318 m_PSRenderer.SetClip_PathFill(&path, NULL, FXFILL_WINDING); | 309 m_PSRenderer.SetClip_PathFill(&path, NULL, FXFILL_WINDING); |
319 } | 310 } |
320 FX_Free(pData); | 311 FX_Free(pData); |
321 } | 312 } |
322 } | 313 } |
323 ::DeleteObject(hRgn); | 314 ::DeleteObject(hRgn); |
324 return TRUE; | 315 return TRUE; |
Lei Zhang
2015/04/16 08:04:10
This always returns true now but we can make anoth
| |
325 } | 316 } |
326 int CPSPrinterDriver::GetDeviceCaps(int caps_id) | 317 int CPSPrinterDriver::GetDeviceCaps(int caps_id) |
327 { | 318 { |
328 switch (caps_id) { | 319 switch (caps_id) { |
329 case FXDC_DEVICE_CLASS: | 320 case FXDC_DEVICE_CLASS: |
330 return FXDC_PRINTER; | 321 return FXDC_PRINTER; |
331 case FXDC_PIXEL_WIDTH: | 322 case FXDC_PIXEL_WIDTH: |
332 return m_Width; | 323 return m_Width; |
333 case FXDC_PIXEL_HEIGHT: | 324 case FXDC_PIXEL_HEIGHT: |
334 return m_Height; | 325 return m_Height; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 handle = NULL; | 408 handle = NULL; |
418 return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags, alpha_ flag, pIccTransform); | 409 return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags, alpha_ flag, pIccTransform); |
419 } | 410 } |
420 FX_BOOL CPSPrinterDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pChar Pos, CFX_Font* pFont, | 411 FX_BOOL CPSPrinterDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pChar Pos, CFX_Font* pFont, |
421 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color, | 412 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FLOAT font_size, FX_DWORD color, |
422 int alpha_flag, void* pIccTransform) | 413 int alpha_flag, void* pIccTransform) |
423 { | 414 { |
424 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device , font_size, color, alpha_flag, pIccTransform); | 415 return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device , font_size, color, alpha_flag, pIccTransform); |
425 } | 416 } |
426 #endif | 417 #endif |
OLD | NEW |