| 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 #include <utility> | 10 #include <utility> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "core/fpdfdoc/cpdf_occontext.h" | 27 #include "core/fpdfdoc/cpdf_occontext.h" |
| 28 #include "core/fxcodec/fx_codec.h" | 28 #include "core/fxcodec/fx_codec.h" |
| 29 #include "core/fxcrt/fx_safe_types.h" | 29 #include "core/fxcrt/fx_safe_types.h" |
| 30 #include "core/fxge/cfx_fxgedevice.h" | 30 #include "core/fxge/cfx_fxgedevice.h" |
| 31 #include "core/fxge/cfx_pathdata.h" | 31 #include "core/fxge/cfx_pathdata.h" |
| 32 | 32 |
| 33 #ifdef _SKIA_SUPPORT_ | 33 #ifdef _SKIA_SUPPORT_ |
| 34 #include "core/fxge/skia/fx_skia_device.h" | 34 #include "core/fxge/skia/fx_skia_device.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, | 37 bool CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, |
| 38 const CFX_Matrix* pObj2Device) { | 38 const CFX_Matrix* pObj2Device) { |
| 39 CPDF_ImageRenderer render; | 39 CPDF_ImageRenderer render; |
| 40 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { | 40 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { |
| 41 render.Continue(nullptr); | 41 render.Continue(nullptr); |
| 42 } | 42 } |
| 43 return render.m_Result; | 43 return render.m_Result; |
| 44 } | 44 } |
| 45 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, | 45 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, |
| 46 int left, | 46 int left, |
| 47 int top, | 47 int top, |
| 48 FX_ARGB mask_argb, | 48 FX_ARGB mask_argb, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (bIsolated || !bGroup) { | 93 if (bIsolated || !bGroup) { |
| 94 if (pDIBitmap->IsAlphaMask()) { | 94 if (pDIBitmap->IsAlphaMask()) { |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); | 97 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); |
| 98 } else { | 98 } else { |
| 99 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), | 99 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), |
| 100 top + pDIBitmap->GetHeight()); | 100 top + pDIBitmap->GetHeight()); |
| 101 rect.Intersect(m_pDevice->GetClipBox()); | 101 rect.Intersect(m_pDevice->GetClipBox()); |
| 102 CFX_DIBitmap* pClone = nullptr; | 102 CFX_DIBitmap* pClone = nullptr; |
| 103 FX_BOOL bClone = FALSE; | 103 bool bClone = false; |
| 104 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { | 104 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { |
| 105 bClone = TRUE; | 105 bClone = true; |
| 106 pClone = m_pDevice->GetBackDrop()->Clone(&rect); | 106 pClone = m_pDevice->GetBackDrop()->Clone(&rect); |
| 107 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); | 107 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); |
| 108 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), | 108 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), |
| 109 pForeBitmap, rect.left, rect.top); | 109 pForeBitmap, rect.left, rect.top); |
| 110 left = left >= 0 ? 0 : left; | 110 left = left >= 0 ? 0 : left; |
| 111 top = top >= 0 ? 0 : top; | 111 top = top >= 0 ? 0 : top; |
| 112 if (!pDIBitmap->IsAlphaMask()) | 112 if (!pDIBitmap->IsAlphaMask()) |
| 113 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), | 113 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), |
| 114 pDIBitmap, left, top, blend_mode); | 114 pDIBitmap, left, top, blend_mode); |
| 115 else | 115 else |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {} | 165 CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {} |
| 166 | 166 |
| 167 FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) const { | 167 FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) const { |
| 168 return FXSYS_RGB(m_Samples[FXSYS_GetRValue(rgb)], | 168 return FXSYS_RGB(m_Samples[FXSYS_GetRValue(rgb)], |
| 169 m_Samples[256 + FXSYS_GetGValue(rgb)], | 169 m_Samples[256 + FXSYS_GetGValue(rgb)], |
| 170 m_Samples[512 + FXSYS_GetBValue(rgb)]); | 170 m_Samples[512 + FXSYS_GetBValue(rgb)]); |
| 171 } | 171 } |
| 172 | 172 |
| 173 CFX_DIBSource* CPDF_TransferFunc::TranslateImage(const CFX_DIBSource* pSrc, | 173 CFX_DIBSource* CPDF_TransferFunc::TranslateImage(const CFX_DIBSource* pSrc, |
| 174 FX_BOOL bAutoDropSrc) { | 174 bool bAutoDropSrc) { |
| 175 CPDF_DIBTransferFunc* pDest = new CPDF_DIBTransferFunc(this); | 175 CPDF_DIBTransferFunc* pDest = new CPDF_DIBTransferFunc(this); |
| 176 pDest->LoadSrc(pSrc, bAutoDropSrc); | 176 pDest->LoadSrc(pSrc, bAutoDropSrc); |
| 177 return pDest; | 177 return pDest; |
| 178 } | 178 } |
| 179 | 179 |
| 180 CPDF_DIBTransferFunc::~CPDF_DIBTransferFunc() {} | 180 CPDF_DIBTransferFunc::~CPDF_DIBTransferFunc() {} |
| 181 | 181 |
| 182 FXDIB_Format CPDF_DIBTransferFunc::GetDestFormat() { | 182 FXDIB_Format CPDF_DIBTransferFunc::GetDestFormat() { |
| 183 if (m_pSrc->IsAlphaMask()) { | 183 if (m_pSrc->IsAlphaMask()) { |
| 184 return FXDIB_8bppMask; | 184 return FXDIB_8bppMask; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 197 CPDF_DIBTransferFunc::CPDF_DIBTransferFunc( | 197 CPDF_DIBTransferFunc::CPDF_DIBTransferFunc( |
| 198 const CPDF_TransferFunc* pTransferFunc) { | 198 const CPDF_TransferFunc* pTransferFunc) { |
| 199 m_RampR = pTransferFunc->m_Samples; | 199 m_RampR = pTransferFunc->m_Samples; |
| 200 m_RampG = &pTransferFunc->m_Samples[256]; | 200 m_RampG = &pTransferFunc->m_Samples[256]; |
| 201 m_RampB = &pTransferFunc->m_Samples[512]; | 201 m_RampB = &pTransferFunc->m_Samples[512]; |
| 202 } | 202 } |
| 203 | 203 |
| 204 void CPDF_DIBTransferFunc::TranslateScanline( | 204 void CPDF_DIBTransferFunc::TranslateScanline( |
| 205 const uint8_t* src_buf, | 205 const uint8_t* src_buf, |
| 206 std::vector<uint8_t>* dest_buf) const { | 206 std::vector<uint8_t>* dest_buf) const { |
| 207 FX_BOOL bSkip = FALSE; | 207 bool bSkip = false; |
| 208 switch (m_pSrc->GetFormat()) { | 208 switch (m_pSrc->GetFormat()) { |
| 209 case FXDIB_1bppRgb: { | 209 case FXDIB_1bppRgb: { |
| 210 int r0 = m_RampR[0]; | 210 int r0 = m_RampR[0]; |
| 211 int g0 = m_RampG[0]; | 211 int g0 = m_RampG[0]; |
| 212 int b0 = m_RampB[0]; | 212 int b0 = m_RampB[0]; |
| 213 int r1 = m_RampR[255]; | 213 int r1 = m_RampR[255]; |
| 214 int g1 = m_RampG[255]; | 214 int g1 = m_RampG[255]; |
| 215 int b1 = m_RampB[255]; | 215 int b1 = m_RampB[255]; |
| 216 int index = 0; | 216 int index = 0; |
| 217 for (int i = 0; i < m_Width; i++) { | 217 for (int i = 0; i < m_Width; i++) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 (*dest_buf)[index++] = m_RampB[*(src_buf++)]; | 277 (*dest_buf)[index++] = m_RampB[*(src_buf++)]; |
| 278 (*dest_buf)[index++] = m_RampG[*(src_buf++)]; | 278 (*dest_buf)[index++] = m_RampG[*(src_buf++)]; |
| 279 (*dest_buf)[index++] = m_RampR[*(src_buf++)]; | 279 (*dest_buf)[index++] = m_RampR[*(src_buf++)]; |
| 280 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 280 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 281 index++; | 281 index++; |
| 282 #endif | 282 #endif |
| 283 } | 283 } |
| 284 break; | 284 break; |
| 285 } | 285 } |
| 286 case FXDIB_Rgb32: | 286 case FXDIB_Rgb32: |
| 287 bSkip = TRUE; | 287 bSkip = true; |
| 288 case FXDIB_Argb: { | 288 case FXDIB_Argb: { |
| 289 int index = 0; | 289 int index = 0; |
| 290 for (int i = 0; i < m_Width; i++) { | 290 for (int i = 0; i < m_Width; i++) { |
| 291 (*dest_buf)[index++] = m_RampB[*(src_buf++)]; | 291 (*dest_buf)[index++] = m_RampB[*(src_buf++)]; |
| 292 (*dest_buf)[index++] = m_RampG[*(src_buf++)]; | 292 (*dest_buf)[index++] = m_RampG[*(src_buf++)]; |
| 293 (*dest_buf)[index++] = m_RampR[*(src_buf++)]; | 293 (*dest_buf)[index++] = m_RampR[*(src_buf++)]; |
| 294 if (!bSkip) { | 294 if (!bSkip) { |
| 295 (*dest_buf)[index++] = *src_buf; | 295 (*dest_buf)[index++] = *src_buf; |
| 296 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 296 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 297 } else { | 297 } else { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 341 } |
| 342 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 342 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 343 } | 343 } |
| 344 #endif | 344 #endif |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 CPDF_ImageRenderer::CPDF_ImageRenderer() { | 348 CPDF_ImageRenderer::CPDF_ImageRenderer() { |
| 349 m_pRenderStatus = nullptr; | 349 m_pRenderStatus = nullptr; |
| 350 m_pImageObject = nullptr; | 350 m_pImageObject = nullptr; |
| 351 m_Result = TRUE; | 351 m_Result = true; |
| 352 m_Status = 0; | 352 m_Status = 0; |
| 353 m_DeviceHandle = nullptr; | 353 m_DeviceHandle = nullptr; |
| 354 m_bStdCS = FALSE; | 354 m_bStdCS = false; |
| 355 m_bPatternColor = FALSE; | 355 m_bPatternColor = false; |
| 356 m_BlendType = FXDIB_BLEND_NORMAL; | 356 m_BlendType = FXDIB_BLEND_NORMAL; |
| 357 m_pPattern = nullptr; | 357 m_pPattern = nullptr; |
| 358 m_pObj2Device = nullptr; | 358 m_pObj2Device = nullptr; |
| 359 } | 359 } |
| 360 | 360 |
| 361 CPDF_ImageRenderer::~CPDF_ImageRenderer() { | 361 CPDF_ImageRenderer::~CPDF_ImageRenderer() { |
| 362 if (m_DeviceHandle) { | 362 if (m_DeviceHandle) { |
| 363 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); | 363 m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle); |
| 364 } | 364 } |
| 365 } | 365 } |
| 366 | 366 |
| 367 FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { | 367 bool CPDF_ImageRenderer::StartLoadDIBSource() { |
| 368 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 368 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
| 369 FX_RECT image_rect = image_rect_f.GetOuterRect(); | 369 FX_RECT image_rect = image_rect_f.GetOuterRect(); |
| 370 if (!image_rect.Valid()) | 370 if (!image_rect.Valid()) |
| 371 return FALSE; | 371 return false; |
| 372 | 372 |
| 373 int dest_width = image_rect.Width(); | 373 int dest_width = image_rect.Width(); |
| 374 int dest_height = image_rect.Height(); | 374 int dest_height = image_rect.Height(); |
| 375 if (m_ImageMatrix.a < 0) { | 375 if (m_ImageMatrix.a < 0) { |
| 376 dest_width = -dest_width; | 376 dest_width = -dest_width; |
| 377 } | 377 } |
| 378 if (m_ImageMatrix.d > 0) { | 378 if (m_ImageMatrix.d > 0) { |
| 379 dest_height = -dest_height; | 379 dest_height = -dest_height; |
| 380 } | 380 } |
| 381 if (m_Loader.Start(m_pImageObject, | 381 if (m_Loader.Start(m_pImageObject, |
| 382 m_pRenderStatus->m_pContext->GetPageCache(), &m_LoadHandle, | 382 m_pRenderStatus->m_pContext->GetPageCache(), &m_LoadHandle, |
| 383 m_bStdCS, m_pRenderStatus->m_GroupFamily, | 383 m_bStdCS, m_pRenderStatus->m_GroupFamily, |
| 384 m_pRenderStatus->m_bLoadMask, m_pRenderStatus, dest_width, | 384 m_pRenderStatus->m_bLoadMask, m_pRenderStatus, dest_width, |
| 385 dest_height)) { | 385 dest_height)) { |
| 386 if (m_LoadHandle) { | 386 if (m_LoadHandle) { |
| 387 m_Status = 4; | 387 m_Status = 4; |
| 388 return TRUE; | 388 return true; |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 return FALSE; | 391 return false; |
| 392 } | 392 } |
| 393 | 393 |
| 394 FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { | 394 bool CPDF_ImageRenderer::StartRenderDIBSource() { |
| 395 if (!m_Loader.m_pBitmap) | 395 if (!m_Loader.m_pBitmap) |
| 396 return FALSE; | 396 return false; |
| 397 | 397 |
| 398 m_BitmapAlpha = | 398 m_BitmapAlpha = |
| 399 FXSYS_round(255 * m_pImageObject->m_GeneralState.GetFillAlpha()); | 399 FXSYS_round(255 * m_pImageObject->m_GeneralState.GetFillAlpha()); |
| 400 m_pDIBSource = m_Loader.m_pBitmap; | 400 m_pDIBSource = m_Loader.m_pBitmap; |
| 401 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && | 401 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && |
| 402 !m_Loader.m_pMask) { | 402 !m_Loader.m_pMask) { |
| 403 return StartBitmapAlpha(); | 403 return StartBitmapAlpha(); |
| 404 } | 404 } |
| 405 if (m_pImageObject->m_GeneralState.GetTR()) { | 405 if (m_pImageObject->m_GeneralState.GetTR()) { |
| 406 if (!m_pImageObject->m_GeneralState.GetTransferFunc()) { | 406 if (!m_pImageObject->m_GeneralState.GetTransferFunc()) { |
| 407 m_pImageObject->m_GeneralState.SetTransferFunc( | 407 m_pImageObject->m_GeneralState.SetTransferFunc( |
| 408 m_pRenderStatus->GetTransferFunc( | 408 m_pRenderStatus->GetTransferFunc( |
| 409 m_pImageObject->m_GeneralState.GetTR())); | 409 m_pImageObject->m_GeneralState.GetTR())); |
| 410 } | 410 } |
| 411 if (m_pImageObject->m_GeneralState.GetTransferFunc() && | 411 if (m_pImageObject->m_GeneralState.GetTransferFunc() && |
| 412 !m_pImageObject->m_GeneralState.GetTransferFunc()->m_bIdentity) { | 412 !m_pImageObject->m_GeneralState.GetTransferFunc()->m_bIdentity) { |
| 413 m_pDIBSource = m_Loader.m_pBitmap = | 413 m_pDIBSource = m_Loader.m_pBitmap = |
| 414 m_pImageObject->m_GeneralState.GetTransferFunc()->TranslateImage( | 414 m_pImageObject->m_GeneralState.GetTransferFunc()->TranslateImage( |
| 415 m_Loader.m_pBitmap, !m_Loader.m_bCached); | 415 m_Loader.m_pBitmap, !m_Loader.m_bCached); |
| 416 if (m_Loader.m_bCached && m_Loader.m_pMask) { | 416 if (m_Loader.m_bCached && m_Loader.m_pMask) { |
| 417 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); | 417 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); |
| 418 } | 418 } |
| 419 m_Loader.m_bCached = FALSE; | 419 m_Loader.m_bCached = false; |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 m_FillArgb = 0; | 422 m_FillArgb = 0; |
| 423 m_bPatternColor = FALSE; | 423 m_bPatternColor = false; |
| 424 m_pPattern = nullptr; | 424 m_pPattern = nullptr; |
| 425 if (m_pDIBSource->IsAlphaMask()) { | 425 if (m_pDIBSource->IsAlphaMask()) { |
| 426 const CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); | 426 const CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); |
| 427 if (pColor && pColor->IsPattern()) { | 427 if (pColor && pColor->IsPattern()) { |
| 428 m_pPattern = pColor->GetPattern(); | 428 m_pPattern = pColor->GetPattern(); |
| 429 if (m_pPattern) { | 429 if (m_pPattern) { |
| 430 m_bPatternColor = TRUE; | 430 m_bPatternColor = true; |
| 431 } | 431 } |
| 432 } | 432 } |
| 433 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); | 433 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); |
| 434 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { | 434 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { |
| 435 m_pClone.reset(m_pDIBSource->Clone()); | 435 m_pClone.reset(m_pDIBSource->Clone()); |
| 436 m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor, | 436 m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor, |
| 437 m_pRenderStatus->m_Options.m_ForeColor); | 437 m_pRenderStatus->m_Options.m_ForeColor); |
| 438 m_pDIBSource = m_pClone.get(); | 438 m_pDIBSource = m_pClone.get(); |
| 439 } | 439 } |
| 440 m_Flags = 0; | 440 m_Flags = 0; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || | 500 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || |
| 501 format == PDFCS_DEVICEN) { | 501 format == PDFCS_DEVICEN) { |
| 502 m_BlendType = FXDIB_BLEND_DARKEN; | 502 m_BlendType = FXDIB_BLEND_DARKEN; |
| 503 } | 503 } |
| 504 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); | 504 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 return StartDIBSource(); | 507 return StartDIBSource(); |
| 508 } | 508 } |
| 509 | 509 |
| 510 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, | 510 bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, |
| 511 CPDF_PageObject* pObj, | 511 CPDF_PageObject* pObj, |
| 512 const CFX_Matrix* pObj2Device, | 512 const CFX_Matrix* pObj2Device, |
| 513 FX_BOOL bStdCS, | 513 bool bStdCS, |
| 514 int blendType) { | 514 int blendType) { |
| 515 m_pRenderStatus = pStatus; | 515 m_pRenderStatus = pStatus; |
| 516 m_bStdCS = bStdCS; | 516 m_bStdCS = bStdCS; |
| 517 m_pImageObject = pObj->AsImage(); | 517 m_pImageObject = pObj->AsImage(); |
| 518 m_BlendType = blendType; | 518 m_BlendType = blendType; |
| 519 m_pObj2Device = pObj2Device; | 519 m_pObj2Device = pObj2Device; |
| 520 CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC(); | 520 CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC(); |
| 521 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && | 521 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && |
| 522 !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) { | 522 !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) { |
| 523 return FALSE; | 523 return false; |
| 524 } | 524 } |
| 525 m_ImageMatrix = m_pImageObject->m_Matrix; | 525 m_ImageMatrix = m_pImageObject->m_Matrix; |
| 526 m_ImageMatrix.Concat(*pObj2Device); | 526 m_ImageMatrix.Concat(*pObj2Device); |
| 527 if (StartLoadDIBSource()) { | 527 if (StartLoadDIBSource()) { |
| 528 return TRUE; | 528 return true; |
| 529 } | 529 } |
| 530 return StartRenderDIBSource(); | 530 return StartRenderDIBSource(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, | 533 bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, |
| 534 const CFX_DIBSource* pDIBSource, | 534 const CFX_DIBSource* pDIBSource, |
| 535 FX_ARGB bitmap_argb, | 535 FX_ARGB bitmap_argb, |
| 536 int bitmap_alpha, | 536 int bitmap_alpha, |
| 537 const CFX_Matrix* pImage2Device, | 537 const CFX_Matrix* pImage2Device, |
| 538 uint32_t flags, | 538 uint32_t flags, |
| 539 FX_BOOL bStdCS, | 539 bool bStdCS, |
| 540 int blendType) { | 540 int blendType) { |
| 541 m_pRenderStatus = pStatus; | 541 m_pRenderStatus = pStatus; |
| 542 m_pDIBSource = pDIBSource; | 542 m_pDIBSource = pDIBSource; |
| 543 m_FillArgb = bitmap_argb; | 543 m_FillArgb = bitmap_argb; |
| 544 m_BitmapAlpha = bitmap_alpha; | 544 m_BitmapAlpha = bitmap_alpha; |
| 545 m_ImageMatrix = *pImage2Device; | 545 m_ImageMatrix = *pImage2Device; |
| 546 m_Flags = flags; | 546 m_Flags = flags; |
| 547 m_bStdCS = bStdCS; | 547 m_bStdCS = bStdCS; |
| 548 m_BlendType = blendType; | 548 m_BlendType = blendType; |
| 549 return StartDIBSource(); | 549 return StartDIBSource(); |
| 550 } | 550 } |
| 551 | 551 |
| 552 FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { | 552 bool CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { |
| 553 if (m_pRenderStatus->m_bPrint && | 553 if (m_pRenderStatus->m_bPrint && |
| 554 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 554 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 555 m_Result = FALSE; | 555 m_Result = false; |
| 556 return FALSE; | 556 return false; |
| 557 } | 557 } |
| 558 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); | 558 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); |
| 559 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 559 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
| 560 if (rect.IsEmpty()) { | 560 if (rect.IsEmpty()) { |
| 561 return FALSE; | 561 return false; |
| 562 } | 562 } |
| 563 CFX_Matrix new_matrix = m_ImageMatrix; | 563 CFX_Matrix new_matrix = m_ImageMatrix; |
| 564 new_matrix.TranslateI(-rect.left, -rect.top); | 564 new_matrix.TranslateI(-rect.left, -rect.top); |
| 565 int width = rect.Width(); | 565 int width = rect.Width(); |
| 566 int height = rect.Height(); | 566 int height = rect.Height(); |
| 567 CFX_FxgeDevice bitmap_device1; | 567 CFX_FxgeDevice bitmap_device1; |
| 568 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) | 568 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) |
| 569 return TRUE; | 569 return true; |
| 570 | 570 |
| 571 bitmap_device1.GetBitmap()->Clear(0xffffff); | 571 bitmap_device1.GetBitmap()->Clear(0xffffff); |
| 572 { | 572 { |
| 573 CPDF_RenderStatus bitmap_render; | 573 CPDF_RenderStatus bitmap_render; |
| 574 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, | 574 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, |
| 575 nullptr, nullptr, nullptr, nullptr, | 575 nullptr, nullptr, nullptr, nullptr, |
| 576 &m_pRenderStatus->m_Options, 0, | 576 &m_pRenderStatus->m_Options, 0, |
| 577 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); | 577 m_pRenderStatus->m_bDropObjects, nullptr, true); |
| 578 CFX_Matrix patternDevice = *pObj2Device; | 578 CFX_Matrix patternDevice = *pObj2Device; |
| 579 patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); | 579 patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); |
| 580 if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { | 580 if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { |
| 581 bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, | 581 bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, |
| 582 &patternDevice, FALSE); | 582 &patternDevice, false); |
| 583 } else if (CPDF_ShadingPattern* pShadingPattern = | 583 } else if (CPDF_ShadingPattern* pShadingPattern = |
| 584 m_pPattern->AsShadingPattern()) { | 584 m_pPattern->AsShadingPattern()) { |
| 585 bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject, | 585 bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject, |
| 586 &patternDevice, FALSE); | 586 &patternDevice, false); |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 { | 589 { |
| 590 CFX_FxgeDevice bitmap_device2; | 590 CFX_FxgeDevice bitmap_device2; |
| 591 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb, | 591 if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb, |
| 592 nullptr)) { | 592 nullptr)) { |
| 593 return TRUE; | 593 return true; |
| 594 } | 594 } |
| 595 bitmap_device2.GetBitmap()->Clear(0); | 595 bitmap_device2.GetBitmap()->Clear(0); |
| 596 CPDF_RenderStatus bitmap_render; | 596 CPDF_RenderStatus bitmap_render; |
| 597 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, | 597 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, |
| 598 nullptr, nullptr, nullptr, nullptr, nullptr, 0, | 598 nullptr, nullptr, nullptr, nullptr, nullptr, 0, |
| 599 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); | 599 m_pRenderStatus->m_bDropObjects, nullptr, true); |
| 600 CPDF_ImageRenderer image_render; | 600 CPDF_ImageRenderer image_render; |
| 601 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, | 601 if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, |
| 602 &new_matrix, m_Flags, TRUE)) { | 602 &new_matrix, m_Flags, true)) { |
| 603 image_render.Continue(nullptr); | 603 image_render.Continue(nullptr); |
| 604 } | 604 } |
| 605 if (m_Loader.m_MatteColor != 0xffffffff) { | 605 if (m_Loader.m_MatteColor != 0xffffffff) { |
| 606 int matte_r = FXARGB_R(m_Loader.m_MatteColor); | 606 int matte_r = FXARGB_R(m_Loader.m_MatteColor); |
| 607 int matte_g = FXARGB_G(m_Loader.m_MatteColor); | 607 int matte_g = FXARGB_G(m_Loader.m_MatteColor); |
| 608 int matte_b = FXARGB_B(m_Loader.m_MatteColor); | 608 int matte_b = FXARGB_B(m_Loader.m_MatteColor); |
| 609 for (int row = 0; row < height; row++) { | 609 for (int row = 0; row < height; row++) { |
| 610 uint8_t* dest_scan = | 610 uint8_t* dest_scan = |
| 611 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); | 611 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); |
| 612 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); | 612 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 } | 642 } |
| 643 } | 643 } |
| 644 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 644 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
| 645 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 645 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
| 646 bitmap_device1.GetBitmap()->MultiplyAlpha(255); | 646 bitmap_device1.GetBitmap()->MultiplyAlpha(255); |
| 647 } | 647 } |
| 648 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( | 648 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
| 649 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); | 649 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
| 650 return FALSE; | 650 return false; |
| 651 } | 651 } |
| 652 | 652 |
| 653 FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { | 653 bool CPDF_ImageRenderer::DrawMaskedImage() { |
| 654 if (m_pRenderStatus->m_bPrint && | 654 if (m_pRenderStatus->m_bPrint && |
| 655 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 655 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 656 m_Result = FALSE; | 656 m_Result = false; |
| 657 return FALSE; | 657 return false; |
| 658 } | 658 } |
| 659 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); | 659 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); |
| 660 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); | 660 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); |
| 661 if (rect.IsEmpty()) { | 661 if (rect.IsEmpty()) { |
| 662 return FALSE; | 662 return false; |
| 663 } | 663 } |
| 664 CFX_Matrix new_matrix = m_ImageMatrix; | 664 CFX_Matrix new_matrix = m_ImageMatrix; |
| 665 new_matrix.TranslateI(-rect.left, -rect.top); | 665 new_matrix.TranslateI(-rect.left, -rect.top); |
| 666 int width = rect.Width(); | 666 int width = rect.Width(); |
| 667 int height = rect.Height(); | 667 int height = rect.Height(); |
| 668 CFX_FxgeDevice bitmap_device1; | 668 CFX_FxgeDevice bitmap_device1; |
| 669 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) | 669 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) |
| 670 return TRUE; | 670 return true; |
| 671 | 671 |
| 672 #if defined _SKIA_SUPPORT_ | 672 #if defined _SKIA_SUPPORT_ |
| 673 bitmap_device1.Clear(0xffffff); | 673 bitmap_device1.Clear(0xffffff); |
| 674 #else | 674 #else |
| 675 bitmap_device1.GetBitmap()->Clear(0xffffff); | 675 bitmap_device1.GetBitmap()->Clear(0xffffff); |
| 676 #endif | 676 #endif |
| 677 { | 677 { |
| 678 CPDF_RenderStatus bitmap_render; | 678 CPDF_RenderStatus bitmap_render; |
| 679 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, | 679 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, |
| 680 nullptr, nullptr, nullptr, nullptr, nullptr, 0, | 680 nullptr, nullptr, nullptr, nullptr, nullptr, 0, |
| 681 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); | 681 m_pRenderStatus->m_bDropObjects, nullptr, true); |
| 682 CPDF_ImageRenderer image_render; | 682 CPDF_ImageRenderer image_render; |
| 683 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, | 683 if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, |
| 684 m_Flags, TRUE)) { | 684 m_Flags, true)) { |
| 685 image_render.Continue(nullptr); | 685 image_render.Continue(nullptr); |
| 686 } | 686 } |
| 687 } | 687 } |
| 688 { | 688 { |
| 689 CFX_FxgeDevice bitmap_device2; | 689 CFX_FxgeDevice bitmap_device2; |
| 690 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) | 690 if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) |
| 691 return TRUE; | 691 return true; |
| 692 | 692 |
| 693 #if defined _SKIA_SUPPORT_ | 693 #if defined _SKIA_SUPPORT_ |
| 694 bitmap_device2.Clear(0); | 694 bitmap_device2.Clear(0); |
| 695 #else | 695 #else |
| 696 bitmap_device2.GetBitmap()->Clear(0); | 696 bitmap_device2.GetBitmap()->Clear(0); |
| 697 #endif | 697 #endif |
| 698 CPDF_RenderStatus bitmap_render; | 698 CPDF_RenderStatus bitmap_render; |
| 699 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, | 699 bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, |
| 700 nullptr, nullptr, nullptr, nullptr, nullptr, 0, | 700 nullptr, nullptr, nullptr, nullptr, nullptr, 0, |
| 701 m_pRenderStatus->m_bDropObjects, nullptr, TRUE); | 701 m_pRenderStatus->m_bDropObjects, nullptr, true); |
| 702 CPDF_ImageRenderer image_render; | 702 CPDF_ImageRenderer image_render; |
| 703 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, | 703 if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, |
| 704 &new_matrix, m_Flags, TRUE)) { | 704 &new_matrix, m_Flags, true)) { |
| 705 image_render.Continue(nullptr); | 705 image_render.Continue(nullptr); |
| 706 } | 706 } |
| 707 if (m_Loader.m_MatteColor != 0xffffffff) { | 707 if (m_Loader.m_MatteColor != 0xffffffff) { |
| 708 int matte_r = FXARGB_R(m_Loader.m_MatteColor); | 708 int matte_r = FXARGB_R(m_Loader.m_MatteColor); |
| 709 int matte_g = FXARGB_G(m_Loader.m_MatteColor); | 709 int matte_g = FXARGB_G(m_Loader.m_MatteColor); |
| 710 int matte_b = FXARGB_B(m_Loader.m_MatteColor); | 710 int matte_b = FXARGB_B(m_Loader.m_MatteColor); |
| 711 for (int row = 0; row < height; row++) { | 711 for (int row = 0; row < height; row++) { |
| 712 uint8_t* dest_scan = | 712 uint8_t* dest_scan = |
| 713 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); | 713 (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); |
| 714 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); | 714 const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 #else | 751 #else |
| 752 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); | 752 bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask); |
| 753 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); | 753 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); |
| 754 if (m_BitmapAlpha < 255) { | 754 if (m_BitmapAlpha < 255) { |
| 755 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); | 755 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); |
| 756 } | 756 } |
| 757 } | 757 } |
| 758 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( | 758 m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
| 759 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); | 759 bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); |
| 760 #endif // _SKIA_SUPPORT_ | 760 #endif // _SKIA_SUPPORT_ |
| 761 return FALSE; | 761 return false; |
| 762 } | 762 } |
| 763 | 763 |
| 764 FX_BOOL CPDF_ImageRenderer::StartDIBSource() { | 764 bool CPDF_ImageRenderer::StartDIBSource() { |
| 765 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { | 765 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { |
| 766 FX_SAFE_SIZE_T image_size = m_pDIBSource->GetBPP(); | 766 FX_SAFE_SIZE_T image_size = m_pDIBSource->GetBPP(); |
| 767 image_size /= 8; | 767 image_size /= 8; |
| 768 image_size *= m_pDIBSource->GetWidth(); | 768 image_size *= m_pDIBSource->GetWidth(); |
| 769 image_size *= m_pDIBSource->GetHeight(); | 769 image_size *= m_pDIBSource->GetHeight(); |
| 770 if (!image_size.IsValid()) { | 770 if (!image_size.IsValid()) { |
| 771 return FALSE; | 771 return false; |
| 772 } | 772 } |
| 773 | 773 |
| 774 if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE && | 774 if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE && |
| 775 !(m_Flags & RENDER_FORCE_HALFTONE)) { | 775 !(m_Flags & RENDER_FORCE_HALFTONE)) { |
| 776 m_Flags |= RENDER_FORCE_DOWNSAMPLE; | 776 m_Flags |= RENDER_FORCE_DOWNSAMPLE; |
| 777 } | 777 } |
| 778 } | 778 } |
| 779 #ifdef _SKIA_SUPPORT_ | 779 #ifdef _SKIA_SUPPORT_ |
| 780 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); | 780 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); |
| 781 if (m_pDIBSource->HasAlpha()) | 781 if (m_pDIBSource->HasAlpha()) |
| 782 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); | 782 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); |
| 783 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( | 783 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( |
| 784 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, | 784 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, |
| 785 m_DeviceHandle, m_BlendType)) { | 785 m_DeviceHandle, m_BlendType)) { |
| 786 if (m_DeviceHandle) { | 786 if (m_DeviceHandle) { |
| 787 m_Status = 3; | 787 m_Status = 3; |
| 788 return TRUE; | 788 return true; |
| 789 } | 789 } |
| 790 return FALSE; | 790 return false; |
| 791 } | 791 } |
| 792 #else | 792 #else |
| 793 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( | 793 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( |
| 794 m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, | 794 m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, |
| 795 m_DeviceHandle, m_BlendType)) { | 795 m_DeviceHandle, m_BlendType)) { |
| 796 if (m_DeviceHandle) { | 796 if (m_DeviceHandle) { |
| 797 m_Status = 3; | 797 m_Status = 3; |
| 798 return TRUE; | 798 return true; |
| 799 } | 799 } |
| 800 return FALSE; | 800 return false; |
| 801 } | 801 } |
| 802 #endif | 802 #endif |
| 803 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 803 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
| 804 FX_RECT image_rect = image_rect_f.GetOuterRect(); | 804 FX_RECT image_rect = image_rect_f.GetOuterRect(); |
| 805 int dest_width = image_rect.Width(); | 805 int dest_width = image_rect.Width(); |
| 806 int dest_height = image_rect.Height(); | 806 int dest_height = image_rect.Height(); |
| 807 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || | 807 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || |
| 808 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { | 808 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { |
| 809 if (m_pRenderStatus->m_bPrint && | 809 if (m_pRenderStatus->m_bPrint && |
| 810 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 810 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 811 m_Result = FALSE; | 811 m_Result = false; |
| 812 return FALSE; | 812 return false; |
| 813 } | 813 } |
| 814 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); | 814 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); |
| 815 clip_box.Intersect(image_rect); | 815 clip_box.Intersect(image_rect); |
| 816 m_Status = 2; | 816 m_Status = 2; |
| 817 m_pTransformer.reset(new CFX_ImageTransformer(m_pDIBSource, &m_ImageMatrix, | 817 m_pTransformer.reset(new CFX_ImageTransformer(m_pDIBSource, &m_ImageMatrix, |
| 818 m_Flags, &clip_box)); | 818 m_Flags, &clip_box)); |
| 819 m_pTransformer->Start(); | 819 m_pTransformer->Start(); |
| 820 return TRUE; | 820 return true; |
| 821 } | 821 } |
| 822 if (m_ImageMatrix.a < 0) | 822 if (m_ImageMatrix.a < 0) |
| 823 dest_width = -dest_width; | 823 dest_width = -dest_width; |
| 824 | 824 |
| 825 if (m_ImageMatrix.d > 0) | 825 if (m_ImageMatrix.d > 0) |
| 826 dest_height = -dest_height; | 826 dest_height = -dest_height; |
| 827 | 827 |
| 828 int dest_left = dest_width > 0 ? image_rect.left : image_rect.right; | 828 int dest_left = dest_width > 0 ? image_rect.left : image_rect.right; |
| 829 int dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom; | 829 int dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom; |
| 830 if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { | 830 if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { |
| 831 if (m_pRenderStatus->m_pDevice->StretchDIBitsWithFlagsAndBlend( | 831 if (m_pRenderStatus->m_pDevice->StretchDIBitsWithFlagsAndBlend( |
| 832 m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags, | 832 m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags, |
| 833 m_BlendType)) { | 833 m_BlendType)) { |
| 834 return FALSE; | 834 return false; |
| 835 } | 835 } |
| 836 } | 836 } |
| 837 if (m_pDIBSource->IsAlphaMask()) { | 837 if (m_pDIBSource->IsAlphaMask()) { |
| 838 if (m_BitmapAlpha != 255) | 838 if (m_BitmapAlpha != 255) |
| 839 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); | 839 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); |
| 840 if (m_pRenderStatus->m_pDevice->StretchBitMaskWithFlags( | 840 if (m_pRenderStatus->m_pDevice->StretchBitMaskWithFlags( |
| 841 m_pDIBSource, dest_left, dest_top, dest_width, dest_height, | 841 m_pDIBSource, dest_left, dest_top, dest_width, dest_height, |
| 842 m_FillArgb, m_Flags)) { | 842 m_FillArgb, m_Flags)) { |
| 843 return FALSE; | 843 return false; |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 if (m_pRenderStatus->m_bPrint && | 846 if (m_pRenderStatus->m_bPrint && |
| 847 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { | 847 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { |
| 848 m_Result = FALSE; | 848 m_Result = false; |
| 849 return TRUE; | 849 return true; |
| 850 } | 850 } |
| 851 | 851 |
| 852 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); | 852 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); |
| 853 FX_RECT dest_rect = clip_box; | 853 FX_RECT dest_rect = clip_box; |
| 854 dest_rect.Intersect(image_rect); | 854 dest_rect.Intersect(image_rect); |
| 855 FX_RECT dest_clip( | 855 FX_RECT dest_clip( |
| 856 dest_rect.left - image_rect.left, dest_rect.top - image_rect.top, | 856 dest_rect.left - image_rect.left, dest_rect.top - image_rect.top, |
| 857 dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top); | 857 dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top); |
| 858 std::unique_ptr<CFX_DIBitmap> pStretched( | 858 std::unique_ptr<CFX_DIBitmap> pStretched( |
| 859 m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip)); | 859 m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip)); |
| 860 if (pStretched) { | 860 if (pStretched) { |
| 861 m_pRenderStatus->CompositeDIBitmap(pStretched.get(), dest_rect.left, | 861 m_pRenderStatus->CompositeDIBitmap(pStretched.get(), dest_rect.left, |
| 862 dest_rect.top, m_FillArgb, m_BitmapAlpha, | 862 dest_rect.top, m_FillArgb, m_BitmapAlpha, |
| 863 m_BlendType, FALSE); | 863 m_BlendType, false); |
| 864 } | 864 } |
| 865 return FALSE; | 865 return false; |
| 866 } | 866 } |
| 867 | 867 |
| 868 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { | 868 bool CPDF_ImageRenderer::StartBitmapAlpha() { |
| 869 if (m_pDIBSource->IsOpaqueImage()) { | 869 if (m_pDIBSource->IsOpaqueImage()) { |
| 870 CFX_PathData path; | 870 CFX_PathData path; |
| 871 path.AppendRect(0, 0, 1, 1); | 871 path.AppendRect(0, 0, 1, 1); |
| 872 path.Transform(&m_ImageMatrix); | 872 path.Transform(&m_ImageMatrix); |
| 873 uint32_t fill_color = | 873 uint32_t fill_color = |
| 874 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); | 874 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); |
| 875 m_pRenderStatus->m_pDevice->DrawPath(&path, nullptr, nullptr, fill_color, 0, | 875 m_pRenderStatus->m_pDevice->DrawPath(&path, nullptr, nullptr, fill_color, 0, |
| 876 FXFILL_WINDING); | 876 FXFILL_WINDING); |
| 877 } else { | 877 } else { |
| 878 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() | 878 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() |
| 879 ? m_pDIBSource | 879 ? m_pDIBSource |
| 880 : m_pDIBSource->GetAlphaMask(); | 880 : m_pDIBSource->GetAlphaMask(); |
| 881 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || | 881 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || |
| 882 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { | 882 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { |
| 883 int left, top; | 883 int left, top; |
| 884 std::unique_ptr<CFX_DIBitmap> pTransformed( | 884 std::unique_ptr<CFX_DIBitmap> pTransformed( |
| 885 pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); | 885 pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); |
| 886 if (!pTransformed) | 886 if (!pTransformed) |
| 887 return TRUE; | 887 return true; |
| 888 | 888 |
| 889 m_pRenderStatus->m_pDevice->SetBitMask( | 889 m_pRenderStatus->m_pDevice->SetBitMask( |
| 890 pTransformed.get(), left, top, | 890 pTransformed.get(), left, top, |
| 891 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); | 891 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); |
| 892 } else { | 892 } else { |
| 893 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); | 893 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); |
| 894 FX_RECT image_rect = image_rect_f.GetOuterRect(); | 894 FX_RECT image_rect = image_rect_f.GetOuterRect(); |
| 895 int dest_width = | 895 int dest_width = |
| 896 m_ImageMatrix.a > 0 ? image_rect.Width() : -image_rect.Width(); | 896 m_ImageMatrix.a > 0 ? image_rect.Width() : -image_rect.Width(); |
| 897 int dest_height = | 897 int dest_height = |
| 898 m_ImageMatrix.d > 0 ? -image_rect.Height() : image_rect.Height(); | 898 m_ImageMatrix.d > 0 ? -image_rect.Height() : image_rect.Height(); |
| 899 int left = dest_width > 0 ? image_rect.left : image_rect.right; | 899 int left = dest_width > 0 ? image_rect.left : image_rect.right; |
| 900 int top = dest_height > 0 ? image_rect.top : image_rect.bottom; | 900 int top = dest_height > 0 ? image_rect.top : image_rect.bottom; |
| 901 m_pRenderStatus->m_pDevice->StretchBitMask( | 901 m_pRenderStatus->m_pDevice->StretchBitMask( |
| 902 pAlphaMask, left, top, dest_width, dest_height, | 902 pAlphaMask, left, top, dest_width, dest_height, |
| 903 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); | 903 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); |
| 904 } | 904 } |
| 905 if (m_pDIBSource != pAlphaMask) { | 905 if (m_pDIBSource != pAlphaMask) { |
| 906 delete pAlphaMask; | 906 delete pAlphaMask; |
| 907 } | 907 } |
| 908 } | 908 } |
| 909 return FALSE; | 909 return false; |
| 910 } | 910 } |
| 911 | 911 |
| 912 FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { | 912 bool CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { |
| 913 if (m_Status == 2) { | 913 if (m_Status == 2) { |
| 914 if (m_pTransformer->Continue(pPause)) | 914 if (m_pTransformer->Continue(pPause)) |
| 915 return TRUE; | 915 return true; |
| 916 | 916 |
| 917 std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap()); | 917 std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap()); |
| 918 if (!pBitmap) | 918 if (!pBitmap) |
| 919 return FALSE; | 919 return false; |
| 920 | 920 |
| 921 if (pBitmap->IsAlphaMask()) { | 921 if (pBitmap->IsAlphaMask()) { |
| 922 if (m_BitmapAlpha != 255) | 922 if (m_BitmapAlpha != 255) |
| 923 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); | 923 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); |
| 924 m_Result = m_pRenderStatus->m_pDevice->SetBitMask( | 924 m_Result = m_pRenderStatus->m_pDevice->SetBitMask( |
| 925 pBitmap.get(), m_pTransformer->result().left, | 925 pBitmap.get(), m_pTransformer->result().left, |
| 926 m_pTransformer->result().top, m_FillArgb); | 926 m_pTransformer->result().top, m_FillArgb); |
| 927 } else { | 927 } else { |
| 928 if (m_BitmapAlpha != 255) | 928 if (m_BitmapAlpha != 255) |
| 929 pBitmap->MultiplyAlpha(m_BitmapAlpha); | 929 pBitmap->MultiplyAlpha(m_BitmapAlpha); |
| 930 m_Result = m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( | 930 m_Result = m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( |
| 931 pBitmap.get(), m_pTransformer->result().left, | 931 pBitmap.get(), m_pTransformer->result().left, |
| 932 m_pTransformer->result().top, m_BlendType); | 932 m_pTransformer->result().top, m_BlendType); |
| 933 } | 933 } |
| 934 return FALSE; | 934 return false; |
| 935 } | 935 } |
| 936 if (m_Status == 3) | 936 if (m_Status == 3) |
| 937 return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); | 937 return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); |
| 938 | 938 |
| 939 if (m_Status == 4) { | 939 if (m_Status == 4) { |
| 940 if (m_Loader.Continue(m_LoadHandle.get(), pPause)) | 940 if (m_Loader.Continue(m_LoadHandle.get(), pPause)) |
| 941 return TRUE; | 941 return true; |
| 942 | 942 |
| 943 if (StartRenderDIBSource()) | 943 if (StartRenderDIBSource()) |
| 944 return Continue(pPause); | 944 return Continue(pPause); |
| 945 } | 945 } |
| 946 return FALSE; | 946 return false; |
| 947 } | 947 } |
| 948 | 948 |
| 949 CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( | 949 CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( |
| 950 const uint8_t* src_buf, | 950 const uint8_t* src_buf, |
| 951 uint32_t src_size, | 951 uint32_t src_size, |
| 952 int width, | 952 int width, |
| 953 int height, | 953 int height, |
| 954 int nComps, | 954 int nComps, |
| 955 int bpc, | 955 int bpc, |
| 956 const CPDF_Dictionary* pParams); | 956 const CPDF_Dictionary* pParams); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 971 pFunc = CPDF_Function::Load(pFuncObj); | 971 pFunc = CPDF_Function::Load(pFuncObj); |
| 972 | 972 |
| 973 CFX_Matrix matrix = *pMatrix; | 973 CFX_Matrix matrix = *pMatrix; |
| 974 matrix.TranslateI(-pClipRect->left, -pClipRect->top); | 974 matrix.TranslateI(-pClipRect->left, -pClipRect->top); |
| 975 | 975 |
| 976 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), | 976 CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(), |
| 977 pGroup); | 977 pGroup); |
| 978 form.ParseContent(nullptr, nullptr, nullptr); | 978 form.ParseContent(nullptr, nullptr, nullptr); |
| 979 | 979 |
| 980 CFX_FxgeDevice bitmap_device; | 980 CFX_FxgeDevice bitmap_device; |
| 981 FX_BOOL bLuminosity = pSMaskDict->GetStringFor("S") != "Alpha"; | 981 bool bLuminosity = pSMaskDict->GetStringFor("S") != "Alpha"; |
| 982 int width = pClipRect->right - pClipRect->left; | 982 int width = pClipRect->right - pClipRect->left; |
| 983 int height = pClipRect->bottom - pClipRect->top; | 983 int height = pClipRect->bottom - pClipRect->top; |
| 984 FXDIB_Format format; | 984 FXDIB_Format format; |
| 985 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_ | 985 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_ |
| 986 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; | 986 format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; |
| 987 #else | 987 #else |
| 988 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; | 988 format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; |
| 989 #endif | 989 #endif |
| 990 if (!bitmap_device.Create(width, height, format, nullptr)) | 990 if (!bitmap_device.Create(width, height, format, nullptr)) |
| 991 return nullptr; | 991 return nullptr; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 bitmap.Clear(0); | 1035 bitmap.Clear(0); |
| 1036 } | 1036 } |
| 1037 CPDF_Dictionary* pFormResource = nullptr; | 1037 CPDF_Dictionary* pFormResource = nullptr; |
| 1038 if (form.m_pFormDict) { | 1038 if (form.m_pFormDict) { |
| 1039 pFormResource = form.m_pFormDict->GetDictFor("Resources"); | 1039 pFormResource = form.m_pFormDict->GetDictFor("Resources"); |
| 1040 } | 1040 } |
| 1041 CPDF_RenderOptions options; | 1041 CPDF_RenderOptions options; |
| 1042 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; | 1042 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; |
| 1043 CPDF_RenderStatus status; | 1043 CPDF_RenderStatus status; |
| 1044 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, | 1044 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, |
| 1045 nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE, | 1045 nullptr, &options, 0, m_bDropObjects, pFormResource, true, |
| 1046 nullptr, 0, color_space_family, bLuminosity); | 1046 nullptr, 0, color_space_family, bLuminosity); |
| 1047 status.RenderObjectList(&form, &matrix); | 1047 status.RenderObjectList(&form, &matrix); |
| 1048 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); | 1048 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); |
| 1049 if (!pMask->Create(width, height, FXDIB_8bppMask)) | 1049 if (!pMask->Create(width, height, FXDIB_8bppMask)) |
| 1050 return nullptr; | 1050 return nullptr; |
| 1051 | 1051 |
| 1052 uint8_t* dest_buf = pMask->GetBuffer(); | 1052 uint8_t* dest_buf = pMask->GetBuffer(); |
| 1053 int dest_pitch = pMask->GetPitch(); | 1053 int dest_pitch = pMask->GetPitch(); |
| 1054 uint8_t* src_buf = bitmap.GetBuffer(); | 1054 uint8_t* src_buf = bitmap.GetBuffer(); |
| 1055 int src_pitch = bitmap.GetPitch(); | 1055 int src_pitch = bitmap.GetPitch(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1080 } else if (pFunc) { | 1080 } else if (pFunc) { |
| 1081 int size = dest_pitch * height; | 1081 int size = dest_pitch * height; |
| 1082 for (int i = 0; i < size; i++) { | 1082 for (int i = 0; i < size; i++) { |
| 1083 dest_buf[i] = transfers[src_buf[i]]; | 1083 dest_buf[i] = transfers[src_buf[i]]; |
| 1084 } | 1084 } |
| 1085 } else { | 1085 } else { |
| 1086 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 1086 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 1087 } | 1087 } |
| 1088 return pMask.release(); | 1088 return pMask.release(); |
| 1089 } | 1089 } |
| OLD | NEW |