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

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

Issue 2060913003: Make code compile with clang_use_chrome_plugin (part II) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 6 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/fxge/include/fx_ge.h" 7 #include "core/fxge/include/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>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
53 } 53 }
54
54 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, 55 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
55 LPVOID pData, 56 LPVOID pData,
56 FX_BOOL bAlpha) { 57 FX_BOOL bAlpha) {
57 int width = pbmi->bmiHeader.biWidth; 58 int width = pbmi->bmiHeader.biWidth;
58 int height = pbmi->bmiHeader.biHeight; 59 int height = pbmi->bmiHeader.biHeight;
59 BOOL bBottomUp = TRUE; 60 BOOL bBottomUp = TRUE;
60 if (height < 0) { 61 if (height < 0) {
61 height = -height; 62 height = -height;
62 bBottomUp = FALSE; 63 bBottomUp = FALSE;
63 } 64 }
(...skipping 26 matching lines...) Expand all
90 for (int i = 0; i < 2; i++) { 91 for (int i = 0; i < 2; i++) {
91 pBitmap->SetPaletteEntry(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000); 92 pBitmap->SetPaletteEntry(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000);
92 } 93 }
93 } else if (pbmi->bmiHeader.biBitCount == 8) { 94 } else if (pbmi->bmiHeader.biBitCount == 8) {
94 for (int i = 0; i < 256; i++) { 95 for (int i = 0; i < 256; i++) {
95 pBitmap->SetPaletteEntry(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000); 96 pBitmap->SetPaletteEntry(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000);
96 } 97 }
97 } 98 }
98 return pBitmap; 99 return pBitmap;
99 } 100 }
101
100 CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) { 102 CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) {
101 return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE); 103 return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE);
102 } 104 }
105
103 HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) { 106 HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) {
104 CFX_ByteString info = GetBitmapInfo(pBitmap); 107 CFX_ByteString info = GetBitmapInfo(pBitmap);
105 return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, 108 return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT,
106 pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), 109 pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(),
107 DIB_RGB_COLORS); 110 DIB_RGB_COLORS);
108 } 111 }
112
109 void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) { 113 void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) {
110 BITMAP bmp; 114 BITMAP bmp;
111 GetObject(hBitmap, sizeof bmp, &bmp); 115 GetObject(hBitmap, sizeof bmp, &bmp);
112 w = bmp.bmWidth; 116 w = bmp.bmWidth;
113 h = bmp.bmHeight; 117 h = bmp.bmHeight;
114 } 118 }
119
115 CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) { 120 CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) {
116 CWin32Platform* pPlatform = 121 CWin32Platform* pPlatform =
117 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); 122 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
118 if (pPlatform->m_GdiplusExt.IsAvailable()) { 123 if (pPlatform->m_GdiplusExt.IsAvailable()) {
119 WINDIB_Open_Args_ args; 124 WINDIB_Open_Args_ args;
120 args.flags = WINDIB_OPEN_PATHNAME; 125 args.flags = WINDIB_OPEN_PATHNAME;
121 args.path_name = filename; 126 args.path_name = filename;
122 return pPlatform->m_GdiplusExt.LoadDIBitmap(args); 127 return pPlatform->m_GdiplusExt.LoadDIBitmap(args);
123 } 128 }
124 HBITMAP hBitmap = (HBITMAP)LoadImageW(nullptr, (wchar_t*)filename, 129 HBITMAP hBitmap = (HBITMAP)LoadImageW(nullptr, (wchar_t*)filename,
(...skipping 13 matching lines...) Expand all
138 CFX_ByteString info = GetBitmapInfo(pDIBitmap); 143 CFX_ByteString info = GetBitmapInfo(pDIBitmap);
139 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), 144 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(),
140 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); 145 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS);
141 if (!ret) { 146 if (!ret) {
142 delete pDIBitmap; 147 delete pDIBitmap;
143 pDIBitmap = nullptr; 148 pDIBitmap = nullptr;
144 } 149 }
145 DeleteDC(hDC); 150 DeleteDC(hDC);
146 return pDIBitmap; 151 return pDIBitmap;
147 } 152 }
153
154 CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_CHAR* filename) {
155 return LoadFromFile(CFX_WideString::FromLocal(filename).c_str());
156 }
157
148 CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) { 158 CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) {
149 CWin32Platform* pPlatform = 159 CWin32Platform* pPlatform =
150 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); 160 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
151 if (pPlatform->m_GdiplusExt.IsAvailable()) { 161 if (pPlatform->m_GdiplusExt.IsAvailable()) {
152 return pPlatform->m_GdiplusExt.LoadDIBitmap(args); 162 return pPlatform->m_GdiplusExt.LoadDIBitmap(args);
153 } 163 }
154 if (args.flags == WINDIB_OPEN_MEMORY) { 164 if (args.flags == WINDIB_OPEN_MEMORY) {
155 return nullptr; 165 return nullptr;
156 } 166 }
157 HBITMAP hBitmap = (HBITMAP)LoadImageW(nullptr, (wchar_t*)args.path_name, 167 HBITMAP hBitmap = (HBITMAP)LoadImageW(nullptr, (wchar_t*)args.path_name,
(...skipping 13 matching lines...) Expand all
171 CFX_ByteString info = GetBitmapInfo(pDIBitmap); 181 CFX_ByteString info = GetBitmapInfo(pDIBitmap);
172 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), 182 int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(),
173 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); 183 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS);
174 if (!ret) { 184 if (!ret) {
175 delete pDIBitmap; 185 delete pDIBitmap;
176 pDIBitmap = nullptr; 186 pDIBitmap = nullptr;
177 } 187 }
178 DeleteDC(hDC); 188 DeleteDC(hDC);
179 return pDIBitmap; 189 return pDIBitmap;
180 } 190 }
191
181 CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, 192 CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC,
182 HBITMAP hBitmap, 193 HBITMAP hBitmap,
183 uint32_t* pPalette, 194 uint32_t* pPalette,
184 uint32_t palsize) { 195 uint32_t palsize) {
185 FX_BOOL bCreatedDC = !hDC; 196 FX_BOOL bCreatedDC = !hDC;
186 if (bCreatedDC) { 197 if (bCreatedDC) {
187 hDC = CreateCompatibleDC(nullptr); 198 hDC = CreateCompatibleDC(nullptr);
188 } 199 }
189 BITMAPINFOHEADER bmih; 200 BITMAPINFOHEADER bmih;
190 FXSYS_memset(&bmih, 0, sizeof bmih); 201 FXSYS_memset(&bmih, 0, sizeof bmih);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 263 }
253 if (ret == 0) { 264 if (ret == 0) {
254 delete pDIBitmap; 265 delete pDIBitmap;
255 pDIBitmap = nullptr; 266 pDIBitmap = nullptr;
256 } 267 }
257 if (bCreatedDC) { 268 if (bCreatedDC) {
258 DeleteDC(hDC); 269 DeleteDC(hDC);
259 } 270 }
260 return pDIBitmap; 271 return pDIBitmap;
261 } 272 }
273
262 CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) { 274 CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) {
263 Create(width, height, FXDIB_Rgb, (uint8_t*)1); 275 Create(width, height, FXDIB_Rgb, (uint8_t*)1);
264 BITMAPINFOHEADER bmih; 276 BITMAPINFOHEADER bmih;
265 FXSYS_memset(&bmih, 0, sizeof bmih); 277 FXSYS_memset(&bmih, 0, sizeof bmih);
266 bmih.biSize = sizeof bmih; 278 bmih.biSize = sizeof bmih;
267 bmih.biBitCount = 24; 279 bmih.biBitCount = 24;
268 bmih.biHeight = -height; 280 bmih.biHeight = -height;
269 bmih.biPlanes = 1; 281 bmih.biPlanes = 1;
270 bmih.biWidth = width; 282 bmih.biWidth = width;
271 m_hBitmap = CreateDIBSection(hDC, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, 283 m_hBitmap = CreateDIBSection(hDC, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
272 (LPVOID*)&m_pBuffer, nullptr, 0); 284 (LPVOID*)&m_pBuffer, nullptr, 0);
273 m_hMemDC = CreateCompatibleDC(hDC); 285 m_hMemDC = CreateCompatibleDC(hDC);
274 m_hOldBitmap = (HBITMAP)SelectObject(m_hMemDC, m_hBitmap); 286 m_hOldBitmap = (HBITMAP)SelectObject(m_hMemDC, m_hBitmap);
275 } 287 }
288
276 CFX_WindowsDIB::~CFX_WindowsDIB() { 289 CFX_WindowsDIB::~CFX_WindowsDIB() {
277 SelectObject(m_hMemDC, m_hOldBitmap); 290 SelectObject(m_hMemDC, m_hOldBitmap);
278 DeleteDC(m_hMemDC); 291 DeleteDC(m_hMemDC);
279 DeleteObject(m_hBitmap); 292 DeleteObject(m_hBitmap);
280 } 293 }
294
281 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) { 295 void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) {
282 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY); 296 ::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY);
283 } 297 }
298
284 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) { 299 void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) {
285 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY); 300 ::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY);
286 } 301 }
287 #endif 302 #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