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

Side by Side Diff: core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp

Issue 2571913002: Avoid the ptr.reset(new XXX()) anti-pattern (Closed)
Patch Set: rebase 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
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_scaledrenderbuffer.h" 7 #include "core/fpdfapi/render/cpdf_scaledrenderbuffer.h"
8 8
9 #include "core/fpdfapi/render/cpdf_rendercontext.h" 9 #include "core/fpdfapi/render/cpdf_rendercontext.h"
10 #include "core/fpdfapi/render/cpdf_renderoptions.h" 10 #include "core/fpdfapi/render/cpdf_renderoptions.h"
11 #include "core/fxge/cfx_fxgedevice.h" 11 #include "core/fxge/cfx_fxgedevice.h"
12 #include "core/fxge/cfx_renderdevice.h" 12 #include "core/fxge/cfx_renderdevice.h"
13 #include "third_party/base/ptr_util.h"
13 14
14 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) 15 #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024)
15 16
16 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {} 17 CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {}
17 18
18 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} 19 CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {}
19 20
20 bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, 21 bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext,
21 CFX_RenderDevice* pDevice, 22 CFX_RenderDevice* pDevice,
22 const FX_RECT& pRect, 23 const FX_RECT& pRect,
(...skipping 13 matching lines...) Expand all
36 if (horz_size && vert_size && max_dpi) { 37 if (horz_size && vert_size && max_dpi) {
37 int dpih = 38 int dpih =
38 pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size * 10); 39 pDevice->GetDeviceCaps(FXDC_PIXEL_WIDTH) * 254 / (horz_size * 10);
39 int dpiv = 40 int dpiv =
40 pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size * 10); 41 pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size * 10);
41 if (dpih > max_dpi) 42 if (dpih > max_dpi)
42 m_Matrix.Scale((FX_FLOAT)(max_dpi) / dpih, 1.0f); 43 m_Matrix.Scale((FX_FLOAT)(max_dpi) / dpih, 1.0f);
43 if (dpiv > max_dpi) 44 if (dpiv > max_dpi)
44 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); 45 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv);
45 } 46 }
46 m_pBitmapDevice.reset(new CFX_FxgeDevice); 47 m_pBitmapDevice = pdfium::MakeUnique<CFX_FxgeDevice>();
47 FXDIB_Format dibFormat = FXDIB_Rgb; 48 FXDIB_Format dibFormat = FXDIB_Rgb;
48 int32_t bpp = 24; 49 int32_t bpp = 24;
49 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) { 50 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) {
50 dibFormat = FXDIB_Argb; 51 dibFormat = FXDIB_Argb;
51 bpp = 32; 52 bpp = 32;
52 } 53 }
53 while (1) { 54 while (1) {
54 CFX_FloatRect rect(pRect); 55 CFX_FloatRect rect(pRect);
55 m_Matrix.TransformRect(rect); 56 m_Matrix.TransformRect(rect);
56 FX_RECT bitmap_rect = rect.GetOuterRect(); 57 FX_RECT bitmap_rect = rect.GetOuterRect();
(...skipping 13 matching lines...) Expand all
70 &m_Matrix); 71 &m_Matrix);
71 return true; 72 return true;
72 } 73 }
73 74
74 void CPDF_ScaledRenderBuffer::OutputToDevice() { 75 void CPDF_ScaledRenderBuffer::OutputToDevice() {
75 if (m_pBitmapDevice) { 76 if (m_pBitmapDevice) {
76 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, 77 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left,
77 m_Rect.top, m_Rect.Width(), m_Rect.Height()); 78 m_Rect.top, m_Rect.Width(), m_Rect.Height());
78 } 79 }
79 } 80 }
OLDNEW
« no previous file with comments | « core/fpdfapi/render/cpdf_renderstatus.cpp ('k') | core/fpdfapi/render/fpdf_render_loadimage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698