From ff46aaf499edcf153ee2f57c7016587aa96dcfa0 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 27 Jul 2015 11:55:29 -0700 Subject: FX Bool considered harmful, part 3 Try to reland this patch after fixing underlying issues that caused it to be reverted. fx_system.h is the only manual edit. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1258093002 . --- core/src/fxge/ge/fx_ge_device.cpp | 94 +++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 47 deletions(-) (limited to 'core/src/fxge/ge/fx_ge_device.cpp') diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp index 0baa99cdc7..ecdd1b0183 100644 --- a/core/src/fxge/ge/fx_ge_device.cpp +++ b/core/src/fxge/ge/fx_ge_device.cpp @@ -35,7 +35,7 @@ void CFX_RenderDevice::InitDeviceInfo() m_ClipBox.bottom = m_Height; } } -FX_BOOL CFX_RenderDevice::StartRendering() +bool CFX_RenderDevice::StartRendering() { return m_pDeviceDriver->StartRendering(); } @@ -47,7 +47,7 @@ void CFX_RenderDevice::SaveState() { m_pDeviceDriver->SaveState(); } -void CFX_RenderDevice::RestoreState(FX_BOOL bKeepSaved) +void CFX_RenderDevice::RestoreState(bool bKeepSaved) { m_pDeviceDriver->RestoreState(bKeepSaved); UpdateClipBox(); @@ -60,7 +60,7 @@ CFX_Matrix CFX_RenderDevice::GetCTM() const { return m_pDeviceDriver->GetCTM(); } -FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, int height) const +bool CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, int height) const { if (m_RenderCaps & FXRC_CMYK_OUTPUT) { return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Cmyka : FXDIB_Cmyk); @@ -74,37 +74,37 @@ FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); #endif } -FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, +bool CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, int fill_mode ) { if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, fill_mode)) { - return FALSE; + return false; } UpdateClipBox(); - return TRUE; + return true; } -FX_BOOL CFX_RenderDevice::SetClip_PathStroke(const CFX_PathData* pPathData, +bool CFX_RenderDevice::SetClip_PathStroke(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, const CFX_GraphStateData* pGraphState ) { if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, pGraphState)) { - return FALSE; + return false; } UpdateClipBox(); - return TRUE; + return true; } -FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT* pRect) +bool CFX_RenderDevice::SetClip_Rect(const FX_RECT* pRect) { CFX_PathData path; path.AppendRect((FX_FLOAT)(pRect->left), (FX_FLOAT)(pRect->bottom), (FX_FLOAT)(pRect->right), (FX_FLOAT)(pRect->top)); if (!SetClip_PathFill(&path, NULL, FXFILL_WINDING)) { - return FALSE; + return false; } UpdateClipBox(); - return TRUE; + return true; } void CFX_RenderDevice::UpdateClipBox() { @@ -116,7 +116,7 @@ void CFX_RenderDevice::UpdateClipBox() m_ClipBox.right = m_Width; m_ClipBox.bottom = m_Height; } -FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, +bool CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, const CFX_GraphStateData* pGraphState, FX_DWORD fill_color, FX_DWORD stroke_color, int fill_mode, @@ -149,7 +149,7 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, y2 = pPoints[1].m_PointY; } DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, alpha_flag, pIccTransform, blend_type); - return TRUE; + return true; } if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && stroke_alpha == 0) { CFX_FloatRect rect_f; @@ -184,13 +184,13 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, } } if (FillRect(&rect_i, fill_color, alpha_flag, pIccTransform, blend_type)) { - return TRUE; + return true; } } } if((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) && !(fill_mode & FX_FILL_TEXT_MODE)) { CFX_PathData newPath; - FX_BOOL bThin = FALSE; + bool bThin = false; if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bThin, m_pDeviceDriver->GetDriverType())) { CFX_GraphStateData graphState; graphState.m_LineWidth = 0.0f; @@ -215,7 +215,7 @@ 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_GET_BITS)) { - return FALSE; + return false; } CFX_FloatRect bbox; if (pGraphState) { @@ -232,19 +232,19 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, FX_RECT rect = bbox.GetOutterRect(); CFX_DIBitmap bitmap, Backdrop; if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX), FXSYS_round(rect.Height() * fScaleY))) { - return FALSE; + return false; } if (bitmap.HasAlpha()) { bitmap.Clear(0); Backdrop.Copy(&bitmap); } else { if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, NULL)) { - return FALSE; + return false; } Backdrop.Copy(&bitmap); } CFX_FxgeDevice bitmap_device; - bitmap_device.Attach(&bitmap, 0, FALSE, &Backdrop, TRUE); + bitmap_device.Attach(&bitmap, 0, false, &Backdrop, true); CFX_AffineMatrix matrix; if (pObject2Device) { matrix = *pObject2Device; @@ -252,51 +252,51 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, matrix.TranslateI(-rect.left, -rect.top); 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)) { - return FALSE; + return false; } FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), 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, int alpha_flag, void* pIccTransform) +bool CFX_RenderDevice::SetPixel(int x, int y, FX_DWORD color, int alpha_flag, void* pIccTransform) { if (m_pDeviceDriver->SetPixel(x, y, color, alpha_flag, pIccTransform)) { - return TRUE; + return true; } FX_RECT rect(x, y, x + 1, y + 1); return FillRect(&rect, color, alpha_flag, pIccTransform); } -FX_BOOL CFX_RenderDevice::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, int alpha_flag, void* pIccTransform, int blend_type) +bool CFX_RenderDevice::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, int alpha_flag, void* pIccTransform, int blend_type) { if (m_pDeviceDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform, blend_type)) { - return TRUE; + return true; } if (!(m_RenderCaps & FXRC_GET_BITS)) { - return FALSE; + return false; } CFX_DIBitmap bitmap; if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) { - return FALSE; + return false; } if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) { - return FALSE; + return false; } if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, alpha_flag, pIccTransform)) { - return FALSE; + return false; } FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, FXDIB_BLEND_NORMAL); - return TRUE; + return true; } -FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD color, +bool CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_DWORD 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; + return true; } CFX_GraphStateData graph_state; CFX_PathData path; @@ -305,10 +305,10 @@ FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2 path.SetPoint(1, x2, y2, FXPT_LINETO); return m_pDeviceDriver->DrawPath(&path, NULL, &graph_state, 0, color, fill_mode, alpha_flag, pIccTransform, blend_type); } -FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform) +bool CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform) { if (!(m_RenderCaps & FXRC_GET_BITS)) { - return FALSE; + return false; } return m_pDeviceDriver->GetDIBits(pBitmap, left, top, pIccTransform); } @@ -316,7 +316,7 @@ 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, +bool CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, int left, int top, int blend_mode, void* pIccTransform) { ASSERT(!pBitmap->IsAlphaMask()); @@ -326,7 +326,7 @@ FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, int left, int FX_RECT dest_rect(left, top, FXSYS_round(left + pBitmap->GetWidth() / fScaleX), FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); dest_rect.Intersect(m_ClipBox); if (dest_rect.IsEmpty()) { - return TRUE; + return true; } FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top, dest_rect.left - left + dest_rect.Width(), dest_rect.top - top + dest_rect.Height()); @@ -337,29 +337,29 @@ FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, int left, int if ((blend_mode != FXDIB_BLEND_NORMAL && !(m_RenderCaps & FXRC_BLEND_MODE)) || (pBitmap->HasAlpha() && !(m_RenderCaps & FXRC_ALPHA_IMAGE))) { if (!(m_RenderCaps & FXRC_GET_BITS)) { - return FALSE; + return false; } int bg_pixel_width = FXSYS_round(dest_rect.Width() * fScaleX); int bg_pixel_height = FXSYS_round(dest_rect.Height() * fScaleY); CFX_DIBitmap background; if (!background.Create(bg_pixel_width, bg_pixel_height, (m_RenderCaps & FXRC_CMYK_OUTPUT) ? FXDIB_Cmyk : FXDIB_Rgb32)) { - return FALSE; + return false; } if (!m_pDeviceDriver->GetDIBits(&background, dest_rect.left, dest_rect.top)) { - return FALSE; + return false; } if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height, pBitmap, src_rect.left, src_rect.top, - blend_mode, NULL, FALSE, pIccTransform)) { - return FALSE; + blend_mode, NULL, false, pIccTransform)) { + return false; } FX_RECT src_rect(0, 0, bg_pixel_width, bg_pixel_height); return m_pDeviceDriver->SetDIBits(&background, 0, &src_rect, dest_rect.left, dest_rect.top, FXDIB_BLEND_NORMAL); } return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, dest_rect.top, blend_mode, 0, pIccTransform); } -FX_BOOL CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap, int left, int top, +bool CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap, int left, int top, int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform, int blend_mode) { @@ -367,17 +367,17 @@ FX_BOOL CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap, int left, FX_RECT clip_box = m_ClipBox; clip_box.Intersect(dest_rect); if (clip_box.IsEmpty()) { - return TRUE; + return true; } return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, dest_height, &clip_box, flags, 0, pIccTransform, blend_mode); } -FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, int left, int top, FX_DWORD argb, +bool CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, int left, int top, FX_DWORD argb, int alpha_flag, void* pIccTransform) { 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); } -FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, int left, int top, +bool CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, int left, int top, int dest_width, int dest_height, FX_DWORD argb, FX_DWORD flags, int alpha_flag, void* pIccTransform) { @@ -386,13 +386,13 @@ FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, int left, clip_box.Intersect(dest_rect); return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, dest_height, &clip_box, flags, alpha_flag, pIccTransform); } -FX_BOOL CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD argb, +bool CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD argb, const CFX_AffineMatrix* pMatrix, FX_DWORD flags, void*& handle, int alpha_flag, void* pIccTransform, int blend_mode) { return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, flags, handle, alpha_flag, pIccTransform, blend_mode); } -FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) +bool CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { return m_pDeviceDriver->ContinueDIBits(handle, pPause); } -- cgit v1.2.3