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

Side by Side Diff: core/fpdfapi/page/cpdf_image.cpp

Issue 2489423002: Make CPDF_PageContentGenerator methods take object numbers (Closed)
Patch Set: Call the plumber Created 4 years, 1 month 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/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 pDict->SetNameFor("Filter", "DCTDecode"); 115 pDict->SetNameFor("Filter", "DCTDecode");
116 if (!color_trans) { 116 if (!color_trans) {
117 CPDF_Dictionary* pParms = 117 CPDF_Dictionary* pParms =
118 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); 118 new CPDF_Dictionary(m_pDocument->GetByteStringPool());
119 pDict->SetFor("DecodeParms", pParms); 119 pDict->SetFor("DecodeParms", pParms);
120 pParms->SetIntegerFor("ColorTransform", 0); 120 pParms->SetIntegerFor("ColorTransform", 0);
121 } 121 }
122 m_bIsMask = false; 122 m_bIsMask = false;
123 m_Width = width; 123 m_Width = width;
124 m_Height = height; 124 m_Height = height;
125 if (!m_pStream) 125 if (!m_pStream) {
126 m_pStream = new CPDF_Stream; 126 m_pOwnedStream = pdfium::MakeUnique<CPDF_Stream>();
127 m_pStream = m_pOwnedStream.get();
128 }
127 return pDict; 129 return pDict;
128 } 130 }
129 131
130 void CPDF_Image::SetJpegImage(IFX_SeekableReadStream* pFile) { 132 void CPDF_Image::SetJpegImage(IFX_SeekableReadStream* pFile) {
131 uint32_t size = (uint32_t)pFile->GetSize(); 133 uint32_t size = (uint32_t)pFile->GetSize();
132 if (!size) 134 if (!size)
133 return; 135 return;
134 136
135 uint32_t dwEstimateSize = std::min(size, 8192U); 137 uint32_t dwEstimateSize = std::min(size, 8192U);
136 std::vector<uint8_t> data(dwEstimateSize); 138 std::vector<uint8_t> data(dwEstimateSize);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 pDest[dest_offset + 1] = (uint8_t)(src_buf[src_offset + 1] * alpha); 329 pDest[dest_offset + 1] = (uint8_t)(src_buf[src_offset + 1] * alpha);
328 pDest[dest_offset + 2] = (uint8_t)(src_buf[src_offset] * alpha); 330 pDest[dest_offset + 2] = (uint8_t)(src_buf[src_offset] * alpha);
329 dest_offset += 3; 331 dest_offset += 3;
330 src_offset += bpp == 24 ? 3 : 4; 332 src_offset += bpp == 24 ? 3 : 4;
331 } 333 }
332 334
333 pDest += dest_pitch; 335 pDest += dest_pitch;
334 dest_offset = 0; 336 dest_offset = 0;
335 } 337 }
336 } 338 }
337 if (!m_pStream) 339 if (!m_pStream) {
338 m_pStream = new CPDF_Stream; 340 m_pOwnedStream = pdfium::MakeUnique<CPDF_Stream>();
339 341 m_pStream = m_pOwnedStream.get();
342 }
340 m_pStream->InitStream(dest_buf, dest_size, pDict); 343 m_pStream->InitStream(dest_buf, dest_size, pDict);
341 m_bIsMask = pBitmap->IsAlphaMask(); 344 m_bIsMask = pBitmap->IsAlphaMask();
342 m_Width = BitmapWidth; 345 m_Width = BitmapWidth;
343 m_Height = BitmapHeight; 346 m_Height = BitmapHeight;
344 FX_Free(dest_buf); 347 FX_Free(dest_buf);
345 } 348 }
346 349
347 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { 350 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) {
348 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); 351 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap);
349 } 352 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 408 }
406 if (!ret) { 409 if (!ret) {
407 delete m_pDIBSource; 410 delete m_pDIBSource;
408 m_pDIBSource = nullptr; 411 m_pDIBSource = nullptr;
409 return false; 412 return false;
410 } 413 }
411 m_pMask = pSource->DetachMask(); 414 m_pMask = pSource->DetachMask();
412 m_MatteColor = pSource->GetMatteColor(); 415 m_MatteColor = pSource->GetMatteColor();
413 return false; 416 return false;
414 } 417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698