From e385244f8cd6ae376f6b3cf1265a0795d5d30eff Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 14 Dec 2015 18:29:28 -0800 Subject: Get rid of most instance of 'foo == NULL' R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1520063002 . --- core/src/fxge/skia/fx_skia_blitter_new.cpp | 24 +++++++++---------- core/src/fxge/skia/fx_skia_device.cpp | 38 ++++++++++++++++-------------- 2 files changed, 32 insertions(+), 30 deletions(-) (limited to 'core/src/fxge/skia') diff --git a/core/src/fxge/skia/fx_skia_blitter_new.cpp b/core/src/fxge/skia/fx_skia_blitter_new.cpp index ed7b1c74bf..85391cb77a 100644 --- a/core/src/fxge/skia/fx_skia_blitter_new.cpp +++ b/core/src/fxge/skia/fx_skia_blitter_new.cpp @@ -16,7 +16,7 @@ void CFX_SkiaRenderer::blitAntiH(int x, const SkAlpha antialias[], const int16_t runs[]) { FXSYS_assert(m_Alpha); - if (m_pOriDevice == NULL && composite_span == NULL) + if (!m_pOriDevice && !composite_span) return; if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return; @@ -106,12 +106,13 @@ void CFX_SkiaRenderer::CompositeSpan1bpp_0(uint8_t* dest_scan, dest_scan += col_start / 8; int index = 0; - if (m_pDevice->GetPalette() == NULL) - index = ((uint8_t)m_Color == 0xff) ? 1 : 0; - else { - for (int i = 0; i < 2; i++) + if (m_pDevice->GetPalette()) { + for (int i = 0; i < 2; i++) { if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) index = i; + } + } else { + index = ((uint8_t)m_Color == 0xff) ? 1 : 0; } uint8_t* dest_scan1 = dest_scan; int src_alpha = m_Alpha * cover_scan / 255; @@ -150,12 +151,13 @@ void CFX_SkiaRenderer::CompositeSpan1bpp_4(uint8_t* dest_scan, dest_scan += col_start / 8; int index = 0; - if (m_pDevice->GetPalette() == NULL) - index = ((uint8_t)m_Color == 0xff) ? 1 : 0; - else { - for (int i = 0; i < 2; i++) + if (m_pDevice->GetPalette()) { + for (int i = 0; i < 2; i++) { if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) index = i; + } + } else { + index = ((uint8_t)m_Color == 0xff) ? 1 : 0; } uint8_t* dest_scan1 = dest_scan; int src_alpha = m_Alpha * cover_scan / 255; @@ -1736,9 +1738,7 @@ FX_BOOL CFX_SkiaRenderer::Init( composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; break; } - if (composite_span == NULL) - return FALSE; - return TRUE; + return !!composite_span; } /*----------------------------------------------------------------------------------------------------*/ diff --git a/core/src/fxge/skia/fx_skia_device.cpp b/core/src/fxge/skia/fx_skia_device.cpp index 8e012c82e0..2e0371f312 100644 --- a/core/src/fxge/skia/fx_skia_device.cpp +++ b/core/src/fxge/skia/fx_skia_device.cpp @@ -212,20 +212,7 @@ static void SkRasterizeStroke(SkPaint& spaint, if (width <= unit) width = unit; - if (pGraphState->m_DashArray == NULL) { - SkStroke stroker; - stroker.setCap(cap); - stroker.setJoin(join); - stroker.setMiterLimit(pGraphState->m_MiterLimit); - stroker.setWidth(width); - stroker.setDoFill(FALSE); - stroker.strokePath(path_data, dstPathData); - SkMatrix smatrix; - smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e, - pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, - 0, 1); - dstPathData->transform(smatrix); - } else { + if (pGraphState->m_DashArray) { int count = (pGraphState->m_DashCount + 1) / 2; SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar)); // Set dash pattern @@ -255,6 +242,19 @@ static void SkRasterizeStroke(SkPaint& spaint, 0, 1); dstPathData->transform(smatrix); FX_Free(intervals); + } else { + SkStroke stroker; + stroker.setCap(cap); + stroker.setJoin(join); + stroker.setMiterLimit(pGraphState->m_MiterLimit); + stroker.setWidth(width); + stroker.setDoFill(FALSE); + stroker.strokePath(path_data, dstPathData); + SkMatrix smatrix; + smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e, + pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, + 0, 1); + dstPathData->transform(smatrix); } } @@ -331,9 +331,10 @@ FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill( const CFX_Matrix* pObject2Device, // optional transformation int fill_mode // fill mode, WINDING or ALTERNATE ) { - if (m_pAggDriver->m_pClipRgn == NULL) + if (!m_pAggDriver->m_pClipRgn) { m_pAggDriver->m_pClipRgn = new CFX_ClipRgn( GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); + } if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { CFX_FloatRect rectf; @@ -368,9 +369,10 @@ FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke( const CFX_Matrix* pObject2Device, // optional transformation const CFX_GraphStateData* pGraphState // graphic state, for pen attributes ) { - if (m_pAggDriver->m_pClipRgn == NULL) + if (!m_pAggDriver->m_pClipRgn) { m_pAggDriver->m_pClipRgn = new CFX_ClipRgn( GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); + } // build path data CSkia_PathData path_data; @@ -432,7 +434,7 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawPath( int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled int alpha_flag, void* pIccTransform) { - if (GetBuffer() == NULL) + if (!GetBuffer()) return TRUE; FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering"); SkIRect rect; @@ -592,7 +594,7 @@ FX_BOOL CFX_SkiaDevice::Attach(CFX_DIBitmap* pBitmap, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) { - if (pBitmap == NULL) + if (!pBitmap) return FALSE; SetBitmap(pBitmap); CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver( -- cgit v1.2.3