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

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

Issue 1876023003: Remove ICodec_* Interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « core/fxcodec/codec/fx_codec.cpp ('k') | core/fxcodec/codec/fx_codec_fax.cpp » ('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/include/fx_codec.h" 8 #include "core/fxcodec/include/fx_codec.h"
9 #include "core/fxcodec/lbmp/fx_bmp.h" 9 #include "core/fxcodec/lbmp/fx_bmp.h"
10 #include "core/fxge/include/fx_dib.h" 10 #include "core/fxge/include/fx_dib.h"
(...skipping 24 matching lines...) Expand all
35 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; 35 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr;
36 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; 36 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr;
37 pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf); 37 pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf);
38 } 38 }
39 static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, 39 static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr,
40 uint32_t rcd_pos) { 40 uint32_t rcd_pos) {
41 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; 41 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr;
42 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; 42 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr;
43 return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos); 43 return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos);
44 } 44 }
45 void* CCodec_BmpModule::Start(void* pModule) { 45
46 FXBMP_Context* p = (FXBMP_Context*)FX_Alloc(uint8_t, sizeof(FXBMP_Context)); 46 FXBMP_Context* CCodec_BmpModule::Start(void* pModule) {
47 if (p == NULL) { 47 FXBMP_Context* p = FX_Alloc(FXBMP_Context, 1);
48 return NULL; 48 if (!p)
49 } 49 return nullptr;
50
50 FXSYS_memset(p, 0, sizeof(FXBMP_Context)); 51 FXSYS_memset(p, 0, sizeof(FXBMP_Context));
51 if (p == NULL) { 52 if (!p)
52 return NULL; 53 return nullptr;
53 } 54
54 p->m_AllocFunc = bmp_alloc_func; 55 p->m_AllocFunc = bmp_alloc_func;
55 p->m_FreeFunc = bmp_free_func; 56 p->m_FreeFunc = bmp_free_func;
56 p->bmp_ptr = NULL; 57 p->bmp_ptr = nullptr;
57 p->parent_ptr = (void*)this; 58 p->parent_ptr = (void*)this;
58 p->child_ptr = pModule; 59 p->child_ptr = pModule;
59 p->bmp_ptr = bmp_create_decompress(); 60 p->bmp_ptr = bmp_create_decompress();
60 if (p->bmp_ptr == NULL) { 61 if (!p->bmp_ptr) {
61 FX_Free(p); 62 FX_Free(p);
62 return NULL; 63 return nullptr;
63 } 64 }
64 p->bmp_ptr->context_ptr = (void*)p; 65 p->bmp_ptr->context_ptr = (void*)p;
65 p->bmp_ptr->err_ptr = m_szLastError; 66 p->bmp_ptr->err_ptr = m_szLastError;
66 p->bmp_ptr->bmp_error_fn = bmp_error_data; 67 p->bmp_ptr->bmp_error_fn = bmp_error_data;
67 p->bmp_ptr->bmp_get_row_fn = bmp_read_scanline; 68 p->bmp_ptr->bmp_get_row_fn = bmp_read_scanline;
68 p->bmp_ptr->bmp_get_data_position_fn = bmp_get_data_position; 69 p->bmp_ptr->bmp_get_data_position_fn = bmp_get_data_position;
69 return p; 70 return p;
70 } 71 }
71 void CCodec_BmpModule::Finish(void* pContext) { 72
72 FXBMP_Context* p = (FXBMP_Context*)pContext; 73 void CCodec_BmpModule::Finish(FXBMP_Context* ctx) {
73 if (p) { 74 if (ctx) {
74 bmp_destroy_decompress(&p->bmp_ptr); 75 bmp_destroy_decompress(&ctx->bmp_ptr);
75 p->m_FreeFunc(p); 76 ctx->m_FreeFunc(ctx);
76 } 77 }
77 } 78 }
78 int32_t CCodec_BmpModule::ReadHeader(void* pContext, 79 int32_t CCodec_BmpModule::ReadHeader(FXBMP_Context* ctx,
79 int32_t* width, 80 int32_t* width,
80 int32_t* height, 81 int32_t* height,
81 FX_BOOL* tb_flag, 82 FX_BOOL* tb_flag,
82 int32_t* components, 83 int32_t* components,
83 int32_t* pal_num, 84 int32_t* pal_num,
84 uint32_t** pal_pp, 85 uint32_t** pal_pp,
85 CFX_DIBAttribute* pAttribute) { 86 CFX_DIBAttribute* pAttribute) {
86 FXBMP_Context* p = (FXBMP_Context*)pContext; 87 if (setjmp(ctx->bmp_ptr->jmpbuf)) {
87 if (setjmp(p->bmp_ptr->jmpbuf)) {
88 return 0; 88 return 0;
89 } 89 }
90 int32_t ret = bmp_read_header(p->bmp_ptr); 90 int32_t ret = bmp_read_header(ctx->bmp_ptr);
91 if (ret != 1) { 91 if (ret != 1) {
92 return ret; 92 return ret;
93 } 93 }
94 *width = p->bmp_ptr->width; 94 *width = ctx->bmp_ptr->width;
95 *height = p->bmp_ptr->height; 95 *height = ctx->bmp_ptr->height;
96 *tb_flag = p->bmp_ptr->imgTB_flag; 96 *tb_flag = ctx->bmp_ptr->imgTB_flag;
97 *components = p->bmp_ptr->components; 97 *components = ctx->bmp_ptr->components;
98 *pal_num = p->bmp_ptr->pal_num; 98 *pal_num = ctx->bmp_ptr->pal_num;
99 *pal_pp = p->bmp_ptr->pal_ptr; 99 *pal_pp = ctx->bmp_ptr->pal_ptr;
100 if (pAttribute) { 100 if (pAttribute) {
101 pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER; 101 pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER;
102 pAttribute->m_nXDPI = p->bmp_ptr->dpi_x; 102 pAttribute->m_nXDPI = ctx->bmp_ptr->dpi_x;
103 pAttribute->m_nYDPI = p->bmp_ptr->dpi_y; 103 pAttribute->m_nYDPI = ctx->bmp_ptr->dpi_y;
104 pAttribute->m_nBmpCompressType = p->bmp_ptr->compress_flag; 104 pAttribute->m_nBmpCompressType = ctx->bmp_ptr->compress_flag;
105 } 105 }
106 return 1; 106 return 1;
107 } 107 }
108 int32_t CCodec_BmpModule::LoadImage(void* pContext) { 108
109 FXBMP_Context* p = (FXBMP_Context*)pContext; 109 int32_t CCodec_BmpModule::LoadImage(FXBMP_Context* ctx) {
110 if (setjmp(p->bmp_ptr->jmpbuf)) { 110 if (setjmp(ctx->bmp_ptr->jmpbuf))
111 return 0; 111 return 0;
112 } 112 return bmp_decode_image(ctx->bmp_ptr);
113 return bmp_decode_image(p->bmp_ptr);
114 } 113 }
115 uint32_t CCodec_BmpModule::GetAvailInput(void* pContext, 114
115 uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx,
116 uint8_t** avial_buf_ptr) { 116 uint8_t** avial_buf_ptr) {
117 FXBMP_Context* p = (FXBMP_Context*)pContext; 117 return bmp_get_avail_input(ctx->bmp_ptr, avial_buf_ptr);
118 return bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr);
119 } 118 }
120 void CCodec_BmpModule::Input(void* pContext, 119
120 void CCodec_BmpModule::Input(FXBMP_Context* ctx,
121 const uint8_t* src_buf, 121 const uint8_t* src_buf,
122 uint32_t src_size) { 122 uint32_t src_size) {
123 FXBMP_Context* p = (FXBMP_Context*)pContext; 123 bmp_input_buffer(ctx->bmp_ptr, (uint8_t*)src_buf, src_size);
124 bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size);
125 } 124 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec.cpp ('k') | core/fxcodec/codec/fx_codec_fax.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698