OLD | NEW |
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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 rect.top = width - clip.left; | 294 rect.top = width - clip.left; |
295 rect.bottom = width - clip.right; | 295 rect.bottom = width - clip.right; |
296 } else { | 296 } else { |
297 rect.top = clip.left; | 297 rect.top = clip.left; |
298 rect.bottom = clip.right; | 298 rect.bottom = clip.right; |
299 } | 299 } |
300 rect.Normalize(); | 300 rect.Normalize(); |
301 return rect; | 301 return rect; |
302 } | 302 } |
303 | 303 |
304 CFX_DIBitmap* CFX_DIBSource::TransformTo(const CFX_Matrix* pDestMatrix, | 304 std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::TransformTo( |
305 int& result_left, | 305 const CFX_Matrix* pDestMatrix, |
306 int& result_top, | 306 int& result_left, |
307 uint32_t flags, | 307 int& result_top, |
308 const FX_RECT* pDestClip) const { | 308 uint32_t flags, |
| 309 const FX_RECT* pDestClip) const { |
309 CFX_ImageTransformer transformer(this, pDestMatrix, flags, pDestClip); | 310 CFX_ImageTransformer transformer(this, pDestMatrix, flags, pDestClip); |
310 transformer.Start(); | 311 transformer.Start(); |
311 transformer.Continue(nullptr); | 312 transformer.Continue(nullptr); |
312 result_left = transformer.result().left; | 313 result_left = transformer.result().left; |
313 result_top = transformer.result().top; | 314 result_top = transformer.result().top; |
314 return transformer.DetachBitmap().release(); | 315 return transformer.DetachBitmap(); |
315 } | 316 } |
316 | 317 |
317 CFX_DIBitmap* CFX_DIBSource::StretchTo(int dest_width, | 318 std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::StretchTo( |
318 int dest_height, | 319 int dest_width, |
319 uint32_t flags, | 320 int dest_height, |
320 const FX_RECT* pClip) const { | 321 uint32_t flags, |
| 322 const FX_RECT* pClip) const { |
321 FX_RECT clip_rect(0, 0, FXSYS_abs(dest_width), FXSYS_abs(dest_height)); | 323 FX_RECT clip_rect(0, 0, FXSYS_abs(dest_width), FXSYS_abs(dest_height)); |
322 if (pClip) | 324 if (pClip) |
323 clip_rect.Intersect(*pClip); | 325 clip_rect.Intersect(*pClip); |
324 | 326 |
325 if (clip_rect.IsEmpty()) | 327 if (clip_rect.IsEmpty()) |
326 return nullptr; | 328 return nullptr; |
327 | 329 |
328 if (dest_width == m_Width && dest_height == m_Height) | 330 if (dest_width == m_Width && dest_height == m_Height) |
329 return Clone(&clip_rect); | 331 return Clone(&clip_rect); |
330 | 332 |
331 CFX_BitmapStorer storer; | 333 CFX_BitmapStorer storer; |
332 CFX_ImageStretcher stretcher(&storer, this, dest_width, dest_height, | 334 CFX_ImageStretcher stretcher(&storer, this, dest_width, dest_height, |
333 clip_rect, flags); | 335 clip_rect, flags); |
334 if (stretcher.Start()) | 336 if (stretcher.Start()) |
335 stretcher.Continue(nullptr); | 337 stretcher.Continue(nullptr); |
336 return storer.Detach().release(); | 338 |
| 339 return storer.Detach(); |
337 } | 340 } |
338 | 341 |
339 CFX_ImageTransformer::CFX_ImageTransformer(const CFX_DIBSource* pSrc, | 342 CFX_ImageTransformer::CFX_ImageTransformer(const CFX_DIBSource* pSrc, |
340 const CFX_Matrix* pMatrix, | 343 const CFX_Matrix* pMatrix, |
341 int flags, | 344 int flags, |
342 const FX_RECT* pClip) | 345 const FX_RECT* pClip) |
343 : m_pSrc(pSrc), | 346 : m_pSrc(pSrc), |
344 m_pMatrix(pMatrix), | 347 m_pMatrix(pMatrix), |
345 m_pClip(pClip), | 348 m_pClip(pClip), |
346 m_Flags(flags), | 349 m_Flags(flags), |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 } | 952 } |
950 } | 953 } |
951 } | 954 } |
952 m_Storer.Replace(std::move(pTransformed)); | 955 m_Storer.Replace(std::move(pTransformed)); |
953 return false; | 956 return false; |
954 } | 957 } |
955 | 958 |
956 std::unique_ptr<CFX_DIBitmap> CFX_ImageTransformer::DetachBitmap() { | 959 std::unique_ptr<CFX_DIBitmap> CFX_ImageTransformer::DetachBitmap() { |
957 return m_Storer.Detach(); | 960 return m_Storer.Detach(); |
958 } | 961 } |
OLD | NEW |