From 342f6fa66f6d843fe07d9b6a133656f83c8d62f6 Mon Sep 17 00:00:00 2001 From: caryclark Date: Fri, 25 Mar 2016 14:08:26 -0700 Subject: support gradients and stroke+fill To draw paths that are stroked and filled with a pair of colors, reduce the fill by the width of the stroke. This is implemented with path ops subtracting the resolved stroke shape from the fill shape. This permits rendering the result without requiring an offscreen bitmap. The implementation for stroke+fill requires a new entry into the graphics engine, so a bit was added to device caps for that. Extract the gradient information out of the axial gradient function descriptions, and when possible, use Skia to draw the linear gradient directly. This requires making the function descriptions non-opaque, and adding a bit to device caps for another entry into the graphics engine. BUG= Review URL: https://codereview.chromium.org/1828283002 --- core/fxge/ge/fx_ge_device.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'core/fxge/ge') diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp index b8ddfec841..eefac5c033 100644 --- a/core/fxge/ge/fx_ge_device.cpp +++ b/core/fxge/ge/fx_ge_device.cpp @@ -109,6 +109,7 @@ void CFX_RenderDevice::UpdateClipBox() { m_ClipBox.right = m_Width; m_ClipBox.bottom = m_Height; } + FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, @@ -224,6 +225,31 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, } if ((fill_mode & 3) && fill_alpha && stroke_alpha < 0xff && (fill_mode & FX_FILL_STROKE)) { + if (m_RenderCaps & FXRC_FILLSTROKE_PATH) { + return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, + fill_color, stroke_color, fill_mode, + alpha_flag, pIccTransform, blend_type); + } + return DrawFillStrokePath(pPathData, pObject2Device, pGraphState, + fill_color, stroke_color, fill_mode, alpha_flag, + pIccTransform, blend_type); + } + return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, + fill_color, stroke_color, fill_mode, + alpha_flag, pIccTransform, blend_type); +} + +// This can be removed once PDFium entirely relies on Skia +FX_BOOL CFX_RenderDevice::DrawFillStrokePath( + const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + FX_DWORD fill_color, + FX_DWORD stroke_color, + int fill_mode, + int alpha_flag, + void* pIccTransform, + int blend_type) { if (!(m_RenderCaps & FXRC_GET_BITS)) { return FALSE; } @@ -272,11 +298,8 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, FXSYS_round(rect.Height() * fScaleY)); return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, rect.top, FXDIB_BLEND_NORMAL); - } - return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, - fill_color, stroke_color, fill_mode, - alpha_flag, pIccTransform, blend_type); } + FX_BOOL CFX_RenderDevice::SetPixel(int x, int y, FX_DWORD color, -- cgit v1.2.3