diff options
author | thestig <thestig@chromium.org> | 2016-05-26 11:04:40 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-26 11:04:40 -0700 |
commit | d3e354a43531eaed87e43d9ff2df4525186ea28d (patch) | |
tree | fe4ddb4219e7027f200eb240f18fdabfd70a9a4c /core/fxge/ge | |
parent | 41846a0fcc7d98476a18ec6c97778ead58069d99 (diff) | |
download | pdfium-d3e354a43531eaed87e43d9ff2df4525186ea28d.tar.xz |
Remove default arguments in CFX_RenderDevice.
Review-Url: https://codereview.chromium.org/2011943004
Diffstat (limited to 'core/fxge/ge')
-rw-r--r-- | core/fxge/ge/fx_ge_device.cpp | 239 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_text.cpp | 99 |
2 files changed, 137 insertions, 201 deletions
diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp index 2d3ba566be..d6c7b18b47 100644 --- a/core/fxge/ge/fx_ge_device.cpp +++ b/core/fxge/ge/fx_ge_device.cpp @@ -112,29 +112,16 @@ void CFX_RenderDevice::UpdateClipBox() { m_ClipBox.bottom = m_Height; } -FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - int fill_mode, - int alpha_flag, - void* pIccTransform, - int blend_type) { - uint8_t fill_alpha, stroke_alpha; - if (FXGETFLAG_COLORTYPE(alpha_flag)) { - fill_alpha = FXGETFLAG_ALPHA_FILL(alpha_flag); - stroke_alpha = FXGETFLAG_ALPHA_STROKE(alpha_flag); - } else { - fill_alpha = FXARGB_A(fill_color); - stroke_alpha = FXARGB_A(stroke_color); - } - if ((fill_mode & 3) == 0) { - fill_alpha = 0; - } - if (!pGraphState) { - stroke_alpha = 0; - } +FX_BOOL CFX_RenderDevice::DrawPathWithBlend( + const CFX_PathData* pPathData, + const CFX_Matrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + uint32_t stroke_color, + int fill_mode, + int blend_type) { + uint8_t stroke_alpha = pGraphState ? FXARGB_A(stroke_color) : 0; + uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0; if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) { FX_PATHPOINT* pPoints = pPathData->GetPoints(); FX_FLOAT x1, x2, y1, y2; @@ -149,8 +136,8 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, x2 = pPoints[1].m_PointX; y2 = pPoints[1].m_PointY; } - DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, alpha_flag, - pIccTransform, blend_type); + DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, fill_color, fill_mode, + blend_type); return TRUE; } if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && @@ -189,8 +176,7 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, rect_i.bottom--; } } - if (FillRect(&rect_i, fill_color, alpha_flag, pIccTransform, - blend_type)) { + if (FillRectWithBlend(&rect_i, fill_color, blend_type)) { return TRUE; } } @@ -205,12 +191,7 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, graphState.m_LineWidth = 0.0f; uint32_t strokecolor = fill_color; if (bThin) { - if (FXGETFLAG_COLORTYPE(alpha_flag)) { - FXSETFLAG_ALPHA_STROKE(alpha_flag, fill_alpha >> 2); - } else { - strokecolor = - (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); - } + strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); } CFX_Matrix* pMatrix = NULL; if (pObject2Device && !pObject2Device->IsIdentity()) { @@ -221,24 +202,22 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, smooth_path |= FXFILL_NOPATHSMOOTH; } m_pDeviceDriver->DrawPath(&newPath, pMatrix, &graphState, 0, strokecolor, - smooth_path, alpha_flag, pIccTransform, - blend_type); + smooth_path, 0, nullptr, blend_type); } } 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); + fill_color, stroke_color, fill_mode, 0, + nullptr, blend_type); } return DrawFillStrokePath(pPathData, pObject2Device, pGraphState, - fill_color, stroke_color, fill_mode, alpha_flag, - pIccTransform, blend_type); + fill_color, stroke_color, fill_mode, blend_type); } return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, - fill_color, stroke_color, fill_mode, - alpha_flag, pIccTransform, blend_type); + fill_color, stroke_color, fill_mode, 0, + nullptr, blend_type); } // This can be removed once PDFium entirely relies on Skia @@ -249,8 +228,6 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath( uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int alpha_flag, - void* pIccTransform, int blend_type) { if (!(m_RenderCaps & FXRC_GET_BITS)) { return FALSE; @@ -293,7 +270,7 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath( matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); if (!bitmap_device.GetDeviceDriver()->DrawPath( pPathData, &matrix, pGraphState, fill_color, stroke_color, - fill_mode, alpha_flag, pIccTransform, blend_type)) { + fill_mode, 0, nullptr, blend_type)) { return FALSE; } FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), @@ -302,38 +279,32 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath( rect.top, FXDIB_BLEND_NORMAL); } -FX_BOOL CFX_RenderDevice::SetPixel(int x, - int y, - uint32_t color, - int alpha_flag, - void* pIccTransform) { - if (m_pDeviceDriver->SetPixel(x, y, color, alpha_flag, pIccTransform)) { +FX_BOOL CFX_RenderDevice::SetPixel(int x, int y, uint32_t color) { + if (m_pDeviceDriver->SetPixel(x, y, color, 0, nullptr)) return TRUE; - } + FX_RECT rect(x, y, x + 1, y + 1); - return FillRect(&rect, color, alpha_flag, pIccTransform); + return FillRectWithBlend(&rect, color, FXDIB_BLEND_NORMAL); } -FX_BOOL CFX_RenderDevice::FillRect(const FX_RECT* pRect, - uint32_t fill_color, - int alpha_flag, - void* pIccTransform, - int blend_type) { - if (m_pDeviceDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform, - blend_type)) { + +FX_BOOL CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect, + uint32_t fill_color, + int blend_type) { + if (m_pDeviceDriver->FillRect(pRect, fill_color, 0, nullptr, blend_type)) return TRUE; - } - if (!(m_RenderCaps & FXRC_GET_BITS)) { + + if (!(m_RenderCaps & FXRC_GET_BITS)) return FALSE; - } + CFX_DIBitmap bitmap; - if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) { + if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) return FALSE; - } - if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) { + + if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) return FALSE; - } + if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, - alpha_flag, pIccTransform)) { + 0, nullptr)) { return FALSE; } FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); @@ -341,50 +312,42 @@ FX_BOOL CFX_RenderDevice::FillRect(const FX_RECT* pRect, FXDIB_BLEND_NORMAL); return TRUE; } -FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - uint32_t color, - int fill_mode, - int alpha_flag, - void* pIccTransform, - int blend_type) { - if (((m_RenderCaps & FXRC_ALPHA_PATH) && - (FXGETFLAG_COLORTYPE(alpha_flag) && - FXGETFLAG_ALPHA_FILL(alpha_flag) == 0xff)) || - color >= 0xff000000) { - if (m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, alpha_flag, - pIccTransform, blend_type)) { - return TRUE; - } + +FX_BOOL CFX_RenderDevice::DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + uint32_t color, + int fill_mode, + int blend_type) { + if ((color >= 0xff000000) && + m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, 0, nullptr, + blend_type)) { + return TRUE; } CFX_GraphStateData graph_state; CFX_PathData path; path.SetPointCount(2); path.SetPoint(0, x1, y1, FXPT_MOVETO); path.SetPoint(1, x2, y2, FXPT_LINETO); - return m_pDeviceDriver->DrawPath(&path, NULL, &graph_state, 0, color, - fill_mode, alpha_flag, pIccTransform, - blend_type); + return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, + fill_mode, 0, nullptr, blend_type); } -FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, - int left, - int top, - void* pIccTransform) { - if (!(m_RenderCaps & FXRC_GET_BITS)) { + +FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { + if (!(m_RenderCaps & FXRC_GET_BITS)) return FALSE; - } - return m_pDeviceDriver->GetDIBits(pBitmap, left, top, pIccTransform); + return m_pDeviceDriver->GetDIBits(pBitmap, left, top, nullptr); } + CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() { return m_pDeviceDriver->GetBackDrop(); } -FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, - int left, - int top, - int blend_mode, - void* pIccTransform) { + +FX_BOOL CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, + int left, + int top, + int blend_mode) { ASSERT(!pBitmap->IsAlphaMask()); CFX_Matrix ctm = GetCTM(); FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); @@ -422,7 +385,7 @@ FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, } if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height, pBitmap, src_rect.left, src_rect.top, - blend_mode, NULL, FALSE, pIccTransform)) { + blend_mode, nullptr, FALSE, nullptr)) { return FALSE; } FX_RECT src_rect(0, 0, bg_pixel_width, bg_pixel_height); @@ -430,70 +393,66 @@ FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, dest_rect.top, FXDIB_BLEND_NORMAL); } return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, - dest_rect.top, blend_mode, 0, - pIccTransform); + dest_rect.top, blend_mode, 0, nullptr); } -FX_BOOL CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t flags, - void* pIccTransform, - int blend_mode) { + +FX_BOOL CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend( + const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t flags, + int blend_mode) { FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); FX_RECT clip_box = m_ClipBox; clip_box.Intersect(dest_rect); - if (clip_box.IsEmpty()) { + if (clip_box.IsEmpty()) return TRUE; - } return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, dest_height, &clip_box, flags, 0, - pIccTransform, blend_mode); + nullptr, blend_mode); } + FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, int left, int top, - uint32_t argb, - int alpha_flag, - void* pIccTransform) { + uint32_t argb) { FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, - FXDIB_BLEND_NORMAL, alpha_flag, - pIccTransform); + FXDIB_BLEND_NORMAL, 0, nullptr); } -FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, - int left, - int top, - int dest_width, - int dest_height, - uint32_t argb, - uint32_t flags, - int alpha_flag, - void* pIccTransform) { + +FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, + int left, + int top, + int dest_width, + int dest_height, + uint32_t argb, + uint32_t flags) { FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); FX_RECT clip_box = m_ClipBox; clip_box.Intersect(dest_rect); return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, - dest_height, &clip_box, flags, - alpha_flag, pIccTransform); + dest_height, &clip_box, flags, 0, + nullptr); } -FX_BOOL CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, - int bitmap_alpha, - uint32_t argb, - const CFX_Matrix* pMatrix, - uint32_t flags, - void*& handle, - int alpha_flag, - void* pIccTransform, - int blend_mode) { + +FX_BOOL CFX_RenderDevice::StartDIBitsWithBlend(const CFX_DIBSource* pBitmap, + int bitmap_alpha, + uint32_t argb, + const CFX_Matrix* pMatrix, + uint32_t flags, + void*& handle, + int blend_mode) { return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, - flags, handle, alpha_flag, pIccTransform, - blend_mode); + flags, handle, 0, nullptr, blend_mode); } + FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { return m_pDeviceDriver->ContinueDIBits(handle, pPause); } + void CFX_RenderDevice::CancelDIBits(void* handle) { m_pDeviceDriver->CancelDIBits(handle); } diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index f2867aaf11..aeac66b4b0 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -427,9 +427,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, FX_FLOAT font_size, const CFX_Matrix* pText2Device, uint32_t fill_color, - uint32_t text_flags, - int alpha_flag, - void* pIccTransform) { + uint32_t text_flags) { int nativetext_flags = text_flags; if (m_DeviceClass != FXDC_DISPLAY) { if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { @@ -445,16 +443,12 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, if (should_call_draw_device_text && m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache, pText2Device, font_size, fill_color, - alpha_flag, pIccTransform)) { + 0, nullptr)) { return TRUE; } } - int alpha = FXGETFLAG_COLORTYPE(alpha_flag) - ? FXGETFLAG_ALPHA_FILL(alpha_flag) - : FXARGB_A(fill_color); - if (alpha < 255) { + if (FXARGB_A(fill_color) < 255) return FALSE; - } } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) { bool should_call_draw_device_text = true; #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ @@ -465,8 +459,8 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, #endif if (should_call_draw_device_text && m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache, - pText2Device, font_size, fill_color, - alpha_flag, pIccTransform)) { + pText2Device, font_size, fill_color, 0, + nullptr)) { return TRUE; } } @@ -484,9 +478,9 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, (pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) { int nPathFlags = (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NOPATHSMOOTH; - return DrawTextPath(nChars, pCharPos, pFont, pCache, font_size, - pText2Device, NULL, NULL, fill_color, 0, NULL, - nPathFlags, alpha_flag, pIccTransform); + return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size, + pText2Device, nullptr, nullptr, fill_color, + 0, nullptr, nPathFlags); } } int anti_alias = FXFT_RENDER_MODE_MONO; @@ -621,7 +615,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, int g = 0; int b = 0; if (anti_alias == FXFT_RENDER_MODE_LCD) { - Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); + Color2Argb(fill_color, fill_color, (1 << 24), nullptr); ArgbDecode(fill_color, a, r, g, b); } for (const FXTEXT_GLYPHPOS& glyph : glyphs) { @@ -635,8 +629,8 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, int nrows = pGlyph->GetHeight(); if (anti_alias == FXFT_RENDER_MODE_NORMAL) { if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_color, 0, - 0, FXDIB_BLEND_NORMAL, nullptr, FALSE, - alpha_flag, pIccTransform)) { + 0, FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, + nullptr)) { return FALSE; } continue; @@ -653,34 +647,29 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, DrawNormalTextHelper(&bitmap, pGlyph, nrows, left, top, start_col, end_col, bNormal, bBGRStripe, x_subpixel, a, r, g, b); } - if (bitmap.IsAlphaMask()) { - SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color, alpha_flag, - pIccTransform); - } else { + if (bitmap.IsAlphaMask()) + SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); + else SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); - } - return TRUE; } -FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - FX_FLOAT font_size, - const CFX_Matrix* pText2User, - const CFX_Matrix* pUser2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - FX_ARGB stroke_color, - CFX_PathData* pClippingPath, - int nFlag, - int alpha_flag, - void* pIccTransform, - int blend_type) { - if (!pCache) { +FX_BOOL CFX_RenderDevice::DrawTextPathWithFlags( + int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + FX_FLOAT font_size, + const CFX_Matrix* pText2User, + const CFX_Matrix* pUser2Device, + const CFX_GraphStateData* pGraphState, + uint32_t fill_color, + FX_ARGB stroke_color, + CFX_PathData* pClippingPath, + int nFlag) { + if (!pCache) pCache = CFX_GEModule::Get()->GetFontCache(); - } + CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); FX_FONTCACHE_DEFINE(pCache, pFont); for (int iChar = 0; iChar < nChars; iChar++) { @@ -693,37 +682,25 @@ FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars, charpos.m_OriginY); const CFX_PathData* pPath = pFaceCache->LoadGlyphPath( pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); - if (!pPath) { + if (!pPath) continue; - } + matrix.Concat(*pText2User); CFX_PathData TransformedPath(*pPath); TransformedPath.Transform(&matrix); - FX_BOOL bHasAlpha = FXGETFLAG_COLORTYPE(alpha_flag) - ? (FXGETFLAG_ALPHA_FILL(alpha_flag) || - FXGETFLAG_ALPHA_STROKE(alpha_flag)) - : (fill_color || stroke_color); - if (bHasAlpha) { + if (fill_color || stroke_color) { int fill_mode = nFlag; - if (FXGETFLAG_COLORTYPE(alpha_flag)) { - if (FXGETFLAG_ALPHA_FILL(alpha_flag)) { - fill_mode |= FXFILL_WINDING; - } - } else { - if (fill_color) { - fill_mode |= FXFILL_WINDING; - } - } + if (fill_color) + fill_mode |= FXFILL_WINDING; fill_mode |= FX_FILL_TEXT_MODE; - if (!DrawPath(&TransformedPath, pUser2Device, pGraphState, fill_color, - stroke_color, fill_mode, alpha_flag, pIccTransform, - blend_type)) { + if (!DrawPathWithBlend(&TransformedPath, pUser2Device, pGraphState, + fill_color, stroke_color, fill_mode, + FXDIB_BLEND_NORMAL)) { return FALSE; } } - if (pClippingPath) { + if (pClippingPath) pClippingPath->Append(&TransformedPath, pUser2Device); - } } return TRUE; } |