summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfview.cpp
diff options
context:
space:
mode:
authorrbpotter <rbpotter@chromium.org>2017-08-16 16:45:44 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-08-17 00:06:48 +0000
commit8d7672e941fa58326c4c6aeac47418e9b36527e9 (patch)
treefd24ca408405e8e47fe508dd9e673bdfaca74d3c /fpdfsdk/fpdfview.cpp
parent574015e0ad53c592fe8a923390b31edeb30c41fe (diff)
downloadpdfium-8d7672e941fa58326c4c6aeac47418e9b36527e9.tar.xz
Fix some issues with individual image mask rendering
Re-enable individual image mask rendering to improve spool sizes, with bug fixes and improvements: - Fix bug with missing images by ensuring all masks are recorded - Fix printing to landscape paper sizes - Improve spool sizes by processing the location of the masks in the progressive renderer when rendering to the printer instead of needlessly fully rendering them (they will be rendered as bitmaps anyway). Bug: chromium:753700 Change-Id: I86bdcce9f10855274c56ba2ddae2c2522b36426d Reviewed-on: https://pdfium-review.googlesource.com/11115 Commit-Queue: Rebekah Potter <rbpotter@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfview.cpp')
-rw-r--r--fpdfsdk/fpdfview.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index 51d9c9f6a3..964d769d2b 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -765,6 +765,9 @@ FX_RECT GetMaskDimensionsAndOffsets(CPDF_Page* pPage,
// Compute offsets
int offset_x = 0;
int offset_y = 0;
+ if (size_x > size_y)
+ std::swap(size_x_bm, size_y_bm);
+
switch ((rotate + page_rotation) % 4) {
case 0:
offset_x = start_x_bm + start_x;
@@ -829,9 +832,8 @@ void RenderBitmap(CFX_RenderDevice* device,
FXDIB_BLEND_NORMAL, nullptr, false);
if (device->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) {
- device->StretchDIBitsWithFlagsAndBlend(pDst, mask_area.left, mask_area.top,
- size_x_bm, size_y_bm, 0,
- FXDIB_BLEND_NORMAL);
+ device->StretchDIBits(pDst, mask_area.left, mask_area.top, size_x_bm,
+ size_y_bm);
} else {
device->SetDIBits(pDst, mask_area.left, mask_area.top);
}
@@ -854,16 +856,14 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc,
CPDF_PageRenderContext* pContext = pPage->GetRenderContext();
CFX_RetainPtr<CFX_DIBitmap> pBitmap;
- // TODO(rbpotter): Restore the behavior described below after resolving
- // crbug.com/753700
// Don't render the full page to bitmap for a mask unless there are a lot
// of masks. Full page bitmaps result in large spool sizes, so they should
// only be used when necessary. For large numbers of masks, rendering each
// individually is inefficient and unlikely to significantly improve spool
- // size. This fix is temporarily disabled due to crbug.com/753700 so all
- // image masks will result in the full page rendering as bitmap.
+ // size.
const bool bNewBitmap =
- pPage->BackgroundAlphaNeeded() || pPage->HasImageMask();
+ pPage->BackgroundAlphaNeeded() ||
+ (pPage->HasImageMask() && pPage->GetMaskBoundingBoxes().size() > 100);
const bool bHasMask = pPage->HasImageMask() && !bNewBitmap;
if (bNewBitmap || bHasMask) {
pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();