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

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

Issue 1545183002: Merge to XFA: Switch from nonstd::unique_ptr to std::unique_ptr. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: xfa Created 4 years, 12 months 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 <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 if (bClone) { 101 if (bClone) {
102 delete pClone; 102 delete pClone;
103 } 103 }
104 } 104 }
105 return; 105 return;
106 } 106 }
107 int back_left, back_top; 107 int back_left, back_top;
108 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), 108 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(),
109 top + pDIBitmap->GetHeight()); 109 top + pDIBitmap->GetHeight());
110 nonstd::unique_ptr<CFX_DIBitmap> pBackdrop( 110 std::unique_ptr<CFX_DIBitmap> pBackdrop(
111 GetBackdrop(m_pCurObj, rect, back_left, back_top, 111 GetBackdrop(m_pCurObj, rect, back_left, back_top,
112 blend_mode > FXDIB_BLEND_NORMAL && bIsolated)); 112 blend_mode > FXDIB_BLEND_NORMAL && bIsolated));
113 if (!pBackdrop) 113 if (!pBackdrop)
114 return; 114 return;
115 115
116 if (!pDIBitmap->IsAlphaMask()) { 116 if (!pDIBitmap->IsAlphaMask()) {
117 pBackdrop->CompositeBitmap(left - back_left, top - back_top, 117 pBackdrop->CompositeBitmap(left - back_left, top - back_top,
118 pDIBitmap->GetWidth(), pDIBitmap->GetHeight(), 118 pDIBitmap->GetWidth(), pDIBitmap->GetHeight(),
119 pDIBitmap, 0, 0, blend_mode); 119 pDIBitmap, 0, 0, blend_mode);
120 } else { 120 } else {
121 pBackdrop->CompositeMask(left - back_left, top - back_top, 121 pBackdrop->CompositeMask(left - back_left, top - back_top,
122 pDIBitmap->GetWidth(), pDIBitmap->GetHeight(), 122 pDIBitmap->GetWidth(), pDIBitmap->GetHeight(),
123 pDIBitmap, mask_argb, 0, 0, blend_mode); 123 pDIBitmap, mask_argb, 0, 0, blend_mode);
124 } 124 }
125 125
126 nonstd::unique_ptr<CFX_DIBitmap> pBackdrop1(new CFX_DIBitmap); 126 std::unique_ptr<CFX_DIBitmap> pBackdrop1(new CFX_DIBitmap);
127 pBackdrop1->Create(pBackdrop->GetWidth(), pBackdrop->GetHeight(), 127 pBackdrop1->Create(pBackdrop->GetWidth(), pBackdrop->GetHeight(),
128 FXDIB_Rgb32); 128 FXDIB_Rgb32);
129 pBackdrop1->Clear((FX_DWORD)-1); 129 pBackdrop1->Clear((FX_DWORD)-1);
130 pBackdrop1->CompositeBitmap(0, 0, pBackdrop->GetWidth(), 130 pBackdrop1->CompositeBitmap(0, 0, pBackdrop->GetWidth(),
131 pBackdrop->GetHeight(), pBackdrop.get(), 0, 0); 131 pBackdrop->GetHeight(), pBackdrop.get(), 0, 0);
132 pBackdrop = std::move(pBackdrop1); 132 pBackdrop = std::move(pBackdrop1);
133 m_pDevice->SetDIBits(pBackdrop.get(), back_left, back_top); 133 m_pDevice->SetDIBits(pBackdrop.get(), back_left, back_top);
134 } 134 }
135 135
136 CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {} 136 CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {}
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { 753 !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) {
754 m_Result = FALSE; 754 m_Result = FALSE;
755 return TRUE; 755 return TRUE;
756 } 756 }
757 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); 757 FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox();
758 FX_RECT dest_rect = clip_box; 758 FX_RECT dest_rect = clip_box;
759 dest_rect.Intersect(image_rect); 759 dest_rect.Intersect(image_rect);
760 FX_RECT dest_clip( 760 FX_RECT dest_clip(
761 dest_rect.left - image_rect.left, dest_rect.top - image_rect.top, 761 dest_rect.left - image_rect.left, dest_rect.top - image_rect.top,
762 dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top); 762 dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top);
763 nonstd::unique_ptr<CFX_DIBitmap> pStretched( 763 std::unique_ptr<CFX_DIBitmap> pStretched(
764 m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip)); 764 m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip));
765 if (pStretched) { 765 if (pStretched) {
766 m_pRenderStatus->CompositeDIBitmap(pStretched.get(), dest_rect.left, 766 m_pRenderStatus->CompositeDIBitmap(pStretched.get(), dest_rect.left,
767 dest_rect.top, m_FillArgb, m_BitmapAlpha, 767 dest_rect.top, m_FillArgb, m_BitmapAlpha,
768 m_BlendType, FALSE); 768 m_BlendType, FALSE);
769 } 769 }
770 return FALSE; 770 return FALSE;
771 } 771 }
772 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { 772 FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() {
773 if (m_pDIBSource->IsOpaqueImage()) { 773 if (m_pDIBSource->IsOpaqueImage()) {
774 CFX_PathData path; 774 CFX_PathData path;
775 path.AppendRect(0, 0, 1, 1); 775 path.AppendRect(0, 0, 1, 1);
776 path.Transform(&m_ImageMatrix); 776 path.Transform(&m_ImageMatrix);
777 FX_DWORD fill_color = 777 FX_DWORD fill_color =
778 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); 778 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha);
779 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, 779 m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0,
780 FXFILL_WINDING); 780 FXFILL_WINDING);
781 } else { 781 } else {
782 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() 782 const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask()
783 ? m_pDIBSource 783 ? m_pDIBSource
784 : m_pDIBSource->GetAlphaMask(); 784 : m_pDIBSource->GetAlphaMask();
785 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || 785 if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f ||
786 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { 786 FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) {
787 int left, top; 787 int left, top;
788 nonstd::unique_ptr<CFX_DIBitmap> pTransformed( 788 std::unique_ptr<CFX_DIBitmap> pTransformed(
789 pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); 789 pAlphaMask->TransformTo(&m_ImageMatrix, left, top));
790 if (!pTransformed) 790 if (!pTransformed)
791 return TRUE; 791 return TRUE;
792 792
793 m_pRenderStatus->m_pDevice->SetBitMask( 793 m_pRenderStatus->m_pDevice->SetBitMask(
794 pTransformed.get(), left, top, 794 pTransformed.get(), left, top,
795 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); 795 ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha));
796 } else { 796 } else {
797 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); 797 CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
798 FX_RECT image_rect = image_rect_f.GetOutterRect(); 798 FX_RECT image_rect = image_rect_f.GetOutterRect();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 return NULL; 867 return NULL;
868 } 868 }
869 int width = pClipRect->right - pClipRect->left; 869 int width = pClipRect->right - pClipRect->left;
870 int height = pClipRect->bottom - pClipRect->top; 870 int height = pClipRect->bottom - pClipRect->top;
871 FX_BOOL bLuminosity = FALSE; 871 FX_BOOL bLuminosity = FALSE;
872 bLuminosity = pSMaskDict->GetConstString("S") != "Alpha"; 872 bLuminosity = pSMaskDict->GetConstString("S") != "Alpha";
873 CPDF_Stream* pGroup = pSMaskDict->GetStream("G"); 873 CPDF_Stream* pGroup = pSMaskDict->GetStream("G");
874 if (!pGroup) { 874 if (!pGroup) {
875 return NULL; 875 return NULL;
876 } 876 }
877 nonstd::unique_ptr<CPDF_Function> pFunc; 877 std::unique_ptr<CPDF_Function> pFunc;
878 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue("TR"); 878 CPDF_Object* pFuncObj = pSMaskDict->GetElementValue("TR");
879 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) 879 if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream()))
880 pFunc.reset(CPDF_Function::Load(pFuncObj)); 880 pFunc.reset(CPDF_Function::Load(pFuncObj));
881 881
882 CFX_Matrix matrix = *pMatrix; 882 CFX_Matrix matrix = *pMatrix;
883 matrix.TranslateI(-pClipRect->left, -pClipRect->top); 883 matrix.TranslateI(-pClipRect->left, -pClipRect->top);
884 CPDF_Form form(m_pContext->m_pDocument, m_pContext->m_pPageResources, pGroup); 884 CPDF_Form form(m_pContext->m_pDocument, m_pContext->m_pPageResources, pGroup);
885 form.ParseContent(NULL, NULL, NULL, NULL); 885 form.ParseContent(NULL, NULL, NULL, NULL);
886 CFX_FxgeDevice bitmap_device; 886 CFX_FxgeDevice bitmap_device;
887 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 887 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 if (form.m_pFormDict) { 940 if (form.m_pFormDict) {
941 pFormResource = form.m_pFormDict->GetDict("Resources"); 941 pFormResource = form.m_pFormDict->GetDict("Resources");
942 } 942 }
943 CPDF_RenderOptions options; 943 CPDF_RenderOptions options;
944 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; 944 options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA;
945 CPDF_RenderStatus status; 945 CPDF_RenderStatus status;
946 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, 946 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL,
947 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, 947 &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0,
948 pCS ? pCS->GetFamily() : 0, bLuminosity); 948 pCS ? pCS->GetFamily() : 0, bLuminosity);
949 status.RenderObjectList(&form, &matrix); 949 status.RenderObjectList(&form, &matrix);
950 nonstd::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); 950 std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap);
951 if (!pMask->Create(width, height, FXDIB_8bppMask)) 951 if (!pMask->Create(width, height, FXDIB_8bppMask))
952 return nullptr; 952 return nullptr;
953 953
954 uint8_t* dest_buf = pMask->GetBuffer(); 954 uint8_t* dest_buf = pMask->GetBuffer();
955 int dest_pitch = pMask->GetPitch(); 955 int dest_pitch = pMask->GetPitch();
956 uint8_t* src_buf = bitmap.GetBuffer(); 956 uint8_t* src_buf = bitmap.GetBuffer();
957 int src_pitch = bitmap.GetPitch(); 957 int src_pitch = bitmap.GetPitch();
958 std::vector<uint8_t> transfers(256); 958 std::vector<uint8_t> transfers(256);
959 if (pFunc) { 959 if (pFunc) {
960 CFX_FixedBufGrow<FX_FLOAT, 16> results(pFunc->CountOutputs()); 960 CFX_FixedBufGrow<FX_FLOAT, 16> results(pFunc->CountOutputs());
(...skipping 21 matching lines...) Expand all
982 } else if (pFunc) { 982 } else if (pFunc) {
983 int size = dest_pitch * height; 983 int size = dest_pitch * height;
984 for (int i = 0; i < size; i++) { 984 for (int i = 0; i < size; i++) {
985 dest_buf[i] = transfers[src_buf[i]]; 985 dest_buf[i] = transfers[src_buf[i]];
986 } 986 }
987 } else { 987 } else {
988 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); 988 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height);
989 } 989 }
990 return pMask.release(); 990 return pMask.release();
991 } 991 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698