summaryrefslogtreecommitdiff
path: root/core/src/fxge/dib
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-14 18:34:00 -0800
committerLei Zhang <thestig@chromium.org>2015-12-14 18:34:00 -0800
commit412e908082a361d0fd9591eab939e96a882212f1 (patch)
tree11726052ae08f13dc5a05a82cbce870758580aeb /core/src/fxge/dib
parent96660d6f382204339d6b1aadc3913303d436e252 (diff)
downloadpdfium-412e908082a361d0fd9591eab939e96a882212f1.tar.xz
Merge to XFA: Get rid of most instance of 'foo == NULL'
TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1520063002 . (cherry picked from commit e385244f8cd6ae376f6b3cf1265a0795d5d30eff) Review URL: https://codereview.chromium.org/1528763003 .
Diffstat (limited to 'core/src/fxge/dib')
-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
5 files changed, 185 insertions, 194 deletions
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();