| OLD | NEW |
| 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 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ | 13 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ |
| 14 #include <crtdbg.h> | 14 #include <crtdbg.h> |
| 15 | 15 |
| 16 #include "core/fxcodec/include/fx_codec.h" | 16 #include "core/fxcodec/include/fx_codec.h" |
| 17 #include "core/fxcrt/include/fx_memory.h" |
| 17 | 18 |
| 18 #ifndef _SKIA_SUPPORT_ | 19 #ifndef _SKIA_SUPPORT_ |
| 19 #include "core/fxge/agg/fx_agg_driver.h" | 20 #include "core/fxge/agg/fx_agg_driver.h" |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 #include "core/fxge/dib/dib_int.h" | 23 #include "core/fxge/dib/dib_int.h" |
| 23 #include "core/fxge/ge/fx_text_int.h" | 24 #include "core/fxge/ge/fx_text_int.h" |
| 24 #include "core/fxge/include/fx_font.h" | 25 #include "core/fxge/include/fx_font.h" |
| 25 #include "core/fxge/include/fx_freetype.h" | 26 #include "core/fxge/include/fx_freetype.h" |
| 26 #include "core/fxge/include/fx_ge_win32.h" | 27 #include "core/fxge/include/fx_ge_win32.h" |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 !GetDIBits(&bitmap, left, top) || | 1247 !GetDIBits(&bitmap, left, top) || |
| 1247 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, | 1248 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, |
| 1248 pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, | 1249 pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, |
| 1249 FALSE, nullptr)) { | 1250 FALSE, nullptr)) { |
| 1250 return FALSE; | 1251 return FALSE; |
| 1251 } | 1252 } |
| 1252 FX_RECT src_rect(0, 0, width, height); | 1253 FX_RECT src_rect(0, 0, width, height); |
| 1253 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); | 1254 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); |
| 1254 } | 1255 } |
| 1255 CFX_DIBExtractor temp(pSource); | 1256 CFX_DIBExtractor temp(pSource); |
| 1256 CFX_DIBitmap* pBitmap = temp; | 1257 CFX_DIBitmap* pBitmap = temp.GetBitmap(); |
| 1257 if (!pBitmap) | 1258 if (!pBitmap) |
| 1258 return FALSE; | 1259 return FALSE; |
| 1259 return GDI_SetDIBits(pBitmap, pSrcRect, left, top); | 1260 return GDI_SetDIBits(pBitmap, pSrcRect, left, top); |
| 1260 } | 1261 } |
| 1261 | 1262 |
| 1262 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, | 1263 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, |
| 1263 uint32_t color, | 1264 uint32_t color, |
| 1264 int dest_left, | 1265 int dest_left, |
| 1265 int dest_top, | 1266 int dest_top, |
| 1266 int dest_width, | 1267 int dest_width, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 FX_RECT src_rect(0, 0, clip_width, clip_height); | 1329 FX_RECT src_rect(0, 0, clip_width, clip_height); |
| 1329 return SetDIBits(&background, 0, &src_rect, | 1330 return SetDIBits(&background, 0, &src_rect, |
| 1330 image_rect.left + clip_rect.left, | 1331 image_rect.left + clip_rect.left, |
| 1331 image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL); | 1332 image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL); |
| 1332 } | 1333 } |
| 1333 if (pSource->HasAlpha()) { | 1334 if (pSource->HasAlpha()) { |
| 1334 CWin32Platform* pPlatform = | 1335 CWin32Platform* pPlatform = |
| 1335 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); | 1336 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); |
| 1336 if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) { | 1337 if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) { |
| 1337 CFX_DIBExtractor temp(pSource); | 1338 CFX_DIBExtractor temp(pSource); |
| 1338 CFX_DIBitmap* pBitmap = temp; | 1339 CFX_DIBitmap* pBitmap = temp.GetBitmap(); |
| 1339 if (!pBitmap) | 1340 if (!pBitmap) |
| 1340 return FALSE; | 1341 return FALSE; |
| 1341 return pPlatform->m_GdiplusExt.StretchDIBits( | 1342 return pPlatform->m_GdiplusExt.StretchDIBits( |
| 1342 m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, | 1343 m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, |
| 1343 pClipRect, flags); | 1344 pClipRect, flags); |
| 1344 } | 1345 } |
| 1345 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, | 1346 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, |
| 1346 dest_width, dest_height, pClipRect, flags); | 1347 dest_width, dest_height, pClipRect, flags); |
| 1347 } | 1348 } |
| 1348 CFX_DIBExtractor temp(pSource); | 1349 CFX_DIBExtractor temp(pSource); |
| 1349 CFX_DIBitmap* pBitmap = temp; | 1350 CFX_DIBitmap* pBitmap = temp.GetBitmap(); |
| 1350 if (!pBitmap) | 1351 if (!pBitmap) |
| 1351 return FALSE; | 1352 return FALSE; |
| 1352 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, | 1353 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, |
| 1353 dest_height, flags); | 1354 dest_height, flags); |
| 1354 } | 1355 } |
| 1355 | 1356 |
| 1356 FX_BOOL CGdiDisplayDriver::StartDIBits(const CFX_DIBSource* pBitmap, | 1357 FX_BOOL CGdiDisplayDriver::StartDIBits(const CFX_DIBSource* pBitmap, |
| 1357 int bitmap_alpha, | 1358 int bitmap_alpha, |
| 1358 uint32_t color, | 1359 uint32_t color, |
| 1359 const CFX_Matrix* pMatrix, | 1360 const CFX_Matrix* pMatrix, |
| 1360 uint32_t render_flags, | 1361 uint32_t render_flags, |
| 1361 void*& handle, | 1362 void*& handle, |
| 1362 int blend_type) { | 1363 int blend_type) { |
| 1363 return FALSE; | 1364 return FALSE; |
| 1364 } | 1365 } |
| 1365 | 1366 |
| 1366 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { | 1367 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { |
| 1367 SetDeviceDriver(CreateDriver(hDC)); | 1368 SetDeviceDriver(WrapUnique(CreateDriver(hDC))); |
| 1368 } | 1369 } |
| 1369 | 1370 |
| 1370 CFX_WindowsDevice::~CFX_WindowsDevice() {} | 1371 CFX_WindowsDevice::~CFX_WindowsDevice() {} |
| 1371 | 1372 |
| 1372 HDC CFX_WindowsDevice::GetDC() const { | 1373 HDC CFX_WindowsDevice::GetDC() const { |
| 1373 IFX_RenderDeviceDriver* pRDD = GetDeviceDriver(); | 1374 IFX_RenderDeviceDriver* pRDD = GetDeviceDriver(); |
| 1374 return pRDD ? reinterpret_cast<HDC>(pRDD->GetPlatformSurface()) : nullptr; | 1375 return pRDD ? reinterpret_cast<HDC>(pRDD->GetPlatformSurface()) : nullptr; |
| 1375 } | 1376 } |
| 1376 | 1377 |
| 1377 // static | 1378 // static |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1400 DIB_RGB_COLORS, &pBufferPtr, nullptr, 0); | 1401 DIB_RGB_COLORS, &pBufferPtr, nullptr, 0); |
| 1401 if (!m_hBitmap) | 1402 if (!m_hBitmap) |
| 1402 return; | 1403 return; |
| 1403 | 1404 |
| 1404 uint8_t* pBuffer = static_cast<uint8_t*>(pBufferPtr); | 1405 uint8_t* pBuffer = static_cast<uint8_t*>(pBufferPtr); |
| 1405 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 1406 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
| 1406 pBitmap->Create(width, height, format, pBuffer); | 1407 pBitmap->Create(width, height, format, pBuffer); |
| 1407 SetBitmap(pBitmap); | 1408 SetBitmap(pBitmap); |
| 1408 m_hDC = ::CreateCompatibleDC(nullptr); | 1409 m_hDC = ::CreateCompatibleDC(nullptr); |
| 1409 m_hOldBitmap = (HBITMAP)SelectObject(m_hDC, m_hBitmap); | 1410 m_hOldBitmap = (HBITMAP)SelectObject(m_hDC, m_hBitmap); |
| 1410 IFX_RenderDeviceDriver* pDriver = new CGdiDisplayDriver(m_hDC); | 1411 SetDeviceDriver(WrapUnique(new CGdiDisplayDriver(m_hDC))); |
| 1411 SetDeviceDriver(pDriver); | |
| 1412 } | 1412 } |
| 1413 | 1413 |
| 1414 CFX_WinBitmapDevice::~CFX_WinBitmapDevice() { | 1414 CFX_WinBitmapDevice::~CFX_WinBitmapDevice() { |
| 1415 if (m_hDC) { | 1415 if (m_hDC) { |
| 1416 SelectObject(m_hDC, m_hOldBitmap); | 1416 SelectObject(m_hDC, m_hOldBitmap); |
| 1417 DeleteDC(m_hDC); | 1417 DeleteDC(m_hDC); |
| 1418 } | 1418 } |
| 1419 if (m_hBitmap) | 1419 if (m_hBitmap) |
| 1420 DeleteObject(m_hBitmap); | 1420 DeleteObject(m_hBitmap); |
| 1421 delete GetBitmap(); | 1421 delete GetBitmap(); |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ | 1424 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ |
| OLD | NEW |