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

Side by Side Diff: core/fpdfapi/render/cpdf_imagerenderer.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 | « core/fpdfapi/render/cpdf_imagecacheentry.cpp ('k') | core/fpdfapi/render/cpdf_renderstatus.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/cpdf_imagerenderer.h" 7 #include "core/fpdfapi/render/cpdf_imagerenderer.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 m_pImageObject->m_GeneralState.SetTransferFunc( 87 m_pImageObject->m_GeneralState.SetTransferFunc(
88 m_pRenderStatus->GetTransferFunc( 88 m_pRenderStatus->GetTransferFunc(
89 m_pImageObject->m_GeneralState.GetTR())); 89 m_pImageObject->m_GeneralState.GetTR()));
90 } 90 }
91 if (m_pImageObject->m_GeneralState.GetTransferFunc() && 91 if (m_pImageObject->m_GeneralState.GetTransferFunc() &&
92 !m_pImageObject->m_GeneralState.GetTransferFunc()->m_bIdentity) { 92 !m_pImageObject->m_GeneralState.GetTransferFunc()->m_bIdentity) {
93 m_pDIBSource = m_Loader.m_pBitmap = 93 m_pDIBSource = m_Loader.m_pBitmap =
94 m_pImageObject->m_GeneralState.GetTransferFunc()->TranslateImage( 94 m_pImageObject->m_GeneralState.GetTransferFunc()->TranslateImage(
95 m_Loader.m_pBitmap, !m_Loader.m_bCached); 95 m_Loader.m_pBitmap, !m_Loader.m_bCached);
96 if (m_Loader.m_bCached && m_Loader.m_pMask) 96 if (m_Loader.m_bCached && m_Loader.m_pMask)
97 m_Loader.m_pMask = m_Loader.m_pMask->Clone(); 97 m_Loader.m_pMask = m_Loader.m_pMask->Clone().release();
98 m_Loader.m_bCached = false; 98 m_Loader.m_bCached = false;
99 } 99 }
100 } 100 }
101 m_FillArgb = 0; 101 m_FillArgb = 0;
102 m_bPatternColor = false; 102 m_bPatternColor = false;
103 m_pPattern = nullptr; 103 m_pPattern = nullptr;
104 if (m_pDIBSource->IsAlphaMask()) { 104 if (m_pDIBSource->IsAlphaMask()) {
105 const CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); 105 const CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor();
106 if (pColor && pColor->IsPattern()) { 106 if (pColor && pColor->IsPattern()) {
107 m_pPattern = pColor->GetPattern(); 107 m_pPattern = pColor->GetPattern();
108 if (m_pPattern) 108 if (m_pPattern)
109 m_bPatternColor = true; 109 m_bPatternColor = true;
110 } 110 }
111 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); 111 m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject);
112 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) { 112 } else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
113 m_pClone.reset(m_pDIBSource->Clone()); 113 m_pClone = m_pDIBSource->Clone();
114 m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor, 114 m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor,
115 m_pRenderStatus->m_Options.m_ForeColor); 115 m_pRenderStatus->m_Options.m_ForeColor);
116 m_pDIBSource = m_pClone.get(); 116 m_pDIBSource = m_pClone.get();
117 } 117 }
118 m_Flags = 0; 118 m_Flags = 0;
119 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) 119 if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE)
120 m_Flags |= RENDER_FORCE_DOWNSAMPLE; 120 m_Flags |= RENDER_FORCE_DOWNSAMPLE;
121 else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) 121 else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE)
122 m_Flags |= RENDER_FORCE_HALFTONE; 122 m_Flags |= RENDER_FORCE_HALFTONE;
123 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { 123 if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 image_size *= m_pDIBSource->GetHeight(); 393 image_size *= m_pDIBSource->GetHeight();
394 if (!image_size.IsValid()) 394 if (!image_size.IsValid())
395 return false; 395 return false;
396 396
397 if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE && 397 if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE &&
398 !(m_Flags & RENDER_FORCE_HALFTONE)) { 398 !(m_Flags & RENDER_FORCE_HALFTONE)) {
399 m_Flags |= RENDER_FORCE_DOWNSAMPLE; 399 m_Flags |= RENDER_FORCE_DOWNSAMPLE;
400 } 400 }
401 } 401 }
402 #ifdef _SKIA_SUPPORT_ 402 #ifdef _SKIA_SUPPORT_
403 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone(); 403 CFX_DIBitmap* premultiplied = m_pDIBSource->Clone().release();
404 if (m_pDIBSource->HasAlpha()) 404 if (m_pDIBSource->HasAlpha())
405 CFX_SkiaDeviceDriver::PreMultiply(premultiplied); 405 CFX_SkiaDeviceDriver::PreMultiply(premultiplied);
406 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( 406 if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend(
407 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, 407 premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
408 m_DeviceHandle, m_BlendType)) { 408 m_DeviceHandle, m_BlendType)) {
409 if (m_DeviceHandle) { 409 if (m_DeviceHandle) {
410 m_Status = 3; 410 m_Status = 3;
411 return true; 411 return true;
412 } 412 }
413 return false; 413 return false;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 558
559 if (m_Status == 4) { 559 if (m_Status == 4) {
560 if (m_Loader.Continue(pPause)) 560 if (m_Loader.Continue(pPause))
561 return true; 561 return true;
562 562
563 if (StartRenderDIBSource()) 563 if (StartRenderDIBSource())
564 return Continue(pPause); 564 return Continue(pPause);
565 } 565 }
566 return false; 566 return false;
567 } 567 }
OLDNEW
« no previous file with comments | « core/fpdfapi/render/cpdf_imagecacheentry.cpp ('k') | core/fpdfapi/render/cpdf_renderstatus.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698