Remove unused CFX_DIBitmap::SetPixel()
It has no callers. Also rename GetPixel() to GetPixelForTesting(), since
only fx_skia_device_embeddertest.cpp calls is.
Change-Id: I9f9db6d9d86a1800aa89c981520d119740dbb01e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/115471
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index f4bbf61..8a1eb61 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -494,7 +494,7 @@
}
#if defined(PDF_USE_SKIA)
-uint32_t CFX_DIBitmap::GetPixel(int x, int y) const {
+uint32_t CFX_DIBitmap::GetPixelForTesting(int x, int y) const {
if (!m_pBuffer)
return 0;
@@ -533,77 +533,6 @@
}
return 0;
}
-
-void CFX_DIBitmap::SetPixel(int x, int y, uint32_t color) {
- if (!m_pBuffer)
- return;
-
- if (x < 0 || x >= m_Width || y < 0 || y >= m_Height)
- return;
-
- FX_SAFE_UINT32 offset = x;
- offset *= GetBPP();
- offset /= 8;
- if (!offset.IsValid())
- return;
-
- uint8_t* pos = m_pBuffer.Get() + y * m_Pitch + offset.ValueOrDie();
- switch (GetFormat()) {
- case FXDIB_Format::k1bppMask:
- if (color >> 24) {
- *pos |= 1 << (7 - x % 8);
- } else {
- *pos &= ~(1 << (7 - x % 8));
- }
- break;
- case FXDIB_Format::k1bppRgb:
- if (HasPalette()) {
- if (color == GetPaletteSpan()[1]) {
- *pos |= 1 << (7 - x % 8);
- } else {
- *pos &= ~(1 << (7 - x % 8));
- }
- } else {
- if (color == 0xffffffff) {
- *pos |= 1 << (7 - x % 8);
- } else {
- *pos &= ~(1 << (7 - x % 8));
- }
- }
- break;
- case FXDIB_Format::k8bppMask:
- *pos = (uint8_t)(color >> 24);
- break;
- case FXDIB_Format::k8bppRgb: {
- if (HasPalette()) {
- pdfium::span<const uint32_t> palette = GetPaletteSpan();
- for (int i = 0; i < 256; i++) {
- if (palette[i] == color) {
- *pos = (uint8_t)i;
- return;
- }
- }
- *pos = 0;
- } else {
- *pos = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color));
- }
- break;
- }
- case FXDIB_Format::kRgb:
- case FXDIB_Format::kRgb32: {
- int alpha = FXARGB_A(color);
- pos[0] = (FXARGB_B(color) * alpha + pos[0] * (255 - alpha)) / 255;
- pos[1] = (FXARGB_G(color) * alpha + pos[1] * (255 - alpha)) / 255;
- pos[2] = (FXARGB_R(color) * alpha + pos[2] * (255 - alpha)) / 255;
- break;
- }
- case FXDIB_Format::kArgb:
- FXARGB_SETDIB(pos, color);
- break;
- default:
- break;
- }
-}
#endif // defined(PDF_USE_SKIA)
void CFX_DIBitmap::ConvertBGRColorScale(uint32_t forecolor,
diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h
index 5b10811..e48f35a 100644
--- a/core/fxge/dib/cfx_dibitmap.h
+++ b/core/fxge/dib/cfx_dibitmap.h
@@ -56,8 +56,7 @@
void Clear(uint32_t color);
#if defined(PDF_USE_SKIA)
- uint32_t GetPixel(int x, int y) const;
- void SetPixel(int x, int y, uint32_t color);
+ uint32_t GetPixelForTesting(int x, int y) const;
#endif // defined(PDF_USE_SKIA)
bool SetRedFromBitmap(RetainPtr<const CFX_DIBBase> source);
diff --git a/core/fxge/skia/fx_skia_device_embeddertest.cpp b/core/fxge/skia/fx_skia_device_embeddertest.cpp
index d904230..5d64a1c 100644
--- a/core/fxge/skia/fx_skia_device_embeddertest.cpp
+++ b/core/fxge/skia/fx_skia_device_embeddertest.cpp
@@ -159,7 +159,7 @@
auto driver = CFX_SkiaDeviceDriver::Create(pBitmap, false, nullptr, false);
ASSERT_TRUE(driver);
(*Test)(driver.get(), state);
- uint32_t pixel = pBitmap->GetPixel(0, 0);
+ uint32_t pixel = pBitmap->GetPixelForTesting(0, 0);
EXPECT_EQ(state.m_pixel, pixel);
}