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

Side by Side Diff: fpdfsdk/fpdfview.cpp

Issue 2010813003: Remove default arguments from CFX_FxgeDevice. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@fxgeclean2_textrenderer
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 | « fpdfsdk/fpdfformfill.cpp ('k') | fpdfsdk/include/fsdk_define.h » ('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 "public/fpdfview.h" 7 #include "public/fpdfview.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { 69 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
70 #ifdef PDF_ENABLE_XFA 70 #ifdef PDF_ENABLE_XFA
71 return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr; 71 return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr;
72 #else // PDF_ENABLE_XFA 72 #else // PDF_ENABLE_XFA
73 return UnderlyingFromFPDFPage(page); 73 return UnderlyingFromFPDFPage(page);
74 #endif // PDF_ENABLE_XFA 74 #endif // PDF_ENABLE_XFA
75 } 75 }
76 76
77 CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) {
78 return static_cast<CFX_DIBitmap*>(bitmap);
79 }
80
77 #ifdef PDF_ENABLE_XFA 81 #ifdef PDF_ENABLE_XFA
78 CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) { 82 CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) {
79 m_pFS = pFS; 83 m_pFS = pFS;
80 m_nCurPos = 0; 84 m_nCurPos = 0;
81 } 85 }
82 86
83 IFX_FileStream* CFPDF_FileStream::Retain() { 87 IFX_FileStream* CFPDF_FileStream::Retain() {
84 return this; 88 return this;
85 } 89 }
86 90
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 CRenderContext* pContext = new CRenderContext; 541 CRenderContext* pContext = new CRenderContext;
538 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); 542 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
539 543
540 CFX_DIBitmap* pBitmap = nullptr; 544 CFX_DIBitmap* pBitmap = nullptr;
541 FX_BOOL bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); 545 FX_BOOL bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded();
542 FX_BOOL bHasImageMask = pPage->HasImageMask(); 546 FX_BOOL bHasImageMask = pPage->HasImageMask();
543 if (bBackgroundAlphaNeeded || bHasImageMask) { 547 if (bBackgroundAlphaNeeded || bHasImageMask) {
544 pBitmap = new CFX_DIBitmap; 548 pBitmap = new CFX_DIBitmap;
545 pBitmap->Create(size_x, size_y, FXDIB_Argb); 549 pBitmap->Create(size_x, size_y, FXDIB_Argb);
546 pBitmap->Clear(0x00ffffff); 550 pBitmap->Clear(0x00ffffff);
547 pContext->m_pDevice = new CFX_FxgeDevice; 551 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
548 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); 552 pContext->m_pDevice = pDevice;
553 pDevice->Attach(pBitmap, false, nullptr, false);
549 } else { 554 } else {
550 pContext->m_pDevice = new CFX_WindowsDevice(dc); 555 pContext->m_pDevice = new CFX_WindowsDevice(dc);
551 } 556 }
552 557
553 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, 558 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
554 rotate, flags, TRUE, NULL); 559 rotate, flags, TRUE, nullptr);
555 560
556 if (bBackgroundAlphaNeeded || bHasImageMask) { 561 if (bBackgroundAlphaNeeded || bHasImageMask) {
557 if (pBitmap) { 562 if (pBitmap) {
558 CFX_WindowsDevice WinDC(dc); 563 CFX_WindowsDevice WinDC(dc);
559 564
560 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { 565 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) {
561 CFX_DIBitmap* pDst = new CFX_DIBitmap; 566 CFX_DIBitmap* pDst = new CFX_DIBitmap;
562 int pitch = pBitmap->GetPitch(); 567 int pitch = pBitmap->GetPitch();
563 pDst->Create(size_x, size_y, FXDIB_Rgb32); 568 pDst->Create(size_x, size_y, FXDIB_Rgb32);
564 FXSYS_memset(pDst->GetBuffer(), -1, pitch * size_y); 569 FXSYS_memset(pDst->GetBuffer(), -1, pitch * size_y);
(...skipping 23 matching lines...) Expand all
588 int flags) { 593 int flags) {
589 if (!bitmap) 594 if (!bitmap)
590 return; 595 return;
591 596
592 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 597 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
593 if (!pPage) 598 if (!pPage)
594 return; 599 return;
595 600
596 CRenderContext* pContext = new CRenderContext; 601 CRenderContext* pContext = new CRenderContext;
597 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); 602 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
598 pContext->m_pDevice = new CFX_FxgeDevice; 603 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
599 if (flags & FPDF_REVERSE_BYTE_ORDER) { 604 pContext->m_pDevice = pDevice;
600 ((CFX_FxgeDevice*)pContext->m_pDevice) 605 CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap);
601 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); 606 pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false);
602 } else {
603 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
604 }
605 607
606 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, 608 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
607 rotate, flags, TRUE, nullptr); 609 rotate, flags, TRUE, nullptr);
608 610
609 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); 611 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
610 } 612 }
611 613
612 #ifdef _SKIA_SUPPORT_ 614 #ifdef _SKIA_SUPPORT_
613 DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, 615 DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
614 int size_x, 616 int size_x,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 766 }
765 767
766 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, 768 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
767 int left, 769 int left,
768 int top, 770 int top,
769 int width, 771 int width,
770 int height, 772 int height,
771 FPDF_DWORD color) { 773 FPDF_DWORD color) {
772 if (!bitmap) 774 if (!bitmap)
773 return; 775 return;
776
774 CFX_FxgeDevice device; 777 CFX_FxgeDevice device;
775 device.Attach((CFX_DIBitmap*)bitmap); 778 CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap);
776 if (!((CFX_DIBitmap*)bitmap)->HasAlpha()) 779 device.Attach(pBitmap, false, nullptr, false);
780 if (!pBitmap->HasAlpha())
777 color |= 0xFF000000; 781 color |= 0xFF000000;
778 FX_RECT rect(left, top, left + width, top + height); 782 FX_RECT rect(left, top, left + width, top + height);
779 device.FillRect(&rect, color); 783 device.FillRect(&rect, color);
780 } 784 }
781 785
782 DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) { 786 DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) {
783 return bitmap ? ((CFX_DIBitmap*)bitmap)->GetBuffer() : nullptr; 787 return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetBuffer() : nullptr;
784 } 788 }
785 789
786 DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap) { 790 DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap) {
787 return bitmap ? ((CFX_DIBitmap*)bitmap)->GetWidth() : 0; 791 return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetWidth() : 0;
788 } 792 }
789 793
790 DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap) { 794 DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap) {
791 return bitmap ? ((CFX_DIBitmap*)bitmap)->GetHeight() : 0; 795 return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetHeight() : 0;
792 } 796 }
793 797
794 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) { 798 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) {
795 return bitmap ? ((CFX_DIBitmap*)bitmap)->GetPitch() : 0; 799 return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetPitch() : 0;
796 } 800 }
797 801
798 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) { 802 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) {
799 delete (CFX_DIBitmap*)bitmap; 803 delete CFXBitmapFromFPDFBitmap(bitmap);
800 } 804 }
801 805
802 void FPDF_RenderPage_Retail(CRenderContext* pContext, 806 void FPDF_RenderPage_Retail(CRenderContext* pContext,
803 FPDF_PAGE page, 807 FPDF_PAGE page,
804 int start_x, 808 int start_x,
805 int start_y, 809 int start_y,
806 int size_x, 810 int size_x,
807 int size_y, 811 int size_y,
808 int rotate, 812 int rotate,
809 int flags, 813 int flags,
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 if (!buffer) { 1098 if (!buffer) {
1095 *buflen = len; 1099 *buflen = len;
1096 } else if (*buflen >= len) { 1100 } else if (*buflen >= len) {
1097 memcpy(buffer, utf16Name.c_str(), len); 1101 memcpy(buffer, utf16Name.c_str(), len);
1098 *buflen = len; 1102 *buflen = len;
1099 } else { 1103 } else {
1100 *buflen = -1; 1104 *buflen = -1;
1101 } 1105 }
1102 return (FPDF_DEST)pDestObj; 1106 return (FPDF_DEST)pDestObj;
1103 } 1107 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfformfill.cpp ('k') | fpdfsdk/include/fsdk_define.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698