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

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

Issue 1519693002: Merge to XFA: Remove CFX_AffineMatrix/CPDF_Matrix (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: XFA-specific changes Created 5 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 "render_int.h" 7 #include "render_int.h"
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_pageobj.h" 10 #include "core/include/fpdfapi/fpdf_pageobj.h"
11 #include "core/include/fpdfapi/fpdf_render.h" 11 #include "core/include/fpdfapi/fpdf_render.h"
12 #include "core/include/fxcodec/fx_codec.h" 12 #include "core/include/fxcodec/fx_codec.h"
13 #include "core/include/fxcrt/fx_safe_types.h" 13 #include "core/include/fxcrt/fx_safe_types.h"
14 #include "core/include/fxge/fx_ge.h" 14 #include "core/include/fxge/fx_ge.h"
15 #include "core/src/fpdfapi/fpdf_page/pageint.h" 15 #include "core/src/fpdfapi/fpdf_page/pageint.h"
16 16
17 FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, 17 FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj,
18 const CFX_AffineMatrix* pObj2Device) { 18 const CFX_Matrix* pObj2Device) {
19 CPDF_ImageRenderer render; 19 CPDF_ImageRenderer render;
20 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { 20 if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) {
21 render.Continue(NULL); 21 render.Continue(NULL);
22 } 22 }
23 return render.m_Result; 23 return render.m_Result;
24 } 24 }
25 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, 25 void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
26 int left, 26 int left,
27 int top, 27 int top,
28 FX_ARGB mask_argb, 28 FX_ARGB mask_argb,
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 format == PDFCS_DEVICEN) { 464 format == PDFCS_DEVICEN) {
465 m_BlendType = FXDIB_BLEND_DARKEN; 465 m_BlendType = FXDIB_BLEND_DARKEN;
466 } 466 }
467 pDocument->GetPageData()->ReleaseColorSpace(pCSObj); 467 pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
468 } 468 }
469 } 469 }
470 return StartDIBSource(); 470 return StartDIBSource();
471 } 471 }
472 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, 472 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus,
473 const CPDF_PageObject* pObj, 473 const CPDF_PageObject* pObj,
474 const CFX_AffineMatrix* pObj2Device, 474 const CFX_Matrix* pObj2Device,
475 FX_BOOL bStdCS, 475 FX_BOOL bStdCS,
476 int blendType) { 476 int blendType) {
477 m_pRenderStatus = pStatus; 477 m_pRenderStatus = pStatus;
478 m_bStdCS = bStdCS; 478 m_bStdCS = bStdCS;
479 m_pImageObject = (CPDF_ImageObject*)pObj; 479 m_pImageObject = (CPDF_ImageObject*)pObj;
480 m_BlendType = blendType; 480 m_BlendType = blendType;
481 m_pObj2Device = pObj2Device; 481 m_pObj2Device = pObj2Device;
482 CPDF_Dictionary* pOC = m_pImageObject->m_pImage->GetOC(); 482 CPDF_Dictionary* pOC = m_pImageObject->m_pImage->GetOC();
483 if (pOC && m_pRenderStatus->m_Options.m_pOCContext && 483 if (pOC && m_pRenderStatus->m_Options.m_pOCContext &&
484 !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) { 484 !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) {
485 return FALSE; 485 return FALSE;
486 } 486 }
487 m_ImageMatrix = m_pImageObject->m_Matrix; 487 m_ImageMatrix = m_pImageObject->m_Matrix;
488 m_ImageMatrix.Concat(*pObj2Device); 488 m_ImageMatrix.Concat(*pObj2Device);
489 if (StartLoadDIBSource()) { 489 if (StartLoadDIBSource()) {
490 return TRUE; 490 return TRUE;
491 } 491 }
492 return StartRenderDIBSource(); 492 return StartRenderDIBSource();
493 } 493 }
494 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, 494 FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus,
495 const CFX_DIBSource* pDIBSource, 495 const CFX_DIBSource* pDIBSource,
496 FX_ARGB bitmap_argb, 496 FX_ARGB bitmap_argb,
497 int bitmap_alpha, 497 int bitmap_alpha,
498 const CFX_AffineMatrix* pImage2Device, 498 const CFX_Matrix* pImage2Device,
499 FX_DWORD flags, 499 FX_DWORD flags,
500 FX_BOOL bStdCS, 500 FX_BOOL bStdCS,
501 int blendType) { 501 int blendType) {
502 m_pRenderStatus = pStatus; 502 m_pRenderStatus = pStatus;
503 m_pDIBSource = pDIBSource; 503 m_pDIBSource = pDIBSource;
504 m_FillArgb = bitmap_argb; 504 m_FillArgb = bitmap_argb;
505 m_BitmapAlpha = bitmap_alpha; 505 m_BitmapAlpha = bitmap_alpha;
506 m_ImageMatrix = *pImage2Device; 506 m_ImageMatrix = *pImage2Device;
507 m_Flags = flags; 507 m_Flags = flags;
508 m_bStdCS = bStdCS; 508 m_bStdCS = bStdCS;
509 m_BlendType = blendType; 509 m_BlendType = blendType;
510 return StartDIBSource(); 510 return StartDIBSource();
511 } 511 }
512 FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { 512 FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) {
513 if (m_pRenderStatus->m_bPrint && 513 if (m_pRenderStatus->m_bPrint &&
514 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { 514 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) {
515 m_Result = FALSE; 515 m_Result = FALSE;
516 return FALSE; 516 return FALSE;
517 } 517 }
518 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); 518 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect();
519 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); 519 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox());
520 if (rect.IsEmpty()) { 520 if (rect.IsEmpty()) {
521 return FALSE; 521 return FALSE;
522 } 522 }
523 CFX_AffineMatrix new_matrix = m_ImageMatrix; 523 CFX_Matrix new_matrix = m_ImageMatrix;
524 new_matrix.TranslateI(-rect.left, -rect.top); 524 new_matrix.TranslateI(-rect.left, -rect.top);
525 int width = rect.Width(); 525 int width = rect.Width();
526 int height = rect.Height(); 526 int height = rect.Height();
527 CFX_FxgeDevice bitmap_device1; 527 CFX_FxgeDevice bitmap_device1;
528 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32)) { 528 if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32)) {
529 return TRUE; 529 return TRUE;
530 } 530 }
531 bitmap_device1.GetBitmap()->Clear(0xffffff); 531 bitmap_device1.GetBitmap()->Clear(0xffffff);
532 { 532 {
533 CPDF_RenderStatus bitmap_render; 533 CPDF_RenderStatus bitmap_render;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 if (m_pRenderStatus->m_bPrint && 610 if (m_pRenderStatus->m_bPrint &&
611 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { 611 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) {
612 m_Result = FALSE; 612 m_Result = FALSE;
613 return FALSE; 613 return FALSE;
614 } 614 }
615 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect(); 615 FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect();
616 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); 616 rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox());
617 if (rect.IsEmpty()) { 617 if (rect.IsEmpty()) {
618 return FALSE; 618 return FALSE;
619 } 619 }
620 CFX_AffineMatrix new_matrix = m_ImageMatrix; 620 CFX_Matrix new_matrix = m_ImageMatrix;
621 new_matrix.TranslateI(-rect.left, -rect.top); 621 new_matrix.TranslateI(-rect.left, -rect.top);
622 int width = rect.Width(); 622 int width = rect.Width();
623 int height = rect.Height(); 623 int height = rect.Height();
624 CFX_FxgeDevice bitmap_device1; 624 CFX_FxgeDevice bitmap_device1;
625 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32)) { 625 if (!bitmap_device1.Create(width, height, FXDIB_Rgb32)) {
626 return TRUE; 626 return TRUE;
627 } 627 }
628 bitmap_device1.GetBitmap()->Clear(0xffffff); 628 bitmap_device1.GetBitmap()->Clear(0xffffff);
629 { 629 {
630 CPDF_RenderStatus bitmap_render; 630 CPDF_RenderStatus bitmap_render;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } 894 }
895 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( 895 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
896 const uint8_t* src_buf, 896 const uint8_t* src_buf,
897 FX_DWORD src_size, 897 FX_DWORD src_size,
898 int width, 898 int width,
899 int height, 899 int height,
900 int nComps, 900 int nComps,
901 int bpc, 901 int bpc,
902 const CPDF_Dictionary* pParams); 902 const CPDF_Dictionary* pParams);
903 FX_BOOL CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj, 903 FX_BOOL CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj,
904 CFX_AffineMatrix* pImage2Device, 904 CFX_Matrix* pImage2Device,
905 const FX_RECT* pClipBox) { 905 const FX_RECT* pClipBox) {
906 if (FXSYS_fabs(pImage2Device->a) < FXSYS_fabs(pImage2Device->b) * 10 && 906 if (FXSYS_fabs(pImage2Device->a) < FXSYS_fabs(pImage2Device->b) * 10 &&
907 FXSYS_fabs(pImage2Device->d) < FXSYS_fabs(pImage2Device->c) * 10) { 907 FXSYS_fabs(pImage2Device->d) < FXSYS_fabs(pImage2Device->c) * 10) {
908 return FALSE; 908 return FALSE;
909 } 909 }
910 CFX_FloatRect image_rect_f = pImage2Device->GetUnitRect(); 910 CFX_FloatRect image_rect_f = pImage2Device->GetUnitRect();
911 FX_RECT image_rect = image_rect_f.GetOutterRect(); 911 FX_RECT image_rect = image_rect_f.GetOutterRect();
912 m_DestWidth = image_rect.Width(); 912 m_DestWidth = image_rect.Width();
913 m_DestHeight = image_rect.Height(); 913 m_DestHeight = image_rect.Height();
914 m_bFlipX = pImage2Device->a < 0; 914 m_bFlipX = pImage2Device->a < 0;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 } 1035 }
1036 m_LineIndex++; 1036 m_LineIndex++;
1037 if (pPause && pPause->NeedToPauseNow()) { 1037 if (pPause && pPause->NeedToPauseNow()) {
1038 return TRUE; 1038 return TRUE;
1039 } 1039 }
1040 } 1040 }
1041 return FALSE; 1041 return FALSE;
1042 } 1042 }
1043 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, 1043 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
1044 FX_RECT* pClipRect, 1044 FX_RECT* pClipRect,
1045 const CFX_AffineMatrix* pMatrix) { 1045 const CFX_Matrix* pMatrix) {
1046 if (pSMaskDict == NULL) { 1046 if (pSMaskDict == NULL) {
1047 return NULL; 1047 return NULL;
1048 } 1048 }
1049 int width = pClipRect->right - pClipRect->left; 1049 int width = pClipRect->right - pClipRect->left;
1050 int height = pClipRect->bottom - pClipRect->top; 1050 int height = pClipRect->bottom - pClipRect->top;
1051 FX_BOOL bLuminosity = FALSE; 1051 FX_BOOL bLuminosity = FALSE;
1052 bLuminosity = pSMaskDict->GetConstString(FX_BSTRC("S")) != FX_BSTRC("Alpha"); 1052 bLuminosity = pSMaskDict->GetConstString(FX_BSTRC("S")) != FX_BSTRC("Alpha");
1053 CPDF_Stream* pGroup = pSMaskDict->GetStream(FX_BSTRC("G")); 1053 CPDF_Stream* pGroup = pSMaskDict->GetStream(FX_BSTRC("G"));
1054 if (pGroup == NULL) { 1054 if (pGroup == NULL) {
1055 return NULL; 1055 return NULL;
1056 } 1056 }
1057 nonstd::unique_ptr<CPDF_Function> pFunc; 1057 nonstd::unique_ptr<CPDF_Function> pFunc;
1058 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue(FX_BSTRC("TR")); 1058 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue(FX_BSTRC("TR"));
1059 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) 1059 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream()))
1060 pFunc.reset(CPDF_Function::Load(pFuncObj)); 1060 pFunc.reset(CPDF_Function::Load(pFuncObj));
1061 1061
1062 CFX_AffineMatrix matrix = *pMatrix; 1062 CFX_Matrix matrix = *pMatrix;
1063 matrix.TranslateI(-pClipRect->left, -pClipRect->top); 1063 matrix.TranslateI(-pClipRect->left, -pClipRect->top);
1064 CPDF_Form form(m_pContext->m_pDocument, m_pContext->m_pPageResources, pGroup); 1064 CPDF_Form form(m_pContext->m_pDocument, m_pContext->m_pPageResources, pGroup);
1065 form.ParseContent(NULL, NULL, NULL, NULL); 1065 form.ParseContent(NULL, NULL, NULL, NULL);
1066 CFX_FxgeDevice bitmap_device; 1066 CFX_FxgeDevice bitmap_device;
1067 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1067 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1068 if (!bitmap_device.Create(width, height, 1068 if (!bitmap_device.Create(width, height,
1069 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { 1069 bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) {
1070 return NULL; 1070 return NULL;
1071 } 1071 }
1072 #else 1072 #else
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 } else if (pFunc) { 1163 } else if (pFunc) {
1164 int size = dest_pitch * height; 1164 int size = dest_pitch * height;
1165 for (int i = 0; i < size; i++) { 1165 for (int i = 0; i < size; i++) {
1166 dest_buf[i] = transfers[src_buf[i]]; 1166 dest_buf[i] = transfers[src_buf[i]];
1167 } 1167 }
1168 } else { 1168 } else {
1169 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 1169 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
1170 } 1170 }
1171 return pMask.release(); 1171 return pMask.release();
1172 } 1172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698