summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
diff options
context:
space:
mode:
authorcaryclark <caryclark@google.com>2016-07-06 10:20:25 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-06 10:20:25 -0700
commita27d49a3e9eafd7fd911a0a6039ce80284ccb463 (patch)
tree73fbb66b229652524c21c956e25f88e42d37be88 /core/fpdfapi/fpdf_render/fpdf_render_image.cpp
parentc4dedf32b1f5c71740df5be2a9b1446a01df304c (diff)
downloadpdfium-a27d49a3e9eafd7fd911a0a6039ce80284ccb463.tar.xz
copy graphics state fully
The dash parameters where not copied; the copy could point at random data and cause corpus tests to hang when testing Skia. PDFium measures text directly by calling FreeType. Turn off hinting altogether in Skia so that drawn text matches the metrics that PDFium measures. Premultiply bits retrieved from images, and check to see that the device bits are always premultiplied. Look for null graphics state and matrices. R=thestig@chromium.org,dsinclair@chromium.org BUG=pdfium:532 Review-Url: https://codereview.chromium.org/2120353004
Diffstat (limited to 'core/fpdfapi/fpdf_render/fpdf_render_image.cpp')
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 10fd5f3f15..b9826a9338 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -63,8 +63,7 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
#endif
}
#ifdef _SKIA_SUPPORT_
- static_cast<CFX_SkiaDeviceDriver*>(m_pDevice->GetDeviceDriver())
- ->PreMultiply(pDIBitmap);
+ CFX_SkiaDeviceDriver::PreMultiply(pDIBitmap);
#endif
if (m_pDevice->SetDIBits(pDIBitmap, left, top)) {
return;
@@ -717,7 +716,7 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() {
bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask);
bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap());
#ifdef _SKIA_SUPPORT_
- bitmap_device1.PreMultiply(); // convert unpremultiplied to premultiplied
+ CFX_SkiaDeviceDriver::PreMultiply(bitmap_device1.GetBitmap());
#endif
if (m_BitmapAlpha < 255) {
bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha);
@@ -737,6 +736,19 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
m_Flags |= RENDER_FORCE_DOWNSAMPLE;
}
}
+#ifdef _SKIA_SUPPORT_
+ CFX_DIBitmap* premultiplied = m_pDIBSource->Clone();
+ CFX_SkiaDeviceDriver::PreMultiply(premultiplied);
+ if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend(
+ premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
+ m_DeviceHandle, m_BlendType)) {
+ if (m_DeviceHandle) {
+ m_Status = 3;
+ return TRUE;
+ }
+ return FALSE;
+ }
+#else
if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend(
m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
m_DeviceHandle, m_BlendType)) {
@@ -746,6 +758,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
}
return FALSE;
}
+#endif
CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
FX_RECT image_rect = image_rect_f.GetOutterRect();
int dest_width = image_rect.Width();