| 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/render/render_int.h" | 7 #include "core/fpdfapi/render/render_int.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "core/fpdfdoc/cpdf_occontext.h" | 33 #include "core/fpdfdoc/cpdf_occontext.h" |
| 34 #include "core/fxge/cfx_fxgedevice.h" | 34 #include "core/fxge/cfx_fxgedevice.h" |
| 35 #include "core/fxge/cfx_graphstatedata.h" | 35 #include "core/fxge/cfx_graphstatedata.h" |
| 36 #include "core/fxge/cfx_pathdata.h" | 36 #include "core/fxge/cfx_pathdata.h" |
| 37 #include "core/fxge/cfx_renderdevice.h" | 37 #include "core/fxge/cfx_renderdevice.h" |
| 38 | 38 |
| 39 CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) | 39 CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) |
| 40 : m_pPDFDoc(pPDFDoc) {} | 40 : m_pPDFDoc(pPDFDoc) {} |
| 41 | 41 |
| 42 CPDF_DocRenderData::~CPDF_DocRenderData() { | 42 CPDF_DocRenderData::~CPDF_DocRenderData() { |
| 43 Clear(TRUE); | 43 Clear(true); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void CPDF_DocRenderData::Clear(FX_BOOL bRelease) { | 46 void CPDF_DocRenderData::Clear(bool bRelease) { |
| 47 for (auto it = m_Type3FaceMap.begin(); it != m_Type3FaceMap.end();) { | 47 for (auto it = m_Type3FaceMap.begin(); it != m_Type3FaceMap.end();) { |
| 48 auto curr_it = it++; | 48 auto curr_it = it++; |
| 49 CPDF_CountedObject<CPDF_Type3Cache>* cache = curr_it->second; | 49 CPDF_CountedObject<CPDF_Type3Cache>* cache = curr_it->second; |
| 50 if (bRelease || cache->use_count() < 2) { | 50 if (bRelease || cache->use_count() < 2) { |
| 51 delete cache->get(); | 51 delete cache->get(); |
| 52 delete cache; | 52 delete cache; |
| 53 m_Type3FaceMap.erase(curr_it); | 53 m_Type3FaceMap.erase(curr_it); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 return ArgbEncode(a, r, g, b); | 139 return ArgbEncode(a, r, g, b); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // static | 142 // static |
| 143 int CPDF_RenderStatus::s_CurrentRecursionDepth = 0; | 143 int CPDF_RenderStatus::s_CurrentRecursionDepth = 0; |
| 144 | 144 |
| 145 CPDF_RenderStatus::CPDF_RenderStatus() | 145 CPDF_RenderStatus::CPDF_RenderStatus() |
| 146 : m_pFormResource(nullptr), | 146 : m_pFormResource(nullptr), |
| 147 m_pPageResource(nullptr), | 147 m_pPageResource(nullptr), |
| 148 m_pContext(nullptr), | 148 m_pContext(nullptr), |
| 149 m_bStopped(FALSE), | 149 m_bStopped(false), |
| 150 m_pDevice(nullptr), | 150 m_pDevice(nullptr), |
| 151 m_pCurObj(nullptr), | 151 m_pCurObj(nullptr), |
| 152 m_pStopObj(nullptr), | 152 m_pStopObj(nullptr), |
| 153 m_HalftoneLimit(0), | 153 m_HalftoneLimit(0), |
| 154 m_bPrint(FALSE), | 154 m_bPrint(false), |
| 155 m_Transparency(0), | 155 m_Transparency(0), |
| 156 m_bDropObjects(FALSE), | 156 m_bDropObjects(false), |
| 157 m_bStdCS(FALSE), | 157 m_bStdCS(false), |
| 158 m_GroupFamily(0), | 158 m_GroupFamily(0), |
| 159 m_bLoadMask(FALSE), | 159 m_bLoadMask(false), |
| 160 m_pType3Char(nullptr), | 160 m_pType3Char(nullptr), |
| 161 m_T3FillColor(0), | 161 m_T3FillColor(0), |
| 162 m_curBlend(FXDIB_BLEND_NORMAL) {} | 162 m_curBlend(FXDIB_BLEND_NORMAL) {} |
| 163 | 163 |
| 164 CPDF_RenderStatus::~CPDF_RenderStatus() {} | 164 CPDF_RenderStatus::~CPDF_RenderStatus() {} |
| 165 | 165 |
| 166 FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, | 166 bool CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, |
| 167 CFX_RenderDevice* pDevice, | 167 CFX_RenderDevice* pDevice, |
| 168 const CFX_Matrix* pDeviceMatrix, | 168 const CFX_Matrix* pDeviceMatrix, |
| 169 const CPDF_PageObject* pStopObj, | 169 const CPDF_PageObject* pStopObj, |
| 170 const CPDF_RenderStatus* pParentState, | 170 const CPDF_RenderStatus* pParentState, |
| 171 const CPDF_GraphicStates* pInitialStates, | 171 const CPDF_GraphicStates* pInitialStates, |
| 172 const CPDF_RenderOptions* pOptions, | 172 const CPDF_RenderOptions* pOptions, |
| 173 int transparency, | 173 int transparency, |
| 174 FX_BOOL bDropObjects, | 174 bool bDropObjects, |
| 175 CPDF_Dictionary* pFormResource, | 175 CPDF_Dictionary* pFormResource, |
| 176 FX_BOOL bStdCS, | 176 bool bStdCS, |
| 177 CPDF_Type3Char* pType3Char, | 177 CPDF_Type3Char* pType3Char, |
| 178 FX_ARGB fill_color, | 178 FX_ARGB fill_color, |
| 179 uint32_t GroupFamily, | 179 uint32_t GroupFamily, |
| 180 FX_BOOL bLoadMask) { | 180 bool bLoadMask) { |
| 181 m_pContext = pContext; | 181 m_pContext = pContext; |
| 182 m_pDevice = pDevice; | 182 m_pDevice = pDevice; |
| 183 m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; | 183 m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; |
| 184 if (pDeviceMatrix) { | 184 if (pDeviceMatrix) { |
| 185 m_DeviceMatrix = *pDeviceMatrix; | 185 m_DeviceMatrix = *pDeviceMatrix; |
| 186 } | 186 } |
| 187 m_pStopObj = pStopObj; | 187 m_pStopObj = pStopObj; |
| 188 if (pOptions) { | 188 if (pOptions) { |
| 189 m_Options = *pOptions; | 189 m_Options = *pOptions; |
| 190 } | 190 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 210 pParentState->m_InitialStates.m_ColorState.GetFillRGB()); | 210 pParentState->m_InitialStates.m_ColorState.GetFillRGB()); |
| 211 m_InitialStates.m_ColorState.GetMutableStrokeColor()->Copy( | 211 m_InitialStates.m_ColorState.GetMutableStrokeColor()->Copy( |
| 212 pParentState->m_InitialStates.m_ColorState.GetStrokeColor()); | 212 pParentState->m_InitialStates.m_ColorState.GetStrokeColor()); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 } else { | 215 } else { |
| 216 m_InitialStates.DefaultStates(); | 216 m_InitialStates.DefaultStates(); |
| 217 } | 217 } |
| 218 m_pImageRenderer.reset(); | 218 m_pImageRenderer.reset(); |
| 219 m_Transparency = transparency; | 219 m_Transparency = transparency; |
| 220 return TRUE; | 220 return true; |
| 221 } | 221 } |
| 222 void CPDF_RenderStatus::RenderObjectList( | 222 void CPDF_RenderStatus::RenderObjectList( |
| 223 const CPDF_PageObjectHolder* pObjectHolder, | 223 const CPDF_PageObjectHolder* pObjectHolder, |
| 224 const CFX_Matrix* pObj2Device) { | 224 const CFX_Matrix* pObj2Device) { |
| 225 #if defined _SKIA_SUPPORT_ | 225 #if defined _SKIA_SUPPORT_ |
| 226 DebugVerifyDeviceIsPreMultiplied(); | 226 DebugVerifyDeviceIsPreMultiplied(); |
| 227 #endif | 227 #endif |
| 228 CFX_FloatRect clip_rect(m_pDevice->GetClipBox()); | 228 CFX_FloatRect clip_rect(m_pDevice->GetClipBox()); |
| 229 CFX_Matrix device2object; | 229 CFX_Matrix device2object; |
| 230 device2object.SetReverse(*pObj2Device); | 230 device2object.SetReverse(*pObj2Device); |
| 231 device2object.TransformRect(clip_rect); | 231 device2object.TransformRect(clip_rect); |
| 232 | 232 |
| 233 for (const auto& pCurObj : *pObjectHolder->GetPageObjectList()) { | 233 for (const auto& pCurObj : *pObjectHolder->GetPageObjectList()) { |
| 234 if (pCurObj.get() == m_pStopObj) { | 234 if (pCurObj.get() == m_pStopObj) { |
| 235 m_bStopped = TRUE; | 235 m_bStopped = true; |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 if (!pCurObj) | 238 if (!pCurObj) |
| 239 continue; | 239 continue; |
| 240 | 240 |
| 241 if (pCurObj->m_Left > clip_rect.right || | 241 if (pCurObj->m_Left > clip_rect.right || |
| 242 pCurObj->m_Right < clip_rect.left || | 242 pCurObj->m_Right < clip_rect.left || |
| 243 pCurObj->m_Bottom > clip_rect.top || | 243 pCurObj->m_Bottom > clip_rect.top || |
| 244 pCurObj->m_Top < clip_rect.bottom) { | 244 pCurObj->m_Top < clip_rect.bottom) { |
| 245 continue; | 245 continue; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 271 ProcessClipPath(pObj->m_ClipPath, pObj2Device); | 271 ProcessClipPath(pObj->m_ClipPath, pObj2Device); |
| 272 if (ProcessTransparency(pObj, pObj2Device)) { | 272 if (ProcessTransparency(pObj, pObj2Device)) { |
| 273 return; | 273 return; |
| 274 } | 274 } |
| 275 ProcessObjectNoClip(pObj, pObj2Device); | 275 ProcessObjectNoClip(pObj, pObj2Device); |
| 276 #if defined _SKIA_SUPPORT_ | 276 #if defined _SKIA_SUPPORT_ |
| 277 DebugVerifyDeviceIsPreMultiplied(); | 277 DebugVerifyDeviceIsPreMultiplied(); |
| 278 #endif | 278 #endif |
| 279 } | 279 } |
| 280 | 280 |
| 281 FX_BOOL CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj, | 281 bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj, |
| 282 const CFX_Matrix* pObj2Device, | 282 const CFX_Matrix* pObj2Device, |
| 283 IFX_Pause* pPause) { | 283 IFX_Pause* pPause) { |
| 284 if (m_pImageRenderer) { | 284 if (m_pImageRenderer) { |
| 285 if (m_pImageRenderer->Continue(pPause)) | 285 if (m_pImageRenderer->Continue(pPause)) |
| 286 return TRUE; | 286 return true; |
| 287 | 287 |
| 288 if (!m_pImageRenderer->m_Result) | 288 if (!m_pImageRenderer->m_Result) |
| 289 DrawObjWithBackground(pObj, pObj2Device); | 289 DrawObjWithBackground(pObj, pObj2Device); |
| 290 m_pImageRenderer.reset(); | 290 m_pImageRenderer.reset(); |
| 291 return FALSE; | 291 return false; |
| 292 } | 292 } |
| 293 | 293 |
| 294 m_pCurObj = pObj; | 294 m_pCurObj = pObj; |
| 295 if (m_Options.m_pOCContext && pObj->m_ContentMark && | 295 if (m_Options.m_pOCContext && pObj->m_ContentMark && |
| 296 !m_Options.m_pOCContext->CheckObjectVisible(pObj)) { | 296 !m_Options.m_pOCContext->CheckObjectVisible(pObj)) { |
| 297 return FALSE; | 297 return false; |
| 298 } | 298 } |
| 299 | 299 |
| 300 ProcessClipPath(pObj->m_ClipPath, pObj2Device); | 300 ProcessClipPath(pObj->m_ClipPath, pObj2Device); |
| 301 if (ProcessTransparency(pObj, pObj2Device)) | 301 if (ProcessTransparency(pObj, pObj2Device)) |
| 302 return FALSE; | 302 return false; |
| 303 | 303 |
| 304 if (pObj->IsImage()) { | 304 if (pObj->IsImage()) { |
| 305 m_pImageRenderer.reset(new CPDF_ImageRenderer); | 305 m_pImageRenderer.reset(new CPDF_ImageRenderer); |
| 306 if (!m_pImageRenderer->Start(this, pObj, pObj2Device, FALSE)) { | 306 if (!m_pImageRenderer->Start(this, pObj, pObj2Device, false)) { |
| 307 if (!m_pImageRenderer->m_Result) | 307 if (!m_pImageRenderer->m_Result) |
| 308 DrawObjWithBackground(pObj, pObj2Device); | 308 DrawObjWithBackground(pObj, pObj2Device); |
| 309 m_pImageRenderer.reset(); | 309 m_pImageRenderer.reset(); |
| 310 return FALSE; | 310 return false; |
| 311 } | 311 } |
| 312 return ContinueSingleObject(pObj, pObj2Device, pPause); | 312 return ContinueSingleObject(pObj, pObj2Device, pPause); |
| 313 } | 313 } |
| 314 | 314 |
| 315 ProcessObjectNoClip(pObj, pObj2Device); | 315 ProcessObjectNoClip(pObj, pObj2Device); |
| 316 return FALSE; | 316 return false; |
| 317 } | 317 } |
| 318 | 318 |
| 319 FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, | 319 bool CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, |
| 320 const CFX_Matrix* pObj2Device, | 320 const CFX_Matrix* pObj2Device, |
| 321 FX_BOOL bLogical, | 321 bool bLogical, |
| 322 FX_RECT& rect) const { | 322 FX_RECT& rect) const { |
| 323 rect = pObj->GetBBox(pObj2Device); | 323 rect = pObj->GetBBox(pObj2Device); |
| 324 FX_RECT rtClip = m_pDevice->GetClipBox(); | 324 FX_RECT rtClip = m_pDevice->GetClipBox(); |
| 325 if (!bLogical) { | 325 if (!bLogical) { |
| 326 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 326 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
| 327 FX_FLOAT a = FXSYS_fabs(dCTM.a); | 327 FX_FLOAT a = FXSYS_fabs(dCTM.a); |
| 328 FX_FLOAT d = FXSYS_fabs(dCTM.d); | 328 FX_FLOAT d = FXSYS_fabs(dCTM.d); |
| 329 if (a != 1.0f || d != 1.0f) { | 329 if (a != 1.0f || d != 1.0f) { |
| 330 rect.right = rect.left + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Width() * a); | 330 rect.right = rect.left + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Width() * a); |
| 331 rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height() * d); | 331 rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height() * d); |
| 332 rtClip.right = | 332 rtClip.right = |
| 333 rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Width() * a); | 333 rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Width() * a); |
| 334 rtClip.bottom = | 334 rtClip.bottom = |
| 335 rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d); | 335 rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d); |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 rect.Intersect(rtClip); | 338 rect.Intersect(rtClip); |
| 339 return rect.IsEmpty(); | 339 return rect.IsEmpty(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void CPDF_RenderStatus::ProcessObjectNoClip(CPDF_PageObject* pObj, | 342 void CPDF_RenderStatus::ProcessObjectNoClip(CPDF_PageObject* pObj, |
| 343 const CFX_Matrix* pObj2Device) { | 343 const CFX_Matrix* pObj2Device) { |
| 344 #if defined _SKIA_SUPPORT_ | 344 #if defined _SKIA_SUPPORT_ |
| 345 DebugVerifyDeviceIsPreMultiplied(); | 345 DebugVerifyDeviceIsPreMultiplied(); |
| 346 #endif | 346 #endif |
| 347 FX_BOOL bRet = FALSE; | 347 bool bRet = false; |
| 348 switch (pObj->GetType()) { | 348 switch (pObj->GetType()) { |
| 349 case CPDF_PageObject::TEXT: | 349 case CPDF_PageObject::TEXT: |
| 350 bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr); | 350 bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr); |
| 351 break; | 351 break; |
| 352 case CPDF_PageObject::PATH: | 352 case CPDF_PageObject::PATH: |
| 353 bRet = ProcessPath(pObj->AsPath(), pObj2Device); | 353 bRet = ProcessPath(pObj->AsPath(), pObj2Device); |
| 354 break; | 354 break; |
| 355 case CPDF_PageObject::IMAGE: | 355 case CPDF_PageObject::IMAGE: |
| 356 bRet = ProcessImage(pObj->AsImage(), pObj2Device); | 356 bRet = ProcessImage(pObj->AsImage(), pObj2Device); |
| 357 break; | 357 break; |
| 358 case CPDF_PageObject::SHADING: | 358 case CPDF_PageObject::SHADING: |
| 359 ProcessShading(pObj->AsShading(), pObj2Device); | 359 ProcessShading(pObj->AsShading(), pObj2Device); |
| 360 return; | 360 return; |
| 361 case CPDF_PageObject::FORM: | 361 case CPDF_PageObject::FORM: |
| 362 bRet = ProcessForm(pObj->AsForm(), pObj2Device); | 362 bRet = ProcessForm(pObj->AsForm(), pObj2Device); |
| 363 break; | 363 break; |
| 364 } | 364 } |
| 365 if (!bRet) | 365 if (!bRet) |
| 366 DrawObjWithBackground(pObj, pObj2Device); | 366 DrawObjWithBackground(pObj, pObj2Device); |
| 367 #if defined _SKIA_SUPPORT_ | 367 #if defined _SKIA_SUPPORT_ |
| 368 DebugVerifyDeviceIsPreMultiplied(); | 368 DebugVerifyDeviceIsPreMultiplied(); |
| 369 #endif | 369 #endif |
| 370 } | 370 } |
| 371 | 371 |
| 372 FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj, | 372 bool CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj, |
| 373 const CFX_Matrix* pObj2Device) { | 373 const CFX_Matrix* pObj2Device) { |
| 374 FX_BOOL bRet = FALSE; | 374 bool bRet = false; |
| 375 switch (pObj->GetType()) { | 375 switch (pObj->GetType()) { |
| 376 case CPDF_PageObject::PATH: | 376 case CPDF_PageObject::PATH: |
| 377 bRet = ProcessPath(pObj->AsPath(), pObj2Device); | 377 bRet = ProcessPath(pObj->AsPath(), pObj2Device); |
| 378 break; | 378 break; |
| 379 case CPDF_PageObject::IMAGE: | 379 case CPDF_PageObject::IMAGE: |
| 380 bRet = ProcessImage(pObj->AsImage(), pObj2Device); | 380 bRet = ProcessImage(pObj->AsImage(), pObj2Device); |
| 381 break; | 381 break; |
| 382 case CPDF_PageObject::FORM: | 382 case CPDF_PageObject::FORM: |
| 383 bRet = ProcessForm(pObj->AsForm(), pObj2Device); | 383 bRet = ProcessForm(pObj->AsForm(), pObj2Device); |
| 384 break; | 384 break; |
| 385 default: | 385 default: |
| 386 break; | 386 break; |
| 387 } | 387 } |
| 388 return bRet; | 388 return bRet; |
| 389 } | 389 } |
| 390 void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix& matrix) const { | 390 void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix& matrix) const { |
| 391 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 391 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
| 392 matrix.a *= FXSYS_fabs(dCTM.a); | 392 matrix.a *= FXSYS_fabs(dCTM.a); |
| 393 matrix.d *= FXSYS_fabs(dCTM.d); | 393 matrix.d *= FXSYS_fabs(dCTM.d); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, | 396 void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, |
| 397 const CFX_Matrix* pObj2Device) { | 397 const CFX_Matrix* pObj2Device) { |
| 398 FX_RECT rect; | 398 FX_RECT rect; |
| 399 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { | 399 if (GetObjectClippedRect(pObj, pObj2Device, false, rect)) { |
| 400 return; | 400 return; |
| 401 } | 401 } |
| 402 int res = 300; | 402 int res = 300; |
| 403 if (pObj->IsImage() && | 403 if (pObj->IsImage() && |
| 404 m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { | 404 m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { |
| 405 res = 0; | 405 res = 0; |
| 406 } | 406 } |
| 407 CPDF_ScaledRenderBuffer buffer; | 407 CPDF_ScaledRenderBuffer buffer; |
| 408 if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) { | 408 if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) { |
| 409 return; | 409 return; |
| 410 } | 410 } |
| 411 CFX_Matrix matrix = *pObj2Device; | 411 CFX_Matrix matrix = *pObj2Device; |
| 412 matrix.Concat(*buffer.GetMatrix()); | 412 matrix.Concat(*buffer.GetMatrix()); |
| 413 GetScaledMatrix(matrix); | 413 GetScaledMatrix(matrix); |
| 414 CPDF_Dictionary* pFormResource = nullptr; | 414 CPDF_Dictionary* pFormResource = nullptr; |
| 415 if (pObj->IsForm()) { | 415 if (pObj->IsForm()) { |
| 416 const CPDF_FormObject* pFormObj = pObj->AsForm(); | 416 const CPDF_FormObject* pFormObj = pObj->AsForm(); |
| 417 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { | 417 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { |
| 418 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); | 418 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 CPDF_RenderStatus status; | 421 CPDF_RenderStatus status; |
| 422 status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), nullptr, | 422 status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), nullptr, |
| 423 nullptr, nullptr, &m_Options, m_Transparency, | 423 nullptr, nullptr, &m_Options, m_Transparency, |
| 424 m_bDropObjects, pFormResource); | 424 m_bDropObjects, pFormResource); |
| 425 status.RenderSingleObject(pObj, &matrix); | 425 status.RenderSingleObject(pObj, &matrix); |
| 426 buffer.OutputToDevice(); | 426 buffer.OutputToDevice(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, | 429 bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, |
| 430 const CFX_Matrix* pObj2Device) { | 430 const CFX_Matrix* pObj2Device) { |
| 431 #if defined _SKIA_SUPPORT_ | 431 #if defined _SKIA_SUPPORT_ |
| 432 DebugVerifyDeviceIsPreMultiplied(); | 432 DebugVerifyDeviceIsPreMultiplied(); |
| 433 #endif | 433 #endif |
| 434 CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictFor("OC"); | 434 CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictFor("OC"); |
| 435 if (pOC && m_Options.m_pOCContext && | 435 if (pOC && m_Options.m_pOCContext && |
| 436 !m_Options.m_pOCContext->CheckOCGVisible(pOC)) { | 436 !m_Options.m_pOCContext->CheckOCGVisible(pOC)) { |
| 437 return TRUE; | 437 return true; |
| 438 } | 438 } |
| 439 CFX_Matrix matrix = pFormObj->m_FormMatrix; | 439 CFX_Matrix matrix = pFormObj->m_FormMatrix; |
| 440 matrix.Concat(*pObj2Device); | 440 matrix.Concat(*pObj2Device); |
| 441 CPDF_Dictionary* pResources = nullptr; | 441 CPDF_Dictionary* pResources = nullptr; |
| 442 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { | 442 if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { |
| 443 pResources = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); | 443 pResources = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); |
| 444 } | 444 } |
| 445 CPDF_RenderStatus status; | 445 CPDF_RenderStatus status; |
| 446 status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj, | 446 status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj, |
| 447 &m_Options, m_Transparency, m_bDropObjects, pResources, | 447 &m_Options, m_Transparency, m_bDropObjects, pResources, |
| 448 FALSE); | 448 false); |
| 449 status.m_curBlend = m_curBlend; | 449 status.m_curBlend = m_curBlend; |
| 450 m_pDevice->SaveState(); | 450 m_pDevice->SaveState(); |
| 451 status.RenderObjectList(pFormObj->m_pForm.get(), &matrix); | 451 status.RenderObjectList(pFormObj->m_pForm.get(), &matrix); |
| 452 m_bStopped = status.m_bStopped; | 452 m_bStopped = status.m_bStopped; |
| 453 m_pDevice->RestoreState(false); | 453 m_pDevice->RestoreState(false); |
| 454 #if defined _SKIA_SUPPORT_ | 454 #if defined _SKIA_SUPPORT_ |
| 455 DebugVerifyDeviceIsPreMultiplied(); | 455 DebugVerifyDeviceIsPreMultiplied(); |
| 456 #endif | 456 #endif |
| 457 return TRUE; | 457 return true; |
| 458 } | 458 } |
| 459 | 459 |
| 460 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) { | 460 bool IsAvailableMatrix(const CFX_Matrix& matrix) { |
| 461 if (matrix.a == 0 || matrix.d == 0) { | 461 if (matrix.a == 0 || matrix.d == 0) { |
| 462 return matrix.b != 0 && matrix.c != 0; | 462 return matrix.b != 0 && matrix.c != 0; |
| 463 } | 463 } |
| 464 if (matrix.b == 0 || matrix.c == 0) { | 464 if (matrix.b == 0 || matrix.c == 0) { |
| 465 return matrix.a != 0 && matrix.d != 0; | 465 return matrix.a != 0 && matrix.d != 0; |
| 466 } | 466 } |
| 467 return TRUE; | 467 return true; |
| 468 } | 468 } |
| 469 | 469 |
| 470 FX_BOOL CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, | 470 bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, |
| 471 const CFX_Matrix* pObj2Device) { | 471 const CFX_Matrix* pObj2Device) { |
| 472 int FillType = pPathObj->m_FillType; | 472 int FillType = pPathObj->m_FillType; |
| 473 FX_BOOL bStroke = pPathObj->m_bStroke; | 473 bool bStroke = pPathObj->m_bStroke; |
| 474 ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke); | 474 ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke); |
| 475 if (FillType == 0 && !bStroke) | 475 if (FillType == 0 && !bStroke) |
| 476 return TRUE; | 476 return true; |
| 477 | 477 |
| 478 uint32_t fill_argb = FillType ? GetFillArgb(pPathObj) : 0; | 478 uint32_t fill_argb = FillType ? GetFillArgb(pPathObj) : 0; |
| 479 uint32_t stroke_argb = bStroke ? GetStrokeArgb(pPathObj) : 0; | 479 uint32_t stroke_argb = bStroke ? GetStrokeArgb(pPathObj) : 0; |
| 480 CFX_Matrix path_matrix = pPathObj->m_Matrix; | 480 CFX_Matrix path_matrix = pPathObj->m_Matrix; |
| 481 path_matrix.Concat(*pObj2Device); | 481 path_matrix.Concat(*pObj2Device); |
| 482 if (!IsAvailableMatrix(path_matrix)) | 482 if (!IsAvailableMatrix(path_matrix)) |
| 483 return TRUE; | 483 return true; |
| 484 | 484 |
| 485 if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) | 485 if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) |
| 486 FillType |= FXFILL_RECT_AA; | 486 FillType |= FXFILL_RECT_AA; |
| 487 if (m_Options.m_Flags & RENDER_FILL_FULLCOVER) | 487 if (m_Options.m_Flags & RENDER_FILL_FULLCOVER) |
| 488 FillType |= FXFILL_FULLCOVER; | 488 FillType |= FXFILL_FULLCOVER; |
| 489 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) | 489 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) |
| 490 FillType |= FXFILL_NOPATHSMOOTH; | 490 FillType |= FXFILL_NOPATHSMOOTH; |
| 491 if (bStroke) | 491 if (bStroke) |
| 492 FillType |= FX_FILL_STROKE; | 492 FillType |= FX_FILL_STROKE; |
| 493 | 493 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 506 fill_argb, stroke_argb, FillType, m_curBlend); | 506 fill_argb, stroke_argb, FillType, m_curBlend); |
| 507 } | 507 } |
| 508 | 508 |
| 509 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const { | 509 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const { |
| 510 ASSERT(pObj); | 510 ASSERT(pObj); |
| 511 CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData(); | 511 CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData(); |
| 512 return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr; | 512 return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr; |
| 513 } | 513 } |
| 514 | 514 |
| 515 FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj, | 515 FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj, |
| 516 FX_BOOL bType3) const { | 516 bool bType3) const { |
| 517 const CPDF_ColorState* pColorState = &pObj->m_ColorState; | 517 const CPDF_ColorState* pColorState = &pObj->m_ColorState; |
| 518 if (m_pType3Char && !bType3 && | 518 if (m_pType3Char && !bType3 && |
| 519 (!m_pType3Char->m_bColored || | 519 (!m_pType3Char->m_bColored || |
| 520 (m_pType3Char->m_bColored && | 520 (m_pType3Char->m_bColored && |
| 521 (!*pColorState || pColorState->GetFillColor()->IsNull())))) { | 521 (!*pColorState || pColorState->GetFillColor()->IsNull())))) { |
| 522 return m_T3FillColor; | 522 return m_T3FillColor; |
| 523 } | 523 } |
| 524 if (!*pColorState || pColorState->GetFillColor()->IsNull()) | 524 if (!*pColorState || pColorState->GetFillColor()->IsNull()) |
| 525 pColorState = &m_InitialStates.m_ColorState; | 525 pColorState = &m_InitialStates.m_ColorState; |
| 526 | 526 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 continue; | 645 continue; |
| 646 } | 646 } |
| 647 CFX_GraphStateData stroke_state; | 647 CFX_GraphStateData stroke_state; |
| 648 if (m_Options.m_Flags & RENDER_THINLINE) { | 648 if (m_Options.m_Flags & RENDER_THINLINE) { |
| 649 stroke_state.m_LineWidth = 0; | 649 stroke_state.m_LineWidth = 0; |
| 650 } | 650 } |
| 651 m_pDevice->DrawPath(pPathData, pObj2Device, &stroke_state, 0, 0xffff0000, | 651 m_pDevice->DrawPath(pPathData, pObj2Device, &stroke_state, 0, 0xffff0000, |
| 652 fill_mode); | 652 fill_mode); |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 FX_BOOL CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj, | 655 bool CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj, |
| 656 const CFX_Matrix* pObj2Device, | 656 const CFX_Matrix* pObj2Device, |
| 657 FX_BOOL bStroke) { | 657 bool bStroke) { |
| 658 CFX_Matrix path_matrix = pPathObj->m_Matrix; | 658 CFX_Matrix path_matrix = pPathObj->m_Matrix; |
| 659 path_matrix.Concat(*pObj2Device); | 659 path_matrix.Concat(*pObj2Device); |
| 660 if (bStroke) { | 660 if (bStroke) { |
| 661 CFX_GraphState graphState = pPathObj->m_GraphState; | 661 CFX_GraphState graphState = pPathObj->m_GraphState; |
| 662 if (m_Options.m_Flags & RENDER_THINLINE) | 662 if (m_Options.m_Flags & RENDER_THINLINE) |
| 663 graphState.SetLineWidth(0); | 663 graphState.SetLineWidth(0); |
| 664 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(), | 664 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(), |
| 665 &path_matrix, graphState.GetObject()); | 665 &path_matrix, graphState.GetObject()); |
| 666 } | 666 } |
| 667 int fill_mode = pPathObj->m_FillType; | 667 int fill_mode = pPathObj->m_FillType; |
| 668 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { | 668 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { |
| 669 fill_mode |= FXFILL_NOPATHSMOOTH; | 669 fill_mode |= FXFILL_NOPATHSMOOTH; |
| 670 } | 670 } |
| 671 return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix, | 671 return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix, |
| 672 fill_mode); | 672 fill_mode); |
| 673 } | 673 } |
| 674 FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, | 674 bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, |
| 675 const CFX_Matrix* pObj2Device) { | 675 const CFX_Matrix* pObj2Device) { |
| 676 #if defined _SKIA_SUPPORT_ | 676 #if defined _SKIA_SUPPORT_ |
| 677 DebugVerifyDeviceIsPreMultiplied(); | 677 DebugVerifyDeviceIsPreMultiplied(); |
| 678 #endif | 678 #endif |
| 679 int blend_type = pPageObj->m_GeneralState.GetBlendType(); | 679 int blend_type = pPageObj->m_GeneralState.GetBlendType(); |
| 680 if (blend_type == FXDIB_BLEND_UNSUPPORTED) | 680 if (blend_type == FXDIB_BLEND_UNSUPPORTED) |
| 681 return TRUE; | 681 return true; |
| 682 | 682 |
| 683 CPDF_Dictionary* pSMaskDict = | 683 CPDF_Dictionary* pSMaskDict = |
| 684 ToDictionary(pPageObj->m_GeneralState.GetSoftMask()); | 684 ToDictionary(pPageObj->m_GeneralState.GetSoftMask()); |
| 685 if (pSMaskDict) { | 685 if (pSMaskDict) { |
| 686 if (pPageObj->IsImage() && | 686 if (pPageObj->IsImage() && |
| 687 pPageObj->AsImage()->GetImage()->GetDict()->KeyExist("SMask")) { | 687 pPageObj->AsImage()->GetImage()->GetDict()->KeyExist("SMask")) { |
| 688 pSMaskDict = nullptr; | 688 pSMaskDict = nullptr; |
| 689 } | 689 } |
| 690 } | 690 } |
| 691 CPDF_Dictionary* pFormResource = nullptr; | 691 CPDF_Dictionary* pFormResource = nullptr; |
| 692 FX_FLOAT group_alpha = 1.0f; | 692 FX_FLOAT group_alpha = 1.0f; |
| 693 int Transparency = m_Transparency; | 693 int Transparency = m_Transparency; |
| 694 FX_BOOL bGroupTransparent = FALSE; | 694 bool bGroupTransparent = false; |
| 695 if (pPageObj->IsForm()) { | 695 if (pPageObj->IsForm()) { |
| 696 const CPDF_FormObject* pFormObj = pPageObj->AsForm(); | 696 const CPDF_FormObject* pFormObj = pPageObj->AsForm(); |
| 697 group_alpha = pFormObj->m_GeneralState.GetFillAlpha(); | 697 group_alpha = pFormObj->m_GeneralState.GetFillAlpha(); |
| 698 Transparency = pFormObj->m_pForm->m_Transparency; | 698 Transparency = pFormObj->m_pForm->m_Transparency; |
| 699 bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED); | 699 bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED); |
| 700 if (pFormObj->m_pForm->m_pFormDict) { | 700 if (pFormObj->m_pForm->m_pFormDict) { |
| 701 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); | 701 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources"); |
| 702 } | 702 } |
| 703 } | 703 } |
| 704 bool bTextClip = | 704 bool bTextClip = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 728 int format = pColorSpace->GetFamily(); | 728 int format = pColorSpace->GetFamily(); |
| 729 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || | 729 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || |
| 730 format == PDFCS_DEVICEN) { | 730 format == PDFCS_DEVICEN) { |
| 731 blend_type = FXDIB_BLEND_DARKEN; | 731 blend_type = FXDIB_BLEND_DARKEN; |
| 732 } | 732 } |
| 733 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); | 733 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 if (!pSMaskDict && group_alpha == 1.0f && blend_type == FXDIB_BLEND_NORMAL && | 736 if (!pSMaskDict && group_alpha == 1.0f && blend_type == FXDIB_BLEND_NORMAL && |
| 737 !bTextClip && !bGroupTransparent) { | 737 !bTextClip && !bGroupTransparent) { |
| 738 return FALSE; | 738 return false; |
| 739 } | 739 } |
| 740 bool isolated = !!(Transparency & PDFTRANS_ISOLATED); | 740 bool isolated = !!(Transparency & PDFTRANS_ISOLATED); |
| 741 if (m_bPrint) { | 741 if (m_bPrint) { |
| 742 FX_BOOL bRet = FALSE; | 742 bool bRet = false; |
| 743 int rendCaps = m_pDevice->GetRenderCaps(); | 743 int rendCaps = m_pDevice->GetRenderCaps(); |
| 744 if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) && | 744 if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) && |
| 745 (rendCaps & FXRC_BLEND_MODE)) { | 745 (rendCaps & FXRC_BLEND_MODE)) { |
| 746 int oldBlend = m_curBlend; | 746 int oldBlend = m_curBlend; |
| 747 m_curBlend = blend_type; | 747 m_curBlend = blend_type; |
| 748 bRet = DrawObjWithBlend(pPageObj, pObj2Device); | 748 bRet = DrawObjWithBlend(pPageObj, pObj2Device); |
| 749 m_curBlend = oldBlend; | 749 m_curBlend = oldBlend; |
| 750 } | 750 } |
| 751 if (!bRet) { | 751 if (!bRet) { |
| 752 DrawObjWithBackground(pPageObj, pObj2Device); | 752 DrawObjWithBackground(pPageObj, pObj2Device); |
| 753 } | 753 } |
| 754 return TRUE; | 754 return true; |
| 755 } | 755 } |
| 756 FX_RECT rect = pPageObj->GetBBox(pObj2Device); | 756 FX_RECT rect = pPageObj->GetBBox(pObj2Device); |
| 757 rect.Intersect(m_pDevice->GetClipBox()); | 757 rect.Intersect(m_pDevice->GetClipBox()); |
| 758 if (rect.IsEmpty()) { | 758 if (rect.IsEmpty()) { |
| 759 return TRUE; | 759 return true; |
| 760 } | 760 } |
| 761 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); | 761 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); |
| 762 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); | 762 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); |
| 763 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); | 763 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); |
| 764 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); | 764 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); |
| 765 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); | 765 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); |
| 766 CFX_FxgeDevice bitmap_device; | 766 CFX_FxgeDevice bitmap_device; |
| 767 std::unique_ptr<CFX_DIBitmap> oriDevice; | 767 std::unique_ptr<CFX_DIBitmap> oriDevice; |
| 768 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { | 768 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { |
| 769 oriDevice.reset(new CFX_DIBitmap); | 769 oriDevice.reset(new CFX_DIBitmap); |
| 770 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) | 770 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) |
| 771 return TRUE; | 771 return true; |
| 772 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); | 772 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); |
| 773 } | 773 } |
| 774 if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice.get())) | 774 if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice.get())) |
| 775 return TRUE; | 775 return true; |
| 776 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); | 776 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); |
| 777 bitmap->Clear(0); | 777 bitmap->Clear(0); |
| 778 CFX_Matrix new_matrix = *pObj2Device; | 778 CFX_Matrix new_matrix = *pObj2Device; |
| 779 new_matrix.TranslateI(-rect.left, -rect.top); | 779 new_matrix.TranslateI(-rect.left, -rect.top); |
| 780 new_matrix.Scale(scaleX, scaleY); | 780 new_matrix.Scale(scaleX, scaleY); |
| 781 std::unique_ptr<CFX_DIBitmap> pTextMask; | 781 std::unique_ptr<CFX_DIBitmap> pTextMask; |
| 782 if (bTextClip) { | 782 if (bTextClip) { |
| 783 pTextMask.reset(new CFX_DIBitmap); | 783 pTextMask.reset(new CFX_DIBitmap); |
| 784 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) | 784 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) |
| 785 return TRUE; | 785 return true; |
| 786 | 786 |
| 787 pTextMask->Clear(0); | 787 pTextMask->Clear(0); |
| 788 CFX_FxgeDevice text_device; | 788 CFX_FxgeDevice text_device; |
| 789 text_device.Attach(pTextMask.get(), false, nullptr, false); | 789 text_device.Attach(pTextMask.get(), false, nullptr, false); |
| 790 for (uint32_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { | 790 for (uint32_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { |
| 791 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); | 791 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); |
| 792 if (!textobj) { | 792 if (!textobj) { |
| 793 break; | 793 break; |
| 794 } | 794 } |
| 795 CFX_Matrix text_matrix; | 795 CFX_Matrix text_matrix; |
| 796 textobj->GetTextMatrix(&text_matrix); | 796 textobj->GetTextMatrix(&text_matrix); |
| 797 CPDF_TextRenderer::DrawTextPath( | 797 CPDF_TextRenderer::DrawTextPath( |
| 798 &text_device, textobj->m_nChars, textobj->m_pCharCodes, | 798 &text_device, textobj->m_nChars, textobj->m_pCharCodes, |
| 799 textobj->m_pCharPos, textobj->m_TextState.GetFont(), | 799 textobj->m_pCharPos, textobj->m_TextState.GetFont(), |
| 800 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, | 800 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, |
| 801 textobj->m_GraphState.GetObject(), (FX_ARGB)-1, 0, nullptr, 0); | 801 textobj->m_GraphState.GetObject(), (FX_ARGB)-1, 0, nullptr, 0); |
| 802 } | 802 } |
| 803 } | 803 } |
| 804 CPDF_RenderStatus bitmap_render; | 804 CPDF_RenderStatus bitmap_render; |
| 805 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, | 805 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, |
| 806 nullptr, nullptr, &m_Options, 0, m_bDropObjects, | 806 nullptr, nullptr, &m_Options, 0, m_bDropObjects, |
| 807 pFormResource, TRUE); | 807 pFormResource, true); |
| 808 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); | 808 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); |
| 809 m_bStopped = bitmap_render.m_bStopped; | 809 m_bStopped = bitmap_render.m_bStopped; |
| 810 if (pSMaskDict) { | 810 if (pSMaskDict) { |
| 811 CFX_Matrix smask_matrix = *pPageObj->m_GeneralState.GetSMaskMatrix(); | 811 CFX_Matrix smask_matrix = *pPageObj->m_GeneralState.GetSMaskMatrix(); |
| 812 smask_matrix.Concat(*pObj2Device); | 812 smask_matrix.Concat(*pObj2Device); |
| 813 std::unique_ptr<CFX_DIBSource> pSMaskSource( | 813 std::unique_ptr<CFX_DIBSource> pSMaskSource( |
| 814 LoadSMask(pSMaskDict, &rect, &smask_matrix)); | 814 LoadSMask(pSMaskDict, &rect, &smask_matrix)); |
| 815 if (pSMaskSource) | 815 if (pSMaskSource) |
| 816 bitmap->MultiplyAlpha(pSMaskSource.get()); | 816 bitmap->MultiplyAlpha(pSMaskSource.get()); |
| 817 } | 817 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 829 } | 829 } |
| 830 Transparency = m_Transparency; | 830 Transparency = m_Transparency; |
| 831 if (pPageObj->IsForm()) { | 831 if (pPageObj->IsForm()) { |
| 832 Transparency |= PDFTRANS_GROUP; | 832 Transparency |= PDFTRANS_GROUP; |
| 833 } | 833 } |
| 834 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, blitAlpha, blend_type, | 834 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, blitAlpha, blend_type, |
| 835 Transparency); | 835 Transparency); |
| 836 #if defined _SKIA_SUPPORT_ | 836 #if defined _SKIA_SUPPORT_ |
| 837 DebugVerifyDeviceIsPreMultiplied(); | 837 DebugVerifyDeviceIsPreMultiplied(); |
| 838 #endif | 838 #endif |
| 839 return TRUE; | 839 return true; |
| 840 } | 840 } |
| 841 | 841 |
| 842 CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, | 842 CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, |
| 843 const FX_RECT& rect, | 843 const FX_RECT& rect, |
| 844 int& left, | 844 int& left, |
| 845 int& top, | 845 int& top, |
| 846 FX_BOOL bBackAlphaRequired) { | 846 bool bBackAlphaRequired) { |
| 847 FX_RECT bbox = rect; | 847 FX_RECT bbox = rect; |
| 848 bbox.Intersect(m_pDevice->GetClipBox()); | 848 bbox.Intersect(m_pDevice->GetClipBox()); |
| 849 left = bbox.left; | 849 left = bbox.left; |
| 850 top = bbox.top; | 850 top = bbox.top; |
| 851 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); | 851 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); |
| 852 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); | 852 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); |
| 853 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); | 853 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); |
| 854 int width = FXSYS_round(bbox.Width() * scaleX); | 854 int width = FXSYS_round(bbox.Width() * scaleX); |
| 855 int height = FXSYS_round(bbox.Height() * scaleY); | 855 int height = FXSYS_round(bbox.Height() * scaleY); |
| 856 std::unique_ptr<CFX_DIBitmap> pBackdrop(new CFX_DIBitmap); | 856 std::unique_ptr<CFX_DIBitmap> pBackdrop(new CFX_DIBitmap); |
| 857 if (bBackAlphaRequired && !m_bDropObjects) | 857 if (bBackAlphaRequired && !m_bDropObjects) |
| 858 pBackdrop->Create(width, height, FXDIB_Argb); | 858 pBackdrop->Create(width, height, FXDIB_Argb); |
| 859 else | 859 else |
| 860 m_pDevice->CreateCompatibleBitmap(pBackdrop.get(), width, height); | 860 m_pDevice->CreateCompatibleBitmap(pBackdrop.get(), width, height); |
| 861 | 861 |
| 862 if (!pBackdrop->GetBuffer()) | 862 if (!pBackdrop->GetBuffer()) |
| 863 return nullptr; | 863 return nullptr; |
| 864 | 864 |
| 865 FX_BOOL bNeedDraw; | 865 bool bNeedDraw; |
| 866 if (pBackdrop->HasAlpha()) | 866 if (pBackdrop->HasAlpha()) |
| 867 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT); | 867 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT); |
| 868 else | 868 else |
| 869 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS); | 869 bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS); |
| 870 | 870 |
| 871 if (!bNeedDraw) { | 871 if (!bNeedDraw) { |
| 872 m_pDevice->GetDIBits(pBackdrop.get(), left, top); | 872 m_pDevice->GetDIBits(pBackdrop.get(), left, top); |
| 873 return pBackdrop.release(); | 873 return pBackdrop.release(); |
| 874 } | 874 } |
| 875 | 875 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 889 CFX_Matrix* pFinalMatrix) { | 889 CFX_Matrix* pFinalMatrix) { |
| 890 CFX_FxgeDevice device; | 890 CFX_FxgeDevice device; |
| 891 device.Attach(pBuffer, false, nullptr, false); | 891 device.Attach(pBuffer, false, nullptr, false); |
| 892 | 892 |
| 893 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); | 893 FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); |
| 894 device.FillRect(&rect, 0xffffffff); | 894 device.FillRect(&rect, 0xffffffff); |
| 895 Render(&device, pObj, pOptions, pFinalMatrix); | 895 Render(&device, pObj, pOptions, pFinalMatrix); |
| 896 } | 896 } |
| 897 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates( | 897 CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates( |
| 898 const CPDF_GraphicStates* pSrcStates, | 898 const CPDF_GraphicStates* pSrcStates, |
| 899 FX_BOOL bStroke) { | 899 bool bStroke) { |
| 900 if (!pSrcStates) | 900 if (!pSrcStates) |
| 901 return nullptr; | 901 return nullptr; |
| 902 | 902 |
| 903 CPDF_GraphicStates* pStates = new CPDF_GraphicStates; | 903 CPDF_GraphicStates* pStates = new CPDF_GraphicStates; |
| 904 pStates->CopyStates(*pSrcStates); | 904 pStates->CopyStates(*pSrcStates); |
| 905 const CPDF_Color* pObjColor = bStroke | 905 const CPDF_Color* pObjColor = bStroke |
| 906 ? pSrcStates->m_ColorState.GetStrokeColor() | 906 ? pSrcStates->m_ColorState.GetStrokeColor() |
| 907 : pSrcStates->m_ColorState.GetFillColor(); | 907 : pSrcStates->m_ColorState.GetFillColor(); |
| 908 if (!pObjColor->IsNull()) { | 908 if (!pObjColor->IsNull()) { |
| 909 pStates->m_ColorState.SetFillRGB( | 909 pStates->m_ColorState.SetFillRGB( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 int count = m_Layers.GetSize(); | 947 int count = m_Layers.GetSize(); |
| 948 for (int j = 0; j < count; j++) { | 948 for (int j = 0; j < count; j++) { |
| 949 pDevice->SaveState(); | 949 pDevice->SaveState(); |
| 950 Layer* pLayer = m_Layers.GetDataPtr(j); | 950 Layer* pLayer = m_Layers.GetDataPtr(j); |
| 951 if (pLastMatrix) { | 951 if (pLastMatrix) { |
| 952 CFX_Matrix FinalMatrix = pLayer->m_Matrix; | 952 CFX_Matrix FinalMatrix = pLayer->m_Matrix; |
| 953 FinalMatrix.Concat(*pLastMatrix); | 953 FinalMatrix.Concat(*pLastMatrix); |
| 954 CPDF_RenderStatus status; | 954 CPDF_RenderStatus status; |
| 955 status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr, | 955 status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr, |
| 956 pOptions, pLayer->m_pObjectHolder->m_Transparency, | 956 pOptions, pLayer->m_pObjectHolder->m_Transparency, |
| 957 FALSE, nullptr); | 957 false, nullptr); |
| 958 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); | 958 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); |
| 959 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 959 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
| 960 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); | 960 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); |
| 961 } | 961 } |
| 962 if (status.m_bStopped) { | 962 if (status.m_bStopped) { |
| 963 pDevice->RestoreState(false); | 963 pDevice->RestoreState(false); |
| 964 break; | 964 break; |
| 965 } | 965 } |
| 966 } else { | 966 } else { |
| 967 CPDF_RenderStatus status; | 967 CPDF_RenderStatus status; |
| 968 status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr, | 968 status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr, |
| 969 pOptions, pLayer->m_pObjectHolder->m_Transparency, | 969 pOptions, pLayer->m_pObjectHolder->m_Transparency, |
| 970 FALSE, nullptr); | 970 false, nullptr); |
| 971 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); | 971 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); |
| 972 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 972 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
| 973 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); | 973 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); |
| 974 } | 974 } |
| 975 if (status.m_bStopped) { | 975 if (status.m_bStopped) { |
| 976 pDevice->RestoreState(false); | 976 pDevice->RestoreState(false); |
| 977 break; | 977 break; |
| 978 } | 978 } |
| 979 } | 979 } |
| 980 pDevice->RestoreState(false); | 980 pDevice->RestoreState(false); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 if (m_LayerIndex >= m_pContext->CountLayers()) { | 1012 if (m_LayerIndex >= m_pContext->CountLayers()) { |
| 1013 m_Status = Done; | 1013 m_Status = Done; |
| 1014 return; | 1014 return; |
| 1015 } | 1015 } |
| 1016 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); | 1016 m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex); |
| 1017 m_LastObjectRendered = | 1017 m_LastObjectRendered = |
| 1018 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); | 1018 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); |
| 1019 m_pRenderStatus.reset(new CPDF_RenderStatus()); | 1019 m_pRenderStatus.reset(new CPDF_RenderStatus()); |
| 1020 m_pRenderStatus->Initialize( | 1020 m_pRenderStatus->Initialize( |
| 1021 m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions, | 1021 m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions, |
| 1022 m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, nullptr); | 1022 m_pCurrentLayer->m_pObjectHolder->m_Transparency, false, nullptr); |
| 1023 m_pDevice->SaveState(); | 1023 m_pDevice->SaveState(); |
| 1024 m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); | 1024 m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); |
| 1025 CFX_Matrix device2object; | 1025 CFX_Matrix device2object; |
| 1026 device2object.SetReverse(m_pCurrentLayer->m_Matrix); | 1026 device2object.SetReverse(m_pCurrentLayer->m_Matrix); |
| 1027 device2object.TransformRect(m_ClipRect); | 1027 device2object.TransformRect(m_ClipRect); |
| 1028 } | 1028 } |
| 1029 CPDF_PageObjectList::iterator iter; | 1029 CPDF_PageObjectList::iterator iter; |
| 1030 CPDF_PageObjectList::iterator iterEnd = | 1030 CPDF_PageObjectList::iterator iterEnd = |
| 1031 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); | 1031 m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); |
| 1032 if (m_LastObjectRendered != iterEnd) { | 1032 if (m_LastObjectRendered != iterEnd) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 if (!pObj) | 1085 if (!pObj) |
| 1086 return nullptr; | 1086 return nullptr; |
| 1087 | 1087 |
| 1088 auto it = m_TransferFuncMap.find(pObj); | 1088 auto it = m_TransferFuncMap.find(pObj); |
| 1089 if (it != m_TransferFuncMap.end()) { | 1089 if (it != m_TransferFuncMap.end()) { |
| 1090 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second; | 1090 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second; |
| 1091 return pTransferCounter->AddRef(); | 1091 return pTransferCounter->AddRef(); |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 std::unique_ptr<CPDF_Function> pFuncs[3]; | 1094 std::unique_ptr<CPDF_Function> pFuncs[3]; |
| 1095 FX_BOOL bUniTransfer = TRUE; | 1095 bool bUniTransfer = true; |
| 1096 FX_BOOL bIdentity = TRUE; | 1096 bool bIdentity = true; |
| 1097 if (CPDF_Array* pArray = pObj->AsArray()) { | 1097 if (CPDF_Array* pArray = pObj->AsArray()) { |
| 1098 bUniTransfer = FALSE; | 1098 bUniTransfer = false; |
| 1099 if (pArray->GetCount() < 3) | 1099 if (pArray->GetCount() < 3) |
| 1100 return nullptr; | 1100 return nullptr; |
| 1101 | 1101 |
| 1102 for (uint32_t i = 0; i < 3; ++i) { | 1102 for (uint32_t i = 0; i < 3; ++i) { |
| 1103 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); | 1103 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); |
| 1104 if (!pFuncs[2 - i]) | 1104 if (!pFuncs[2 - i]) |
| 1105 return nullptr; | 1105 return nullptr; |
| 1106 } | 1106 } |
| 1107 } else { | 1107 } else { |
| 1108 pFuncs[0] = CPDF_Function::Load(pObj); | 1108 pFuncs[0] = CPDF_Function::Load(pObj); |
| 1109 if (!pFuncs[0]) | 1109 if (!pFuncs[0]) |
| 1110 return nullptr; | 1110 return nullptr; |
| 1111 } | 1111 } |
| 1112 CPDF_TransferFunc* pTransfer = new CPDF_TransferFunc(m_pPDFDoc); | 1112 CPDF_TransferFunc* pTransfer = new CPDF_TransferFunc(m_pPDFDoc); |
| 1113 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = | 1113 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = |
| 1114 new CPDF_CountedObject<CPDF_TransferFunc>(pTransfer); | 1114 new CPDF_CountedObject<CPDF_TransferFunc>(pTransfer); |
| 1115 m_TransferFuncMap[pObj] = pTransferCounter; | 1115 m_TransferFuncMap[pObj] = pTransferCounter; |
| 1116 static const int kMaxOutputs = 16; | 1116 static const int kMaxOutputs = 16; |
| 1117 FX_FLOAT output[kMaxOutputs]; | 1117 FX_FLOAT output[kMaxOutputs]; |
| 1118 FXSYS_memset(output, 0, sizeof(output)); | 1118 FXSYS_memset(output, 0, sizeof(output)); |
| 1119 FX_FLOAT input; | 1119 FX_FLOAT input; |
| 1120 int noutput; | 1120 int noutput; |
| 1121 for (int v = 0; v < 256; ++v) { | 1121 for (int v = 0; v < 256; ++v) { |
| 1122 input = (FX_FLOAT)v / 255.0f; | 1122 input = (FX_FLOAT)v / 255.0f; |
| 1123 if (bUniTransfer) { | 1123 if (bUniTransfer) { |
| 1124 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) | 1124 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) |
| 1125 pFuncs[0]->Call(&input, 1, output, noutput); | 1125 pFuncs[0]->Call(&input, 1, output, noutput); |
| 1126 int o = FXSYS_round(output[0] * 255); | 1126 int o = FXSYS_round(output[0] * 255); |
| 1127 if (o != v) | 1127 if (o != v) |
| 1128 bIdentity = FALSE; | 1128 bIdentity = false; |
| 1129 for (int i = 0; i < 3; ++i) { | 1129 for (int i = 0; i < 3; ++i) { |
| 1130 pTransfer->m_Samples[i * 256 + v] = o; | 1130 pTransfer->m_Samples[i * 256 + v] = o; |
| 1131 } | 1131 } |
| 1132 } else { | 1132 } else { |
| 1133 for (int i = 0; i < 3; ++i) { | 1133 for (int i = 0; i < 3; ++i) { |
| 1134 if (pFuncs[i] && pFuncs[i]->CountOutputs() <= kMaxOutputs) { | 1134 if (pFuncs[i] && pFuncs[i]->CountOutputs() <= kMaxOutputs) { |
| 1135 pFuncs[i]->Call(&input, 1, output, noutput); | 1135 pFuncs[i]->Call(&input, 1, output, noutput); |
| 1136 int o = FXSYS_round(output[0] * 255); | 1136 int o = FXSYS_round(output[0] * 255); |
| 1137 if (o != v) | 1137 if (o != v) |
| 1138 bIdentity = FALSE; | 1138 bIdentity = false; |
| 1139 pTransfer->m_Samples[i * 256 + v] = o; | 1139 pTransfer->m_Samples[i * 256 + v] = o; |
| 1140 } else { | 1140 } else { |
| 1141 pTransfer->m_Samples[i * 256 + v] = v; | 1141 pTransfer->m_Samples[i * 256 + v] = v; |
| 1142 } | 1142 } |
| 1143 } | 1143 } |
| 1144 } | 1144 } |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 pTransfer->m_bIdentity = bIdentity; | 1147 pTransfer->m_bIdentity = bIdentity; |
| 1148 return pTransferCounter->AddRef(); | 1148 return pTransferCounter->AddRef(); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 void CPDF_DocRenderData::ReleaseTransferFunc(CPDF_Object* pObj) { | 1151 void CPDF_DocRenderData::ReleaseTransferFunc(CPDF_Object* pObj) { |
| 1152 auto it = m_TransferFuncMap.find(pObj); | 1152 auto it = m_TransferFuncMap.find(pObj); |
| 1153 if (it != m_TransferFuncMap.end()) | 1153 if (it != m_TransferFuncMap.end()) |
| 1154 it->second->RemoveRef(); | 1154 it->second->RemoveRef(); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 CPDF_DeviceBuffer::CPDF_DeviceBuffer() | 1157 CPDF_DeviceBuffer::CPDF_DeviceBuffer() |
| 1158 : m_pDevice(nullptr), m_pContext(nullptr), m_pObject(nullptr) {} | 1158 : m_pDevice(nullptr), m_pContext(nullptr), m_pObject(nullptr) {} |
| 1159 | 1159 |
| 1160 CPDF_DeviceBuffer::~CPDF_DeviceBuffer() {} | 1160 CPDF_DeviceBuffer::~CPDF_DeviceBuffer() {} |
| 1161 | 1161 |
| 1162 FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, | 1162 bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, |
| 1163 CFX_RenderDevice* pDevice, | 1163 CFX_RenderDevice* pDevice, |
| 1164 FX_RECT* pRect, | 1164 FX_RECT* pRect, |
| 1165 const CPDF_PageObject* pObj, | 1165 const CPDF_PageObject* pObj, |
| 1166 int max_dpi) { | 1166 int max_dpi) { |
| 1167 m_pDevice = pDevice; | 1167 m_pDevice = pDevice; |
| 1168 m_pContext = pContext; | 1168 m_pContext = pContext; |
| 1169 m_Rect = *pRect; | 1169 m_Rect = *pRect; |
| 1170 m_pObject = pObj; | 1170 m_pObject = pObj; |
| 1171 m_Matrix.TranslateI(-pRect->left, -pRect->top); | 1171 m_Matrix.TranslateI(-pRect->left, -pRect->top); |
| 1172 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1172 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1173 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); | 1173 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); |
| 1174 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); | 1174 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); |
| 1175 if (horz_size && vert_size && max_dpi) { | 1175 if (horz_size && vert_size && max_dpi) { |
| 1176 int dpih = | 1176 int dpih = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1187 #endif | 1187 #endif |
| 1188 CFX_Matrix ctm = m_pDevice->GetCTM(); | 1188 CFX_Matrix ctm = m_pDevice->GetCTM(); |
| 1189 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); | 1189 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); |
| 1190 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); | 1190 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); |
| 1191 m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); | 1191 m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); |
| 1192 CFX_FloatRect rect(*pRect); | 1192 CFX_FloatRect rect(*pRect); |
| 1193 m_Matrix.TransformRect(rect); | 1193 m_Matrix.TransformRect(rect); |
| 1194 FX_RECT bitmap_rect = rect.GetOuterRect(); | 1194 FX_RECT bitmap_rect = rect.GetOuterRect(); |
| 1195 m_pBitmap.reset(new CFX_DIBitmap); | 1195 m_pBitmap.reset(new CFX_DIBitmap); |
| 1196 m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); | 1196 m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); |
| 1197 return TRUE; | 1197 return true; |
| 1198 } | 1198 } |
| 1199 void CPDF_DeviceBuffer::OutputToDevice() { | 1199 void CPDF_DeviceBuffer::OutputToDevice() { |
| 1200 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { | 1200 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { |
| 1201 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { | 1201 if (m_Matrix.a == 1.0f && m_Matrix.d == 1.0f) { |
| 1202 m_pDevice->SetDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top); | 1202 m_pDevice->SetDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top); |
| 1203 } else { | 1203 } else { |
| 1204 m_pDevice->StretchDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top, | 1204 m_pDevice->StretchDIBits(m_pBitmap.get(), m_Rect.left, m_Rect.top, |
| 1205 m_Rect.Width(), m_Rect.Height()); | 1205 m_Rect.Width(), m_Rect.Height()); |
| 1206 } | 1206 } |
| 1207 } else { | 1207 } else { |
| 1208 CFX_DIBitmap buffer; | 1208 CFX_DIBitmap buffer; |
| 1209 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), | 1209 m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), |
| 1210 m_pBitmap->GetHeight()); | 1210 m_pBitmap->GetHeight()); |
| 1211 m_pContext->GetBackground(&buffer, m_pObject, nullptr, &m_Matrix); | 1211 m_pContext->GetBackground(&buffer, m_pObject, nullptr, &m_Matrix); |
| 1212 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), | 1212 buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), |
| 1213 m_pBitmap.get(), 0, 0); | 1213 m_pBitmap.get(), 0, 0); |
| 1214 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(), | 1214 m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(), |
| 1215 m_Rect.Height()); | 1215 m_Rect.Height()); |
| 1216 } | 1216 } |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {} | 1219 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {} |
| 1220 | 1220 |
| 1221 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} | 1221 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} |
| 1222 | 1222 |
| 1223 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) | 1223 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) |
| 1224 FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, | 1224 bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, |
| 1225 CFX_RenderDevice* pDevice, | 1225 CFX_RenderDevice* pDevice, |
| 1226 const FX_RECT& pRect, | 1226 const FX_RECT& pRect, |
| 1227 const CPDF_PageObject* pObj, | 1227 const CPDF_PageObject* pObj, |
| 1228 const CPDF_RenderOptions* pOptions, | 1228 const CPDF_RenderOptions* pOptions, |
| 1229 int max_dpi) { | 1229 int max_dpi) { |
| 1230 m_pDevice = pDevice; | 1230 m_pDevice = pDevice; |
| 1231 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { | 1231 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { |
| 1232 return TRUE; | 1232 return true; |
| 1233 } | 1233 } |
| 1234 m_pContext = pContext; | 1234 m_pContext = pContext; |
| 1235 m_Rect = pRect; | 1235 m_Rect = pRect; |
| 1236 m_pObject = pObj; | 1236 m_pObject = pObj; |
| 1237 m_Matrix.TranslateI(-pRect.left, -pRect.top); | 1237 m_Matrix.TranslateI(-pRect.left, -pRect.top); |
| 1238 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); | 1238 int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); |
| 1239 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); | 1239 int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); |
| 1240 if (horz_size && vert_size && max_dpi) { | 1240 if (horz_size && vert_size && max_dpi) { |
| 1241 int dpih = | 1241 int dpih = |
| 1242 pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size * 10); | 1242 pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size * 10); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1257 bpp = 32; | 1257 bpp = 32; |
| 1258 } | 1258 } |
| 1259 while (1) { | 1259 while (1) { |
| 1260 CFX_FloatRect rect(pRect); | 1260 CFX_FloatRect rect(pRect); |
| 1261 m_Matrix.TransformRect(rect); | 1261 m_Matrix.TransformRect(rect); |
| 1262 FX_RECT bitmap_rect = rect.GetOuterRect(); | 1262 FX_RECT bitmap_rect = rect.GetOuterRect(); |
| 1263 int32_t iWidth = bitmap_rect.Width(); | 1263 int32_t iWidth = bitmap_rect.Width(); |
| 1264 int32_t iHeight = bitmap_rect.Height(); | 1264 int32_t iHeight = bitmap_rect.Height(); |
| 1265 int32_t iPitch = (iWidth * bpp + 31) / 32 * 4; | 1265 int32_t iPitch = (iWidth * bpp + 31) / 32 * 4; |
| 1266 if (iWidth * iHeight < 1) | 1266 if (iWidth * iHeight < 1) |
| 1267 return FALSE; | 1267 return false; |
| 1268 | 1268 |
| 1269 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && | 1269 if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && |
| 1270 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat, nullptr)) { | 1270 m_pBitmapDevice->Create(iWidth, iHeight, dibFormat, nullptr)) { |
| 1271 break; | 1271 break; |
| 1272 } | 1272 } |
| 1273 m_Matrix.Scale(0.5f, 0.5f); | 1273 m_Matrix.Scale(0.5f, 0.5f); |
| 1274 } | 1274 } |
| 1275 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, | 1275 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, |
| 1276 &m_Matrix); | 1276 &m_Matrix); |
| 1277 return TRUE; | 1277 return true; |
| 1278 } | 1278 } |
| 1279 void CPDF_ScaledRenderBuffer::OutputToDevice() { | 1279 void CPDF_ScaledRenderBuffer::OutputToDevice() { |
| 1280 if (m_pBitmapDevice) { | 1280 if (m_pBitmapDevice) { |
| 1281 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1281 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
| 1282 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1282 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
| 1283 } | 1283 } |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 #if defined _SKIA_SUPPORT_ | 1286 #if defined _SKIA_SUPPORT_ |
| 1287 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { | 1287 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { |
| 1288 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); | 1288 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); |
| 1289 } | 1289 } |
| 1290 #endif | 1290 #endif |
| OLD | NEW |