From a27d49a3e9eafd7fd911a0a6039ce80284ccb463 Mon Sep 17 00:00:00 2001 From: caryclark Date: Wed, 6 Jul 2016 10:20:25 -0700 Subject: 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 --- core/fpdfapi/fpdf_render/fpdf_render_image.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi/fpdf_render/fpdf_render_image.cpp') 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(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(); -- cgit v1.2.3