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/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" | 9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" |
10 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" | 10 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 : m_pFormResource(nullptr), | 135 : m_pFormResource(nullptr), |
136 m_pPageResource(nullptr), | 136 m_pPageResource(nullptr), |
137 m_pContext(nullptr), | 137 m_pContext(nullptr), |
138 m_bStopped(FALSE), | 138 m_bStopped(FALSE), |
139 m_pDevice(nullptr), | 139 m_pDevice(nullptr), |
140 m_pCurObj(nullptr), | 140 m_pCurObj(nullptr), |
141 m_pStopObj(nullptr), | 141 m_pStopObj(nullptr), |
142 m_HalftoneLimit(0), | 142 m_HalftoneLimit(0), |
143 m_bPrint(FALSE), | 143 m_bPrint(FALSE), |
144 m_Transparency(0), | 144 m_Transparency(0), |
145 m_DitherBits(0), | |
146 m_bDropObjects(FALSE), | 145 m_bDropObjects(FALSE), |
147 m_bStdCS(FALSE), | 146 m_bStdCS(FALSE), |
148 m_GroupFamily(0), | 147 m_GroupFamily(0), |
149 m_bLoadMask(FALSE), | 148 m_bLoadMask(FALSE), |
150 m_pType3Char(nullptr), | 149 m_pType3Char(nullptr), |
151 m_T3FillColor(0), | 150 m_T3FillColor(0), |
152 m_curBlend(FXDIB_BLEND_NORMAL) {} | 151 m_curBlend(FXDIB_BLEND_NORMAL) {} |
153 | 152 |
154 CPDF_RenderStatus::~CPDF_RenderStatus() {} | 153 CPDF_RenderStatus::~CPDF_RenderStatus() {} |
155 | 154 |
156 FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, | 155 FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, |
157 CFX_RenderDevice* pDevice, | 156 CFX_RenderDevice* pDevice, |
158 const CFX_Matrix* pDeviceMatrix, | 157 const CFX_Matrix* pDeviceMatrix, |
159 const CPDF_PageObject* pStopObj, | 158 const CPDF_PageObject* pStopObj, |
160 const CPDF_RenderStatus* pParentState, | 159 const CPDF_RenderStatus* pParentState, |
161 const CPDF_GraphicStates* pInitialStates, | 160 const CPDF_GraphicStates* pInitialStates, |
162 const CPDF_RenderOptions* pOptions, | 161 const CPDF_RenderOptions* pOptions, |
163 int transparency, | 162 int transparency, |
164 FX_BOOL bDropObjects, | 163 FX_BOOL bDropObjects, |
165 CPDF_Dictionary* pFormResource, | 164 CPDF_Dictionary* pFormResource, |
166 FX_BOOL bStdCS, | 165 FX_BOOL bStdCS, |
167 CPDF_Type3Char* pType3Char, | 166 CPDF_Type3Char* pType3Char, |
168 FX_ARGB fill_color, | 167 FX_ARGB fill_color, |
169 uint32_t GroupFamily, | 168 uint32_t GroupFamily, |
170 FX_BOOL bLoadMask) { | 169 FX_BOOL bLoadMask) { |
171 m_pContext = pContext; | 170 m_pContext = pContext; |
172 m_pDevice = pDevice; | 171 m_pDevice = pDevice; |
173 m_DitherBits = pDevice->GetDeviceCaps(FXDC_DITHER_BITS); | |
174 m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; | 172 m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; |
175 if (pDeviceMatrix) { | 173 if (pDeviceMatrix) { |
176 m_DeviceMatrix = *pDeviceMatrix; | 174 m_DeviceMatrix = *pDeviceMatrix; |
177 } | 175 } |
178 m_pStopObj = pStopObj; | 176 m_pStopObj = pStopObj; |
179 if (pOptions) { | 177 if (pOptions) { |
180 m_Options = *pOptions; | 178 m_Options = *pOptions; |
181 } | 179 } |
182 m_bDropObjects = bDropObjects; | 180 m_bDropObjects = bDropObjects; |
183 m_bStdCS = bStdCS; | 181 m_bStdCS = bStdCS; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height() * d); | 311 rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height() * d); |
314 rtClip.right = | 312 rtClip.right = |
315 rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Width() * a); | 313 rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Width() * a); |
316 rtClip.bottom = | 314 rtClip.bottom = |
317 rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d); | 315 rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d); |
318 } | 316 } |
319 } | 317 } |
320 rect.Intersect(rtClip); | 318 rect.Intersect(rtClip); |
321 return rect.IsEmpty(); | 319 return rect.IsEmpty(); |
322 } | 320 } |
323 void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, | |
324 const CFX_Matrix* pObj2Device) { | |
325 CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap(); | |
326 if (!pBitmap) { | |
327 return; | |
328 } | |
329 FX_RECT rect; | |
330 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { | |
331 return; | |
332 } | |
333 if (m_DitherBits == 2) { | |
334 static FX_ARGB pal[4] = {0, 85, 170, 255}; | |
335 pBitmap->DitherFS(pal, 4, &rect); | |
336 } else if (m_DitherBits == 3) { | |
337 static FX_ARGB pal[8] = {0, 36, 73, 109, 146, 182, 219, 255}; | |
338 pBitmap->DitherFS(pal, 8, &rect); | |
339 } else if (m_DitherBits == 4) { | |
340 static FX_ARGB pal[16] = {0, 17, 34, 51, 68, 85, 102, 119, | |
341 136, 153, 170, 187, 204, 221, 238, 255}; | |
342 pBitmap->DitherFS(pal, 16, &rect); | |
343 } | |
344 } | |
345 | 321 |
346 void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, | 322 void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, |
347 const CFX_Matrix* pObj2Device) { | 323 const CFX_Matrix* pObj2Device) { |
348 FX_BOOL bRet = FALSE; | 324 FX_BOOL bRet = FALSE; |
349 switch (pObj->GetType()) { | 325 switch (pObj->GetType()) { |
350 case CPDF_PageObject::TEXT: | 326 case CPDF_PageObject::TEXT: |
351 bRet = ProcessText(pObj->AsText(), pObj2Device, NULL); | 327 bRet = ProcessText(pObj->AsText(), pObj2Device, NULL); |
352 break; | 328 break; |
353 case CPDF_PageObject::PATH: | 329 case CPDF_PageObject::PATH: |
354 bRet = ProcessPath(pObj->AsPath(), pObj2Device); | 330 bRet = ProcessPath(pObj->AsPath(), pObj2Device); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); | 757 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); |
782 CFX_FxgeDevice bitmap_device; | 758 CFX_FxgeDevice bitmap_device; |
783 std::unique_ptr<CFX_DIBitmap> oriDevice; | 759 std::unique_ptr<CFX_DIBitmap> oriDevice; |
784 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { | 760 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { |
785 oriDevice.reset(new CFX_DIBitmap); | 761 oriDevice.reset(new CFX_DIBitmap); |
786 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) | 762 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) |
787 return TRUE; | 763 return TRUE; |
788 | 764 |
789 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); | 765 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); |
790 } | 766 } |
791 if (!bitmap_device.Create(width, height, FXDIB_Argb, 0, oriDevice.get())) | 767 if (!bitmap_device.CreateEx(width, height, FXDIB_Argb, oriDevice.get())) |
792 return TRUE; | 768 return TRUE; |
793 | 769 |
794 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); | 770 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); |
795 bitmap->Clear(0); | 771 bitmap->Clear(0); |
796 CFX_Matrix new_matrix = *pObj2Device; | 772 CFX_Matrix new_matrix = *pObj2Device; |
797 new_matrix.TranslateI(-rect.left, -rect.top); | 773 new_matrix.TranslateI(-rect.left, -rect.top); |
798 new_matrix.Scale(scaleX, scaleY); | 774 new_matrix.Scale(scaleX, scaleY); |
799 std::unique_ptr<CFX_DIBitmap> pTextMask; | 775 std::unique_ptr<CFX_DIBitmap> pTextMask; |
800 if (bTextClip) { | 776 if (bTextClip) { |
801 pTextMask.reset(new CFX_DIBitmap); | 777 pTextMask.reset(new CFX_DIBitmap); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, | 1266 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, |
1291 &m_Matrix); | 1267 &m_Matrix); |
1292 return TRUE; | 1268 return TRUE; |
1293 } | 1269 } |
1294 void CPDF_ScaledRenderBuffer::OutputToDevice() { | 1270 void CPDF_ScaledRenderBuffer::OutputToDevice() { |
1295 if (m_pBitmapDevice) { | 1271 if (m_pBitmapDevice) { |
1296 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1272 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
1297 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1273 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
1298 } | 1274 } |
1299 } | 1275 } |
OLD | NEW |