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

Side by Side Diff: core/fxge/win32/fx_win32_dib.cpp

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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/fxge/win32/fx_win32_device.cpp ('k') | core/fxge/win32/fx_win32_dwrite.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/include/fxge/fx_ge.h" 7 #include "core/include/fxge/fx_ge.h"
8 8
9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ 9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
10 #include <windows.h> 10 #include <windows.h>
11 11
12 #include "core/fxge/win32/win32_int.h" 12 #include "core/fxge/win32/win32_int.h"
13 #include "core/include/fxge/fx_ge_win32.h" 13 #include "core/include/fxge/fx_ge_win32.h"
14 14
15 CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) { 15 CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) {
16 CFX_ByteString result; 16 CFX_ByteString result;
17 int len = sizeof(BITMAPINFOHEADER); 17 int len = sizeof(BITMAPINFOHEADER);
18 if (pBitmap->GetBPP() == 1 || pBitmap->GetBPP() == 8) { 18 if (pBitmap->GetBPP() == 1 || pBitmap->GetBPP() == 8) {
19 len += sizeof(DWORD) * (int)(1 << pBitmap->GetBPP()); 19 len += sizeof(DWORD) * (int)(1 << pBitmap->GetBPP());
20 } 20 }
21 BITMAPINFOHEADER* pbmih = (BITMAPINFOHEADER*)result.GetBuffer(len); 21 BITMAPINFOHEADER* pbmih = (BITMAPINFOHEADER*)result.GetBuffer(len);
22 FXSYS_memset(pbmih, 0, sizeof(BITMAPINFOHEADER)); 22 FXSYS_memset(pbmih, 0, sizeof(BITMAPINFOHEADER));
23 pbmih->biSize = sizeof(BITMAPINFOHEADER); 23 pbmih->biSize = sizeof(BITMAPINFOHEADER);
24 pbmih->biBitCount = pBitmap->GetBPP(); 24 pbmih->biBitCount = pBitmap->GetBPP();
25 pbmih->biCompression = BI_RGB; 25 pbmih->biCompression = BI_RGB;
26 pbmih->biHeight = -(int)pBitmap->GetHeight(); 26 pbmih->biHeight = -(int)pBitmap->GetHeight();
27 pbmih->biPlanes = 1; 27 pbmih->biPlanes = 1;
28 pbmih->biWidth = pBitmap->GetWidth(); 28 pbmih->biWidth = pBitmap->GetWidth();
29 if (pBitmap->GetBPP() == 8) { 29 if (pBitmap->GetBPP() == 8) {
30 FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1); 30 uint32_t* pPalette = (uint32_t*)(pbmih + 1);
31 if (pBitmap->GetPalette()) { 31 if (pBitmap->GetPalette()) {
32 for (int i = 0; i < 256; i++) { 32 for (int i = 0; i < 256; i++) {
33 pPalette[i] = pBitmap->GetPalette()[i]; 33 pPalette[i] = pBitmap->GetPalette()[i];
34 } 34 }
35 } else { 35 } else {
36 for (int i = 0; i < 256; i++) { 36 for (int i = 0; i < 256; i++) {
37 pPalette[i] = i * 0x010101; 37 pPalette[i] = i * 0x010101;
38 } 38 }
39 } 39 }
40 } 40 }
41 if (pBitmap->GetBPP() == 1) { 41 if (pBitmap->GetBPP() == 1) {
42 FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1); 42 uint32_t* pPalette = (uint32_t*)(pbmih + 1);
43 if (pBitmap->GetPalette()) { 43 if (pBitmap->GetPalette()) {
44 pPalette[0] = pBitmap->GetPalette()[0]; 44 pPalette[0] = pBitmap->GetPalette()[0];
45 pPalette[1] = pBitmap->GetPalette()[1]; 45 pPalette[1] = pBitmap->GetPalette()[1];
46 } else { 46 } else {
47 pPalette[0] = 0; 47 pPalette[0] = 0;
48 pPalette[1] = 0xffffff; 48 pPalette[1] = 0xffffff;
49 } 49 }
50 } 50 }
51 result.ReleaseBuffer(len); 51 result.ReleaseBuffer(len);
52 return result; 52 return result;
(...skipping 28 matching lines...) Expand all
81 pBitmap->GetBuffer() + bottom * pitch, pitch); 81 pBitmap->GetBuffer() + bottom * pitch, pitch);
82 FXSYS_memcpy(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitch); 82 FXSYS_memcpy(pBitmap->GetBuffer() + bottom * pitch, temp_buf, pitch);
83 top++; 83 top++;
84 bottom--; 84 bottom--;
85 } 85 }
86 FX_Free(temp_buf); 86 FX_Free(temp_buf);
87 temp_buf = NULL; 87 temp_buf = NULL;
88 } 88 }
89 if (pbmi->bmiHeader.biBitCount == 1) { 89 if (pbmi->bmiHeader.biBitCount == 1) {
90 for (int i = 0; i < 2; i++) { 90 for (int i = 0; i < 2; i++) {
91 pBitmap->SetPaletteEntry(i, ((FX_DWORD*)pbmi->bmiColors)[i] | 0xff000000); 91 pBitmap->SetPaletteEntry(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000);
92 } 92 }
93 } else if (pbmi->bmiHeader.biBitCount == 8) { 93 } else if (pbmi->bmiHeader.biBitCount == 8) {
94 for (int i = 0; i < 256; i++) { 94 for (int i = 0; i < 256; i++) {
95 pBitmap->SetPaletteEntry(i, ((FX_DWORD*)pbmi->bmiColors)[i] | 0xff000000); 95 pBitmap->SetPaletteEntry(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000);
96 } 96 }
97 } 97 }
98 return pBitmap; 98 return pBitmap;
99 } 99 }
100 CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) { 100 CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) {
101 return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE); 101 return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE);
102 } 102 }
103 HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) { 103 HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) {
104 CFX_ByteString info = GetBitmapInfo(pBitmap); 104 CFX_ByteString info = GetBitmapInfo(pBitmap);
105 HBITMAP hBitmap = NULL; 105 HBITMAP hBitmap = NULL;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); 175 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS);
176 if (!ret) { 176 if (!ret) {
177 delete pDIBitmap; 177 delete pDIBitmap;
178 pDIBitmap = NULL; 178 pDIBitmap = NULL;
179 } 179 }
180 DeleteDC(hDC); 180 DeleteDC(hDC);
181 return pDIBitmap; 181 return pDIBitmap;
182 } 182 }
183 CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, 183 CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC,
184 HBITMAP hBitmap, 184 HBITMAP hBitmap,
185 FX_DWORD* pPalette, 185 uint32_t* pPalette,
186 FX_DWORD palsize) { 186 uint32_t palsize) {
187 FX_BOOL bCreatedDC = !hDC; 187 FX_BOOL bCreatedDC = !hDC;
188 if (bCreatedDC) { 188 if (bCreatedDC) {
189 hDC = CreateCompatibleDC(NULL); 189 hDC = CreateCompatibleDC(NULL);
190 } 190 }
191 BITMAPINFOHEADER bmih; 191 BITMAPINFOHEADER bmih;
192 FXSYS_memset(&bmih, 0, sizeof bmih); 192 FXSYS_memset(&bmih, 0, sizeof bmih);
193 bmih.biSize = sizeof bmih; 193 bmih.biSize = sizeof bmih;
194 GetDIBits(hDC, hBitmap, 0, 0, NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS); 194 GetDIBits(hDC, hBitmap, 0, 0, NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS);
195 int width = bmih.biWidth; 195 int width = bmih.biWidth;
196 int height = abs(bmih.biHeight); 196 int height = abs(bmih.biHeight);
197 bmih.biHeight = -height; 197 bmih.biHeight = -height;
198 bmih.biCompression = BI_RGB; 198 bmih.biCompression = BI_RGB;
199 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; 199 CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;
200 int ret = 0; 200 int ret = 0;
201 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) { 201 if (bmih.biBitCount == 1 || bmih.biBitCount == 8) {
202 int size = sizeof(BITMAPINFOHEADER) + 8; 202 int size = sizeof(BITMAPINFOHEADER) + 8;
203 if (bmih.biBitCount == 8) { 203 if (bmih.biBitCount == 8) {
204 size += sizeof(FX_DWORD) * 254; 204 size += sizeof(uint32_t) * 254;
205 } 205 }
206 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(uint8_t, size); 206 BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(uint8_t, size);
207 pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 207 pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
208 pbmih->bmiHeader.biBitCount = bmih.biBitCount; 208 pbmih->bmiHeader.biBitCount = bmih.biBitCount;
209 pbmih->bmiHeader.biCompression = BI_RGB; 209 pbmih->bmiHeader.biCompression = BI_RGB;
210 pbmih->bmiHeader.biHeight = -height; 210 pbmih->bmiHeader.biHeight = -height;
211 pbmih->bmiHeader.biPlanes = 1; 211 pbmih->bmiHeader.biPlanes = 1;
212 pbmih->bmiHeader.biWidth = bmih.biWidth; 212 pbmih->bmiHeader.biWidth = bmih.biWidth;
213 if (!pDIBitmap->Create(bmih.biWidth, height, bmih.biBitCount == 1 213 if (!pDIBitmap->Create(bmih.biWidth, height, bmih.biBitCount == 1
214 ? FXDIB_1bppRgb 214 ? FXDIB_1bppRgb
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 DeleteDC(m_hMemDC); 280 DeleteDC(m_hMemDC);
281 DeleteObject(m_hBitmap); 281 DeleteObject(m_hBitmap);
282 } 282 }
283 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) { 283 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) {
284 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); 284 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY);
285 } 285 }
286 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) { 286 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) {
287 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); 287 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY);
288 } 288 }
289 #endif 289 #endif
OLDNEW
« no previous file with comments | « core/fxge/win32/fx_win32_device.cpp ('k') | core/fxge/win32/fx_win32_dwrite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698