Move DebugVerifyBitmapIsPreMultiplied to CFX_DIBitmap (skia only). Introduce DebugVerifyBufferIsPreMultiplied() for CFX_DIBBase. This is one step in moving to a world where GetBuffer() is only called on CFX_DIBitmap, not the base class (which doesn't have a buffer). Change-Id: Ie05d6b9f2a7249421b003c5be15b7a7073e58378 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85690 Reviewed-by: Hui Yingst <nigi@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h index fb50e51..705c3bf 100644 --- a/core/fxge/dib/cfx_dibbase.h +++ b/core/fxge/dib/cfx_dibbase.h
@@ -94,7 +94,7 @@ const CFX_ClipRgn* pClipRgn) const; #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_) - void DebugVerifyBitmapIsPreMultiplied(void* buffer) const; + void DebugVerifyBufferIsPreMultiplied(void* buffer) const; #endif protected:
diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h index 1ffbdc0..c3d9eb0 100644 --- a/core/fxge/dib/cfx_dibitmap.h +++ b/core/fxge/dib/cfx_dibitmap.h
@@ -107,6 +107,7 @@ #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_) void PreMultiply(); + void DebugVerifyBitmapIsPreMultiplied() const; #endif #if defined(_SKIA_SUPPORT_PATHS_) void UnPreMultiply();
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index cd2a6bf..5d0567c 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp
@@ -286,13 +286,13 @@ if (bitmap) { DCHECK(bitmap->GetBPP() == 8 || bitmap->GetBPP() == 32); if (bitmap->GetBPP() == 32) { - bitmap->DebugVerifyBitmapIsPreMultiplied(nullptr); + bitmap->DebugVerifyBitmapIsPreMultiplied(); } } if (device) { DCHECK(device->GetBPP() == 8 || device->GetBPP() == 32); if (device->GetBPP() == 32) { - device->DebugVerifyBitmapIsPreMultiplied(nullptr); + device->DebugVerifyBitmapIsPreMultiplied(); } } } @@ -716,7 +716,7 @@ case 32: colorType = Get32BitSkColorType(bRgbByteOrder); alphaType = kPremul_SkAlphaType; - pSource->DebugVerifyBitmapIsPreMultiplied(buffer); + pSource->DebugVerifyBufferIsPreMultiplied(buffer); break; default: NOTREACHED(); // TODO(bug_11) ensure that all cases are covered @@ -2625,7 +2625,7 @@ SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); SkPixmap premultiplied(premultipliedInfo, buffer, rowBytes); unpremultiplied.readPixels(premultiplied); - this->DebugVerifyBitmapIsPreMultiplied(nullptr); + this->DebugVerifyBitmapIsPreMultiplied(); } #if defined(_SKIA_SUPPORT_PATHS_) @@ -2639,7 +2639,7 @@ m_nFormat = Format::kUnPreMultiplied; if (priorFormat != Format::kPreMultiplied) return; - this->DebugVerifyBitmapIsPreMultiplied(nullptr); + this->DebugVerifyBitmapIsPreMultiplied(); int height = this->GetHeight(); int width = this->GetWidth(); int rowBytes = this->GetPitch(); @@ -2730,7 +2730,7 @@ #if defined(_SKIA_SUPPORT_) void CFX_SkiaDeviceDriver::DebugVerifyBitmapIsPreMultiplied() const { if (m_pBackdropBitmap) - m_pBackdropBitmap->DebugVerifyBitmapIsPreMultiplied(nullptr); + m_pBackdropBitmap->DebugVerifyBitmapIsPreMultiplied(); } #endif @@ -2818,10 +2818,10 @@ } #endif // defined(_SKIA_SUPPORT_) -void CFX_DIBBase::DebugVerifyBitmapIsPreMultiplied(void* opt) const { +void CFX_DIBBase::DebugVerifyBufferIsPreMultiplied(void* arg) const { #ifdef SK_DEBUG DCHECK_EQ(GetBPP(), 32); - const uint32_t* buffer = (const uint32_t*)(opt ? opt : GetBuffer()); + const uint32_t* buffer = (const uint32_t*)arg; int width = GetWidth(); int height = GetHeight(); // verify that input is really premultiplied @@ -2840,3 +2840,9 @@ } #endif // SK_DEBUG } + +void CFX_DIBitmap::DebugVerifyBitmapIsPreMultiplied() const { +#ifdef SK_DEBUG + DebugVerifyBufferIsPreMultiplied(GetBuffer()); +#endif // SK_DEBUG +}