Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(897)

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp

Issue 801913002: Simplify PDFium by removing code that's not used in the open source repo. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #include "../../../include/fxcodec/fx_codec.h" 8 #include "../../../include/fxcodec/fx_codec.h"
9 #include "../../../include/fpdfapi/fpdf_module.h" 9 #include "../../../include/fpdfapi/fpdf_module.h"
10 #include "../../../include/fpdfapi/fpdf_render.h" 10 #include "../../../include/fpdfapi/fpdf_render.h"
11 #include "../../../include/fpdfapi/fpdf_pageobj.h" 11 #include "../../../include/fpdfapi/fpdf_pageobj.h"
12 #include "../fpdf_page/pageint.h" 12 #include "../fpdf_page/pageint.h"
13 #include "render_int.h" 13 #include "render_int.h"
14 FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, const CFX_A ffineMatrix* pObj2Device) 14 FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, const CFX_A ffineMatrix* pObj2Device)
15 { 15 {
16 CPDF_ImageRenderer render; 16 CPDF_ImageRenderer render;
17 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { 17 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) {
18 render.Continue(NULL); 18 render.Continue(NULL);
19 } 19 }
20 #ifdef _FPDFAPI_MINI_
21 if (m_DitherBits) {
22 DitherObjectArea(pImageObj, pObj2Device);
23 }
24 #endif
25 return render.m_Result; 20 return render.m_Result;
26 } 21 }
27 #if defined(_FPDFAPI_MINI_)
28 FX_BOOL CPDF_RenderStatus::ProcessInlines(CPDF_InlineImages* pInlines, const CFX _AffineMatrix* pObj2Device)
29 {
30 int bitmap_alpha = 255;
31 if (!pInlines->m_GeneralState.IsNull()) {
32 bitmap_alpha = FXSYS_round(pInlines->m_GeneralState.GetObject()->m_FillA lpha * 255);
33 }
34 if (pInlines->m_pStream) {
35 CPDF_DIBSource dibsrc;
36 if (!dibsrc.Load(m_pContext->m_pDocument, pInlines->m_pStream, NULL, NUL L, NULL, NULL)) {
37 return TRUE;
38 }
39 pInlines->m_pBitmap = dibsrc.Clone();
40 pInlines->m_pStream->Release();
41 pInlines->m_pStream = NULL;
42 }
43 if (pInlines->m_pBitmap == NULL) {
44 return TRUE;
45 }
46 FX_ARGB fill_argb = 0;
47 if (pInlines->m_pBitmap->IsAlphaMask()) {
48 fill_argb = GetFillArgb(pInlines);
49 }
50 int flags = 0;
51 if (m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) {
52 flags |= RENDER_FORCE_DOWNSAMPLE;
53 } else if (m_Options.m_Flags & RENDER_FORCE_HALFTONE) {
54 flags = 0;
55 }
56 for (int i = 0; i < pInlines->m_Matrices.GetSize(); i ++) {
57 CFX_AffineMatrix image_matrix = pInlines->m_Matrices.GetAt(i);
58 image_matrix.Concat(*pObj2Device);
59 CPDF_ImageRenderer renderer;
60 if (renderer.Start(this, pInlines->m_pBitmap, fill_argb, bitmap_alpha, & image_matrix, flags, FALSE, m_curBlend)) {
61 renderer.Continue(NULL);
62 }
63 }
64 return TRUE;
65 }
66 #endif
67 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, int left, int top, FX_ARGB mask_argb, 22 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, int left, int top, FX_ARGB mask_argb,
68 int bitmap_alpha, int blend_mode, int Transparency) 23 int bitmap_alpha, int blend_mode, int Transparency)
69 { 24 {
70 if (pDIBitmap == NULL) { 25 if (pDIBitmap == NULL) {
71 return; 26 return;
72 } 27 }
73 FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED; 28 FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED;
74 FX_BOOL bGroup = Transparency & PDFTRANS_GROUP; 29 FX_BOOL bGroup = Transparency & PDFTRANS_GROUP;
75 if (blend_mode == FXDIB_BLEND_NORMAL) { 30 if (blend_mode == FXDIB_BLEND_NORMAL) {
76 if (!pDIBitmap->IsAlphaMask()) { 31 if (!pDIBitmap->IsAlphaMask()) {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 340 }
386 m_BitmapAlpha = 255; 341 m_BitmapAlpha = 255;
387 const CPDF_GeneralStateData* pGeneralState = m_pImageObject->m_GeneralState; 342 const CPDF_GeneralStateData* pGeneralState = m_pImageObject->m_GeneralState;
388 if (pGeneralState) { 343 if (pGeneralState) {
389 m_BitmapAlpha = FXSYS_round(pGeneralState->m_FillAlpha * 255); 344 m_BitmapAlpha = FXSYS_round(pGeneralState->m_FillAlpha * 255);
390 } 345 }
391 m_pDIBSource = m_Loader.m_pBitmap; 346 m_pDIBSource = m_Loader.m_pBitmap;
392 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && m_Loader .m_pMask == NULL) { 347 if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && m_Loader .m_pMask == NULL) {
393 return StartBitmapAlpha(); 348 return StartBitmapAlpha();
394 } 349 }
395 #ifndef _FPDFAPI_MINI_
396 if (pGeneralState && pGeneralState->m_pTR) { 350 if (pGeneralState && pGeneralState->m_pTR) {
397 if (!pGeneralState->m_pTransferFunc) { 351 if (!pGeneralState->m_pTransferFunc) {
398 ((CPDF_GeneralStateData*)pGeneralState)->m_pTransferFunc = m_pRender Status->GetTransferFunc(pGeneralState->m_pTR); 352 ((CPDF_GeneralStateData*)pGeneralState)->m_pTransferFunc = m_pRender Status->GetTransferFunc(pGeneralState->m_pTR);
399 } 353 }
400 if (pGeneralState->m_pTransferFunc && !pGeneralState->m_pTransferFunc->m _bIdentity) { 354 if (pGeneralState->m_pTransferFunc && !pGeneralState->m_pTransferFunc->m _bIdentity) {
401 m_pDIBSource = m_Loader.m_pBitmap = pGeneralState->m_pTransferFunc-> TranslateImage(m_Loader.m_pBitmap, !m_Loader.m_bCached); 355 m_pDIBSource = m_Loader.m_pBitmap = pGeneralState->m_pTransferFunc-> TranslateImage(m_Loader.m_pBitmap, !m_Loader.m_bCached);
402 if (m_Loader.m_bCached && m_Loader.m_pMask) { 356 if (m_Loader.m_bCached && m_Loader.m_pMask) {
403 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); 357 m_Loader.m_pMask = m_Loader.m_pMask->Clone();
404 } 358 }
405 m_Loader.m_bCached = FALSE; 359 m_Loader.m_bCached = FALSE;
406 } 360 }
407 } 361 }
408 #endif
409 m_FillArgb = 0; 362 m_FillArgb = 0;
410 m_bPatternColor = FALSE; 363 m_bPatternColor = FALSE;
411 m_pPattern = NULL; 364 m_pPattern = NULL;
412 if (m_pDIBSource->IsAlphaMask()) { 365 if (m_pDIBSource->IsAlphaMask()) {
413 CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); 366 CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor();
414 if (pColor && pColor->IsPattern()) { 367 if (pColor && pColor->IsPattern()) {
415 m_pPattern = pColor->GetPattern(); 368 m_pPattern = pColor->GetPattern();
416 if (m_pPattern != NULL) { 369 if (m_pPattern != NULL) {
417 m_bPatternColor = TRUE; 370 m_bPatternColor = TRUE;
418 } 371 }
419 } 372 }
420 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); 373 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject);
421 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { 374 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
422 m_pClone = m_pDIBSource->Clone(); 375 m_pClone = m_pDIBSource->Clone();
423 m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor, m_pR enderStatus->m_Options.m_ForeColor); 376 m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor, m_pR enderStatus->m_Options.m_ForeColor);
424 m_pDIBSource = m_pClone; 377 m_pDIBSource = m_pClone;
425 } 378 }
426 m_Flags = 0; 379 m_Flags = 0;
427 #if !defined(_FPDFAPI_MINI_)
428 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { 380 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) {
429 m_Flags |= RENDER_FORCE_DOWNSAMPLE; 381 m_Flags |= RENDER_FORCE_DOWNSAMPLE;
430 } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) { 382 } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) {
431 m_Flags |= RENDER_FORCE_HALFTONE; 383 m_Flags |= RENDER_FORCE_HALFTONE;
432 } 384 }
433 #else
434 if (!(m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE)) {
435 if (m_pRenderStatus->m_HalftoneLimit) {
436 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
437 FX_RECT image_rect = image_rect_f.GetOutterRect();
438 FX_RECT image_clip = image_rect;
439 image_rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox());
440 if (image_rect.Width() && image_rect.Height()) {
441 if ((image_clip.Width() * m_pDIBSource->GetWidth() / image_rect. Width()) *
442 (image_clip.Height() * m_pDIBSource->GetHeight() / image _rect.Height()) >
443 m_pRenderStatus->m_HalftoneLimit) {
444 m_Flags |= RENDER_FORCE_DOWNSAMPLE;
445 }
446 }
447 } else {
448 m_Flags |= RENDER_FORCE_DOWNSAMPLE;
449 }
450 }
451 #endif
452 #ifndef _FPDFAPI_MINI_
453 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { 385 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) {
454 CPDF_Object* pFilters = m_pImageObject->m_pImage->GetStream()->GetDict() ->GetElementValue(FX_BSTRC("Filter")); 386 CPDF_Object* pFilters = m_pImageObject->m_pImage->GetStream()->GetDict() ->GetElementValue(FX_BSTRC("Filter"));
455 if (pFilters) { 387 if (pFilters) {
456 if (pFilters->GetType() == PDFOBJ_NAME) { 388 if (pFilters->GetType() == PDFOBJ_NAME) {
457 CFX_ByteStringC bsDecodeType = pFilters->GetConstString(); 389 CFX_ByteStringC bsDecodeType = pFilters->GetConstString();
458 if (bsDecodeType == FX_BSTRC("DCTDecode") || bsDecodeType == FX_ BSTRC("JPXDecode")) { 390 if (bsDecodeType == FX_BSTRC("DCTDecode") || bsDecodeType == FX_ BSTRC("JPXDecode")) {
459 m_Flags |= FXRENDER_IMAGE_LOSSY; 391 m_Flags |= FXRENDER_IMAGE_LOSSY;
460 } 392 }
461 } else if (pFilters->GetType() == PDFOBJ_ARRAY) { 393 } else if (pFilters->GetType() == PDFOBJ_ARRAY) {
462 CPDF_Array* pArray = (CPDF_Array*)pFilters; 394 CPDF_Array* pArray = (CPDF_Array*)pFilters;
463 for (FX_DWORD i = 0; i < pArray->GetCount(); i ++) { 395 for (FX_DWORD i = 0; i < pArray->GetCount(); i ++) {
464 CFX_ByteStringC bsDecodeType = pArray->GetConstString(i); 396 CFX_ByteStringC bsDecodeType = pArray->GetConstString(i);
465 if (bsDecodeType == FX_BSTRC("DCTDecode") || bsDecodeType == FX_BSTRC("JPXDecode")) { 397 if (bsDecodeType == FX_BSTRC("DCTDecode") || bsDecodeType == FX_BSTRC("JPXDecode")) {
466 m_Flags |= FXRENDER_IMAGE_LOSSY; 398 m_Flags |= FXRENDER_IMAGE_LOSSY;
467 break; 399 break;
468 } 400 }
469 } 401 }
470 } 402 }
471 } 403 }
472 } 404 }
473 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) { 405 if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) {
474 m_Flags |= FXDIB_NOSMOOTH; 406 m_Flags |= FXDIB_NOSMOOTH;
475 } else if (m_pImageObject->m_pImage->IsInterpol()) { 407 } else if (m_pImageObject->m_pImage->IsInterpol()) {
476 m_Flags |= FXDIB_INTERPOL; 408 m_Flags |= FXDIB_INTERPOL;
477 } 409 }
478 #endif
479 if (m_Loader.m_pMask) { 410 if (m_Loader.m_pMask) {
480 return DrawMaskedImage(); 411 return DrawMaskedImage();
481 } 412 }
482 if (m_bPatternColor) { 413 if (m_bPatternColor) {
483 return DrawPatternImage(m_pObj2Device); 414 return DrawPatternImage(m_pObj2Device);
484 } 415 }
485 #if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_)
486 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP && 416 if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP &&
487 pGeneralState->m_OPMode == 0 && pGeneralState->m_BlendType == FXDIB_ BLEND_NORMAL && pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { 417 pGeneralState->m_OPMode == 0 && pGeneralState->m_BlendType == FXDIB_ BLEND_NORMAL && pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) {
488 CPDF_Document* pDocument = NULL; 418 CPDF_Document* pDocument = NULL;
489 CPDF_Page* pPage = NULL; 419 CPDF_Page* pPage = NULL;
490 if (m_pRenderStatus->m_pContext->m_pPageCache) { 420 if (m_pRenderStatus->m_pContext->m_pPageCache) {
491 pPage = m_pRenderStatus->m_pContext->m_pPageCache->GetPage(); 421 pPage = m_pRenderStatus->m_pContext->m_pPageCache->GetPage();
492 pDocument = pPage->m_pDocument; 422 pDocument = pPage->m_pDocument;
493 } else { 423 } else {
494 pDocument = m_pImageObject->m_pImage->GetDocument(); 424 pDocument = m_pImageObject->m_pImage->GetDocument();
495 } 425 }
496 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL ; 426 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL ;
497 CPDF_Object* pCSObj = m_pImageObject->m_pImage->GetStream()->GetDict()-> GetElementValue(FX_BSTRC("ColorSpace")); 427 CPDF_Object* pCSObj = m_pImageObject->m_pImage->GetStream()->GetDict()-> GetElementValue(FX_BSTRC("ColorSpace"));
498 CPDF_ColorSpace* pColorSpace = pDocument->LoadColorSpace(pCSObj, pPageRe sources); 428 CPDF_ColorSpace* pColorSpace = pDocument->LoadColorSpace(pCSObj, pPageRe sources);
499 if (pColorSpace) { 429 if (pColorSpace) {
500 int format = pColorSpace->GetFamily(); 430 int format = pColorSpace->GetFamily();
501 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || form at == PDFCS_DEVICEN) { 431 if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || form at == PDFCS_DEVICEN) {
502 m_BlendType = FXDIB_BLEND_DARKEN; 432 m_BlendType = FXDIB_BLEND_DARKEN;
503 } 433 }
504 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); 434 pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
505 } 435 }
506 } 436 }
507 #endif
508 return StartDIBSource(); 437 return StartDIBSource();
509 } 438 }
510 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CPDF_PageObj ect* pObj, const CFX_AffineMatrix* pObj2Device, FX_BOOL bStdCS, int blendType) 439 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CPDF_PageObj ect* pObj, const CFX_AffineMatrix* pObj2Device, FX_BOOL bStdCS, int blendType)
511 { 440 {
512 m_pRenderStatus = pStatus; 441 m_pRenderStatus = pStatus;
513 m_bStdCS = bStdCS; 442 m_bStdCS = bStdCS;
514 m_pImageObject = (CPDF_ImageObject*)pObj; 443 m_pImageObject = (CPDF_ImageObject*)pObj;
515 m_BlendType = blendType; 444 m_BlendType = blendType;
516 m_pObj2Device = pObj2Device; 445 m_pObj2Device = pObj2Device;
517 #ifndef _FPDFAPI_MINI_
518 CPDF_Dictionary* pOC = m_pImageObject->m_pImage->GetOC(); 446 CPDF_Dictionary* pOC = m_pImageObject->m_pImage->GetOC();
519 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && !m_pRenderStatus->m_Op tions.m_pOCContext->CheckOCGVisible(pOC)) { 447 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && !m_pRenderStatus->m_Op tions.m_pOCContext->CheckOCGVisible(pOC)) {
520 return FALSE; 448 return FALSE;
521 } 449 }
522 #endif
523 m_ImageMatrix = m_pImageObject->m_Matrix; 450 m_ImageMatrix = m_pImageObject->m_Matrix;
524 m_ImageMatrix.Concat(*pObj2Device); 451 m_ImageMatrix.Concat(*pObj2Device);
525 if (StartLoadDIBSource()) { 452 if (StartLoadDIBSource()) {
526 return TRUE; 453 return TRUE;
527 } 454 }
528 return StartRenderDIBSource(); 455 return StartRenderDIBSource();
529 } 456 }
530 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CFX_DIBSourc e* pDIBSource, FX_ARGB bitmap_argb, 457 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CFX_DIBSourc e* pDIBSource, FX_ARGB bitmap_argb,
531 int bitmap_alpha, const CFX_AffineMatrix* pIma ge2Device, FX_DWORD flags, FX_BOOL bStdCS, int blendType) 458 int bitmap_alpha, const CFX_AffineMatrix* pIma ge2Device, FX_DWORD flags, FX_BOOL bStdCS, int blendType)
532 { 459 {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap()); 641 bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap());
715 if (m_BitmapAlpha < 255) { 642 if (m_BitmapAlpha < 255) {
716 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha); 643 bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha);
717 } 644 }
718 } 645 }
719 m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); 646 m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType);
720 return FALSE; 647 return FALSE;
721 } 648 }
722 FX_BOOL CPDF_ImageRenderer::StartDIBSource() 649 FX_BOOL CPDF_ImageRenderer::StartDIBSource()
723 { 650 {
724 #if !defined(_FPDFAPI_MINI_)
725 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { 651 if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) {
726 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * m_pDIBSource->GetHeight(); 652 int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * m_pDIBSource->GetHeight();
727 if (image_size > FPDF_HUGE_IMAGE_SIZE && !(m_Flags & RENDER_FORCE_HALFTO NE)) { 653 if (image_size > FPDF_HUGE_IMAGE_SIZE && !(m_Flags & RENDER_FORCE_HALFTO NE)) {
728 m_Flags |= RENDER_FORCE_DOWNSAMPLE; 654 m_Flags |= RENDER_FORCE_DOWNSAMPLE;
729 } 655 }
730 } 656 }
731 #endif
732 if (m_pRenderStatus->m_pDevice->StartDIBits(m_pDIBSource, m_BitmapAlpha, m_F illArgb, 657 if (m_pRenderStatus->m_pDevice->StartDIBits(m_pDIBSource, m_BitmapAlpha, m_F illArgb,
733 &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL, m_BlendType)) { 658 &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL, m_BlendType)) {
734 if (m_DeviceHandle != NULL) { 659 if (m_DeviceHandle != NULL) {
735 m_Status = 3; 660 m_Status = 3;
736 return TRUE; 661 return TRUE;
737 } 662 }
738 return FALSE; 663 return FALSE;
739 } 664 }
740 #if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_)
741 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); 665 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
742 FX_RECT image_rect = image_rect_f.GetOutterRect(); 666 FX_RECT image_rect = image_rect_f.GetOutterRect();
743 int dest_width = image_rect.Width(); 667 int dest_width = image_rect.Width();
744 int dest_height = image_rect.Height(); 668 int dest_height = image_rect.Height();
745 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || 669 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) ||
746 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0) ) { 670 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0) ) {
747 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRender Caps() & FXRC_BLEND_MODE)) { 671 if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRender Caps() & FXRC_BLEND_MODE)) {
748 m_Result = FALSE; 672 m_Result = FALSE;
749 return FALSE; 673 return FALSE;
750 } 674 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 dest_rect.Intersect(image_rect); 711 dest_rect.Intersect(image_rect);
788 FX_RECT dest_clip(dest_rect.left - image_rect.left, dest_rect.top - image_re ct.top, 712 FX_RECT dest_clip(dest_rect.left - image_rect.left, dest_rect.top - image_re ct.top,
789 dest_rect.right - image_rect.left, dest_rect.bottom - imag e_rect.top); 713 dest_rect.right - image_rect.left, dest_rect.bottom - imag e_rect.top);
790 CFX_DIBitmap* pStretched = m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip); 714 CFX_DIBitmap* pStretched = m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip);
791 if (pStretched) { 715 if (pStretched) {
792 m_pRenderStatus->CompositeDIBitmap(pStretched, dest_rect.left, dest_rect .top, m_FillArgb, 716 m_pRenderStatus->CompositeDIBitmap(pStretched, dest_rect.left, dest_rect .top, m_FillArgb,
793 m_BitmapAlpha, m_BlendType, FALSE); 717 m_BitmapAlpha, m_BlendType, FALSE);
794 delete pStretched; 718 delete pStretched;
795 pStretched = NULL; 719 pStretched = NULL;
796 } 720 }
797 #endif
798 return FALSE; 721 return FALSE;
799 } 722 }
800 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() 723 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha()
801 { 724 {
802 #ifndef _FPDFAPI_MINI_
803 if (m_pDIBSource->IsOpaqueImage()) { 725 if (m_pDIBSource->IsOpaqueImage()) {
804 CFX_PathData path; 726 CFX_PathData path;
805 path.AppendRect(0, 0, 1, 1); 727 path.AppendRect(0, 0, 1, 1);
806 path.Transform(&m_ImageMatrix); 728 path.Transform(&m_ImageMatrix);
807 FX_DWORD fill_color = ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_B itmapAlpha); 729 FX_DWORD fill_color = ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_B itmapAlpha);
808 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, F XFILL_WINDING); 730 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, F XFILL_WINDING);
809 } else { 731 } else {
810 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() ? m_pDIBSo urce : m_pDIBSource->GetAlphaMask(); 732 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() ? m_pDIBSo urce : m_pDIBSource->GetAlphaMask();
811 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || FXSYS_fabs(m_ImageMatrix.c) > = 0.5f) { 733 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || FXSYS_fabs(m_ImageMatrix.c) > = 0.5f) {
812 int left, top; 734 int left, top;
(...skipping 10 matching lines...) Expand all
823 int dest_height = m_ImageMatrix.d > 0 ? -image_rect.Height() : image _rect.Height(); 745 int dest_height = m_ImageMatrix.d > 0 ? -image_rect.Height() : image _rect.Height();
824 int left = dest_width > 0 ? image_rect.left : image_rect.right; 746 int left = dest_width > 0 ? image_rect.left : image_rect.right;
825 int top = dest_height > 0 ? image_rect.top : image_rect.bottom; 747 int top = dest_height > 0 ? image_rect.top : image_rect.bottom;
826 m_pRenderStatus->m_pDevice->StretchBitMask(pAlphaMask, left, top, de st_width, dest_height, 748 m_pRenderStatus->m_pDevice->StretchBitMask(pAlphaMask, left, top, de st_width, dest_height,
827 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha )); 749 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha ));
828 } 750 }
829 if (m_pDIBSource != pAlphaMask) { 751 if (m_pDIBSource != pAlphaMask) {
830 delete pAlphaMask; 752 delete pAlphaMask;
831 } 753 }
832 } 754 }
833 #endif
834 return FALSE; 755 return FALSE;
835 } 756 }
836 FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) 757 FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause)
837 { 758 {
838 if (m_Status == 1) { 759 if (m_Status == 1) {
839 #ifndef _FPDFAPI_MINI_
840 if (m_pQuickStretcher->Continue(pPause)) { 760 if (m_pQuickStretcher->Continue(pPause)) {
841 return TRUE; 761 return TRUE;
842 } 762 }
843 if (m_pQuickStretcher->m_pBitmap->IsAlphaMask()) 763 if (m_pQuickStretcher->m_pBitmap->IsAlphaMask())
844 m_pRenderStatus->m_pDevice->SetBitMask(m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft, 764 m_pRenderStatus->m_pDevice->SetBitMask(m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft,
845 m_pQuickStretcher->m_ResultTo p, m_FillArgb); 765 m_pQuickStretcher->m_ResultTo p, m_FillArgb);
846 else 766 else
847 m_pRenderStatus->m_pDevice->SetDIBits(m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft, 767 m_pRenderStatus->m_pDevice->SetDIBits(m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft,
848 m_pQuickStretcher->m_ResultTop , m_BlendType); 768 m_pQuickStretcher->m_ResultTop , m_BlendType);
849 return FALSE; 769 return FALSE;
850 #endif
851 } else if (m_Status == 2) { 770 } else if (m_Status == 2) {
852 #if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_)
853 if (m_pTransformer->Continue(pPause)) { 771 if (m_pTransformer->Continue(pPause)) {
854 return TRUE; 772 return TRUE;
855 } 773 }
856 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); 774 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
857 if (pBitmap == NULL) { 775 if (pBitmap == NULL) {
858 return FALSE; 776 return FALSE;
859 } 777 }
860 if (pBitmap->IsAlphaMask()) { 778 if (pBitmap->IsAlphaMask()) {
861 if (m_BitmapAlpha != 255) { 779 if (m_BitmapAlpha != 255) {
862 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); 780 m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
863 } 781 }
864 m_Result = m_pRenderStatus->m_pDevice->SetBitMask(pBitmap, 782 m_Result = m_pRenderStatus->m_pDevice->SetBitMask(pBitmap,
865 m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop , m_FillArgb); 783 m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop , m_FillArgb);
866 } else { 784 } else {
867 if (m_BitmapAlpha != 255) { 785 if (m_BitmapAlpha != 255) {
868 pBitmap->MultiplyAlpha(m_BitmapAlpha); 786 pBitmap->MultiplyAlpha(m_BitmapAlpha);
869 } 787 }
870 m_Result = m_pRenderStatus->m_pDevice->SetDIBits(pBitmap, 788 m_Result = m_pRenderStatus->m_pDevice->SetDIBits(pBitmap,
871 m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop , m_BlendType); 789 m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop , m_BlendType);
872 } 790 }
873 delete pBitmap; 791 delete pBitmap;
874 return FALSE; 792 return FALSE;
875 #endif
876 } else if (m_Status == 3) { 793 } else if (m_Status == 3) {
877 return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause ); 794 return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause );
878 } else if (m_Status == 4) { 795 } else if (m_Status == 4) {
879 if (m_Loader.Continue(m_LoadHandle, pPause)) { 796 if (m_Loader.Continue(m_LoadHandle, pPause)) {
880 return TRUE; 797 return TRUE;
881 } 798 }
882 if (StartRenderDIBSource()) { 799 if (StartRenderDIBSource()) {
883 return Continue(pPause); 800 return Continue(pPause);
884 } 801 }
885 return FALSE; 802 return FALSE;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 } 1077 }
1161 } else { 1078 } else {
1162 FXSYS_memcpy32(dest_buf, src_buf, dest_pitch * height); 1079 FXSYS_memcpy32(dest_buf, src_buf, dest_pitch * height);
1163 } 1080 }
1164 if (pFunc) { 1081 if (pFunc) {
1165 delete pFunc; 1082 delete pFunc;
1166 } 1083 }
1167 FX_Free(pTransfer); 1084 FX_Free(pTransfer);
1168 return pMask; 1085 return pMask;
1169 } 1086 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698