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

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

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: 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/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 <windows.h> 7 #include <windows.h>
8 8
9 #include "core/fxcrt/fx_system.h" 9 #include "core/fxcrt/fx_system.h"
10 #include "core/fxge/cfx_gemodule.h" 10 #include "core/fxge/cfx_gemodule.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 pPalette[0] = 0; 46 pPalette[0] = 0;
47 pPalette[1] = 0xffffff; 47 pPalette[1] = 0xffffff;
48 } 48 }
49 } 49 }
50 result.ReleaseBuffer(len); 50 result.ReleaseBuffer(len);
51 return result; 51 return result;
52 } 52 }
53 53
54 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, 54 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
55 LPVOID pData, 55 LPVOID pData,
56 FX_BOOL bAlpha) { 56 bool bAlpha) {
57 int width = pbmi->bmiHeader.biWidth; 57 int width = pbmi->bmiHeader.biWidth;
58 int height = pbmi->bmiHeader.biHeight; 58 int height = pbmi->bmiHeader.biHeight;
59 BOOL bBottomUp = TRUE; 59 BOOL bBottomUp = true;
60 if (height < 0) { 60 if (height < 0) {
61 height = -height; 61 height = -height;
62 bBottomUp = FALSE; 62 bBottomUp = false;
63 } 63 }
64 int pitch = (width * pbmi->bmiHeader.biBitCount + 31) / 32 * 4; 64 int pitch = (width * pbmi->bmiHeader.biBitCount + 31) / 32 * 4;
65 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; 65 CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
66 FXDIB_Format format = bAlpha 66 FXDIB_Format format = bAlpha
67 ? (FXDIB_Format)(pbmi->bmiHeader.biBitCount + 0x200) 67 ? (FXDIB_Format)(pbmi->bmiHeader.biBitCount + 0x200)
68 : (FXDIB_Format)pbmi->bmiHeader.biBitCount; 68 : (FXDIB_Format)pbmi->bmiHeader.biBitCount;
69 FX_BOOL ret = pBitmap->Create(width, height, format); 69 bool ret = pBitmap->Create(width, height, format);
70 if (!ret) { 70 if (!ret) {
71 delete pBitmap; 71 delete pBitmap;
72 return nullptr; 72 return nullptr;
73 } 73 }
74 FXSYS_memcpy(pBitmap->GetBuffer(), pData, pitch * height); 74 FXSYS_memcpy(pBitmap->GetBuffer(), pData, pitch * height);
75 if (bBottomUp) { 75 if (bBottomUp) {
76 uint8_t* temp_buf = FX_Alloc(uint8_t, pitch); 76 uint8_t* temp_buf = FX_Alloc(uint8_t, pitch);
77 int top = 0, bottom = height - 1; 77 int top = 0, bottom = height - 1;
78 while (top < bottom) { 78 while (top < bottom) {
79 FXSYS_memcpy(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch); 79 FXSYS_memcpy(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch);
(...skipping 12 matching lines...) Expand all
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, ((uint32_t*)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 100
101 CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) { 101 CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) {
102 return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE); 102 return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, false);
103 } 103 }
104 104
105 HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) { 105 HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) {
106 CFX_ByteString info = GetBitmapInfo(pBitmap); 106 CFX_ByteString info = GetBitmapInfo(pBitmap);
107 return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, 107 return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT,
108 pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), 108 pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(),
109 DIB_RGB_COLORS); 109 DIB_RGB_COLORS);
110 } 110 }
111 111
112 void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) { 112 void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 DeleteObject(m_hBitmap); 209 DeleteObject(m_hBitmap);
210 } 210 }
211 211
212 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) { 212 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) {
213 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); 213 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY);
214 } 214 }
215 215
216 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) { 216 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) {
217 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); 217 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY);
218 } 218 }
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