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

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

Issue 2347993002: Clean up CPDF_Stream. (Closed)
Patch Set: ctor Created 4 years, 3 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
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/fpdf_page/include/cpdf_image.h" 7 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 pDict->SetNameFor("Filter", "DCTDecode"); 109 pDict->SetNameFor("Filter", "DCTDecode");
110 if (!color_trans) { 110 if (!color_trans) {
111 CPDF_Dictionary* pParms = new CPDF_Dictionary; 111 CPDF_Dictionary* pParms = new CPDF_Dictionary;
112 pDict->SetFor("DecodeParms", pParms); 112 pDict->SetFor("DecodeParms", pParms);
113 pParms->SetIntegerFor("ColorTransform", 0); 113 pParms->SetIntegerFor("ColorTransform", 0);
114 } 114 }
115 m_bIsMask = FALSE; 115 m_bIsMask = FALSE;
116 m_Width = width; 116 m_Width = width;
117 m_Height = height; 117 m_Height = height;
118 if (!m_pStream) 118 if (!m_pStream)
119 m_pStream = new CPDF_Stream(nullptr, 0, nullptr); 119 m_pStream = new CPDF_Stream;
120 return pDict; 120 return pDict;
121 } 121 }
122 122
123 void CPDF_Image::SetJpegImage(IFX_FileRead* pFile) { 123 void CPDF_Image::SetJpegImage(IFX_FileRead* pFile) {
124 uint32_t size = (uint32_t)pFile->GetSize(); 124 uint32_t size = (uint32_t)pFile->GetSize();
125 if (!size) 125 if (!size)
126 return; 126 return;
127 127
128 uint32_t dwEstimateSize = std::min(size, 8192U); 128 uint32_t dwEstimateSize = std::min(size, 8192U);
129 std::vector<uint8_t> data(dwEstimateSize); 129 std::vector<uint8_t> data(dwEstimateSize);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 pDest[dest_offset + 1] = (uint8_t)(src_buf[src_offset + 1] * alpha); 322 pDest[dest_offset + 1] = (uint8_t)(src_buf[src_offset + 1] * alpha);
323 pDest[dest_offset + 2] = (uint8_t)(src_buf[src_offset] * alpha); 323 pDest[dest_offset + 2] = (uint8_t)(src_buf[src_offset] * alpha);
324 dest_offset += 3; 324 dest_offset += 3;
325 src_offset += bpp == 24 ? 3 : 4; 325 src_offset += bpp == 24 ? 3 : 4;
326 } 326 }
327 327
328 pDest += dest_pitch; 328 pDest += dest_pitch;
329 dest_offset = 0; 329 dest_offset = 0;
330 } 330 }
331 } 331 }
332 if (!m_pStream) { 332 if (!m_pStream)
333 m_pStream = new CPDF_Stream(nullptr, 0, nullptr); 333 m_pStream = new CPDF_Stream;
334 } 334
335 m_pStream->InitStream(dest_buf, dest_size, pDict); 335 m_pStream->InitStream(dest_buf, dest_size, pDict);
336 m_bIsMask = pBitmap->IsAlphaMask(); 336 m_bIsMask = pBitmap->IsAlphaMask();
337 m_Width = BitmapWidth; 337 m_Width = BitmapWidth;
338 m_Height = BitmapHeight; 338 m_Height = BitmapHeight;
339 FX_Free(dest_buf); 339 FX_Free(dest_buf);
340 } 340 }
341 341
342 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { 342 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) {
343 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); 343 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap);
344 } 344 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } 400 }
401 if (!ret) { 401 if (!ret) {
402 delete m_pDIBSource; 402 delete m_pDIBSource;
403 m_pDIBSource = nullptr; 403 m_pDIBSource = nullptr;
404 return FALSE; 404 return FALSE;
405 } 405 }
406 m_pMask = pSource->DetachMask(); 406 m_pMask = pSource->DetachMask();
407 m_MatteColor = pSource->GetMatteColor(); 407 m_MatteColor = pSource->GetMatteColor();
408 return FALSE; 408 return FALSE;
409 } 409 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698