Rename weight table Calc() methods to CalculateWeights()
Be more explicit that only the weights are calculated, and not any
pixels resulting from a convolution.
Change-Id: I7f80db9dd350e96879d027588849cf22bb675616
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/82013
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/progressive_decoder.cpp b/core/fxcodec/progressive_decoder.cpp
index fede3e8..8d4e9d5 100644
--- a/core/fxcodec/progressive_decoder.cpp
+++ b/core/fxcodec/progressive_decoder.cpp
@@ -68,7 +68,8 @@
ProgressiveDecoder::WeightTable::~WeightTable() = default;
-void ProgressiveDecoder::WeightTable::Calc(int dest_len, int src_len) {
+void ProgressiveDecoder::WeightTable::CalculateWeights(int dest_len,
+ int src_len) {
CHECK_GE(dest_len, 0);
double scale = static_cast<double>(src_len) / dest_len;
const size_t weight_count = static_cast<size_t>(ceil(fabs(scale))) + 1;
@@ -140,7 +141,8 @@
ProgressiveDecoder::HorzTable::~HorzTable() = default;
-void ProgressiveDecoder::HorzTable::Calc(int dest_len, int src_len) {
+void ProgressiveDecoder::HorzTable::CalculateWeights(int dest_len,
+ int src_len) {
CHECK_GE(dest_len, 0);
m_ItemSize = PixelWeight::TotalBytesForWeightCount(2);
FX_SAFE_SIZE_T safe_size = m_ItemSize;
@@ -195,7 +197,8 @@
ProgressiveDecoder::VertTable::~VertTable() = default;
-void ProgressiveDecoder::VertTable::Calc(int dest_len, int src_len) {
+void ProgressiveDecoder::VertTable::CalculateWeights(int dest_len,
+ int src_len) {
CHECK_GE(dest_len, 0);
m_ItemSize = PixelWeight::TotalBytesForWeightCount(2);
FX_SAFE_SIZE_T safe_size = m_ItemSize;
@@ -789,8 +792,8 @@
GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
m_ScanlineSize = FxAlignToBoundary<4>(m_SrcWidth * m_SrcComponents);
m_pDecodeBuf.reset(FX_Alloc(uint8_t, m_ScanlineSize));
- m_WeightHorz.Calc(m_sizeX, m_clipBox.Width());
- m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
+ m_WeightHorz.CalculateWeights(m_sizeX, m_clipBox.Width());
+ m_WeightVert.CalculateWeights(m_sizeY, m_clipBox.Height());
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
}
@@ -861,8 +864,8 @@
GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
int scanline_size = FxAlignToBoundary<4>(m_SrcWidth);
m_pDecodeBuf.reset(FX_Alloc(uint8_t, scanline_size));
- m_WeightHorz.Calc(m_sizeX, m_clipBox.Width());
- m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
+ m_WeightHorz.CalculateWeights(m_sizeX, m_clipBox.Width());
+ m_WeightVert.CalculateWeights(m_sizeY, m_clipBox.Height());
m_FrameCur = 0;
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
@@ -1053,8 +1056,8 @@
int scanline_size = (m_SrcWidth + down_scale - 1) / down_scale;
scanline_size = FxAlignToBoundary<4>(scanline_size * m_SrcComponents);
m_pDecodeBuf.reset(FX_Alloc(uint8_t, scanline_size));
- m_WeightHorz.Calc(m_sizeX, m_clipBox.Width());
- m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
+ m_WeightHorz.CalculateWeights(m_sizeX, m_clipBox.Width());
+ m_WeightVert.CalculateWeights(m_sizeY, m_clipBox.Height());
switch (m_SrcComponents) {
case 1:
m_SrcFormat = FXCodec_8bppGray;
@@ -1252,8 +1255,8 @@
GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat);
int scanline_size = FxAlignToBoundary<4>(m_SrcWidth * m_SrcComponents);
m_pDecodeBuf.reset(FX_Alloc(uint8_t, scanline_size));
- m_WeightHorzOO.Calc(m_sizeX, m_clipBox.Width());
- m_WeightVert.Calc(m_sizeY, m_clipBox.Height());
+ m_WeightHorzOO.CalculateWeights(m_sizeX, m_clipBox.Width());
+ m_WeightVert.CalculateWeights(m_sizeY, m_clipBox.Height());
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
}
diff --git a/core/fxcodec/progressive_decoder.h b/core/fxcodec/progressive_decoder.h
index 7e3af0b..1f25302 100644
--- a/core/fxcodec/progressive_decoder.h
+++ b/core/fxcodec/progressive_decoder.h
@@ -125,7 +125,7 @@
WeightTable();
~WeightTable();
- void Calc(int dest_len, int src_len);
+ void CalculateWeights(int dest_len, int src_len);
PixelWeight* GetPixelWeight(int pixel) {
return reinterpret_cast<PixelWeight*>(m_pWeightTables.data() +
(pixel - m_DestMin) * m_ItemSize);
@@ -141,7 +141,7 @@
HorzTable();
~HorzTable();
- void Calc(int dest_len, int src_len);
+ void CalculateWeights(int dest_len, int src_len);
PixelWeight* GetPixelWeight(int pixel) {
return reinterpret_cast<PixelWeight*>(m_pWeightTables.data() +
pixel * m_ItemSize);
@@ -156,7 +156,7 @@
VertTable();
~VertTable();
- void Calc(int dest_len, int src_len);
+ void CalculateWeights(int dest_len, int src_len);
PixelWeight* GetPixelWeight(int pixel) {
return reinterpret_cast<PixelWeight*>(m_pWeightTables.data() +
pixel * m_ItemSize);
diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp
index e2b9d86..64e54d4 100644
--- a/core/fxge/dib/cstretchengine.cpp
+++ b/core/fxge/dib/cstretchengine.cpp
@@ -40,13 +40,14 @@
CStretchEngine::CWeightTable::~CWeightTable() = default;
-bool CStretchEngine::CWeightTable::Calc(int dest_len,
- int dest_min,
- int dest_max,
- int src_len,
- int src_min,
- int src_max,
- const FXDIB_ResampleOptions& options) {
+bool CStretchEngine::CWeightTable::CalculateWeights(
+ int dest_len,
+ int dest_min,
+ int dest_max,
+ int src_len,
+ int src_min,
+ int src_max,
+ const FXDIB_ResampleOptions& options) {
// 512MB should be large enough for this while preventing OOM.
static constexpr size_t kMaxTableBytesAllowed = 512 * 1024 * 1024;
@@ -256,9 +257,9 @@
m_ExtraAlphaBuf.resize(m_SrcClip.Height(), m_ExtraMaskPitch);
m_DestMaskScanline.resize(m_ExtraMaskPitch);
}
- bool ret = m_WeightTable.Calc(m_DestWidth, m_DestClip.left, m_DestClip.right,
- m_SrcWidth, m_SrcClip.left, m_SrcClip.right,
- m_ResampleOptions);
+ bool ret = m_WeightTable.CalculateWeights(
+ m_DestWidth, m_DestClip.left, m_DestClip.right, m_SrcWidth,
+ m_SrcClip.left, m_SrcClip.right, m_ResampleOptions);
if (!ret)
return false;
@@ -448,9 +449,9 @@
return;
CWeightTable table;
- bool ret =
- table.Calc(m_DestHeight, m_DestClip.top, m_DestClip.bottom, m_SrcHeight,
- m_SrcClip.top, m_SrcClip.bottom, m_ResampleOptions);
+ bool ret = table.CalculateWeights(
+ m_DestHeight, m_DestClip.top, m_DestClip.bottom, m_SrcHeight,
+ m_SrcClip.top, m_SrcClip.bottom, m_ResampleOptions);
if (!ret)
return;
diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h
index e860014..4e406fe 100644
--- a/core/fxge/dib/cstretchengine.h
+++ b/core/fxge/dib/cstretchengine.h
@@ -46,13 +46,13 @@
CWeightTable();
~CWeightTable();
- bool Calc(int dest_len,
- int dest_min,
- int dest_max,
- int src_len,
- int src_min,
- int src_max,
- const FXDIB_ResampleOptions& options);
+ bool CalculateWeights(int dest_len,
+ int dest_min,
+ int dest_max,
+ int src_len,
+ int src_min,
+ int src_max,
+ const FXDIB_ResampleOptions& options);
const PixelWeight* GetPixelWeight(int pixel) const;
PixelWeight* GetPixelWeight(int pixel) {