summaryrefslogtreecommitdiff
path: root/core/src/fxge
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fxge')
-rw-r--r--core/src/fxge/agg/src/fx_agg_driver.cpp64
-rw-r--r--core/src/fxge/android/fpf_skiafontmgr.cpp2
-rw-r--r--core/src/fxge/dib/fx_dib_composite.cpp264
-rw-r--r--core/src/fxge/dib/fx_dib_convert.cpp24
-rw-r--r--core/src/fxge/dib/fx_dib_engine.cpp19
-rw-r--r--core/src/fxge/dib/fx_dib_main.cpp68
-rw-r--r--core/src/fxge/dib/fx_dib_transform.cpp4
-rw-r--r--core/src/fxge/ge/fx_ge.cpp2
-rw-r--r--core/src/fxge/ge/fx_ge_device.cpp2
-rw-r--r--core/src/fxge/ge/fx_ge_font.cpp8
-rw-r--r--core/src/fxge/ge/fx_ge_fontmap.cpp33
-rw-r--r--core/src/fxge/ge/fx_ge_path.cpp4
-rw-r--r--core/src/fxge/ge/fx_ge_ps.cpp10
-rw-r--r--core/src/fxge/ge/fx_ge_text.cpp22
-rw-r--r--core/src/fxge/skia/fx_skia_blitter_new.cpp24
-rw-r--r--core/src/fxge/skia/fx_skia_device.cpp38
-rw-r--r--core/src/fxge/win32/fx_win32_device.cpp25
-rw-r--r--core/src/fxge/win32/fx_win32_dib.cpp22
-rw-r--r--core/src/fxge/win32/fx_win32_dwrite.cpp4
-rw-r--r--core/src/fxge/win32/fx_win32_gdipext.cpp18
-rw-r--r--core/src/fxge/win32/fx_win32_print.cpp16
21 files changed, 332 insertions, 341 deletions
diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp
index dfa5c27ebf..ed2e8e41f0 100644
--- a/core/src/fxge/agg/src/fx_agg_driver.cpp
+++ b/core/src/fxge/agg/src/fx_agg_driver.cpp
@@ -150,14 +150,7 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer,
if (width < unit) {
width = unit;
}
- if (pGraphState->m_DashArray == NULL) {
- agg::conv_stroke<agg::path_storage> stroke(path_data);
- stroke.line_join(join);
- stroke.line_cap(cap);
- stroke.miter_limit(pGraphState->m_MiterLimit);
- stroke.width(width);
- rasterizer.add_path_transformed(stroke, pObject2Device);
- } else {
+ if (pGraphState->m_DashArray) {
typedef agg::conv_dash<agg::path_storage> dash_converter;
dash_converter dash(path_data);
for (int i = 0; i < (pGraphState->m_DashCount + 1) / 2; i++) {
@@ -181,6 +174,13 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer,
stroke.miter_limit(pGraphState->m_MiterLimit);
stroke.width(width);
rasterizer.add_path_transformed(stroke, pObject2Device);
+ } else {
+ agg::conv_stroke<agg::path_storage> stroke(path_data);
+ stroke.line_join(join);
+ stroke.line_cap(cap);
+ stroke.miter_limit(pGraphState->m_MiterLimit);
+ stroke.width(width);
+ rasterizer.add_path_transformed(stroke, pObject2Device);
}
}
IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(
@@ -554,13 +554,14 @@ class CFX_Renderer {
}
} else {
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;
for (int col = col_start; col < col_end; col++) {
@@ -598,13 +599,14 @@ class CFX_Renderer {
: (clip_right - span_left);
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;
for (int col = col_start; col < col_end; col++) {
@@ -994,7 +996,7 @@ class CFX_Renderer {
}
template <class Scanline>
void render(const Scanline& sl) {
- if (m_pOriDevice == NULL && composite_span == NULL) {
+ if (!m_pOriDevice && !composite_span) {
return;
}
int y = sl.y();
@@ -1212,7 +1214,7 @@ FX_BOOL CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData,
if (blend_type != FXDIB_BLEND_NORMAL) {
return FALSE;
}
- if (GetBuffer() == NULL) {
+ if (!GetBuffer()) {
return TRUE;
}
m_FillFlags = fill_mode;
@@ -1386,7 +1388,7 @@ void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap,
const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return;
}
pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
@@ -1527,14 +1529,14 @@ FX_BOOL CFX_AggDeviceDriver::SetPixel(int x,
FX_DWORD color,
int alpha_flag,
void* pIccTransform) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
if (!CFX_GEModule::Get()->GetCodecModule() ||
!CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
pIccTransform = NULL;
}
- if (m_pClipRgn == NULL) {
+ if (!m_pClipRgn) {
if (m_bRgbByteOrder) {
RgbByteOrderSetPixel(m_pBitmap, x, y, color);
} else {
@@ -1576,7 +1578,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
if (blend_type != FXDIB_BLEND_NORMAL) {
return FALSE;
}
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
FX_RECT clip_rect;
@@ -1588,7 +1590,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
if (draw_rect.IsEmpty()) {
return TRUE;
}
- if (m_pClipRgn == NULL || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
+ if (!m_pClipRgn || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
if (m_bRgbByteOrder) {
RgbByteOrderCompositeRect(m_pBitmap, draw_rect.left, draw_rect.top,
draw_rect.Width(), draw_rect.Height(),
@@ -1608,7 +1610,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
return TRUE;
}
FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) {
- if (m_pClipRgn == NULL) {
+ if (!m_pClipRgn) {
pRect->left = pRect->top = 0;
pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH);
pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT);
@@ -1622,7 +1624,7 @@ FX_BOOL CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap,
int top,
void* pIccTransform,
FX_BOOL bDEdge) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
if (bDEdge) {
@@ -1673,7 +1675,7 @@ FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
int blend_type,
int alpha_flag,
void* pIccTransform) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
if (pBitmap->IsAlphaMask())
@@ -1696,7 +1698,7 @@ FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
int alpha_flag,
void* pIccTransform,
int blend_type) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
if (dest_width == pSource->GetWidth() &&
@@ -1731,7 +1733,7 @@ FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
int alpha_flag,
void* pIccTransform,
int blend_type) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer;
@@ -1741,13 +1743,13 @@ FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
return TRUE;
}
FX_BOOL CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
return ((CFX_ImageRenderer*)pHandle)->Continue(pPause);
}
void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return;
}
delete (CFX_ImageRenderer*)pHandle;
@@ -1760,7 +1762,7 @@ FX_BOOL CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap,
FX_BOOL bRgbByteOrder,
CFX_DIBitmap* pOriDevice,
FX_BOOL bGroupKnockout) {
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
SetBitmap(pBitmap);
diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp
index 254f806fec..9dbe35d0e5 100644
--- a/core/src/fxge/android/fpf_skiafontmgr.cpp
+++ b/core/src/fxge/android/fpf_skiafontmgr.cpp
@@ -238,7 +238,7 @@ CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() {
}
}
FX_BOOL CFPF_SkiaFontMgr::InitFTLibrary() {
- if (m_FTLibrary == NULL) {
+ if (!m_FTLibrary) {
FXFT_Init_FreeType(&m_FTLibrary);
}
return m_FTLibrary != NULL;
diff --git a/core/src/fxge/dib/fx_dib_composite.cpp b/core/src/fxge/dib/fx_dib_composite.cpp
index e89fdcec99..e284f62050 100644
--- a/core/src/fxge/dib/fx_dib_composite.cpp
+++ b/core/src/fxge/dib/fx_dib_composite.cpp
@@ -737,8 +737,8 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
const uint8_t* src_alpha_scan) {
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
- if (dest_alpha_scan == NULL) {
- if (src_alpha_scan == NULL) {
+ if (!dest_alpha_scan) {
+ if (!src_alpha_scan) {
uint8_t back_alpha = 0;
for (int col = 0; col < pixel_count; col++) {
back_alpha = dest_scan[3];
@@ -755,10 +755,10 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = src_scan[3];
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * src_scan[3] / 255;
+ } else {
+ src_alpha = src_scan[3];
}
if (src_alpha == 0) {
dest_scan += 4;
@@ -807,10 +807,10 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = *src_alpha_scan++;
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+ } else {
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += 4;
@@ -862,10 +862,10 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = *src_alpha_scan++;
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+ } else {
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += 3;
@@ -915,10 +915,10 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = src_scan[3];
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * src_scan[3] / 255;
+ } else {
+ src_alpha = src_scan[3];
}
if (src_alpha == 0) {
dest_scan += 3;
@@ -960,21 +960,18 @@ void _CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan,
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
int src_gap = src_Bpp - 3;
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
for (int col = 0; col < width; col++) {
- uint8_t back_alpha = dest_scan[3];
+ uint8_t back_alpha = *dest_alpha_scan;
if (back_alpha == 0) {
- if (src_Bpp == 4) {
- FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
- } else {
- FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_scan[1],
- src_scan[0]));
- }
- dest_scan += 4;
- src_scan += src_Bpp;
+ *dest_scan++ = *src_scan++;
+ *dest_scan++ = *src_scan++;
+ *dest_scan++ = *src_scan++;
+ *dest_alpha_scan++ = 0xff;
+ src_scan += src_gap;
continue;
}
- dest_scan[3] = 0xff;
+ *dest_alpha_scan++ = 0xff;
if (bNonseparableBlend) {
_RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
}
@@ -987,21 +984,23 @@ void _CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan,
dest_scan++;
src_scan++;
}
- dest_scan++;
src_scan += src_gap;
}
} else {
for (int col = 0; col < width; col++) {
- uint8_t back_alpha = *dest_alpha_scan;
+ uint8_t back_alpha = dest_scan[3];
if (back_alpha == 0) {
- *dest_scan++ = *src_scan++;
- *dest_scan++ = *src_scan++;
- *dest_scan++ = *src_scan++;
- *dest_alpha_scan++ = 0xff;
- src_scan += src_gap;
+ if (src_Bpp == 4) {
+ FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
+ } else {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_scan[1],
+ src_scan[0]));
+ }
+ dest_scan += 4;
+ src_scan += src_Bpp;
continue;
}
- *dest_alpha_scan++ = 0xff;
+ dest_scan[3] = 0xff;
if (bNonseparableBlend) {
_RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
}
@@ -1014,6 +1013,7 @@ void _CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan,
dest_scan++;
src_scan++;
}
+ dest_scan++;
src_scan += src_gap;
}
}
@@ -1028,26 +1028,27 @@ inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan,
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
int src_gap = src_Bpp - 3;
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
for (int col = 0; col < width; col++) {
int src_alpha = *clip_scan++;
- uint8_t back_alpha = dest_scan[3];
+ uint8_t back_alpha = *dest_alpha_scan;
if (back_alpha == 0) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
src_scan += src_gap;
- dest_scan++;
+ dest_alpha_scan++;
continue;
}
if (src_alpha == 0) {
- dest_scan += 4;
+ dest_scan += 3;
+ dest_alpha_scan++;
src_scan += src_Bpp;
continue;
}
uint8_t dest_alpha =
back_alpha + src_alpha - back_alpha * src_alpha / 255;
- dest_scan[3] = dest_alpha;
+ *dest_alpha_scan++ = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
if (bNonseparableBlend) {
_RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
@@ -1062,30 +1063,28 @@ inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan,
dest_scan++;
src_scan++;
}
- dest_scan++;
src_scan += src_gap;
}
} else {
for (int col = 0; col < width; col++) {
int src_alpha = *clip_scan++;
- uint8_t back_alpha = *dest_alpha_scan;
+ uint8_t back_alpha = dest_scan[3];
if (back_alpha == 0) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
src_scan += src_gap;
- dest_alpha_scan++;
+ dest_scan++;
continue;
}
if (src_alpha == 0) {
- dest_scan += 3;
- dest_alpha_scan++;
+ dest_scan += 4;
src_scan += src_Bpp;
continue;
}
uint8_t dest_alpha =
back_alpha + src_alpha - back_alpha * src_alpha / 255;
- *dest_alpha_scan++ = dest_alpha;
+ dest_scan[3] = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
if (bNonseparableBlend) {
_RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
@@ -1100,6 +1099,7 @@ inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan,
dest_scan++;
src_scan++;
}
+ dest_scan++;
src_scan += src_gap;
}
}
@@ -1111,33 +1111,33 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(uint8_t* dest_scan,
const uint8_t* clip_scan,
uint8_t* dest_alpha_scan) {
int src_gap = src_Bpp - 3;
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
for (int col = 0; col < width; col++) {
int src_alpha = clip_scan[col];
if (src_alpha == 255) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
- *dest_scan++ = 255;
+ *dest_alpha_scan++ = 255;
src_scan += src_gap;
continue;
}
if (src_alpha == 0) {
- dest_scan += 4;
+ dest_scan += 3;
+ dest_alpha_scan++;
src_scan += src_Bpp;
continue;
}
- int back_alpha = dest_scan[3];
+ int back_alpha = *dest_alpha_scan;
uint8_t dest_alpha =
back_alpha + src_alpha - back_alpha * src_alpha / 255;
- dest_scan[3] = dest_alpha;
+ *dest_alpha_scan++ = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
for (int color = 0; color < 3; color++) {
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio);
dest_scan++;
src_scan++;
}
- dest_scan++;
src_scan += src_gap;
}
} else {
@@ -1147,26 +1147,26 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(uint8_t* dest_scan,
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
- *dest_alpha_scan++ = 255;
+ *dest_scan++ = 255;
src_scan += src_gap;
continue;
}
if (src_alpha == 0) {
- dest_scan += 3;
- dest_alpha_scan++;
+ dest_scan += 4;
src_scan += src_Bpp;
continue;
}
- int back_alpha = *dest_alpha_scan;
+ int back_alpha = dest_scan[3];
uint8_t dest_alpha =
back_alpha + src_alpha - back_alpha * src_alpha / 255;
- *dest_alpha_scan++ = dest_alpha;
+ dest_scan[3] = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
for (int color = 0; color < 3; color++) {
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio);
dest_scan++;
src_scan++;
}
+ dest_scan++;
src_scan += src_gap;
}
}
@@ -1176,7 +1176,16 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(uint8_t* dest_scan,
int width,
int src_Bpp,
uint8_t* dest_alpha_scan) {
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
+ int src_gap = src_Bpp - 3;
+ for (int col = 0; col < width; col++) {
+ *dest_scan++ = *src_scan++;
+ *dest_scan++ = *src_scan++;
+ *dest_scan++ = *src_scan++;
+ *dest_alpha_scan++ = 0xff;
+ src_scan += src_gap;
+ }
+ } else {
for (int col = 0; col < width; col++) {
if (src_Bpp == 4) {
FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
@@ -1187,15 +1196,6 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(uint8_t* dest_scan,
dest_scan += 4;
src_scan += src_Bpp;
}
- } else {
- int src_gap = src_Bpp - 3;
- for (int col = 0; col < width; col++) {
- *dest_scan++ = *src_scan++;
- *dest_scan++ = *src_scan++;
- *dest_scan++ = *src_scan++;
- *dest_alpha_scan++ = 0xff;
- src_scan += src_gap;
- }
}
}
inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
@@ -1208,17 +1208,17 @@ inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
int dest_gap = dest_Bpp - 3;
- if (src_alpha_scan == NULL) {
+ if (src_alpha_scan) {
for (int col = 0; col < width; col++) {
uint8_t src_alpha;
if (clip_scan) {
- src_alpha = src_scan[3] * (*clip_scan++) / 255;
+ src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
} else {
- src_alpha = src_scan[3];
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += dest_Bpp;
- src_scan += 4;
+ src_scan += 3;
continue;
}
if (bNonseparableBlend) {
@@ -1234,19 +1234,18 @@ inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
src_scan++;
}
dest_scan += dest_gap;
- src_scan++;
}
} else {
for (int col = 0; col < width; col++) {
uint8_t src_alpha;
if (clip_scan) {
- src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
+ src_alpha = src_scan[3] * (*clip_scan++) / 255;
} else {
- src_alpha = *src_alpha_scan++;
+ src_alpha = src_scan[3];
}
if (src_alpha == 0) {
dest_scan += dest_Bpp;
- src_scan += 3;
+ src_scan += 4;
continue;
}
if (bNonseparableBlend) {
@@ -1262,6 +1261,7 @@ inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
src_scan++;
}
dest_scan += dest_gap;
+ src_scan++;
}
}
}
@@ -1272,25 +1272,24 @@ inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan,
const uint8_t* clip_scan,
const uint8_t* src_alpha_scan) {
int dest_gap = dest_Bpp - 3;
- if (src_alpha_scan == NULL) {
+ if (src_alpha_scan) {
for (int col = 0; col < width; col++) {
uint8_t src_alpha;
if (clip_scan) {
- src_alpha = src_scan[3] * (*clip_scan++) / 255;
+ src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
} else {
- src_alpha = src_scan[3];
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 255) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
dest_scan += dest_gap;
- src_scan++;
continue;
}
if (src_alpha == 0) {
dest_scan += dest_Bpp;
- src_scan += 4;
+ src_scan += 3;
continue;
}
for (int color = 0; color < 3; color++) {
@@ -1299,26 +1298,26 @@ inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan,
src_scan++;
}
dest_scan += dest_gap;
- src_scan++;
}
} else {
for (int col = 0; col < width; col++) {
uint8_t src_alpha;
if (clip_scan) {
- src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
+ src_alpha = src_scan[3] * (*clip_scan++) / 255;
} else {
- src_alpha = *src_alpha_scan++;
+ src_alpha = src_scan[3];
}
if (src_alpha == 255) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
dest_scan += dest_gap;
+ src_scan++;
continue;
}
if (src_alpha == 0) {
dest_scan += dest_Bpp;
- src_scan += 3;
+ src_scan += 4;
continue;
}
for (int color = 0; color < 3; color++) {
@@ -1327,6 +1326,7 @@ inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan,
src_scan++;
}
dest_scan += dest_gap;
+ src_scan++;
}
}
}
@@ -1451,7 +1451,9 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
ICodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_alpha_scan) {
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
+ pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count);
+ } else {
for (int col = 0; col < pixel_count; col++) {
pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
dp[3] = *src_alpha_scan++;
@@ -1459,18 +1461,9 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
dp += 4;
}
src_alpha_scan = NULL;
- } else {
- pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count);
}
} else {
- if (dest_alpha_scan == NULL) {
- for (int col = 0; col < pixel_count; col++) {
- pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
- dp[3] = src_scan[3];
- src_scan += 4;
- dp += 4;
- }
- } else {
+ if (dest_alpha_scan) {
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
for (int col = 0; col < pixel_count; col++) {
@@ -1495,10 +1488,10 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = src_scan[3];
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * src_scan[3] / 255;
+ } else {
+ src_alpha = src_scan[3];
}
src_scan += 4;
if (src_alpha == 0) {
@@ -1531,6 +1524,12 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
}
return;
}
+ for (int col = 0; col < pixel_count; col++) {
+ pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
+ dp[3] = src_scan[3];
+ src_scan += 4;
+ dp += 4;
+ }
}
_CompositeRow_Argb2Argb(dest_scan, src_cache_scan, pixel_count, blend_type,
clip_scan, dest_alpha_scan, src_alpha_scan);
@@ -2007,7 +2006,7 @@ inline void _CompositeRow_8bppPal2Graya(uint8_t* dest_scan,
for (int col = 0; col < pixel_count; col++) {
uint8_t gray = pPalette[*src_scan];
src_scan++;
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = gray;
*dest_alpha_scan++ = 255;
continue;
@@ -2037,7 +2036,7 @@ inline void _CompositeRow_8bppPal2Graya(uint8_t* dest_scan,
for (int col = 0; col < pixel_count; col++) {
uint8_t gray = pPalette[*src_scan];
src_scan++;
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = gray;
*dest_alpha_scan++ = 255;
continue;
@@ -2121,7 +2120,7 @@ inline void _CompositeRow_1bppPal2Graya(uint8_t* dest_scan,
(src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
? set_gray
: reset_gray;
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = gray;
*dest_alpha_scan++ = 255;
continue;
@@ -2153,7 +2152,7 @@ inline void _CompositeRow_1bppPal2Graya(uint8_t* dest_scan,
(src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
? set_gray
: reset_gray;
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = gray;
*dest_alpha_scan++ = 255;
continue;
@@ -2309,10 +2308,10 @@ inline void _CompositeRow_8bppRgb2Argb_NoBlend(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = *src_alpha_scan++;
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+ } else {
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += 4;
@@ -2336,7 +2335,7 @@ inline void _CompositeRow_8bppRgb2Argb_NoBlend(uint8_t* dest_scan,
int src_r = FXARGB_R(argb);
int src_g = FXARGB_G(argb);
int src_b = FXARGB_B(argb);
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = src_b;
*dest_scan++ = src_g;
*dest_scan++ = src_r;
@@ -2394,10 +2393,10 @@ void _CompositeRow_8bppRgb2Rgba_NoBlend(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = *src_alpha_scan++;
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+ } else {
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += 3;
@@ -2421,7 +2420,7 @@ void _CompositeRow_8bppRgb2Rgba_NoBlend(uint8_t* dest_scan,
int src_r = FXARGB_R(argb);
int src_g = FXARGB_G(argb);
int src_b = FXARGB_B(argb);
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = src_b;
*dest_scan++ = src_g;
*dest_scan++ = src_r;
@@ -2475,7 +2474,7 @@ inline void _CompositeRow_1bppRgb2Argb_NoBlend(uint8_t* dest_scan,
src_g = reset_g;
src_b = reset_b;
}
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = src_b;
*dest_scan++ = src_g;
*dest_scan++ = src_r;
@@ -2526,7 +2525,7 @@ void _CompositeRow_1bppRgb2Rgba_NoBlend(uint8_t* dest_scan,
src_g = reset_g;
src_b = reset_b;
}
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = src_b;
*dest_scan++ = src_g;
*dest_scan++ = src_r;
@@ -2823,8 +2822,7 @@ void _CompositeRow_BitMask2Argb(uint8_t* dest_scan,
int pixel_count,
int blend_type,
const uint8_t* clip_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b);
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
@@ -2902,8 +2900,7 @@ void _CompositeRow_BitMask2Rgba(uint8_t* dest_scan,
int blend_type,
const uint8_t* clip_scan,
uint8_t* dest_alpha_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
dest_scan[0] = src_b;
@@ -2989,8 +2986,7 @@ void _CompositeRow_BitMask2Rgb(uint8_t* dest_scan,
int blend_type,
int Bpp,
const uint8_t* clip_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
dest_scan[2] = src_r;
@@ -3159,10 +3155,10 @@ void _CompositeRow_Argb2Argb_RgbByteOrder(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = src_scan[3];
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * src_scan[3] / 255;
+ } else {
+ src_alpha = src_scan[3];
}
if (src_alpha == 0) {
dest_scan += 4;
@@ -3623,7 +3619,7 @@ inline void _CompositeRow_8bppRgb2Argb_NoBlend_RgbByteOrder(
} else {
src_r = src_g = src_b = *src_scan;
}
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
dest_scan[2] = FX_GAMMA(src_b);
dest_scan[1] = FX_GAMMA(src_g);
dest_scan[0] = FX_GAMMA(src_r);
@@ -3683,7 +3679,7 @@ inline void _CompositeRow_1bppRgb2Argb_NoBlend_RgbByteOrder(
src_g = reset_g;
src_b = reset_b;
}
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
dest_scan[2] = FX_GAMMA(src_b);
dest_scan[1] = FX_GAMMA(src_g);
dest_scan[0] = FX_GAMMA(src_r);
@@ -3837,8 +3833,7 @@ void _CompositeRow_BitMask2Argb_RgbByteOrder(uint8_t* dest_scan,
int pixel_count,
int blend_type,
const uint8_t* clip_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b);
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
@@ -3915,8 +3910,7 @@ void _CompositeRow_BitMask2Rgb_RgbByteOrder(uint8_t* dest_scan,
int blend_type,
int Bpp,
const uint8_t* clip_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
dest_scan[2] = src_b;
@@ -4215,7 +4209,7 @@ FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format,
if (CFX_GEModule::Get()->GetCodecModule()) {
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
}
- if (pIccModule == NULL) {
+ if (!pIccModule) {
pIccTransform = NULL;
}
m_pIccTransform = pIccTransform;
@@ -4227,8 +4221,7 @@ FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format,
dest_format, alpha_flag, mask_color, m_MaskAlpha, m_MaskRed,
m_MaskGreen, m_MaskBlue, m_MaskBlack, pIccModule, pIccTransform);
}
- if (pIccTransform == NULL && (~src_format & 0x0400) &&
- (dest_format & 0x0400)) {
+ if (!pIccTransform && (~src_format & 0x0400) && (dest_format & 0x0400)) {
return FALSE;
}
if ((m_SrcFormat & 0xff) <= 8) {
@@ -4662,7 +4655,7 @@ FX_BOOL CFX_DIBitmap::CompositeBitmap(int dest_left,
const CFX_ClipRgn* pClipRgn,
FX_BOOL bRgbByteOrder,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
ASSERT(!pSrcBitmap->IsAlphaMask());
@@ -4735,7 +4728,7 @@ FX_BOOL CFX_DIBitmap::CompositeMask(int dest_left,
FX_BOOL bRgbByteOrder,
int alpha_flag,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
ASSERT(pMask->IsAlphaMask());
@@ -4799,7 +4792,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left,
FX_DWORD color,
int alpha_flag,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color);
@@ -4859,13 +4852,14 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left,
int right_shift = rect.right % 8;
int width = rect.right / 8 - rect.left / 8;
int index = 0;
- if (m_pPalette == NULL) {
- index = ((uint8_t)color == 0xff) ? 1 : 0;
- } else {
- for (int i = 0; i < 2; i++)
+ if (m_pPalette) {
+ for (int i = 0; i < 2; i++) {
if (m_pPalette[i] == color) {
index = i;
}
+ }
+ } else {
+ index = ((uint8_t)color == 0xff) ? 1 : 0;
}
for (int row = rect.top; row < rect.bottom; row++) {
uint8_t* dest_scan_top = (uint8_t*)GetScanline(row) + rect.left / 8;
diff --git a/core/src/fxge/dib/fx_dib_convert.cpp b/core/src/fxge/dib/fx_dib_convert.cpp
index 2c310f3cea..d87b1f9a97 100644
--- a/core/src/fxge/dib/fx_dib_convert.cpp
+++ b/core/src/fxge/dib/fx_dib_convert.cpp
@@ -209,7 +209,7 @@ CFX_Palette::~CFX_Palette() {
m_lut = 0;
}
FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type) {
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
FX_Free(m_pPalette);
@@ -560,7 +560,7 @@ inline FX_BOOL _ConvertBuffer_Rgb2PltRgb8_NoTransform(
palette.BuildPalette(pSrcBitmap, FXDIB_PALETTE_LOC);
FX_DWORD* cLut = palette.GetColorLut();
FX_DWORD* aLut = palette.GetAmountLut();
- if (cLut == NULL || aLut == NULL) {
+ if (!cLut || !aLut) {
return FALSE;
}
int lut = palette.Getlut();
@@ -987,7 +987,7 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
}
case FXDIB_8bppRgb:
case FXDIB_8bppRgba: {
- if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL) {
+ if ((src_format & 0xff) == 8 && !pSrcBitmap->GetPalette()) {
return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, width,
height, pSrcBitmap, src_left, src_top, d_pal,
pIccTransform);
@@ -1082,12 +1082,12 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format,
const FX_RECT* pClip,
void* pIccTransform) const {
- if (dest_format == GetFormat() && pIccTransform == NULL) {
+ if (dest_format == GetFormat() && !pIccTransform) {
return Clone(pClip);
}
if (pClip) {
CFX_DIBitmap* pClone = Clone(pClip);
- if (pClone == NULL) {
+ if (!pClone) {
return NULL;
}
if (!pClone->ConvertFormat(dest_format, pIccTransform)) {
@@ -1105,7 +1105,7 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format,
CFX_DIBitmap* pSrcAlpha = NULL;
if (HasAlpha()) {
pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask;
- if (pSrcAlpha == NULL) {
+ if (!pSrcAlpha) {
delete pClone;
return NULL;
}
@@ -1144,16 +1144,16 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format,
FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format,
void* pIccTransform) {
FXDIB_Format src_format = GetFormat();
- if (dest_format == src_format && pIccTransform == NULL) {
+ if (dest_format == src_format && !pIccTransform) {
return TRUE;
}
if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb &&
- m_pPalette == NULL) {
+ !m_pPalette) {
m_AlphaFlag = 1;
return TRUE;
}
if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32 &&
- pIccTransform == NULL) {
+ !pIccTransform) {
m_AlphaFlag = 2;
for (int row = 0; row < m_Height; row++) {
uint8_t* scanline = m_pBuffer + row * m_Pitch + 3;
@@ -1167,7 +1167,7 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format,
int dest_bpp = dest_format & 0xff;
int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4;
uint8_t* dest_buf = FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4);
- if (dest_buf == NULL) {
+ if (!dest_buf) {
return FALSE;
}
CFX_DIBitmap* pAlphaMask = NULL;
@@ -1186,12 +1186,12 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format,
} else if (dest_format & 0x0200) {
if (src_format == FXDIB_Argb) {
pAlphaMask = GetAlphaMask();
- if (pAlphaMask == NULL) {
+ if (!pAlphaMask) {
FX_Free(dest_buf);
return FALSE;
}
} else {
- if (m_pAlphaMask == NULL) {
+ if (!m_pAlphaMask) {
if (!BuildAlphaMask()) {
FX_Free(dest_buf);
return FALSE;
diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp
index 314b600b6c..16772ed003 100644
--- a/core/src/fxge/dib/fx_dib_engine.cpp
+++ b/core/src/fxge/dib/fx_dib_engine.cpp
@@ -36,7 +36,7 @@ void CWeightTable::Calc(int dest_len,
}
m_pWeightTables =
FX_TryAlloc(uint8_t, (dest_max - dest_min) * m_ItemSize + 4);
- if (m_pWeightTables == NULL) {
+ if (!m_pWeightTables) {
return;
}
if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((FX_FLOAT)scale) < 1.0f) {
@@ -242,7 +242,7 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap,
size += 31;
size = size / 32 * 4;
m_pDestScanline = FX_TryAlloc(uint8_t, size);
- if (m_pDestScanline == NULL) {
+ if (!m_pDestScanline) {
return;
}
if (dest_format == FXDIB_Rgb32) {
@@ -339,13 +339,13 @@ CStretchEngine::~CStretchEngine() {
FX_Free(m_pDestMaskScanline);
}
FX_BOOL CStretchEngine::StartStretchHorz() {
- if (m_DestWidth == 0 || m_pDestScanline == NULL ||
+ if (m_DestWidth == 0 || !m_pDestScanline ||
m_SrcClip.Height() > (int)((1U << 29) / m_InterPitch) ||
m_SrcClip.Height() == 0) {
return FALSE;
}
m_pInterBuf = FX_TryAlloc(unsigned char, m_SrcClip.Height() * m_InterPitch);
- if (m_pInterBuf == NULL) {
+ if (!m_pInterBuf) {
return FALSE;
}
if (m_pSource && m_bHasAlpha && m_pSource->m_pAlphaMask) {
@@ -359,7 +359,7 @@ FX_BOOL CStretchEngine::StartStretchHorz() {
}
m_WeightTable.Calc(m_DestWidth, m_DestClip.left, m_DestClip.right, m_SrcWidth,
m_SrcClip.left, m_SrcClip.right, m_Flags);
- if (m_WeightTable.m_pWeightTables == NULL) {
+ if (!m_WeightTable.m_pWeightTables) {
return FALSE;
}
m_CurRow = m_SrcClip.top;
@@ -603,7 +603,7 @@ void CStretchEngine::StretchVert() {
CWeightTable table;
table.Calc(m_DestHeight, m_DestClip.top, m_DestClip.bottom, m_SrcHeight,
m_SrcClip.top, m_SrcClip.bottom, m_Flags);
- if (table.m_pWeightTables == NULL) {
+ if (!table.m_pWeightTables) {
return;
}
int DestBpp = m_DestBpp / 8;
@@ -849,10 +849,7 @@ FX_BOOL CFX_ImageStretcher::StartStretch() {
return TRUE;
}
FX_BOOL CFX_ImageStretcher::ContinueStretch(IFX_Pause* pPause) {
- if (m_pStretchEngine == NULL) {
- return FALSE;
- }
- return m_pStretchEngine->Continue(pPause);
+ return m_pStretchEngine && m_pStretchEngine->Continue(pPause);
}
FX_BOOL CFX_ImageStretcher::StartQuickStretch() {
m_bFlipX = FALSE;
@@ -883,7 +880,7 @@ FX_BOOL CFX_ImageStretcher::StartQuickStretch() {
return TRUE;
}
FX_BOOL CFX_ImageStretcher::ContinueQuickStretch(IFX_Pause* pPause) {
- if (m_pScanline == NULL) {
+ if (!m_pScanline) {
return FALSE;
}
int result_width = m_ClipRect.Width(), result_height = m_ClipRect.Height();
diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp
index 44d6c5022c..87c113d4ae 100644
--- a/core/src/fxge/dib/fx_dib_main.cpp
+++ b/core/src/fxge/dib/fx_dib_main.cpp
@@ -89,7 +89,7 @@ FX_BOOL CFX_DIBitmap::Create(int width,
int oomlimit = _MAX_OOM_LIMIT_;
if (oomlimit >= 0 && size >= oomlimit) {
m_pBuffer = FX_TryAlloc(uint8_t, size);
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
} else {
@@ -250,14 +250,14 @@ FX_DWORD CFX_DIBSource::GetPaletteEntry(int index) const {
}
void CFX_DIBSource::SetPaletteEntry(int index, FX_DWORD color) {
ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask());
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
BuildPalette();
}
m_pPalette[index] = color;
}
int CFX_DIBSource::FindPalette(FX_DWORD color) const {
ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask());
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
if (IsCmykImage()) {
if (GetBPP() == 1) {
return ((uint8_t)color == 0xff) ? 0 : 1;
@@ -277,7 +277,7 @@ int CFX_DIBSource::FindPalette(FX_DWORD color) const {
return -1;
}
void CFX_DIBitmap::Clear(FX_DWORD color) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return;
}
switch (GetFormat()) {
@@ -377,7 +377,7 @@ FX_BOOL CFX_DIBitmap::TransferBitmap(int dest_left,
int src_left,
int src_top,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(),
@@ -387,7 +387,7 @@ FX_BOOL CFX_DIBitmap::TransferBitmap(int dest_left,
}
FXDIB_Format dest_format = GetFormat();
FXDIB_Format src_format = pSrcBitmap->GetFormat();
- if (dest_format == src_format && pIccTransform == NULL) {
+ if (dest_format == src_format && !pIccTransform) {
if (GetBPP() == 1) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch;
@@ -440,7 +440,7 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left,
int src_top,
int alpha_flag,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
ASSERT(HasAlpha() && (m_bpp >= 24));
@@ -540,12 +540,12 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left,
return TRUE;
}
void CFX_DIBSource::CopyPalette(const FX_DWORD* pSrc, FX_DWORD size) {
- if (pSrc == NULL || GetBPP() > 8) {
+ if (!pSrc || GetBPP() > 8) {
FX_Free(m_pPalette);
m_pPalette = NULL;
} else {
FX_DWORD pal_size = 1 << GetBPP();
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
m_pPalette = FX_Alloc(FX_DWORD, pal_size);
}
if (pal_size > size) {
@@ -628,7 +628,7 @@ const int g_ChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3};
FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
const CFX_DIBSource* pSrcBitmap,
FXDIB_Channel srcChannel) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
CFX_DIBSource* pSrcClone = (CFX_DIBSource*)pSrcBitmap;
@@ -640,7 +640,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
}
if (pSrcBitmap->GetBPP() == 1) {
pSrcClone = pSrcBitmap->CloneConvert(FXDIB_8bppMask);
- if (pSrcClone == NULL) {
+ if (!pSrcClone) {
return FALSE;
}
}
@@ -661,7 +661,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
pSrcClone = pSrcBitmap->CloneConvert(
(FXDIB_Format)((pSrcBitmap->GetFormat() & 0xff00) | 0x18));
}
- if (pSrcClone == NULL) {
+ if (!pSrcClone) {
return FALSE;
}
}
@@ -723,7 +723,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
pSrcClone->GetHeight() != m_Height) {
if (pAlphaMask) {
pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height);
- if (pAlphaMask == NULL) {
+ if (!pAlphaMask) {
if (pSrcClone != pSrcBitmap) {
delete pSrcClone;
}
@@ -743,7 +743,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
if (pSrcClone != pSrcBitmap) {
delete pSrcClone;
}
- if (pSrcMatched == NULL) {
+ if (!pSrcMatched) {
return FALSE;
}
pSrcClone = pSrcMatched;
@@ -769,7 +769,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
return TRUE;
}
FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
int destOffset;
@@ -830,7 +830,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) {
return TRUE;
}
FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
ASSERT(pSrcBitmap->IsAlphaMask());
@@ -844,7 +844,7 @@ FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) {
if (pSrcBitmap->GetWidth() != m_Width ||
pSrcBitmap->GetHeight() != m_Height) {
pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height);
- if (pSrcClone == NULL) {
+ if (!pSrcClone) {
return FALSE;
}
}
@@ -897,12 +897,12 @@ FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) {
return TRUE;
}
FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
switch (GetFormat()) {
case FXDIB_1bppRgb: {
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
return FALSE;
}
uint8_t gray[2];
@@ -933,7 +933,7 @@ FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) {
break;
}
case FXDIB_8bppRgb: {
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
return FALSE;
}
uint8_t gray[256];
@@ -1001,7 +1001,7 @@ FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) {
return TRUE;
}
FX_BOOL CFX_DIBitmap::MultiplyAlpha(int alpha) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
switch (GetFormat()) {
@@ -1049,7 +1049,7 @@ FX_BOOL CFX_DIBitmap::MultiplyAlpha(int alpha) {
return TRUE;
}
FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return 0;
}
uint8_t* pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8;
@@ -1082,7 +1082,7 @@ FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const {
return 0;
}
void CFX_DIBitmap::SetPixel(int x, int y, FX_DWORD color) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return;
}
if (x < 0 || x >= m_Width || y < 0 || y >= m_Height) {
@@ -1157,7 +1157,7 @@ void CFX_DIBitmap::DownSampleScanline(int line,
FX_BOOL bFlipX,
int clip_left,
int clip_width) const {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return;
}
int src_Bpp = m_bpp / 8;
@@ -1217,7 +1217,7 @@ void CFX_DIBitmap::DownSampleScanline(int line,
FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor,
FX_DWORD backcolor) {
ASSERT(!IsAlphaMask());
- if (m_pBuffer == NULL || IsAlphaMask()) {
+ if (!m_pBuffer || IsAlphaMask()) {
return FALSE;
}
int fc, fm, fy, fk, bc, bm, by, bk;
@@ -1242,13 +1242,13 @@ FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor,
}
if (m_bpp <= 8) {
if (isCmykImage) {
- if (forecolor == 0xff && backcolor == 0 && m_pPalette == NULL) {
+ if (forecolor == 0xff && backcolor == 0 && !m_pPalette) {
return TRUE;
}
- } else if (forecolor == 0 && backcolor == 0xffffff && m_pPalette == NULL) {
+ } else if (forecolor == 0 && backcolor == 0xffffff && !m_pPalette) {
return TRUE;
}
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
BuildPalette();
}
int size = 1 << m_bpp;
@@ -1336,7 +1336,7 @@ FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor,
FX_BOOL CFX_DIBitmap::DitherFS(const FX_DWORD* pPalette,
int pal_size,
const FX_RECT* pRect) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
if (m_bpp != 8 && m_pPalette && m_AlphaFlag != 0) {
@@ -1490,9 +1490,7 @@ CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const {
}
CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) {
m_pBitmap = NULL;
- if (pSrc->GetBuffer() == NULL) {
- m_pBitmap = pSrc->Clone();
- } else {
+ if (pSrc->GetBuffer()) {
m_pBitmap = new CFX_DIBitmap;
if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(),
pSrc->GetFormat(), pSrc->GetBuffer())) {
@@ -1502,6 +1500,8 @@ CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) {
}
m_pBitmap->CopyPalette(pSrc->GetPalette());
m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask);
+ } else {
+ m_pBitmap = pSrc->Clone();
}
}
CFX_DIBExtractor::~CFX_DIBExtractor() {
@@ -1640,10 +1640,10 @@ FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) {
return TRUE;
}
CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
- if (pBitmap->GetBuffer() == NULL) {
+ if (!pBitmap->GetBuffer()) {
delete pBitmap;
return FALSE;
}
diff --git a/core/src/fxge/dib/fx_dib_transform.cpp b/core/src/fxge/dib/fx_dib_transform.cpp
index 7ff96d5ebf..d9740e0111 100644
--- a/core/src/fxge/dib/fx_dib_transform.cpp
+++ b/core/src/fxge/dib/fx_dib_transform.cpp
@@ -423,7 +423,7 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
int stretch_width = m_StretchClip.Width();
int stretch_height = m_StretchClip.Height();
- if (m_Storer.GetBitmap() == NULL) {
+ if (!m_Storer.GetBitmap()) {
return FALSE;
}
const uint8_t* stretch_buf = m_Storer.GetBitmap()->GetBuffer();
@@ -446,7 +446,7 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
(FX_FLOAT)(m_ResultTop));
result2stretch.Concat(m_dest2stretch);
result2stretch.TranslateI(-m_StretchClip.left, -m_StretchClip.top);
- if (stretch_buf_mask == NULL && pTransformed->m_pAlphaMask) {
+ if (!stretch_buf_mask && pTransformed->m_pAlphaMask) {
pTransformed->m_pAlphaMask->Clear(0xff000000);
} else if (pTransformed->m_pAlphaMask) {
int stretch_pitch_mask = m_Storer.GetBitmap()->m_pAlphaMask->GetPitch();
diff --git a/core/src/fxge/ge/fx_ge.cpp b/core/src/fxge/ge/fx_ge.cpp
index 138f81840e..f7787cf22c 100644
--- a/core/src/fxge/ge/fx_ge.cpp
+++ b/core/src/fxge/ge/fx_ge.cpp
@@ -41,7 +41,7 @@ void CFX_GEModule::Destroy() {
g_pGEModule = NULL;
}
CFX_FontCache* CFX_GEModule::GetFontCache() {
- if (m_pFontCache == NULL) {
+ if (!m_pFontCache) {
m_pFontCache = new CFX_FontCache();
}
return m_pFontCache;
diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp
index 37204268f2..268001b285 100644
--- a/core/src/fxge/ge/fx_ge_device.cpp
+++ b/core/src/fxge/ge/fx_ge_device.cpp
@@ -130,7 +130,7 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData,
if ((fill_mode & 3) == 0) {
fill_alpha = 0;
}
- if (pGraphState == NULL) {
+ if (!pGraphState) {
stroke_alpha = 0;
}
if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) {
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index 92dbf3adeb..4c0cef40c4 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -373,7 +373,7 @@ FX_BOOL CFX_Font::IsFixedWidth() const {
}
CFX_WideString CFX_Font::GetPsName() const {
- if (m_Face == NULL) {
+ if (!m_Face) {
return CFX_WideString();
}
CFX_WideString psName =
@@ -384,7 +384,7 @@ CFX_WideString CFX_Font::GetPsName() const {
return psName;
}
CFX_ByteString CFX_Font::GetFamilyName() const {
- if (m_Face == NULL && m_pSubstFont == NULL) {
+ if (!m_Face && !m_pSubstFont) {
return CFX_ByteString();
}
if (m_Face) {
@@ -393,7 +393,7 @@ CFX_ByteString CFX_Font::GetFamilyName() const {
return m_pSubstFont->m_Family;
}
CFX_ByteString CFX_Font::GetFaceName() const {
- if (m_Face == NULL && m_pSubstFont == NULL) {
+ if (!m_Face && !m_pSubstFont) {
return CFX_ByteString();
}
if (m_Face) {
@@ -411,7 +411,7 @@ CFX_ByteString CFX_Font::GetFaceName() const {
return m_pSubstFont->m_Family;
}
FX_BOOL CFX_Font::GetBBox(FX_RECT& bbox) {
- if (m_Face == NULL) {
+ if (!m_Face) {
return FALSE;
}
int em = FXFT_Get_Face_UnitsPerEM(m_Face);
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index dfd6704fe1..7f5dbe0ce7 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -315,10 +315,7 @@ CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) {
fontName.c_str(), g_AltFontFamilies,
sizeof g_AltFontFamilies / sizeof(AltFontFamily), sizeof(AltFontFamily),
CompareFontFamilyString);
- if (found == NULL) {
- return fontName;
- }
- return found->m_pFontFamily;
+ return found ? CFX_ByteString(found->m_pFontFamily) : fontName;
}
CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) {
@@ -679,7 +676,7 @@ CFX_FontMapper::~CFX_FontMapper() {
}
}
void CFX_FontMapper::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) {
- if (pFontInfo == NULL) {
+ if (!pFontInfo) {
return;
}
if (m_pFontInfo) {
@@ -721,7 +718,7 @@ CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
}
void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
- if (m_pFontInfo == NULL) {
+ if (!m_pFontInfo) {
return;
}
if (m_CharsetArray.Find((FX_DWORD)charset) == -1) {
@@ -740,11 +737,11 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
}
if (bLocalized) {
void* hFont = m_pFontInfo->GetFont(name);
- if (hFont == NULL) {
+ if (!hFont) {
int iExact;
hFont =
m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name, iExact);
- if (hFont == NULL) {
+ if (!hFont) {
return;
}
}
@@ -759,7 +756,7 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
m_LastFamily = name;
}
void CFX_FontMapper::LoadInstalledFonts() {
- if (m_pFontInfo == NULL) {
+ if (!m_pFontInfo) {
return;
}
if (m_bListLoaded) {
@@ -1019,7 +1016,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
Charset == FXFONT_CHINESEBIG5_CHARSET) {
bCJK = TRUE;
}
- if (m_pFontInfo == NULL) {
+ if (!m_pFontInfo) {
pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD;
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily);
@@ -1088,7 +1085,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
if (iExact) {
pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT;
}
- if (hFont == NULL) {
+ if (!hFont) {
#ifdef PDF_ENABLE_XFA
if (flags & FXFONT_EXACTMATCH) {
return NULL;
@@ -1104,7 +1101,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
}
if (!match.IsEmpty()) {
hFont = m_pFontInfo->GetFont(match);
- if (hFont == NULL) {
+ if (!hFont) {
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily);
}
@@ -1168,7 +1165,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
uint8_t* pFontData;
face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum,
ttc_size - font_size, pFontData);
- if (face == NULL) {
+ if (!face) {
pFontData = FX_Alloc(uint8_t, ttc_size);
m_pFontInfo->GetFontData(hFont, kTableTTCF, pFontData, ttc_size);
face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData,
@@ -1177,7 +1174,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
} else {
uint8_t* pFontData;
face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData);
- if (face == NULL) {
+ if (!face) {
pFontData = FX_Alloc(uint8_t, font_size);
m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size);
face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData,
@@ -1185,7 +1182,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
m_pFontInfo->GetFaceIndex(hFont));
}
}
- if (face == NULL) {
+ if (!face) {
m_pFontInfo->DeleteFont(hFont);
return NULL;
}
@@ -1337,7 +1334,7 @@ FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
}
void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
void* handle = FX_OpenFolder(path);
- if (handle == NULL) {
+ if (!handle) {
return;
}
CFX_ByteString filename;
@@ -1371,7 +1368,7 @@ void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
}
void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) {
FXSYS_FILE* pFile = FXSYS_fopen(path, "rb");
- if (pFile == NULL) {
+ if (!pFile) {
return;
}
FXSYS_fseek(pFile, 0, FXSYS_SEEK_END);
@@ -1582,7 +1579,7 @@ FX_DWORD CFX_FolderFontInfo::GetFontData(void* hFont,
void CFX_FolderFontInfo::DeleteFont(void* hFont) {}
FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) {
- if (hFont == NULL) {
+ if (!hFont) {
return FALSE;
}
CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont;
diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp
index 543c33ba14..23b1c2fe07 100644
--- a/core/src/fxge/ge/fx_ge_path.cpp
+++ b/core/src/fxge/ge/fx_ge_path.cpp
@@ -384,7 +384,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
return rect;
}
void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
- if (pMatrix == NULL) {
+ if (!pMatrix) {
return;
}
for (int i = 0; i < m_PointCount; i++) {
@@ -564,7 +564,7 @@ FX_BOOL CFX_PathData::IsRect() const {
}
FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
CFX_FloatRect* pRect) const {
- if (pMatrix == NULL) {
+ if (!pMatrix) {
if (!IsRect()) {
return FALSE;
}
diff --git a/core/src/fxge/ge/fx_ge_ps.cpp b/core/src/fxge/ge/fx_ge_ps.cpp
index ceb2acf2bc..f9fd8dea30 100644
--- a/core/src/fxge/ge/fx_ge_ps.cpp
+++ b/core/src/fxge/ge/fx_ge_ps.cpp
@@ -374,7 +374,7 @@ FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
int width = pSource->GetWidth();
int height = pSource->GetHeight();
buf << width << " " << height;
- if (pSource->GetBPP() == 1 && pSource->GetPalette() == NULL) {
+ if (pSource->GetBPP() == 1 && !pSource->GetPalette()) {
int pitch = (width + 7) / 8;
FX_DWORD src_size = height * pitch;
uint8_t* src_buf = FX_Alloc(uint8_t, src_size);
@@ -433,7 +433,7 @@ FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
break;
}
}
- if (pConverted == NULL) {
+ if (!pConverted) {
OUTPUT_PS("\nQ\n");
return FALSE;
}
@@ -449,7 +449,7 @@ FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
filter = "/DCTDecode filter ";
}
}
- if (filter == NULL) {
+ if (!filter) {
int src_pitch = width * Bpp;
output_size = height * src_pitch;
output_buf = FX_Alloc(uint8_t, output_size);
@@ -603,7 +603,7 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache,
matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0);
const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath(
pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
- if (pPathData == NULL) {
+ if (!pPathData) {
return;
}
CFX_PathData TransformedPath(*pPathData);
@@ -663,7 +663,7 @@ FX_BOOL CFX_PSRenderer::DrawText(int nChars,
buf << "q[" << pObject2Device->a << " " << pObject2Device->b << " "
<< pObject2Device->c << " " << pObject2Device->d << " "
<< pObject2Device->e << " " << pObject2Device->f << "]cm\n";
- if (pCache == NULL) {
+ if (!pCache) {
pCache = CFX_GEModule::Get()->GetFontCache();
}
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp
index cd6b690a12..0ed0bbbbd6 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -51,7 +51,7 @@ FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos,
for (int iChar = 0; iChar < nChars; iChar++) {
FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph;
- if (pGlyph == NULL) {
+ if (!pGlyph) {
continue;
}
int char_left = glyph.m_OriginX + pGlyph->m_Left;
@@ -141,7 +141,7 @@ void _Color2Argb(FX_ARGB& argb,
FX_DWORD color,
int alpha_flag,
void* pIccTransform) {
- if (pIccTransform == NULL && !FXGETFLAG_COLORTYPE(alpha_flag)) {
+ if (!pIccTransform && !FXGETFLAG_COLORTYPE(alpha_flag)) {
argb = color;
return;
}
@@ -243,7 +243,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
if ((text_flags & FXTEXT_NOSMOOTH) == 0) {
if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) {
FX_BOOL bClearType;
- if (pFont->GetFace() == NULL &&
+ if (!pFont->GetFace() &&
!(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_CLEARTYPE)) {
bClearType = FALSE;
} else {
@@ -264,7 +264,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
}
}
}
- if (pCache == NULL) {
+ if (!pCache) {
pCache = CFX_GEModule::Get()->GetFontCache();
}
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
@@ -335,7 +335,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
bitmap.Clear(0);
for (iChar = 0; iChar < nChars; iChar++) {
FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
- if (glyph.m_pGlyph == NULL) {
+ if (!glyph.m_pGlyph) {
continue;
}
const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
@@ -385,7 +385,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
}
for (iChar = 0; iChar < nChars; iChar++) {
FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
- if (glyph.m_pGlyph == NULL) {
+ if (!glyph.m_pGlyph) {
continue;
}
const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
@@ -1118,7 +1118,7 @@ FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars,
int alpha_flag,
void* pIccTransform,
int blend_type) {
- if (pCache == NULL) {
+ if (!pCache) {
pCache = CFX_GEModule::Get()->GetFontCache();
}
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
@@ -1133,7 +1133,7 @@ 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 == NULL) {
+ if (!pPath) {
continue;
}
matrix.Concat(*pText2User);
@@ -1378,7 +1378,7 @@ CFX_SizeGlyphCache::~CFX_SizeGlyphCache() {
void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) {
FXFT_MM_Var pMasters = NULL;
FXFT_Get_MM_Var(m_Face, &pMasters);
- if (pMasters == NULL) {
+ if (!pMasters) {
return;
}
long coords[2];
@@ -1511,7 +1511,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont,
const CFX_Matrix* pMatrix,
int dest_width,
int anti_alias) {
- if (m_Face == NULL) {
+ if (!m_Face) {
return NULL;
}
FXFT_Matrix ft_matrix;
@@ -1787,7 +1787,7 @@ static int _Outline_CubicTo(const FXFT_Vector* control1,
}
};
CFX_PathData* CFX_Font::LoadGlyphPath(FX_DWORD glyph_index, int dest_width) {
- if (m_Face == NULL) {
+ if (!m_Face) {
return NULL;
}
FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
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(
diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp
index 6d520468a3..c346d1bbc1 100644
--- a/core/src/fxge/win32/fx_win32_device.cpp
+++ b/core/src/fxge/win32/fx_win32_device.cpp
@@ -192,7 +192,7 @@ static const struct {
{"Times-Italic", "Times New Roman", FALSE, TRUE},
};
CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) {
- if (m_pMapper == NULL) {
+ if (!m_pMapper) {
return name;
}
int nFonts = m_pMapper->m_InstalledTTFonts.GetSize();
@@ -251,7 +251,7 @@ FX_BOOL _GetSubFontName(CFX_ByteString& name) {
_FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(
name.c_str(), pFontnameMap, size / sizeof(_FontNameMap),
sizeof(_FontNameMap), compareString);
- if (found == NULL) {
+ if (!found) {
return FALSE;
}
name = found->m_pSubFontName;
@@ -528,7 +528,7 @@ FX_BOOL CGdiDeviceDriver::GDI_SetDIBits(const CFX_DIBitmap* pBitmap1,
void* pIccTransform) {
if (m_DeviceClass == FXDC_PRINTER) {
CFX_DIBitmap* pBitmap = pBitmap1->FlipImage(FALSE, TRUE);
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
if ((pBitmap->IsCmykImage() || pIccTransform) &&
@@ -575,7 +575,7 @@ FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1,
FX_DWORD flags,
void* pIccTransform) {
CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
- if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
+ if (!pBitmap || dest_width == 0 || dest_height == 0) {
return FALSE;
}
if ((pBitmap->IsCmykImage() || pIccTransform) &&
@@ -620,7 +620,7 @@ FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1,
int alpha_flag,
void* pIccTransform) {
CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
- if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
+ if (!pBitmap || dest_width == 0 || dest_height == 0) {
return FALSE;
}
_Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24),
@@ -855,7 +855,7 @@ FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
_Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform);
CWin32Platform* pPlatform =
(CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
- if ((pGraphState == NULL || stroke_color == 0) &&
+ if (!(pGraphState || stroke_color == 0) &&
!pPlatform->m_GdiplusExt.IsAvailable()) {
CFX_FloatRect bbox_f = pPathData->GetBoundingBox();
if (pMatrix) {
@@ -1066,8 +1066,7 @@ FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap,
!CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
pIccTransform = NULL;
}
- if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() &&
- pIccTransform == NULL) {
+ if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && !pIccTransform) {
ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi,
DIB_RGB_COLORS) == height;
} else {
@@ -1165,7 +1164,7 @@ FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource,
bitmap_clip.Offset(-dest_left, -dest_top);
CFX_DIBitmap* pStretched =
pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip);
- if (pStretched == NULL) {
+ if (!pStretched) {
return TRUE;
}
FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
@@ -1205,7 +1204,7 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
int clip_width = clip_rect.Width(), clip_height = clip_rect.Height();
CFX_DIBitmap* pStretched =
pSource->StretchTo(dest_width, dest_height, flags, &clip_rect);
- if (pStretched == NULL) {
+ if (!pStretched) {
return TRUE;
}
CFX_DIBitmap background;
@@ -1228,11 +1227,11 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (pSource->HasAlpha()) {
CWin32Platform* pPlatform =
(CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
- if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL &&
+ if (pPlatform->m_GdiplusExt.IsAvailable() && !pIccTransform &&
!pSource->IsCmykImage()) {
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return pPlatform->m_GdiplusExt.StretchDIBits(
@@ -1340,7 +1339,7 @@ CFX_WinBitmapDevice::CFX_WinBitmapDevice(int width,
uint8_t* pBuffer;
m_hBitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
(void**)&pBuffer, NULL, 0);
- if (m_hBitmap == NULL) {
+ if (!m_hBitmap) {
return;
}
CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp
index 1aa60f084e..1fdf3ae9b1 100644
--- a/core/src/fxge/win32/fx_win32_dib.cpp
+++ b/core/src/fxge/win32/fx_win32_dib.cpp
@@ -28,24 +28,24 @@ CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) {
pbmih->biWidth = pBitmap->GetWidth();
if (pBitmap->GetBPP() == 8) {
FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1);
- if (pBitmap->GetPalette() == NULL) {
+ if (pBitmap->GetPalette()) {
for (int i = 0; i < 256; i++) {
- pPalette[i] = i * 0x010101;
+ pPalette[i] = pBitmap->GetPalette()[i];
}
} else {
for (int i = 0; i < 256; i++) {
- pPalette[i] = pBitmap->GetPalette()[i];
+ pPalette[i] = i * 0x010101;
}
}
}
if (pBitmap->GetBPP() == 1) {
FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1);
- if (pBitmap->GetPalette() == NULL) {
- pPalette[0] = 0;
- pPalette[1] = 0xffffff;
- } else {
+ if (pBitmap->GetPalette()) {
pPalette[0] = pBitmap->GetPalette()[0];
pPalette[1] = pBitmap->GetPalette()[1];
+ } else {
+ pPalette[0] = 0;
+ pPalette[1] = 0xffffff;
}
}
result.ReleaseBuffer(len);
@@ -125,7 +125,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) {
}
HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE);
- if (hBitmap == NULL) {
+ if (!hBitmap) {
return NULL;
}
HDC hDC = CreateCompatibleDC(NULL);
@@ -158,7 +158,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) {
}
HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name,
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- if (hBitmap == NULL) {
+ if (!hBitmap) {
return NULL;
}
HDC hDC = CreateCompatibleDC(NULL);
@@ -184,8 +184,8 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC,
HBITMAP hBitmap,
FX_DWORD* pPalette,
FX_DWORD palsize) {
- FX_BOOL bCreatedDC = hDC == NULL;
- if (hDC == NULL) {
+ FX_BOOL bCreatedDC = !hDC;
+ if (bCreatedDC) {
hDC = CreateCompatibleDC(NULL);
}
BITMAPINFOHEADER bmih;
diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp
index 83924f23e7..9e56ee7672 100644
--- a/core/src/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/src/fxge/win32/fx_win32_dwrite.cpp
@@ -65,7 +65,7 @@ class CDwFontFileLoader final : public IDWriteFontFileLoader {
OUT IDWriteFontFileStream** fontFileStream);
static IDWriteFontFileLoader* GetLoader() {
- if (instance_ == NULL) {
+ if (!instance_) {
instance_ = new CDwFontFileLoader();
}
return instance_;
@@ -216,7 +216,7 @@ FX_BOOL CDWriteExt::DwRendingString(void* renderTarget,
FX_FLOAT baselineOriginY,
void* glyph_offsets,
FX_FLOAT* glyph_advances) {
- if (renderTarget == NULL) {
+ if (!renderTarget) {
return TRUE;
}
CDwGdiTextRenderer* pTextRenderer = (CDwGdiTextRenderer*)renderTarget;
diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp
index e79a88cb81..1e4f89540b 100644
--- a/core/src/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/src/fxge/win32/fx_win32_gdipext.cpp
@@ -686,12 +686,12 @@ void CGdiplusExt::Load() {
strPlusPath += "\\";
strPlusPath += "GDIPLUS.DLL";
m_hModule = LoadLibraryA(strPlusPath);
- if (m_hModule == NULL) {
+ if (!m_hModule) {
return;
}
for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);
- if (m_Functions[i] == NULL) {
+ if (!m_Functions[i]) {
m_hModule = NULL;
return;
}
@@ -701,7 +701,7 @@ void CGdiplusExt::Load() {
((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])(
&gdiplusToken, &gdiplusStartupInput, NULL);
m_GdiModule = LoadLibraryA("GDI32.DLL");
- if (m_GdiModule == NULL) {
+ if (!m_GdiModule) {
return;
}
m_pGdiAddFontMemResourceEx =
@@ -973,9 +973,9 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState,
FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f;
if (!bTextMode) {
FX_FLOAT unit =
- pMatrix == NULL
- ? 1.0f
- : FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2);
+ pMatrix
+ ? FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2)
+ : 1.0f;
if (width < unit) {
width = unit;
}
@@ -1198,7 +1198,7 @@ FX_BOOL CGdiplusExt::DrawPath(HDC hDC,
}
}
int new_fill_mode = fill_mode & 3;
- if (nPoints == 4 && pGraphState == NULL) {
+ if (nPoints == 4 && !pGraphState) {
int v1, v2;
if (IsSmallTriangle(points, pObject2Device, v1, v2)) {
GpPen* pPen = NULL;
@@ -1380,7 +1380,7 @@ class GpStream final : public IStream {
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag) {
- if (pStatstg == NULL) {
+ if (!pStatstg) {
return STG_E_INVALIDFUNCTION;
}
ZeroMemory(pStatstg, sizeof(STATSTG));
@@ -1492,7 +1492,7 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
FX_BOOL bAlpha);
CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) {
PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args);
- if (pInfo == NULL) {
+ if (!pInfo) {
return NULL;
}
int height = abs(pInfo->pbmi->bmiHeader.biHeight);
diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp
index 39828b14d8..0c00a7b3d9 100644
--- a/core/src/fxge/win32/fx_win32_print.cpp
+++ b/core/src/fxge/win32/fx_win32_print.cpp
@@ -56,7 +56,7 @@ FX_BOOL CGdiPrinterDriver::SetDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
@@ -82,7 +82,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (dest_width < 0 || dest_height < 0) {
CFX_DIBitmap* pFlipped =
pSource->FlipImage(dest_width < 0, dest_height < 0);
- if (pFlipped == NULL) {
+ if (!pFlipped) {
return FALSE;
}
if (dest_width < 0) {
@@ -99,7 +99,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width,
@@ -112,7 +112,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (dest_width < 0 || dest_height < 0) {
CFX_DIBitmap* pFlipped =
pSource->FlipImage(dest_width < 0, dest_height < 0);
- if (pFlipped == NULL) {
+ if (!pFlipped) {
return FALSE;
}
if (dest_width < 0) {
@@ -129,7 +129,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width,
@@ -142,7 +142,7 @@ static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc,
pSrc->GetFormat() == FXDIB_1bppCmyk);
CFX_DIBExtractor src_bitmap(pSrc);
CFX_DIBitmap* pSrcBitmap = src_bitmap;
- if (pSrcBitmap == NULL) {
+ if (!pSrcBitmap) {
return NULL;
}
int src_width = pSrcBitmap->GetWidth(), src_height = pSrcBitmap->GetHeight();
@@ -250,7 +250,7 @@ FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource,
if (FXSYS_fabs(pMatrix->a) < 0.5f && FXSYS_fabs(pMatrix->d) < 0.5f) {
CFX_DIBitmap* pTransformed =
pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0);
- if (pTransformed == NULL) {
+ if (!pTransformed) {
return FALSE;
}
FX_BOOL ret = StretchDIBits(
@@ -261,7 +261,7 @@ FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource,
}
if (pSource->GetBPP() == 1) {
CFX_DIBitmap* pTransformed = Transform1bppBitmap(pSource, pMatrix);
- if (pIccTransform == NULL) {
+ if (!pIccTransform) {
return FALSE;
}
SaveState();