diff options
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/dib/cfx_dibextractor.cpp | 4 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.cpp | 8 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibsource.cpp | 46 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibsource.h | 32 | ||||
-rw-r--r-- | core/fxge/dib/cfx_imagestretcher.cpp | 8 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 10 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 2 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_dib.cpp | 10 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 5 |
9 files changed, 50 insertions, 75 deletions
diff --git a/core/fxge/dib/cfx_dibextractor.cpp b/core/fxge/dib/cfx_dibextractor.cpp index 8de69e2e3b..325454a580 100644 --- a/core/fxge/dib/cfx_dibextractor.cpp +++ b/core/fxge/dib/cfx_dibextractor.cpp @@ -10,7 +10,7 @@ CFX_DIBExtractor::CFX_DIBExtractor(const CFX_RetainPtr<CFX_DIBSource>& pSrc) { if (!pSrc->GetBuffer()) { - m_pBitmap = pSrc->Clone(); + m_pBitmap = pSrc->Clone(nullptr); return; } CFX_RetainPtr<CFX_DIBSource> pOldSrc(pSrc); @@ -21,7 +21,7 @@ CFX_DIBExtractor::CFX_DIBExtractor(const CFX_RetainPtr<CFX_DIBSource>& pSrc) { return; } m_pBitmap->SetPalette(pOldSrc->GetPalette()); - m_pBitmap->SetAlphaMask(pOldSrc->m_pAlphaMask); + m_pBitmap->SetAlphaMask(pOldSrc->m_pAlphaMask, nullptr); } CFX_DIBExtractor::~CFX_DIBExtractor() {} diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp index 6f46e1d57e..4cba073321 100644 --- a/core/fxge/dib/cfx_dibitmap.cpp +++ b/core/fxge/dib/cfx_dibitmap.cpp @@ -94,7 +94,7 @@ bool CFX_DIBitmap::Copy(const CFX_RetainPtr<CFX_DIBSource>& pSrc) { return false; SetPalette(pSrc->GetPalette()); - SetAlphaMask(pSrc->m_pAlphaMask); + SetAlphaMask(pSrc->m_pAlphaMask, nullptr); for (int row = 0; row < pSrc->GetHeight(); row++) memcpy(m_pBuffer.Get() + row * m_Pitch, pSrc->GetScanline(row), m_Pitch); return true; @@ -317,7 +317,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_Height) { if (pAlphaMask) { - pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height); + pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height, 0, nullptr); if (!pAlphaMask) return false; } @@ -327,7 +327,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, } else if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_Height) { CFX_RetainPtr<CFX_DIBitmap> pSrcMatched = - pSrcClone->StretchTo(m_Width, m_Height); + pSrcClone->StretchTo(m_Width, m_Height, 0, nullptr); if (!pSrcMatched) return false; @@ -426,7 +426,7 @@ bool CFX_DIBitmap::MultiplyAlpha( CFX_RetainPtr<CFX_DIBitmap> pSrcClone = pSrcBitmap.As<CFX_DIBitmap>(); if (pSrcBitmap->GetWidth() != m_Width || pSrcBitmap->GetHeight() != m_Height) { - pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height); + pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height, 0, nullptr); if (!pSrcClone) return false; } diff --git a/core/fxge/dib/cfx_dibsource.cpp b/core/fxge/dib/cfx_dibsource.cpp index 63fcc5806a..547f01690c 100644 --- a/core/fxge/dib/cfx_dibsource.cpp +++ b/core/fxge/dib/cfx_dibsource.cpp @@ -707,24 +707,24 @@ bool CFX_DIBSource::BuildAlphaMask() { return true; } -uint32_t CFX_DIBSource::GetPaletteEntry(int index) const { +uint32_t CFX_DIBSource::GetPaletteArgb(int index) const { ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask()); - if (m_pPalette) { + if (m_pPalette) return m_pPalette.get()[index]; - } + if (IsCmykImage()) { - if (GetBPP() == 1) { + if (GetBPP() == 1) return index ? 0 : 0xff; - } + return 0xff - index; } - if (GetBPP() == 1) { + if (GetBPP() == 1) return index ? 0xffffffff : 0xff000000; - } + return index * 0x10101 | 0xff000000; } -void CFX_DIBSource::SetPaletteEntry(int index, uint32_t color) { +void CFX_DIBSource::SetPaletteArgb(int index, uint32_t color) { ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask()); if (!m_pPalette) { BuildPalette(); @@ -825,15 +825,9 @@ void CFX_DIBSource::GetPalette(uint32_t* pal, int alpha) const { } } -CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::CloneAlphaMask( - const FX_RECT* pClip) const { +CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::CloneAlphaMask() const { ASSERT(GetFormat() == FXDIB_Argb); FX_RECT rect(0, 0, m_Width, m_Height); - if (pClip) { - rect.Intersect(*pClip); - if (rect.IsEmpty()) - return nullptr; - } auto pMask = pdfium::MakeRetain<CFX_DIBitmap>(); if (!pMask->Create(rect.Width(), rect.Height(), FXDIB_8bppMask)) return nullptr; @@ -975,7 +969,7 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::CloneConvert( ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha) : pClone->LoadChannel(FXDIB_Alpha, 0xff); } else { - ret = pClone->SetAlphaMask(pSrcAlpha); + ret = pClone->SetAlphaMask(pSrcAlpha, nullptr); } } if (!ret) @@ -993,13 +987,9 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::CloneConvert( return pClone; } -CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::SwapXY( - bool bXFlip, - bool bYFlip, - const FX_RECT* pDestClip) const { +CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::SwapXY(bool bXFlip, + bool bYFlip) const { FX_RECT dest_clip(0, 0, m_Height, m_Width); - if (pDestClip) - dest_clip.Intersect(*pDestClip); if (dest_clip.IsEmpty()) return nullptr; @@ -1094,16 +1084,14 @@ CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::SwapXY( CFX_RetainPtr<CFX_DIBitmap> CFX_DIBSource::TransformTo( const CFX_Matrix* pDestMatrix, - int& result_left, - int& result_top, - uint32_t flags, - const FX_RECT* pDestClip) { + int* result_left, + int* result_top) { CFX_RetainPtr<CFX_DIBSource> holder(this); - CFX_ImageTransformer transformer(holder, pDestMatrix, flags, pDestClip); + CFX_ImageTransformer transformer(holder, pDestMatrix, 0, nullptr); transformer.Start(); transformer.Continue(nullptr); - result_left = transformer.result().left; - result_top = transformer.result().top; + *result_left = transformer.result().left; + *result_top = transformer.result().top; return transformer.DetachBitmap(); } diff --git a/core/fxge/dib/cfx_dibsource.h b/core/fxge/dib/cfx_dibsource.h index 97af196677..798e092d16 100644 --- a/core/fxge/dib/cfx_dibsource.h +++ b/core/fxge/dib/cfx_dibsource.h @@ -65,39 +65,29 @@ class CFX_DIBSource : public CFX_Retainable { return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0)); } - uint32_t GetPaletteEntry(int index) const; - - void SetPaletteEntry(int index, uint32_t color); - uint32_t GetPaletteArgb(int index) const { return GetPaletteEntry(index); } - void SetPaletteArgb(int index, uint32_t color) { - SetPaletteEntry(index, color); - } + uint32_t GetPaletteArgb(int index) const; + void SetPaletteArgb(int index, uint32_t color); // Copies into internally-owned palette. void SetPalette(const uint32_t* pSrcPal); - CFX_RetainPtr<CFX_DIBitmap> Clone(const FX_RECT* pClip = nullptr) const; + CFX_RetainPtr<CFX_DIBitmap> Clone(const FX_RECT* pClip) const; CFX_RetainPtr<CFX_DIBitmap> CloneConvert(FXDIB_Format format); CFX_RetainPtr<CFX_DIBitmap> StretchTo(int dest_width, int dest_height, - uint32_t flags = 0, - const FX_RECT* pClip = nullptr); + uint32_t flags, + const FX_RECT* pClip); CFX_RetainPtr<CFX_DIBitmap> TransformTo(const CFX_Matrix* pMatrix, - int& left, - int& top, - uint32_t flags = 0, - const FX_RECT* pClip = nullptr); - CFX_RetainPtr<CFX_DIBitmap> SwapXY(bool bXFlip, - bool bYFlip, - const FX_RECT* pClip = nullptr) const; + int* left, + int* top); + CFX_RetainPtr<CFX_DIBitmap> SwapXY(bool bXFlip, bool bYFlip) const; CFX_RetainPtr<CFX_DIBitmap> FlipImage(bool bXFlip, bool bYFlip) const; - CFX_RetainPtr<CFX_DIBitmap> CloneAlphaMask( - const FX_RECT* pClip = nullptr) const; + CFX_RetainPtr<CFX_DIBitmap> CloneAlphaMask() const; // Copies into internally-owned mask. bool SetAlphaMask(const CFX_RetainPtr<CFX_DIBSource>& pAlphaMask, - const FX_RECT* pClip = nullptr); + const FX_RECT* pClip); void GetOverlapRect(int& dest_left, int& dest_top, @@ -110,7 +100,7 @@ class CFX_DIBSource : public CFX_Retainable { const CFX_ClipRgn* pClipRgn); #if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_ - void DebugVerifyBitmapIsPreMultiplied(void* buffer = nullptr) const; + void DebugVerifyBitmapIsPreMultiplied(void* buffer) const; #endif CFX_RetainPtr<CFX_DIBitmap> m_pAlphaMask; diff --git a/core/fxge/dib/cfx_imagestretcher.cpp b/core/fxge/dib/cfx_imagestretcher.cpp index d633318feb..809b72d1fb 100644 --- a/core/fxge/dib/cfx_imagestretcher.cpp +++ b/core/fxge/dib/cfx_imagestretcher.cpp @@ -73,12 +73,12 @@ bool CFX_ImageStretcher::Start() { int r0; int g0; int b0; - std::tie(a0, r0, g0, b0) = ArgbDecode(m_pSource->GetPaletteEntry(0)); + std::tie(a0, r0, g0, b0) = ArgbDecode(m_pSource->GetPaletteArgb(0)); int a1; int r1; int g1; int b1; - std::tie(a1, r1, g1, b1) = ArgbDecode(m_pSource->GetPaletteEntry(1)); + std::tie(a1, r1, g1, b1) = ArgbDecode(m_pSource->GetPaletteArgb(1)); for (int i = 0; i < 256; ++i) { int a = a0 + (a1 - a0) * i / 255; int r = r0 + (r1 - r0) * i / 255; @@ -97,12 +97,12 @@ bool CFX_ImageStretcher::Start() { int m0; int y0; int k0; - std::tie(c0, m0, y0, k0) = CmykDecode(m_pSource->GetPaletteEntry(0)); + std::tie(c0, m0, y0, k0) = CmykDecode(m_pSource->GetPaletteArgb(0)); int c1; int m1; int y1; int k1; - std::tie(c1, m1, y1, k1) = CmykDecode(m_pSource->GetPaletteEntry(1)); + std::tie(c1, m1, y1, k1) = CmykDecode(m_pSource->GetPaletteArgb(1)); for (int i = 0; i < 256; ++i) { int c = c0 + (c1 - c0) * i / 255; int m = m0 + (m1 - m0) * i / 255; diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 46e284d8aa..3ca022b706 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -262,13 +262,13 @@ static void DebugValidate(const CFX_RetainPtr<CFX_DIBitmap>& bitmap, if (bitmap) { SkASSERT(bitmap->GetBPP() == 8 || bitmap->GetBPP() == 32); if (bitmap->GetBPP() == 32) { - bitmap->DebugVerifyBitmapIsPreMultiplied(); + bitmap->DebugVerifyBitmapIsPreMultiplied(nullptr); } } if (device) { SkASSERT(device->GetBPP() == 8 || device->GetBPP() == 32); if (device->GetBPP() == 32) { - device->DebugVerifyBitmapIsPreMultiplied(); + device->DebugVerifyBitmapIsPreMultiplied(nullptr); } } } @@ -2224,7 +2224,7 @@ void CFX_DIBitmap::PreMultiply() { SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); SkPixmap premultiplied(premultipliedInfo, buffer, rowBytes); unpremultiplied.readPixels(premultiplied); - this->DebugVerifyBitmapIsPreMultiplied(); + this->DebugVerifyBitmapIsPreMultiplied(nullptr); } #ifdef _SKIA_SUPPORT_PATHS_ @@ -2238,7 +2238,7 @@ void CFX_DIBitmap::UnPreMultiply() { m_nFormat = Format::kUnPreMultiplied; if (priorFormat != Format::kPreMultiplied) return; - this->DebugVerifyBitmapIsPreMultiplied(); + this->DebugVerifyBitmapIsPreMultiplied(nullptr); int height = this->GetHeight(); int width = this->GetWidth(); int rowBytes = this->GetPitch(); @@ -2327,7 +2327,7 @@ void CFX_SkiaDeviceDriver::Dump() const { #ifdef _SKIA_SUPPORT_ void CFX_SkiaDeviceDriver::DebugVerifyBitmapIsPreMultiplied() const { if (m_pOriDevice) - m_pOriDevice->DebugVerifyBitmapIsPreMultiplied(); + m_pOriDevice->DebugVerifyBitmapIsPreMultiplied(nullptr); } #endif // _SKIA_SUPPORT_ diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index c67ed526d3..6e960f95b4 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -852,7 +852,7 @@ bool CGdiDeviceDriver::GDI_StretchDIBits( if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) { - pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); + pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height, 0, nullptr); } CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap); diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index 677fb3ab80..d1e5688ee1 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -86,13 +86,11 @@ CFX_RetainPtr<CFX_DIBitmap> _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, temp_buf = nullptr; } if (pbmi->bmiHeader.biBitCount == 1) { - for (int i = 0; i < 2; i++) { - pBitmap->SetPaletteEntry(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000); - } + for (int i = 0; i < 2; i++) + pBitmap->SetPaletteArgb(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000); } else if (pbmi->bmiHeader.biBitCount == 8) { - for (int i = 0; i < 256; i++) { - pBitmap->SetPaletteEntry(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000); - } + for (int i = 0; i < 256; i++) + pBitmap->SetPaletteArgb(i, ((uint32_t*)pbmi->bmiColors)[i] | 0xff000000); } return pBitmap; } diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 87172ffff8..d718dc8abf 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -647,9 +647,8 @@ static void OutputImage(GpGraphics* pGraphics, UINT pal[258]; pal[0] = 0; pal[1] = 256; - for (int i = 0; i < 256; i++) { - pal[i + 2] = pBitmap->GetPaletteEntry(i); - } + for (int i = 0; i < 256; i++) + pal[i + 2] = pBitmap->GetPaletteArgb(i); CallFunc(GdipSetImagePalette)(bitmap, (ColorPalette*)pal); break; } |