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

Side by Side Diff: core/fxcodec/codec/fx_codec_tiff.cpp

Issue 2443723002: Rename IFX_ stream names (Closed)
Patch Set: Nits 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
« no previous file with comments | « core/fxcodec/codec/fx_codec_progress.cpp ('k') | core/fxcrt/extension.h » ('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/fxcodec/codec/codec_int.h" 7 #include "core/fxcodec/codec/codec_int.h"
8 #include "core/fxcodec/fx_codec.h" 8 #include "core/fxcodec/fx_codec.h"
9 #include "core/fxge/fx_dib.h" 9 #include "core/fxge/fx_dib.h"
10 10
11 extern "C" { 11 extern "C" {
12 #include "third_party/libtiff/tiffiop.h" 12 #include "third_party/libtiff/tiffiop.h"
13 } 13 }
14 14
15 class CCodec_TiffContext { 15 class CCodec_TiffContext {
16 public: 16 public:
17 CCodec_TiffContext(); 17 CCodec_TiffContext();
18 ~CCodec_TiffContext(); 18 ~CCodec_TiffContext();
19 19
20 bool InitDecoder(IFX_FileRead* file_ptr); 20 bool InitDecoder(IFX_SeekableReadStream* file_ptr);
21 bool LoadFrameInfo(int32_t frame, 21 bool LoadFrameInfo(int32_t frame,
22 int32_t* width, 22 int32_t* width,
23 int32_t* height, 23 int32_t* height,
24 int32_t* comps, 24 int32_t* comps,
25 int32_t* bpc, 25 int32_t* bpc,
26 CFX_DIBAttribute* pAttribute); 26 CFX_DIBAttribute* pAttribute);
27 bool Decode(CFX_DIBitmap* pDIBitmap); 27 bool Decode(CFX_DIBitmap* pDIBitmap);
28 28
29 IFX_FileRead* io_in() const { return m_io_in; } 29 IFX_SeekableReadStream* io_in() const { return m_io_in; }
30 uint32_t offset() const { return m_offset; } 30 uint32_t offset() const { return m_offset; }
31 void set_offset(uint32_t offset) { m_offset = offset; } 31 void set_offset(uint32_t offset) { m_offset = offset; }
32 void increment_offset(uint32_t offset) { m_offset += offset; } 32 void increment_offset(uint32_t offset) { m_offset += offset; }
33 33
34 private: 34 private:
35 bool IsSupport(const CFX_DIBitmap* pDIBitmap) const; 35 bool IsSupport(const CFX_DIBitmap* pDIBitmap) const;
36 void SetPalette(CFX_DIBitmap* pDIBitmap, uint16_t bps); 36 void SetPalette(CFX_DIBitmap* pDIBitmap, uint16_t bps);
37 bool Decode1bppRGB(CFX_DIBitmap* pDIBitmap, 37 bool Decode1bppRGB(CFX_DIBitmap* pDIBitmap,
38 int32_t height, 38 int32_t height,
39 int32_t width, 39 int32_t width,
40 uint16_t bps, 40 uint16_t bps,
41 uint16_t spp); 41 uint16_t spp);
42 bool Decode8bppRGB(CFX_DIBitmap* pDIBitmap, 42 bool Decode8bppRGB(CFX_DIBitmap* pDIBitmap,
43 int32_t height, 43 int32_t height,
44 int32_t width, 44 int32_t width,
45 uint16_t bps, 45 uint16_t bps,
46 uint16_t spp); 46 uint16_t spp);
47 bool Decode24bppRGB(CFX_DIBitmap* pDIBitmap, 47 bool Decode24bppRGB(CFX_DIBitmap* pDIBitmap,
48 int32_t height, 48 int32_t height,
49 int32_t width, 49 int32_t width,
50 uint16_t bps, 50 uint16_t bps,
51 uint16_t spp); 51 uint16_t spp);
52 52
53 IFX_FileRead* m_io_in; 53 IFX_SeekableReadStream* m_io_in;
54 uint32_t m_offset; 54 uint32_t m_offset;
55 TIFF* m_tif_ctx; 55 TIFF* m_tif_ctx;
56 }; 56 };
57 57
58 void* _TIFFmalloc(tmsize_t size) { 58 void* _TIFFmalloc(tmsize_t size) {
59 return FXMEM_DefaultAlloc(size, 0); 59 return FXMEM_DefaultAlloc(size, 0);
60 } 60 }
61 61
62 void _TIFFfree(void* ptr) { 62 void _TIFFfree(void* ptr) {
63 FXMEM_DefaultFree(ptr, 0); 63 FXMEM_DefaultFree(ptr, 0);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } // namespace 186 } // namespace
187 187
188 CCodec_TiffContext::CCodec_TiffContext() 188 CCodec_TiffContext::CCodec_TiffContext()
189 : m_io_in(nullptr), m_offset(0), m_tif_ctx(nullptr) {} 189 : m_io_in(nullptr), m_offset(0), m_tif_ctx(nullptr) {}
190 190
191 CCodec_TiffContext::~CCodec_TiffContext() { 191 CCodec_TiffContext::~CCodec_TiffContext() {
192 if (m_tif_ctx) 192 if (m_tif_ctx)
193 TIFFClose(m_tif_ctx); 193 TIFFClose(m_tif_ctx);
194 } 194 }
195 195
196 bool CCodec_TiffContext::InitDecoder(IFX_FileRead* file_ptr) { 196 bool CCodec_TiffContext::InitDecoder(IFX_SeekableReadStream* file_ptr) {
197 m_io_in = file_ptr; 197 m_io_in = file_ptr;
198 m_tif_ctx = tiff_open(this, "r"); 198 m_tif_ctx = tiff_open(this, "r");
199 return !!m_tif_ctx; 199 return !!m_tif_ctx;
200 } 200 }
201 201
202 bool CCodec_TiffContext::LoadFrameInfo(int32_t frame, 202 bool CCodec_TiffContext::LoadFrameInfo(int32_t frame,
203 int32_t* width, 203 int32_t* width,
204 int32_t* height, 204 int32_t* height,
205 int32_t* comps, 205 int32_t* comps,
206 int32_t* bpc, 206 int32_t* bpc,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 uint32_t bpp = bps * spp; 428 uint32_t bpp = bps * spp;
429 if (bpp == 1) 429 if (bpp == 1)
430 return Decode1bppRGB(pDIBitmap, height, width, bps, spp); 430 return Decode1bppRGB(pDIBitmap, height, width, bps, spp);
431 if (bpp <= 8) 431 if (bpp <= 8)
432 return Decode8bppRGB(pDIBitmap, height, width, bps, spp); 432 return Decode8bppRGB(pDIBitmap, height, width, bps, spp);
433 if (bpp <= 24) 433 if (bpp <= 24)
434 return Decode24bppRGB(pDIBitmap, height, width, bps, spp); 434 return Decode24bppRGB(pDIBitmap, height, width, bps, spp);
435 return false; 435 return false;
436 } 436 }
437 437
438 CCodec_TiffContext* CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr) { 438 CCodec_TiffContext* CCodec_TiffModule::CreateDecoder(
439 IFX_SeekableReadStream* file_ptr) {
439 CCodec_TiffContext* pDecoder = new CCodec_TiffContext; 440 CCodec_TiffContext* pDecoder = new CCodec_TiffContext;
440 if (!pDecoder->InitDecoder(file_ptr)) { 441 if (!pDecoder->InitDecoder(file_ptr)) {
441 delete pDecoder; 442 delete pDecoder;
442 return nullptr; 443 return nullptr;
443 } 444 }
444 return pDecoder; 445 return pDecoder;
445 } 446 }
446 447
447 bool CCodec_TiffModule::LoadFrameInfo(CCodec_TiffContext* ctx, 448 bool CCodec_TiffModule::LoadFrameInfo(CCodec_TiffContext* ctx,
448 int32_t frame, 449 int32_t frame,
449 int32_t* width, 450 int32_t* width,
450 int32_t* height, 451 int32_t* height,
451 int32_t* comps, 452 int32_t* comps,
452 int32_t* bpc, 453 int32_t* bpc,
453 CFX_DIBAttribute* pAttribute) { 454 CFX_DIBAttribute* pAttribute) {
454 return ctx->LoadFrameInfo(frame, width, height, comps, bpc, pAttribute); 455 return ctx->LoadFrameInfo(frame, width, height, comps, bpc, pAttribute);
455 } 456 }
456 457
457 bool CCodec_TiffModule::Decode(CCodec_TiffContext* ctx, 458 bool CCodec_TiffModule::Decode(CCodec_TiffContext* ctx,
458 class CFX_DIBitmap* pDIBitmap) { 459 class CFX_DIBitmap* pDIBitmap) {
459 return ctx->Decode(pDIBitmap); 460 return ctx->Decode(pDIBitmap);
460 } 461 }
461 462
462 void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) { 463 void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) {
463 delete ctx; 464 delete ctx;
464 } 465 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_progress.cpp ('k') | core/fxcrt/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698