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

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

Issue 2386273004: Add ptr_util.h from base until std::make_unique<> available (Closed)
Patch Set: 2016 Created 4 years, 2 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
« no previous file with comments | « core/fxge/dib/fx_dib_main.cpp ('k') | core/fxge/ge/cfx_font.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 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 "core/fxge/fx_dib.h" 9 #include "core/fxge/fx_dib.h"
10 #include "third_party/base/ptr_util.h"
10 11
11 namespace { 12 namespace {
12 13
13 uint8_t bilinear_interpol(const uint8_t* buf, 14 uint8_t bilinear_interpol(const uint8_t* buf,
14 int row_offset_l, 15 int row_offset_l,
15 int row_offset_r, 16 int row_offset_r,
16 int src_col_l, 17 int src_col_l,
17 int src_col_r, 18 int src_col_r,
18 int res_x, 19 int res_x,
19 int res_y, 20 int res_y,
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 357
357 m_result = result_clip; 358 m_result = result_clip;
358 if (FXSYS_fabs(m_pMatrix->a) < FXSYS_fabs(m_pMatrix->b) / 20 && 359 if (FXSYS_fabs(m_pMatrix->a) < FXSYS_fabs(m_pMatrix->b) / 20 &&
359 FXSYS_fabs(m_pMatrix->d) < FXSYS_fabs(m_pMatrix->c) / 20 && 360 FXSYS_fabs(m_pMatrix->d) < FXSYS_fabs(m_pMatrix->c) / 20 &&
360 FXSYS_fabs(m_pMatrix->a) < 0.5f && FXSYS_fabs(m_pMatrix->d) < 0.5f) { 361 FXSYS_fabs(m_pMatrix->a) < 0.5f && FXSYS_fabs(m_pMatrix->d) < 0.5f) {
361 int dest_width = result_rect.Width(); 362 int dest_width = result_rect.Width();
362 int dest_height = result_rect.Height(); 363 int dest_height = result_rect.Height();
363 result_clip.Offset(-result_rect.left, -result_rect.top); 364 result_clip.Offset(-result_rect.left, -result_rect.top);
364 result_clip = FXDIB_SwapClipBox(result_clip, dest_width, dest_height, 365 result_clip = FXDIB_SwapClipBox(result_clip, dest_width, dest_height,
365 m_pMatrix->c > 0, m_pMatrix->b < 0); 366 m_pMatrix->c > 0, m_pMatrix->b < 0);
366 m_Stretcher = WrapUnique(new CFX_ImageStretcher( 367 m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
367 &m_Storer, m_pSrc, dest_height, dest_width, result_clip, m_Flags)); 368 &m_Storer, m_pSrc, dest_height, dest_width, result_clip, m_Flags);
368 m_Stretcher->Start(); 369 m_Stretcher->Start();
369 m_Status = 1; 370 m_Status = 1;
370 return TRUE; 371 return TRUE;
371 } 372 }
372 if (FXSYS_fabs(m_pMatrix->b) < FIX16_005 && 373 if (FXSYS_fabs(m_pMatrix->b) < FIX16_005 &&
373 FXSYS_fabs(m_pMatrix->c) < FIX16_005) { 374 FXSYS_fabs(m_pMatrix->c) < FIX16_005) {
374 int dest_width = m_pMatrix->a > 0 ? (int)FXSYS_ceil(m_pMatrix->a) 375 int dest_width = m_pMatrix->a > 0 ? (int)FXSYS_ceil(m_pMatrix->a)
375 : (int)FXSYS_floor(m_pMatrix->a); 376 : (int)FXSYS_floor(m_pMatrix->a);
376 int dest_height = m_pMatrix->d > 0 ? (int)-FXSYS_ceil(m_pMatrix->d) 377 int dest_height = m_pMatrix->d > 0 ? (int)-FXSYS_ceil(m_pMatrix->d)
377 : (int)-FXSYS_floor(m_pMatrix->d); 378 : (int)-FXSYS_floor(m_pMatrix->d);
378 result_clip.Offset(-result_rect.left, -result_rect.top); 379 result_clip.Offset(-result_rect.left, -result_rect.top);
379 m_Stretcher = WrapUnique(new CFX_ImageStretcher( 380 m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
380 &m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags)); 381 &m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags);
381 m_Stretcher->Start(); 382 m_Stretcher->Start();
382 m_Status = 2; 383 m_Status = 2;
383 return TRUE; 384 return TRUE;
384 } 385 }
385 int stretch_width = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b)); 386 int stretch_width = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b));
386 int stretch_height = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d)); 387 int stretch_height = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d));
387 CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 388 CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f,
388 (FX_FLOAT)(stretch_height)); 389 (FX_FLOAT)(stretch_height));
389 stretch2dest.Concat( 390 stretch2dest.Concat(
390 m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width, 391 m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width,
391 m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height, 392 m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height,
392 m_pMatrix->e, m_pMatrix->f); 393 m_pMatrix->e, m_pMatrix->f);
393 m_dest2stretch.SetReverse(stretch2dest); 394 m_dest2stretch.SetReverse(stretch2dest);
394 CFX_FloatRect clip_rect_f(result_clip); 395 CFX_FloatRect clip_rect_f(result_clip);
395 clip_rect_f.Transform(&m_dest2stretch); 396 clip_rect_f.Transform(&m_dest2stretch);
396 m_StretchClip = clip_rect_f.GetOuterRect(); 397 m_StretchClip = clip_rect_f.GetOuterRect();
397 m_StretchClip.Intersect(0, 0, stretch_width, stretch_height); 398 m_StretchClip.Intersect(0, 0, stretch_width, stretch_height);
398 m_Stretcher = WrapUnique(new CFX_ImageStretcher(&m_Storer, m_pSrc, 399 m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
399 stretch_width, stretch_height, 400 &m_Storer, m_pSrc, stretch_width, stretch_height, m_StretchClip, m_Flags);
400 m_StretchClip, m_Flags));
401 m_Stretcher->Start(); 401 m_Stretcher->Start();
402 m_Status = 3; 402 m_Status = 3;
403 return TRUE; 403 return TRUE;
404 } 404 }
405 405
406 FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) { 406 FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
407 if (m_Status == 1) { 407 if (m_Status == 1) {
408 if (m_Stretcher->Continue(pPause)) 408 if (m_Stretcher->Continue(pPause))
409 return TRUE; 409 return TRUE;
410 410
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 } 946 }
947 } 947 }
948 } 948 }
949 m_Storer.Replace(std::move(pTransformed)); 949 m_Storer.Replace(std::move(pTransformed));
950 return FALSE; 950 return FALSE;
951 } 951 }
952 952
953 std::unique_ptr<CFX_DIBitmap> CFX_ImageTransformer::DetachBitmap() { 953 std::unique_ptr<CFX_DIBitmap> CFX_ImageTransformer::DetachBitmap() {
954 return m_Storer.Detach(); 954 return m_Storer.Detach();
955 } 955 }
OLDNEW
« no previous file with comments | « core/fxge/dib/fx_dib_main.cpp ('k') | core/fxge/ge/cfx_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698