| 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 "public/fpdfview.h" | 7 #include "public/fpdfview.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 int rotate, | 526 int rotate, |
| 527 int flags) { | 527 int flags) { |
| 528 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 528 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 529 if (!pPage) | 529 if (!pPage) |
| 530 return; | 530 return; |
| 531 | 531 |
| 532 CRenderContext* pContext = new CRenderContext; | 532 CRenderContext* pContext = new CRenderContext; |
| 533 pPage->SetPrivateData((void*)1, pContext, DropContext); | 533 pPage->SetPrivateData((void*)1, pContext, DropContext); |
| 534 | 534 |
| 535 #ifndef _WIN32_WCE | 535 #ifndef _WIN32_WCE |
| 536 CFX_DIBitmap* pBitmap = NULL; | 536 CFX_DIBitmap* pBitmap = nullptr; |
| 537 FX_BOOL bBackgroundAlphaNeeded = FALSE; | 537 FX_BOOL bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); |
| 538 bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); | 538 FX_BOOL bHasImageMask = pPage->HasImageMask(); |
| 539 if (bBackgroundAlphaNeeded) { | 539 if (bBackgroundAlphaNeeded || bHasImageMask) { |
| 540 pBitmap = new CFX_DIBitmap; | 540 pBitmap = new CFX_DIBitmap; |
| 541 pBitmap->Create(size_x, size_y, FXDIB_Argb); | 541 pBitmap->Create(size_x, size_y, FXDIB_Argb); |
| 542 pBitmap->Clear(0x00ffffff); | 542 pBitmap->Clear(0x00ffffff); |
| 543 #ifdef _SKIA_SUPPORT_ | 543 #ifdef _SKIA_SUPPORT_ |
| 544 pContext->m_pDevice = new CFX_SkiaDevice; | 544 pContext->m_pDevice = new CFX_SkiaDevice; |
| 545 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); | 545 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); |
| 546 #else | 546 #else |
| 547 pContext->m_pDevice = new CFX_FxgeDevice; | 547 pContext->m_pDevice = new CFX_FxgeDevice; |
| 548 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); | 548 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); |
| 549 #endif | 549 #endif |
| 550 } else | 550 } else { |
| 551 pContext->m_pDevice = new CFX_WindowsDevice(dc); | 551 pContext->m_pDevice = new CFX_WindowsDevice(dc); |
| 552 } |
| 552 | 553 |
| 553 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 554 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
| 554 rotate, flags, TRUE, NULL); | 555 rotate, flags, TRUE, NULL); |
| 555 | 556 |
| 556 if (bBackgroundAlphaNeeded) { | 557 if (bBackgroundAlphaNeeded || bHasImageMask) { |
| 557 if (pBitmap) { | 558 if (pBitmap) { |
| 558 CFX_WindowsDevice WinDC(dc); | 559 CFX_WindowsDevice WinDC(dc); |
| 559 | 560 |
| 560 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { | 561 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { |
| 561 CFX_DIBitmap* pDst = new CFX_DIBitmap; | 562 CFX_DIBitmap* pDst = new CFX_DIBitmap; |
| 562 int pitch = pBitmap->GetPitch(); | 563 int pitch = pBitmap->GetPitch(); |
| 563 pDst->Create(size_x, size_y, FXDIB_Rgb32); | 564 pDst->Create(size_x, size_y, FXDIB_Rgb32); |
| 564 FXSYS_memset(pDst->GetBuffer(), -1, pitch * size_y); | 565 FXSYS_memset(pDst->GetBuffer(), -1, pitch * size_y); |
| 565 pDst->CompositeBitmap(0, 0, size_x, size_y, pBitmap, 0, 0, | 566 pDst->CompositeBitmap(0, 0, size_x, size_y, pBitmap, 0, 0, |
| 566 FXDIB_BLEND_NORMAL, NULL, FALSE, NULL); | 567 FXDIB_BLEND_NORMAL, NULL, FALSE, NULL); |
| 567 WinDC.StretchDIBits(pDst, 0, 0, size_x, size_y); | 568 WinDC.StretchDIBits(pDst, 0, 0, size_x, size_y); |
| 568 delete pDst; | 569 delete pDst; |
| 569 } else | 570 } else { |
| 570 WinDC.SetDIBits(pBitmap, 0, 0); | 571 WinDC.SetDIBits(pBitmap, 0, 0); |
| 572 } |
| 571 } | 573 } |
| 572 } | 574 } |
| 573 #else | 575 #else |
| 574 // get clip region | 576 // get clip region |
| 575 RECT rect, cliprect; | 577 RECT rect, cliprect; |
| 576 rect.left = start_x; | 578 rect.left = start_x; |
| 577 rect.top = start_y; | 579 rect.top = start_y; |
| 578 rect.right = start_x + size_x; | 580 rect.right = start_x + size_x; |
| 579 rect.bottom = start_y + size_y; | 581 rect.bottom = start_y + size_y; |
| 580 GetClipBox(dc, &cliprect); | 582 GetClipBox(dc, &cliprect); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 | 663 |
| 662 BitBlt(dc, rect.left, rect.top, width, height, hMemDC, 0, 0, SRCCOPY); | 664 BitBlt(dc, rect.left, rect.top, width, height, hMemDC, 0, 0, SRCCOPY); |
| 663 SelectObject(hMemDC, hOldBitmap); | 665 SelectObject(hMemDC, hOldBitmap); |
| 664 DeleteDC(hMemDC); | 666 DeleteDC(hMemDC); |
| 665 | 667 |
| 666 #ifdef DEBUG_TRACE | 668 #ifdef DEBUG_TRACE |
| 667 CPDF_ModuleMgr::Get()->ReportError(999, "Finished screen rendering"); | 669 CPDF_ModuleMgr::Get()->ReportError(999, "Finished screen rendering"); |
| 668 #endif | 670 #endif |
| 669 | 671 |
| 670 #endif | 672 #endif |
| 671 if (bBackgroundAlphaNeeded) { | 673 if (bBackgroundAlphaNeeded || bHasImageMask) |
| 672 delete pBitmap; | 674 delete pBitmap; |
| 673 pBitmap = NULL; | 675 |
| 674 } | |
| 675 delete pContext; | 676 delete pContext; |
| 676 pPage->RemovePrivateData((void*)1); | 677 pPage->RemovePrivateData((void*)1); |
| 677 } | 678 } |
| 678 #endif | 679 #endif |
| 679 | 680 |
| 680 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, | 681 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, |
| 681 FPDF_PAGE page, | 682 FPDF_PAGE page, |
| 682 int start_x, | 683 int start_x, |
| 683 int start_y, | 684 int start_y, |
| 684 int size_x, | 685 int size_x, |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 if (!buffer) { | 1181 if (!buffer) { |
| 1181 *buflen = len; | 1182 *buflen = len; |
| 1182 } else if (*buflen >= len) { | 1183 } else if (*buflen >= len) { |
| 1183 memcpy(buffer, utf16Name.c_str(), len); | 1184 memcpy(buffer, utf16Name.c_str(), len); |
| 1184 *buflen = len; | 1185 *buflen = len; |
| 1185 } else { | 1186 } else { |
| 1186 *buflen = -1; | 1187 *buflen = -1; |
| 1187 } | 1188 } |
| 1188 return (FPDF_DEST)pDestObj; | 1189 return (FPDF_DEST)pDestObj; |
| 1189 } | 1190 } |
| OLD | NEW |