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

Side by Side Diff: core/fxge/dib/fx_dib_transform.cpp

Issue 2572293002: More unique_ptr returns from DIB methods. (Closed)
Patch Set: win build 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/fxge/dib/fx_dib_main.cpp ('k') | core/fxge/fx_dib.h » ('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 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 "core/fxge/dib/dib_int.h" 7 #include "core/fxge/dib/dib_int.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (res_x < 0 && res_x > -base) { 171 if (res_x < 0 && res_x > -base) {
172 res_x = base + res_x; 172 res_x = base + res_x;
173 } 173 }
174 if (res_y < 0 && res_x > -base) { 174 if (res_y < 0 && res_x > -base) {
175 res_y = base + res_y; 175 res_y = base + res_y;
176 } 176 }
177 x1 /= base; 177 x1 /= base;
178 y1 /= base; 178 y1 /= base;
179 } 179 }
180 }; 180 };
181 CFX_DIBitmap* CFX_DIBSource::SwapXY(bool bXFlip, 181
182 bool bYFlip, 182 std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::SwapXY(
183 const FX_RECT* pDestClip) const { 183 bool bXFlip,
184 bool bYFlip,
185 const FX_RECT* pDestClip) const {
184 FX_RECT dest_clip(0, 0, m_Height, m_Width); 186 FX_RECT dest_clip(0, 0, m_Height, m_Width);
185 if (pDestClip) { 187 if (pDestClip)
186 dest_clip.Intersect(*pDestClip); 188 dest_clip.Intersect(*pDestClip);
187 } 189 if (dest_clip.IsEmpty())
188 if (dest_clip.IsEmpty()) {
189 return nullptr; 190 return nullptr;
190 } 191
191 CFX_DIBitmap* pTransBitmap = new CFX_DIBitmap; 192 auto pTransBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
192 int result_height = dest_clip.Height(), result_width = dest_clip.Width(); 193 int result_height = dest_clip.Height();
193 if (!pTransBitmap->Create(result_width, result_height, GetFormat())) { 194 int result_width = dest_clip.Width();
194 delete pTransBitmap; 195 if (!pTransBitmap->Create(result_width, result_height, GetFormat()))
195 return nullptr; 196 return nullptr;
196 } 197
197 pTransBitmap->SetPalette(m_pPalette.get()); 198 pTransBitmap->SetPalette(m_pPalette.get());
198 int dest_pitch = pTransBitmap->GetPitch(); 199 int dest_pitch = pTransBitmap->GetPitch();
199 uint8_t* dest_buf = pTransBitmap->GetBuffer(); 200 uint8_t* dest_buf = pTransBitmap->GetBuffer();
200 int row_start = bXFlip ? m_Height - dest_clip.right : dest_clip.left; 201 int row_start = bXFlip ? m_Height - dest_clip.right : dest_clip.left;
201 int row_end = bXFlip ? m_Height - dest_clip.left : dest_clip.right; 202 int row_end = bXFlip ? m_Height - dest_clip.left : dest_clip.right;
202 int col_start = bYFlip ? m_Width - dest_clip.bottom : dest_clip.top; 203 int col_start = bYFlip ? m_Width - dest_clip.bottom : dest_clip.top;
203 int col_end = bYFlip ? m_Width - dest_clip.top : dest_clip.bottom; 204 int col_end = bYFlip ? m_Width - dest_clip.top : dest_clip.bottom;
204 if (GetBPP() == 1) { 205 if (GetBPP() == 1) {
205 FXSYS_memset(dest_buf, 0xff, dest_pitch * result_height); 206 FXSYS_memset(dest_buf, 0xff, dest_pitch * result_height);
206 for (int row = row_start; row < row_end; row++) { 207 for (int row = row_start; row < row_end; row++) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 270 }
270 const uint8_t* src_scan = m_pAlphaMask->GetScanline(row) + col_start; 271 const uint8_t* src_scan = m_pAlphaMask->GetScanline(row) + col_start;
271 for (int col = col_start; col < col_end; col++) { 272 for (int col = col_start; col < col_end; col++) {
272 *dest_scan = *src_scan++; 273 *dest_scan = *src_scan++;
273 dest_scan += dest_step; 274 dest_scan += dest_step;
274 } 275 }
275 } 276 }
276 } 277 }
277 return pTransBitmap; 278 return pTransBitmap;
278 } 279 }
280
279 #define FIX16_005 0.05f 281 #define FIX16_005 0.05f
280 FX_RECT FXDIB_SwapClipBox(FX_RECT& clip, 282 FX_RECT FXDIB_SwapClipBox(FX_RECT& clip,
281 int width, 283 int width,
282 int height, 284 int height,
283 bool bFlipX, 285 bool bFlipX,
284 bool bFlipY) { 286 bool bFlipY) {
285 FX_RECT rect; 287 FX_RECT rect;
286 if (bFlipY) { 288 if (bFlipY) {
287 rect.left = height - clip.top; 289 rect.left = height - clip.top;
288 rect.right = height - clip.bottom; 290 rect.right = height - clip.bottom;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 m_Status = 3; 410 m_Status = 3;
409 return true; 411 return true;
410 } 412 }
411 413
412 bool CFX_ImageTransformer::Continue(IFX_Pause* pPause) { 414 bool CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
413 if (m_Status == 1) { 415 if (m_Status == 1) {
414 if (m_Stretcher->Continue(pPause)) 416 if (m_Stretcher->Continue(pPause))
415 return true; 417 return true;
416 418
417 if (m_Storer.GetBitmap()) { 419 if (m_Storer.GetBitmap()) {
418 std::unique_ptr<CFX_DIBitmap> swapped( 420 m_Storer.Replace(
419 m_Storer.GetBitmap()->SwapXY(m_pMatrix->c > 0, m_pMatrix->b < 0)); 421 m_Storer.GetBitmap()->SwapXY(m_pMatrix->c > 0, m_pMatrix->b < 0));
420 m_Storer.Replace(std::move(swapped));
421 } 422 }
422 return false; 423 return false;
423 } 424 }
424 425
425 if (m_Status == 2) 426 if (m_Status == 2)
426 return m_Stretcher->Continue(pPause); 427 return m_Stretcher->Continue(pPause);
427 428
428 if (m_Status != 3) 429 if (m_Status != 3)
429 return false; 430 return false;
430 431
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 } 953 }
953 } 954 }
954 } 955 }
955 m_Storer.Replace(std::move(pTransformed)); 956 m_Storer.Replace(std::move(pTransformed));
956 return false; 957 return false;
957 } 958 }
958 959
959 std::unique_ptr<CFX_DIBitmap> CFX_ImageTransformer::DetachBitmap() { 960 std::unique_ptr<CFX_DIBitmap> CFX_ImageTransformer::DetachBitmap() {
960 return m_Storer.Detach(); 961 return m_Storer.Detach();
961 } 962 }
OLDNEW
« no previous file with comments | « core/fxge/dib/fx_dib_main.cpp ('k') | core/fxge/fx_dib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698