| 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 CFX_RenderDevice::CFX_RenderDevice() { | 9 CFX_RenderDevice::CFX_RenderDevice() |
| 10 m_pDeviceDriver = nullptr; | 10 : m_pBitmap(nullptr), |
| 11 m_pBitmap = nullptr; | 11 m_Width(0), |
| 12 } | 12 m_Height(0), |
| 13 m_bpp(0), |
| 14 m_RenderCaps(0), |
| 15 m_DeviceClass(0), |
| 16 m_pDeviceDriver(nullptr) {} |
| 17 |
| 13 CFX_RenderDevice::~CFX_RenderDevice() { | 18 CFX_RenderDevice::~CFX_RenderDevice() { |
| 14 delete m_pDeviceDriver; | 19 delete m_pDeviceDriver; |
| 15 } | 20 } |
| 21 |
| 16 void CFX_RenderDevice::SetDeviceDriver(IFX_RenderDeviceDriver* pDriver) { | 22 void CFX_RenderDevice::SetDeviceDriver(IFX_RenderDeviceDriver* pDriver) { |
| 17 delete m_pDeviceDriver; | 23 delete m_pDeviceDriver; |
| 18 m_pDeviceDriver = pDriver; | 24 m_pDeviceDriver = pDriver; |
| 19 InitDeviceInfo(); | 25 InitDeviceInfo(); |
| 20 } | 26 } |
| 27 |
| 21 void CFX_RenderDevice::InitDeviceInfo() { | 28 void CFX_RenderDevice::InitDeviceInfo() { |
| 22 m_Width = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_WIDTH); | 29 m_Width = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_WIDTH); |
| 23 m_Height = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_HEIGHT); | 30 m_Height = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_HEIGHT); |
| 24 m_bpp = m_pDeviceDriver->GetDeviceCaps(FXDC_BITS_PIXEL); | 31 m_bpp = m_pDeviceDriver->GetDeviceCaps(FXDC_BITS_PIXEL); |
| 25 m_RenderCaps = m_pDeviceDriver->GetDeviceCaps(FXDC_RENDER_CAPS); | 32 m_RenderCaps = m_pDeviceDriver->GetDeviceCaps(FXDC_RENDER_CAPS); |
| 26 m_DeviceClass = m_pDeviceDriver->GetDeviceCaps(FXDC_DEVICE_CLASS); | 33 m_DeviceClass = m_pDeviceDriver->GetDeviceCaps(FXDC_DEVICE_CLASS); |
| 27 if (!m_pDeviceDriver->GetClipBox(&m_ClipBox)) { | 34 if (!m_pDeviceDriver->GetClipBox(&m_ClipBox)) { |
| 28 m_ClipBox.left = 0; | 35 m_ClipBox.left = 0; |
| 29 m_ClipBox.top = 0; | 36 m_ClipBox.top = 0; |
| 30 m_ClipBox.right = m_Width; | 37 m_ClipBox.right = m_Width; |
| 31 m_ClipBox.bottom = m_Height; | 38 m_ClipBox.bottom = m_Height; |
| 32 } | 39 } |
| 33 } | 40 } |
| 41 |
| 34 FX_BOOL CFX_RenderDevice::StartRendering() { | 42 FX_BOOL CFX_RenderDevice::StartRendering() { |
| 35 return m_pDeviceDriver->StartRendering(); | 43 return m_pDeviceDriver->StartRendering(); |
| 36 } | 44 } |
| 45 |
| 37 void CFX_RenderDevice::EndRendering() { | 46 void CFX_RenderDevice::EndRendering() { |
| 38 m_pDeviceDriver->EndRendering(); | 47 m_pDeviceDriver->EndRendering(); |
| 39 } | 48 } |
| 49 |
| 40 void CFX_RenderDevice::SaveState() { | 50 void CFX_RenderDevice::SaveState() { |
| 41 m_pDeviceDriver->SaveState(); | 51 m_pDeviceDriver->SaveState(); |
| 42 } | 52 } |
| 43 | 53 |
| 44 void CFX_RenderDevice::RestoreState(bool bKeepSaved) { | 54 void CFX_RenderDevice::RestoreState(bool bKeepSaved) { |
| 45 m_pDeviceDriver->RestoreState(bKeepSaved); | 55 m_pDeviceDriver->RestoreState(bKeepSaved); |
| 46 UpdateClipBox(); | 56 UpdateClipBox(); |
| 47 } | 57 } |
| 48 | 58 |
| 49 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const { | 59 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const { |
| 50 return m_pDeviceDriver->GetDeviceCaps(caps_id); | 60 return m_pDeviceDriver->GetDeviceCaps(caps_id); |
| 51 } | 61 } |
| 52 CFX_Matrix CFX_RenderDevice::GetCTM() const { | 62 CFX_Matrix CFX_RenderDevice::GetCTM() const { |
| 53 return m_pDeviceDriver->GetCTM(); | 63 return m_pDeviceDriver->GetCTM(); |
| 54 } | 64 } |
| 65 |
| 55 FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, | 66 FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, |
| 56 int width, | 67 int width, |
| 57 int height) const { | 68 int height) const { |
| 58 if (m_RenderCaps & FXRC_CMYK_OUTPUT) { | 69 if (m_RenderCaps & FXRC_CMYK_OUTPUT) { |
| 59 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT | 70 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT |
| 60 ? FXDIB_Cmyka | 71 ? FXDIB_Cmyka |
| 61 : FXDIB_Cmyk); | 72 : FXDIB_Cmyk); |
| 62 } | 73 } |
| 63 if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) { | 74 if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) { |
| 64 return pDIB->Create(width, height, FXDIB_8bppMask); | 75 return pDIB->Create(width, height, FXDIB_8bppMask); |
| 65 } | 76 } |
| 66 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 77 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 67 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT | 78 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT |
| 68 ? FXDIB_Argb | 79 ? FXDIB_Argb |
| 69 : FXDIB_Rgb32); | 80 : FXDIB_Rgb32); |
| 70 #else | 81 #else |
| 71 return pDIB->Create( | 82 return pDIB->Create( |
| 72 width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); | 83 width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); |
| 73 #endif | 84 #endif |
| 74 } | 85 } |
| 86 |
| 75 FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, | 87 FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, |
| 76 const CFX_Matrix* pObject2Device, | 88 const CFX_Matrix* pObject2Device, |
| 77 int fill_mode) { | 89 int fill_mode) { |
| 78 if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, | 90 if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, |
| 79 fill_mode)) { | 91 fill_mode)) { |
| 80 return FALSE; | 92 return FALSE; |
| 81 } | 93 } |
| 82 UpdateClipBox(); | 94 UpdateClipBox(); |
| 83 return TRUE; | 95 return TRUE; |
| 84 } | 96 } |
| 97 |
| 85 FX_BOOL CFX_RenderDevice::SetClip_PathStroke( | 98 FX_BOOL CFX_RenderDevice::SetClip_PathStroke( |
| 86 const CFX_PathData* pPathData, | 99 const CFX_PathData* pPathData, |
| 87 const CFX_Matrix* pObject2Device, | 100 const CFX_Matrix* pObject2Device, |
| 88 const CFX_GraphStateData* pGraphState) { | 101 const CFX_GraphStateData* pGraphState) { |
| 89 if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, | 102 if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, |
| 90 pGraphState)) { | 103 pGraphState)) { |
| 91 return FALSE; | 104 return FALSE; |
| 92 } | 105 } |
| 93 UpdateClipBox(); | 106 UpdateClipBox(); |
| 94 return TRUE; | 107 return TRUE; |
| 95 } | 108 } |
| 109 |
| 96 FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) { | 110 FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) { |
| 97 CFX_PathData path; | 111 CFX_PathData path; |
| 98 path.AppendRect(rect.left, rect.bottom, rect.right, rect.top); | 112 path.AppendRect(rect.left, rect.bottom, rect.right, rect.top); |
| 99 if (!SetClip_PathFill(&path, nullptr, FXFILL_WINDING)) | 113 if (!SetClip_PathFill(&path, nullptr, FXFILL_WINDING)) |
| 100 return FALSE; | 114 return FALSE; |
| 101 | 115 |
| 102 UpdateClipBox(); | 116 UpdateClipBox(); |
| 103 return TRUE; | 117 return TRUE; |
| 104 } | 118 } |
| 119 |
| 105 void CFX_RenderDevice::UpdateClipBox() { | 120 void CFX_RenderDevice::UpdateClipBox() { |
| 106 if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) { | 121 if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) { |
| 107 return; | 122 return; |
| 108 } | 123 } |
| 109 m_ClipBox.left = 0; | 124 m_ClipBox.left = 0; |
| 110 m_ClipBox.top = 0; | 125 m_ClipBox.top = 0; |
| 111 m_ClipBox.right = m_Width; | 126 m_ClipBox.right = m_Width; |
| 112 m_ClipBox.bottom = m_Height; | 127 m_ClipBox.bottom = m_Height; |
| 113 } | 128 } |
| 114 | 129 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 429 |
| 415 FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, | 430 FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, |
| 416 int left, | 431 int left, |
| 417 int top, | 432 int top, |
| 418 uint32_t argb) { | 433 uint32_t argb) { |
| 419 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); | 434 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); |
| 420 return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, | 435 return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, |
| 421 FXDIB_BLEND_NORMAL); | 436 FXDIB_BLEND_NORMAL); |
| 422 } | 437 } |
| 423 | 438 |
| 439 FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, |
| 440 int left, |
| 441 int top, |
| 442 int dest_width, |
| 443 int dest_height, |
| 444 uint32_t color) { |
| 445 return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height, |
| 446 color, 0); |
| 447 } |
| 448 |
| 424 FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, | 449 FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, |
| 425 int left, | 450 int left, |
| 426 int top, | 451 int top, |
| 427 int dest_width, | 452 int dest_width, |
| 428 int dest_height, | 453 int dest_height, |
| 429 uint32_t argb, | 454 uint32_t argb, |
| 430 uint32_t flags) { | 455 uint32_t flags) { |
| 431 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); | 456 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); |
| 432 FX_RECT clip_box = m_ClipBox; | 457 FX_RECT clip_box = m_ClipBox; |
| 433 clip_box.Intersect(dest_rect); | 458 clip_box.Intersect(dest_rect); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 447 flags, handle, blend_mode); | 472 flags, handle, blend_mode); |
| 448 } | 473 } |
| 449 | 474 |
| 450 FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { | 475 FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { |
| 451 return m_pDeviceDriver->ContinueDIBits(handle, pPause); | 476 return m_pDeviceDriver->ContinueDIBits(handle, pPause); |
| 452 } | 477 } |
| 453 | 478 |
| 454 void CFX_RenderDevice::CancelDIBits(void* handle) { | 479 void CFX_RenderDevice::CancelDIBits(void* handle) { |
| 455 m_pDeviceDriver->CancelDIBits(handle); | 480 m_pDeviceDriver->CancelDIBits(handle); |
| 456 } | 481 } |
| OLD | NEW |