OLD | NEW |
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/page/cpdf_image.h" | 7 #include "core/fpdfapi/page/cpdf_image.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 m_bIsMask = pBitmap->IsAlphaMask(); | 315 m_bIsMask = pBitmap->IsAlphaMask(); |
316 m_Width = BitmapWidth; | 316 m_Width = BitmapWidth; |
317 m_Height = BitmapHeight; | 317 m_Height = BitmapHeight; |
318 FX_Free(dest_buf); | 318 FX_Free(dest_buf); |
319 } | 319 } |
320 | 320 |
321 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { | 321 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { |
322 pPage->GetRenderCache()->ResetBitmap(m_pStream.Get(), pBitmap); | 322 pPage->GetRenderCache()->ResetBitmap(m_pStream.Get(), pBitmap); |
323 } | 323 } |
324 | 324 |
325 CFX_DIBSource* CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask, | 325 std::unique_ptr<CFX_DIBSource> CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask, |
326 uint32_t* pMatteColor, | 326 uint32_t* pMatteColor, |
327 bool bStdCS, | 327 bool bStdCS, |
328 uint32_t GroupFamily, | 328 uint32_t GroupFamily, |
329 bool bLoadMask) const { | 329 bool bLoadMask) const { |
330 auto source = pdfium::MakeUnique<CPDF_DIBSource>(); | 330 auto source = pdfium::MakeUnique<CPDF_DIBSource>(); |
331 if (source->Load(m_pDocument, m_pStream.Get(), | 331 if (!source->Load(m_pDocument, m_pStream.Get(), |
332 reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor, | 332 reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor, |
333 nullptr, nullptr, bStdCS, GroupFamily, bLoadMask)) { | 333 nullptr, nullptr, bStdCS, GroupFamily, bLoadMask)) { |
334 return source.release(); | 334 return nullptr; |
335 } | 335 } |
336 return nullptr; | 336 return std::move(source); |
337 } | 337 } |
338 | 338 |
339 CFX_DIBSource* CPDF_Image::DetachBitmap() { | 339 CFX_DIBSource* CPDF_Image::DetachBitmap() { |
340 CFX_DIBSource* pBitmap = m_pDIBSource; | 340 CFX_DIBSource* pBitmap = m_pDIBSource; |
341 m_pDIBSource = nullptr; | 341 m_pDIBSource = nullptr; |
342 return pBitmap; | 342 return pBitmap; |
343 } | 343 } |
344 | 344 |
345 CFX_DIBSource* CPDF_Image::DetachMask() { | 345 CFX_DIBSource* CPDF_Image::DetachMask() { |
346 CFX_DIBSource* pBitmap = m_pMask; | 346 CFX_DIBSource* pBitmap = m_pMask; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 } | 379 } |
380 if (!ret) { | 380 if (!ret) { |
381 delete m_pDIBSource; | 381 delete m_pDIBSource; |
382 m_pDIBSource = nullptr; | 382 m_pDIBSource = nullptr; |
383 return false; | 383 return false; |
384 } | 384 } |
385 m_pMask = pSource->DetachMask(); | 385 m_pMask = pSource->DetachMask(); |
386 m_MatteColor = pSource->GetMatteColor(); | 386 m_MatteColor = pSource->GetMatteColor(); |
387 return false; | 387 return false; |
388 } | 388 } |
OLD | NEW |