Avoid UNSAFE_TODO() in CPDF_RenderStatus::CompositeDIBitmap().
Hide the "unsafety" behind a reinterpret_cast to a struct type. It was
always safe to begin with ... but avoid writing a safety comment.
Bug: 42271176
Change-Id: I5f4bd854cc823f38a2181767275da058939a4f42
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/122598
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index a742ad2..d291ecf 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1255,10 +1255,10 @@
return;
}
} else {
- uint32_t fill_argb = m_Options.TranslateColor(mask_argb);
+ FX_ARGB fill_argb = m_Options.TranslateColor(mask_argb);
if (alpha != 1.0f) {
- uint8_t* fill_argb8 = reinterpret_cast<uint8_t*>(&fill_argb);
- UNSAFE_TODO(fill_argb8[3]) *= FXSYS_roundf(alpha * 255) / 255;
+ auto& bgra = reinterpret_cast<FX_BGRA_STRUCT<uint8_t>&>(fill_argb);
+ bgra.alpha *= FXSYS_roundf(alpha * 255) / 255;
}
if (m_pDevice->SetBitMask(bitmap, left, top, fill_argb)) {
return;