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

Side by Side Diff: xfa/fxfa/app/xfa_ffwidget.cpp

Issue 2534953004: Return unique_ptrs from CFX_DIBitmap::Clone(). (Closed)
Patch Set: nits Created 4 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
« no previous file with comments | « xfa/fxbarcode/oned/BC_OneDimWriter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "xfa/fxfa/xfa_ffwidget.h" 7 #include "xfa/fxfa/xfa_ffwidget.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "core/fpdfapi/page/cpdf_pageobjectholder.h" 13 #include "core/fpdfapi/page/cpdf_pageobjectholder.h"
14 #include "core/fxcodec/codec/ccodec_progressivedecoder.h" 14 #include "core/fxcodec/codec/ccodec_progressivedecoder.h"
15 #include "core/fxcodec/fx_codec.h" 15 #include "core/fxcodec/fx_codec.h"
16 #include "core/fxcrt/cfx_maybe_owned.h"
16 #include "core/fxge/cfx_gemodule.h" 17 #include "core/fxge/cfx_gemodule.h"
17 #include "core/fxge/cfx_pathdata.h" 18 #include "core/fxge/cfx_pathdata.h"
18 #include "core/fxge/cfx_renderdevice.h" 19 #include "core/fxge/cfx_renderdevice.h"
19 #include "xfa/fwl/core/fwl_widgethit.h" 20 #include "xfa/fwl/core/fwl_widgethit.h"
20 #include "xfa/fxfa/app/xfa_textlayout.h" 21 #include "xfa/fxfa/app/xfa_textlayout.h"
21 #include "xfa/fxfa/cxfa_eventparam.h" 22 #include "xfa/fxfa/cxfa_eventparam.h"
22 #include "xfa/fxfa/fxfa_widget.h" 23 #include "xfa/fxfa/fxfa_widget.h"
23 #include "xfa/fxfa/parser/cxfa_corner.h" 24 #include "xfa/fxfa/parser/cxfa_corner.h"
24 #include "xfa/fxfa/xfa_ffapp.h" 25 #include "xfa/fxfa/xfa_ffapp.h"
25 #include "xfa/fxfa/xfa_ffdoc.h" 26 #include "xfa/fxfa/xfa_ffdoc.h"
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || 641 if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) ||
641 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { 642 (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) {
642 if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { 643 if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) {
643 m_Result = false; 644 m_Result = false;
644 return false; 645 return false;
645 } 646 }
646 CFX_DIBSource* pDib = m_pDIBSource; 647 CFX_DIBSource* pDib = m_pDIBSource;
647 if (m_pDIBSource->HasAlpha() && 648 if (m_pDIBSource->HasAlpha() &&
648 !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && 649 !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) &&
649 !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { 650 !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) {
650 m_pCloneConvert.reset(m_pDIBSource->CloneConvert(FXDIB_Rgb)); 651 m_pCloneConvert = m_pDIBSource->CloneConvert(FXDIB_Rgb);
651 if (!m_pCloneConvert) { 652 if (!m_pCloneConvert) {
652 m_Result = false; 653 m_Result = false;
653 return false; 654 return false;
654 } 655 }
655 pDib = m_pCloneConvert.get(); 656 pDib = m_pCloneConvert.get();
656 } 657 }
657 FX_RECT clip_box = m_pDevice->GetClipBox(); 658 FX_RECT clip_box = m_pDevice->GetClipBox();
658 clip_box.Intersect(image_rect); 659 clip_box.Intersect(image_rect);
659 m_Status = 2; 660 m_Status = 2;
660 m_pTransformer.reset( 661 m_pTransformer.reset(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 if (bGetBackGround) { 777 if (bGetBackGround) {
777 if (bIsolated || !bGroup) { 778 if (bIsolated || !bGroup) {
778 if (pDIBitmap->IsAlphaMask()) { 779 if (pDIBitmap->IsAlphaMask()) {
779 return; 780 return;
780 } 781 }
781 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); 782 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode);
782 } else { 783 } else {
783 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), 784 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(),
784 top + pDIBitmap->GetHeight()); 785 top + pDIBitmap->GetHeight());
785 rect.Intersect(m_pDevice->GetClipBox()); 786 rect.Intersect(m_pDevice->GetClipBox());
786 CFX_DIBitmap* pClone = nullptr; 787 CFX_MaybeOwned<CFX_DIBitmap> pClone;
787 bool bClone = false;
788 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { 788 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) {
789 bClone = true;
790 pClone = m_pDevice->GetBackDrop()->Clone(&rect); 789 pClone = m_pDevice->GetBackDrop()->Clone(&rect);
791 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); 790 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap();
792 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), 791 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(),
793 pForeBitmap, rect.left, rect.top); 792 pForeBitmap, rect.left, rect.top);
794 left = left >= 0 ? 0 : left; 793 left = left >= 0 ? 0 : left;
795 top = top >= 0 ? 0 : top; 794 top = top >= 0 ? 0 : top;
796 if (!pDIBitmap->IsAlphaMask()) 795 if (!pDIBitmap->IsAlphaMask())
797 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), 796 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(),
798 pDIBitmap, left, top, blend_mode); 797 pDIBitmap, left, top, blend_mode);
799 else 798 else
800 pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), 799 pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(),
801 pDIBitmap, mask_argb, left, top, blend_mode); 800 pDIBitmap, mask_argb, left, top, blend_mode);
802 } else { 801 } else {
803 pClone = pDIBitmap; 802 pClone = pDIBitmap;
804 } 803 }
805 if (m_pDevice->GetBackDrop()) { 804 if (m_pDevice->GetBackDrop()) {
806 m_pDevice->SetDIBits(pClone, rect.left, rect.top); 805 m_pDevice->SetDIBits(pClone.Get(), rect.left, rect.top);
807 } else { 806 } else {
808 if (pDIBitmap->IsAlphaMask()) 807 if (pDIBitmap->IsAlphaMask())
809 return; 808 return;
810 m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top, 809 m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top,
811 blend_mode); 810 blend_mode);
812 } 811 }
813 if (bClone) {
814 delete pClone;
815 }
816 } 812 }
817 return; 813 return;
818 } 814 }
819 if (pDIBitmap->HasAlpha() && 815 if (!pDIBitmap->HasAlpha() ||
820 !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) { 816 (m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) {
821 CFX_DIBitmap* pCloneConvert = pDIBitmap->CloneConvert(FXDIB_Rgb);
822 if (!pCloneConvert) {
823 return;
824 }
825 CXFA_ImageRenderer imageRender;
826 bool bRet = imageRender.Start(m_pDevice, pCloneConvert, m_FillArgb,
827 m_BitmapAlpha, &m_ImageMatrix, m_Flags);
828 while (bRet) {
829 bRet = imageRender.Continue(nullptr);
830 }
831 delete pCloneConvert;
832 return; 817 return;
833 } 818 }
819 std::unique_ptr<CFX_DIBitmap> pCloneConvert =
820 pDIBitmap->CloneConvert(FXDIB_Rgb);
821 if (!pCloneConvert)
822 return;
823
824 CXFA_ImageRenderer imageRender;
825 if (!imageRender.Start(m_pDevice, pCloneConvert.get(), m_FillArgb,
826 m_BitmapAlpha, &m_ImageMatrix, m_Flags)) {
827 return;
828 }
829 while (imageRender.Continue(nullptr))
830 continue;
834 } 831 }
832
835 void XFA_DrawImage(CFX_Graphics* pGS, 833 void XFA_DrawImage(CFX_Graphics* pGS,
836 const CFX_RectF& rtImage, 834 const CFX_RectF& rtImage,
837 CFX_Matrix* pMatrix, 835 CFX_Matrix* pMatrix,
838 CFX_DIBitmap* pDIBitmap, 836 CFX_DIBitmap* pDIBitmap,
839 int32_t iAspect, 837 int32_t iAspect,
840 int32_t iImageXDpi, 838 int32_t iImageXDpi,
841 int32_t iImageYDpi, 839 int32_t iImageYDpi,
842 int32_t iHorzAlign, 840 int32_t iHorzAlign,
843 int32_t iVertAlign) { 841 int32_t iVertAlign) {
844 if (rtImage.IsEmpty()) { 842 if (rtImage.IsEmpty()) {
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 } 2043 }
2046 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); 2044 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags);
2047 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); 2045 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags);
2048 } 2046 }
2049 2047
2050 CXFA_CalcData::CXFA_CalcData() : m_iRefCount(0) {} 2048 CXFA_CalcData::CXFA_CalcData() : m_iRefCount(0) {}
2051 2049
2052 CXFA_CalcData::~CXFA_CalcData() { 2050 CXFA_CalcData::~CXFA_CalcData() {
2053 m_Globals.RemoveAll(); 2051 m_Globals.RemoveAll();
2054 } 2052 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/oned/BC_OneDimWriter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698