diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-25 19:28:10 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-25 19:28:10 +0000 |
commit | 5ada7bcf1f200eaa8d78ea2c74233b6b54f6d5f5 (patch) | |
tree | d30f97e0b55be2a3ca3b720e80e075d36f11e941 | |
parent | 0c327657fb8c23934c5beae520e7a97a48e2eef6 (diff) | |
download | pdfium-5ada7bcf1f200eaa8d78ea2c74233b6b54f6d5f5.tar.xz |
Change StartDIBits() to take a matrix by reference.
In RenderDeviceDriverIface and related classes, and for related methods
in the call stack.
Change-Id: I420fafe70084eb3941dffc6f9f51ecbed79581de
Reviewed-on: https://pdfium-review.googlesource.com/c/44552
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | core/fpdfapi/render/cpdf_imagerenderer.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 2 | ||||
-rw-r--r-- | core/fxge/agg/fx_agg_driver.cpp | 4 | ||||
-rw-r--r-- | core/fxge/agg/fx_agg_driver.h | 2 | ||||
-rw-r--r-- | core/fxge/cfx_renderdevice.cpp | 4 | ||||
-rw-r--r-- | core/fxge/cfx_renderdevice.h | 6 | ||||
-rw-r--r-- | core/fxge/renderdevicedriver_iface.h | 2 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 15 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.h | 2 | ||||
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.cpp | 15 | ||||
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.h | 2 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 2 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_print.cpp | 22 | ||||
-rw-r--r-- | core/fxge/win32/win32_int.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_imagerenderer.cpp | 2 |
15 files changed, 45 insertions, 47 deletions
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index 03e00a2554..c937ee68bb 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -382,7 +382,7 @@ bool CPDF_ImageRenderer::StartDIBBase() { if (m_pDIBBase->HasAlpha()) CFX_SkiaDeviceDriver::PreMultiply(premultiplied); if (m_pRenderStatus->GetRenderDevice()->StartDIBitsWithBlend( - premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, + premultiplied, m_BitmapAlpha, m_FillArgb, m_ImageMatrix, m_Flags, &m_DeviceHandle, m_BlendType)) { if (m_DeviceHandle) { m_Status = 3; @@ -392,7 +392,7 @@ bool CPDF_ImageRenderer::StartDIBBase() { } #else if (m_pRenderStatus->GetRenderDevice()->StartDIBitsWithBlend( - m_pDIBBase, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, + m_pDIBBase, m_BitmapAlpha, m_FillArgb, m_ImageMatrix, m_Flags, &m_DeviceHandle, m_BlendType)) { if (m_DeviceHandle) { m_Status = 3; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index b409203a54..691cdb408c 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -2392,7 +2392,7 @@ void CPDF_RenderStatus::CompositeDIBitmap( std::unique_ptr<CFX_ImageRenderer> dummy; CFX_Matrix m(pDIBitmap->GetWidth(), 0, 0, -pDIBitmap->GetHeight(), left, top + pDIBitmap->GetHeight()); - m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, &m, 0, &dummy); + m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, m, 0, &dummy); return; #else pDIBitmap->MultiplyAlpha(bitmap_alpha); diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 6e680b9796..b20e46d978 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -1548,7 +1548,7 @@ bool CFX_AggDeviceDriver::StartDIBits( const RetainPtr<CFX_DIBBase>& pSource, int bitmap_alpha, uint32_t argb, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) { @@ -1556,7 +1556,7 @@ bool CFX_AggDeviceDriver::StartDIBits( return true; *handle = pdfium::MakeUnique<CFX_ImageRenderer>( - m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, *pMatrix, + m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, matrix, render_flags, m_bRgbByteOrder); return true; } diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index 9a8458e374..bb3062b4ac 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h @@ -85,7 +85,7 @@ class CFX_AggDeviceDriver final : public RenderDeviceDriverIface { bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) override; diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index 8afff1e84a..11b5c4c536 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -820,11 +820,11 @@ bool CFX_RenderDevice::StartDIBitsWithBlend( const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t argb, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_mode) { - return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, + return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, matrix, flags, handle, blend_mode); } diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index d18161627f..18ce7a8608 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -195,16 +195,16 @@ class CFX_RenderDevice { bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle) { - return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, pMatrix, flags, + return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, matrix, flags, handle, BlendMode::kNormal); } bool StartDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type); diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h index 051254db2b..17aa10fe71 100644 --- a/core/fxge/renderdevicedriver_iface.h +++ b/core/fxge/renderdevicedriver_iface.h @@ -82,7 +82,7 @@ class RenderDeviceDriverIface { virtual bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) = 0; diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 63a44cba65..e2c058c1bd 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -551,11 +551,10 @@ void ClipAngledGradient(const SkPoint pts[2], } #ifdef _SKIA_SUPPORT_ -void SetBitmapMatrix(const CFX_Matrix* pMatrix, +void SetBitmapMatrix(const CFX_Matrix& m, int width, int height, SkMatrix* skMatrix) { - const CFX_Matrix& m = *pMatrix; skMatrix->setAll(m.a / width, -m.c / height, m.c + m.e, m.b / width, -m.d / height, m.d + m.f, 0, 0, 1); } @@ -2250,7 +2249,7 @@ bool CFX_SkiaDeviceDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, CFX_Matrix m(pBitmap->GetWidth(), 0, 0, -pBitmap->GetHeight(), left, top + pBitmap->GetHeight()); std::unique_ptr<CFX_ImageRenderer> dummy; - return StartDIBits(pBitmap, 0xFF, argb, &m, 0, &dummy, blend_type); + return StartDIBits(pBitmap, 0xFF, argb, m, 0, &dummy, blend_type); #endif // _SKIA_SUPPORT_ #ifdef _SKIA_SUPPORT_PATHS_ @@ -2288,7 +2287,7 @@ bool CFX_SkiaDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, pClipRect->right, pClipRect->top); m_pCanvas->clipRect(skClipRect, SkClipOp::kIntersect, true); std::unique_ptr<CFX_ImageRenderer> dummy; - bool result = StartDIBits(pSource, 0xFF, argb, &m, 0, &dummy, blend_type); + bool result = StartDIBits(pSource, 0xFF, argb, m, 0, &dummy, blend_type); m_pCanvas->restore(); return result; @@ -2322,7 +2321,7 @@ bool CFX_SkiaDeviceDriver::StartDIBits( const RetainPtr<CFX_DIBBase>& pSource, int bitmap_alpha, uint32_t argb, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) { @@ -2339,7 +2338,7 @@ bool CFX_SkiaDeviceDriver::StartDIBits( } m_pCanvas->save(); SkMatrix skMatrix; - SetBitmapMatrix(pMatrix, width, height, &skMatrix); + SetBitmapMatrix(matrix, width, height, &skMatrix); m_pCanvas->concat(skMatrix); SkPaint paint; SetBitmapPaint(pSource->IsAlphaMask(), argb, bitmap_alpha, blend_type, @@ -2371,7 +2370,7 @@ bool CFX_SkiaDeviceDriver::StartDIBits( return true; m_pBitmap->UnPreMultiply(); *handle = pdfium::MakeUnique<CFX_ImageRenderer>( - m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, *pMatrix, + m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, matrix, render_flags, m_bRgbByteOrder); #endif // _SKIA_SUPPORT_PATHS_ return true; @@ -2472,7 +2471,7 @@ bool CFX_SkiaDeviceDriver::DrawBitsWithMask( } m_pCanvas->save(); SkMatrix skMatrix; - SetBitmapMatrix(pMatrix, srcWidth, srcHeight, &skMatrix); + SetBitmapMatrix(*pMatrix, srcWidth, srcHeight, &skMatrix); m_pCanvas->concat(skMatrix); SkPaint paint; SetBitmapPaint(pSource->IsAlphaMask(), 0xFFFFFFFF, bitmap_alpha, blend_type, diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index 23c85145b1..f7db096d30 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -115,7 +115,7 @@ class CFX_SkiaDeviceDriver final : public RenderDeviceDriverIface { bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) override; diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 921005dd70..becf99b52d 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -348,7 +348,7 @@ bool CFX_PSRenderer::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource, CFX_Matrix matrix((float)(pSource->GetWidth()), 0.0f, 0.0f, -(float)(pSource->GetHeight()), (float)(left), (float)(top + pSource->GetHeight())); - return DrawDIBits(pSource, color, &matrix, 0); + return DrawDIBits(pSource, color, matrix, 0); } bool CFX_PSRenderer::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, @@ -361,18 +361,17 @@ bool CFX_PSRenderer::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, StartRendering(); CFX_Matrix matrix((float)(dest_width), 0.0f, 0.0f, (float)(-dest_height), (float)(dest_left), (float)(dest_top + dest_height)); - return DrawDIBits(pSource, color, &matrix, flags); + return DrawDIBits(pSource, color, matrix, flags); } bool CFX_PSRenderer::DrawDIBits(const RetainPtr<CFX_DIBBase>& pSource, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t flags) { StartRendering(); - if ((pMatrix->a == 0 && pMatrix->b == 0) || - (pMatrix->c == 0 && pMatrix->d == 0)) { + if ((matrix.a == 0 && matrix.b == 0) || (matrix.c == 0 && matrix.d == 0)) return true; - } + if (pSource->HasAlpha()) return false; @@ -383,8 +382,8 @@ bool CFX_PSRenderer::DrawDIBits(const RetainPtr<CFX_DIBBase>& pSource, m_pStream->WriteString("q\n"); std::ostringstream buf; - buf << "[" << pMatrix->a << " " << pMatrix->b << " " << pMatrix->c << " " - << pMatrix->d << " " << pMatrix->e << " " << pMatrix->f << "]cm "; + buf << "[" << matrix.a << " " << matrix.b << " " << matrix.c << " " + << matrix.d << " " << matrix.e << " " << matrix.f << "]cm "; int width = pSource->GetWidth(); int height = pSource->GetHeight(); diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h index e54c2f8744..b5107d9ab1 100644 --- a/core/fxge/win32/cfx_psrenderer.h +++ b/core/fxge/win32/cfx_psrenderer.h @@ -65,7 +65,7 @@ class CFX_PSRenderer { uint32_t flags); bool DrawDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t flags); bool DrawText(int nChars, const FXTEXT_CHARPOS* pCharPos, diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 537e67564c..4b0b01e56e 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -1330,7 +1330,7 @@ bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, bool CGdiDisplayDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) { diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index 1f9b9510f7..b92a46d08f 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -161,7 +161,7 @@ bool CGdiPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, bool CGdiPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pSource, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) { @@ -169,12 +169,12 @@ bool CGdiPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pSource, (pSource->IsAlphaMask() && (pSource->GetBPP() != 1))) { return false; } - CFX_FloatRect unit_rect = pMatrix->GetUnitRect(); + CFX_FloatRect unit_rect = matrix.GetUnitRect(); FX_RECT full_rect = unit_rect.GetOuterRect(); - if (fabs(pMatrix->b) < 0.5f && pMatrix->a != 0 && fabs(pMatrix->c) < 0.5f && - pMatrix->d != 0) { - bool bFlipX = pMatrix->a < 0; - bool bFlipY = pMatrix->d > 0; + if (fabs(matrix.b) < 0.5f && matrix.a != 0 && fabs(matrix.c) < 0.5f && + matrix.d != 0) { + bool bFlipX = matrix.a < 0; + bool bFlipY = matrix.d > 0; return StretchDIBits(pSource, color, bFlipX ? full_rect.right : full_rect.left, bFlipY ? full_rect.bottom : full_rect.top, @@ -182,11 +182,11 @@ bool CGdiPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pSource, bFlipY ? -full_rect.Height() : full_rect.Height(), nullptr, 0, blend_type); } - if (fabs(pMatrix->a) >= 0.5f || fabs(pMatrix->d) >= 0.5f) + if (fabs(matrix.a) >= 0.5f || fabs(matrix.d) >= 0.5f) return false; RetainPtr<CFX_DIBitmap> pTransformed = - pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0); + pSource->SwapXY(matrix.c > 0, matrix.b < 0); if (!pTransformed) return false; @@ -482,7 +482,7 @@ bool CPSPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, bool CPSPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) { @@ -493,7 +493,7 @@ bool CPSPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, return false; *handle = nullptr; - return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags); + return m_PSRenderer.DrawDIBits(pBitmap, color, matrix, render_flags); } bool CPSPrinterDriver::DrawDeviceText(int nChars, @@ -598,7 +598,7 @@ bool CTextOnlyPrinterDriver::StartDIBits( const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) { diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 2a61a4e651..9819be686f 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -215,7 +215,7 @@ class CGdiDisplayDriver final : public CGdiDeviceDriver { bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) override; @@ -254,7 +254,7 @@ class CGdiPrinterDriver final : public CGdiDeviceDriver { bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) override; @@ -313,7 +313,7 @@ class CPSPrinterDriver final : public RenderDeviceDriverIface { bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) override; @@ -376,7 +376,7 @@ class CTextOnlyPrinterDriver final : public RenderDeviceDriverIface { bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, - const CFX_Matrix* pMatrix, + const CFX_Matrix& matrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, BlendMode blend_type) override; diff --git a/xfa/fxfa/cxfa_imagerenderer.cpp b/xfa/fxfa/cxfa_imagerenderer.cpp index 9cfccb9c7a..49f953b7b9 100644 --- a/xfa/fxfa/cxfa_imagerenderer.cpp +++ b/xfa/fxfa/cxfa_imagerenderer.cpp @@ -20,7 +20,7 @@ CXFA_ImageRenderer::CXFA_ImageRenderer(CFX_RenderDevice* pDevice, CXFA_ImageRenderer::~CXFA_ImageRenderer() {} bool CXFA_ImageRenderer::Start() { - if (m_pDevice->StartDIBitsWithBlend(m_pDIBBase, 255, 0, &m_ImageMatrix, + if (m_pDevice->StartDIBitsWithBlend(m_pDIBBase, 255, 0, m_ImageMatrix, FXDIB_INTERPOL, &m_DeviceHandle, BlendMode::kNormal)) { if (m_DeviceHandle) { |