Make CFX_DIBBase::IsAlphaMask() consistent with related functions.
Make IsAlphaMask(), which reads from |m_AlphaFlag|, consistent with
HasAlpha() and IsCmykImage(). This fulfills part of a TODO comment.
The other part of the TODO comment regarding IsOpaqueImage() is wrong,
so delete it. Along the way, reimplement IsOpaqueImage() using
IsAlphaMask() and HasAlpha().
Change-Id: I5bc5a363f94f6d9e3b64995d2cd103ab0ea24e53
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65052
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index bffe7dd..cbde6f9 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -29,7 +29,7 @@
class CFX_DIBitmap;
class PauseIndicatorIface;
-// Base class for all Device-Indepenent Bitmaps.
+// Base class for all Device-Independent Bitmaps.
class CFX_DIBBase : public Retainable {
public:
~CFX_DIBBase() override;
@@ -58,13 +58,10 @@
uint32_t* GetPalette() const { return m_pPalette.get(); }
int GetBPP() const { return m_bpp; }
- // TODO(thestig): Investigate this. Given the possible values of FXDIB_Format,
- // it feels as though this should be implemented as !!(m_AlphaFlag & 1) and
- // IsOpaqueImage() below should never be able to return true.
- bool IsAlphaMask() const { return m_AlphaFlag == 1; }
+ bool IsAlphaMask() const { return !!(m_AlphaFlag & 1); }
bool HasAlpha() const { return !!(m_AlphaFlag & 2); }
- bool IsOpaqueImage() const { return !(m_AlphaFlag & 3); }
bool IsCmykImage() const { return !!(m_AlphaFlag & 4); }
+ bool IsOpaqueImage() const { return !IsAlphaMask() && !HasAlpha(); }
int GetPaletteSize() const {
return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0));