Rename CFX_DIBBase members to use Google C++ style names - Switch to the preferred naming convention. - In CPDF_TransferFuncDIB, avoid direct variable access and upgrade the DCHECK() to a CHECK(). Change-Id: Id1e4e676a3ac7e8a373225410c2b13b95114655c Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/121557 Reviewed-by: dan sinclair <dsinclair@google.com> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_pageimagecache.cpp b/core/fpdfapi/page/cpdf_pageimagecache.cpp index d1ac782..8b58973 100644 --- a/core/fpdfapi/page/cpdf_pageimagecache.cpp +++ b/core/fpdfapi/page/cpdf_pageimagecache.cpp
@@ -58,7 +58,7 @@ if (image_->HasPalette()) { pdfium::span<const uint32_t> palette = image_->GetPaletteSpan(); - m_palette = DataVector<uint32_t>(palette.begin(), palette.end()); + palette_ = DataVector<uint32_t>(palette.begin(), palette.end()); } }
diff --git a/core/fpdfapi/page/cpdf_transferfuncdib.cpp b/core/fpdfapi/page/cpdf_transferfuncdib.cpp index 503e8bf..b2b353a 100644 --- a/core/fpdfapi/page/cpdf_transferfuncdib.cpp +++ b/core/fpdfapi/page/cpdf_transferfuncdib.cpp
@@ -34,7 +34,7 @@ SetFormat(GetDestFormat()); SetPitch(fxge::CalculatePitch32OrDie(GetBPP(), GetWidth())); m_Scanline.resize(GetPitch()); - DCHECK(m_palette.empty()); + CHECK(!HasPalette()); } CPDF_TransferFuncDIB::~CPDF_TransferFuncDIB() = default;
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp index 4df13bf..325ec0d 100644 --- a/core/fxge/dib/cfx_dibbase.cpp +++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -732,11 +732,11 @@ return; if (GetBPP() == 1) { - m_palette = {0xff000000, 0xffffffff}; + palette_ = {0xff000000, 0xffffffff}; } else if (GetBPP() == 8) { - m_palette.resize(256); + palette_.resize(256); for (int i = 0; i < 256; ++i) - m_palette[i] = ArgbEncode(0xff, i, i, i); + palette_[i] = ArgbEncode(0xff, i, i, i); } } @@ -768,7 +768,7 @@ void CFX_DIBBase::SetPaletteArgb(int index, uint32_t color) { DCHECK((GetBPP() == 1 || GetBPP() == 8) && !IsMaskFormat()); BuildPalette(); - m_palette[index] = color; + palette_[index] = color; } int CFX_DIBBase::FindPalette(uint32_t color) const { @@ -889,14 +889,14 @@ void CFX_DIBBase::TakePalette(DataVector<uint32_t> src_palette) { if (src_palette.empty() || GetBPP() > 8) { - m_palette.clear(); + palette_.clear(); return; } - m_palette = std::move(src_palette); + palette_ = std::move(src_palette); uint32_t pal_size = 1 << GetBPP(); CHECK_LE(pal_size, kPaletteSize); - m_palette.resize(pal_size); + palette_.resize(pal_size); } RetainPtr<CFX_DIBitmap> CFX_DIBBase::CloneAlphaMask() const {
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h index 1eb780b..ec9ca09 100644 --- a/core/fxge/dib/cfx_dibbase.h +++ b/core/fxge/dib/cfx_dibbase.h
@@ -56,18 +56,18 @@ return fxcrt::reinterpret_span<const T>(GetScanline(line)); } - int GetWidth() const { return m_Width; } - int GetHeight() const { return m_Height; } - uint32_t GetPitch() const { return m_Pitch; } + int GetWidth() const { return width_; } + int GetHeight() const { return height_; } + uint32_t GetPitch() const { return pitch_; } - FXDIB_Format GetFormat() const { return m_Format; } + FXDIB_Format GetFormat() const { return format_; } int GetBPP() const { return GetBppFromFormat(GetFormat()); } bool IsMaskFormat() const { return GetIsMaskFromFormat(GetFormat()); } bool IsAlphaFormat() const { return GetFormat() == FXDIB_Format::kArgb; } bool IsOpaqueImage() const { return !IsMaskFormat() && !IsAlphaFormat(); } - bool HasPalette() const { return !m_palette.empty(); } - pdfium::span<const uint32_t> GetPaletteSpan() const { return m_palette; } + bool HasPalette() const { return !palette_.empty(); } + pdfium::span<const uint32_t> GetPaletteSpan() const { return palette_; } size_t GetRequiredPaletteSize() const; uint32_t GetPaletteArgb(int index) const; void SetPaletteArgb(int index, uint32_t color); @@ -133,18 +133,18 @@ void BuildPalette(); int FindPalette(uint32_t color) const; - void SetFormat(FXDIB_Format format) { m_Format = format; } - void SetWidth(int width) { m_Width = width; } - void SetHeight(int height) { m_Height = height; } - void SetPitch(uint32_t pitch) { m_Pitch = pitch; } + void SetFormat(FXDIB_Format format) { format_ = format; } + void SetWidth(int width) { width_ = width; } + void SetHeight(int height) { height_ = height; } + void SetPitch(uint32_t pitch) { pitch_ = pitch; } - DataVector<uint32_t> m_palette; + DataVector<uint32_t> palette_; private: - FXDIB_Format m_Format = FXDIB_Format::kInvalid; - int m_Width = 0; - int m_Height = 0; - uint32_t m_Pitch = 0; + FXDIB_Format format_ = FXDIB_Format::kInvalid; + int width_ = 0; + int height_ = 0; + uint32_t pitch_ = 0; }; #endif // CORE_FXGE_DIB_CFX_DIBBASE_H_
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp index ae81e14..e687048 100644 --- a/core/fxge/dib/cfx_dibitmap.cpp +++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -124,7 +124,7 @@ void CFX_DIBitmap::TakeOver(RetainPtr<CFX_DIBitmap>&& pSrcBitmap) { m_pBuffer = std::move(pSrcBitmap->m_pBuffer); - m_palette = std::move(pSrcBitmap->m_palette); + palette_ = std::move(pSrcBitmap->palette_); pSrcBitmap->m_pBuffer = nullptr; SetFormat(pSrcBitmap->GetFormat()); SetWidth(pSrcBitmap->GetWidth()); @@ -435,9 +435,9 @@ BuildPalette(); int size = 1 << GetBPP(); for (int i = 0; i < size; ++i) { - int gray = FXRGB2GRAY(FXARGB_R(m_palette[i]), FXARGB_G(m_palette[i]), - FXARGB_B(m_palette[i])); - m_palette[i] = + int gray = FXRGB2GRAY(FXARGB_R(palette_[i]), FXARGB_G(palette_[i]), + FXARGB_B(palette_[i])); + palette_[i] = ArgbEncode(0xff, br + (fr - br) * gray / 255, bg + (fg - bg) * gray / 255, bb + (fb - bb) * gray / 255); } @@ -859,7 +859,7 @@ } RetainPtr<CFX_DIBBase> holder(this); // SAFETY: `dest_buf` allocated with `dest_buf_size` bytes above. - m_palette = ConvertBuffer( + palette_ = ConvertBuffer( dest_format, UNSAFE_BUFFERS(pdfium::make_span(dest_buf.get(), dest_buf_size)), dest_pitch, GetWidth(), GetHeight(), holder, /*src_left=*/0,