diff options
author | dsinclair <dsinclair@chromium.org> | 2017-03-28 15:47:47 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-28 15:48:01 +0000 |
commit | 31b08d4cdaa17d7a03f35e087096a77036af98ec (patch) | |
tree | 40234b81f2972c857a33a86cb4b59868e56bb86b /xfa/fxgraphics/cfx_graphics.cpp | |
parent | a3e9bf66c3483db926602aa62b0bd1ff8d1357a1 (diff) | |
download | pdfium-31b08d4cdaa17d7a03f35e087096a77036af98ec.tar.xz |
Revert "Refcount all CFX_DIBSources (and subclasses) all the time."
This reverts commit 0004f29bf6ee3c6060a272c79f14993e92e053c7.
Reason for revert: Breaks build with skia_paths enabled (which will break the chrome roll).
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1858:38: error: no member named 'get' in 'CFX_RetainPtr<CFX_DIBitmap>'
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1861:42: error: no member named 'get' in 'CFX_RetainPtr<CFX_DIBitmap>'
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2987:15: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2991:18: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2999:17: error: no viable overloaded '='
../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:3001:43: error: no member named 'GetObject' in 'CFX_RetainPtr<CFX_DIBitmap>'
Original change's description:
> Refcount all CFX_DIBSources (and subclasses) all the time.
>
> There are currently several ownership models for these objects,
> including ad-hoc logic for sharing and deletion, and the
> now-redundant CFX_DIBitmapRef externally-counted handle to the DIBs.
>
> Replace them all with the internal refcount scheme.
>
> Change-Id: I2db399dfc19219eda384f94cc989353b78ce2872
> Reviewed-on: https://pdfium-review.googlesource.com/3166
> Reviewed-by: dsinclair <dsinclair@chromium.org>
> Commit-Queue: dsinclair <dsinclair@chromium.org>
>
TBR=thestig@chromium.org,tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I678b1fbc5e666cf7a19372ebaff3270fb115ba5e
Reviewed-on: https://pdfium-review.googlesource.com/3243
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxgraphics/cfx_graphics.cpp')
-rw-r--r-- | xfa/fxgraphics/cfx_graphics.cpp | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index 3cfe2d0192..48d8f6f80f 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -198,7 +198,7 @@ void CFX_Graphics::FillPath(CFX_Path* path, RenderDeviceFillPath(path, fillMode, matrix); } -void CFX_Graphics::StretchImage(const CFX_RetainPtr<CFX_DIBSource>& source, +void CFX_Graphics::StretchImage(CFX_DIBSource* source, const CFX_RectF& rect, CFX_Matrix* matrix) { if (!source) @@ -318,49 +318,48 @@ void CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, } } -void CFX_Graphics::RenderDeviceStretchImage( - const CFX_RetainPtr<CFX_DIBSource>& source, - const CFX_RectF& rect, - CFX_Matrix* matrix) { +void CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, + const CFX_RectF& rect, + CFX_Matrix* matrix) { CFX_Matrix m1(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, m_info.CTM.f); if (matrix) { m1.Concat(*matrix); } - CFX_RetainPtr<CFX_DIBitmap> bmp1 = + std::unique_ptr<CFX_DIBitmap> bmp1 = source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height()); CFX_Matrix m2(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); m2.Concat(m1); int32_t left; int32_t top; - CFX_RetainPtr<CFX_DIBitmap> bmp2 = bmp1->FlipImage(false, true); - CFX_RetainPtr<CFX_DIBitmap> bmp3 = bmp2->TransformTo(&m2, left, top); + std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->FlipImage(false, true); + std::unique_ptr<CFX_DIBitmap> bmp3 = bmp2->TransformTo(&m2, left, top); CFX_RectF r = GetClipRect(); - CFX_RetainPtr<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap(); + CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), - FXSYS_round(r.Width()), FXSYS_round(r.Height()), bmp3, - FXSYS_round(r.left - left), FXSYS_round(r.top - top)); + FXSYS_round(r.Width()), FXSYS_round(r.Height()), + bmp3.get(), FXSYS_round(r.left - left), + FXSYS_round(r.top - top)); } void CFX_Graphics::FillPathWithPattern(CFX_Path* path, FX_FillMode fillMode, CFX_Matrix* matrix) { CFX_Pattern* pattern = m_info.fillColor->m_info.pattern; - CFX_RetainPtr<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap(); + CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); int32_t width = bitmap->GetWidth(); int32_t height = bitmap->GetHeight(); - auto bmp = pdfium::MakeRetain<CFX_DIBitmap>(); - bmp->Create(width, height, FXDIB_Argb); - m_renderDevice->GetDIBits(bmp, 0, 0); + CFX_DIBitmap bmp; + bmp.Create(width, height, FXDIB_Argb); + m_renderDevice->GetDIBits(&bmp, 0, 0); FX_HatchStyle hatchStyle = m_info.fillColor->m_info.pattern->m_hatchStyle; const FX_HATCHDATA& data = hatchBitmapData[static_cast<int>(hatchStyle)]; - auto mask = pdfium::MakeRetain<CFX_DIBitmap>(); - mask->Create(data.width, data.height, FXDIB_1bppMask); - FXSYS_memcpy(mask->GetBuffer(), data.maskBits, - mask->GetPitch() * data.height); + CFX_DIBitmap mask; + mask.Create(data.width, data.height, FXDIB_1bppMask); + FXSYS_memcpy(mask.GetBuffer(), data.maskBits, mask.GetPitch() * data.height); CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); if (matrix) matrix->TransformRect(rectf); @@ -368,35 +367,35 @@ void CFX_Graphics::FillPathWithPattern(CFX_Path* path, FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); CFX_FxgeDevice device; - device.Attach(bmp, false, nullptr, false); + device.Attach(&bmp, false, nullptr, false); device.FillRect(&rect, m_info.fillColor->m_info.pattern->m_backArgb); - for (int32_t j = rect.bottom; j < rect.top; j += mask->GetHeight()) { - for (int32_t i = rect.left; i < rect.right; i += mask->GetWidth()) { - device.SetBitMask(mask, i, j, + for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { + for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { + device.SetBitMask(&mask, i, j, m_info.fillColor->m_info.pattern->m_foreArgb); } } m_renderDevice->SaveState(); m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode); - SetDIBitsWithMatrix(bmp, &pattern->m_matrix); + SetDIBitsWithMatrix(&bmp, &pattern->m_matrix); m_renderDevice->RestoreState(false); } void CFX_Graphics::FillPathWithShading(CFX_Path* path, FX_FillMode fillMode, CFX_Matrix* matrix) { - CFX_RetainPtr<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap(); + CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); int32_t width = bitmap->GetWidth(); int32_t height = bitmap->GetHeight(); float start_x = m_info.fillColor->m_shading->m_beginPoint.x; float start_y = m_info.fillColor->m_shading->m_beginPoint.y; float end_x = m_info.fillColor->m_shading->m_endPoint.x; float end_y = m_info.fillColor->m_shading->m_endPoint.y; - auto bmp = pdfium::MakeRetain<CFX_DIBitmap>(); - bmp->Create(width, height, FXDIB_Argb); - m_renderDevice->GetDIBits(bmp, 0, 0); - int32_t pitch = bmp->GetPitch(); + CFX_DIBitmap bmp; + bmp.Create(width, height, FXDIB_Argb); + m_renderDevice->GetDIBits(&bmp, 0, 0); + int32_t pitch = bmp.GetPitch(); bool result = false; switch (m_info.fillColor->m_shading->m_type) { case FX_SHADING_Axial: { @@ -404,7 +403,7 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path, float y_span = end_y - start_y; float axis_len_square = (x_span * x_span) + (y_span * y_span); for (int32_t row = 0; row < height; row++) { - uint32_t* dib_buf = (uint32_t*)(bmp->GetBuffer() + row * pitch); + uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch); for (int32_t column = 0; column < width; column++) { float x = (float)(column); float y = (float)(row); @@ -435,7 +434,7 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path, ((start_y - end_y) * (start_y - end_y)) - ((start_r - end_r) * (start_r - end_r)); for (int32_t row = 0; row < height; row++) { - uint32_t* dib_buf = (uint32_t*)(bmp->GetBuffer() + row * pitch); + uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch); for (int32_t column = 0; column < width; column++) { float x = (float)(column); float y = (float)(row); @@ -497,14 +496,13 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path, if (result) { m_renderDevice->SaveState(); m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode); - SetDIBitsWithMatrix(bmp, matrix); + SetDIBitsWithMatrix(&bmp, matrix); m_renderDevice->RestoreState(false); } } -void CFX_Graphics::SetDIBitsWithMatrix( - const CFX_RetainPtr<CFX_DIBSource>& source, - CFX_Matrix* matrix) { +void CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, + CFX_Matrix* matrix) { if (matrix->IsIdentity()) { m_renderDevice->SetDIBits(source, 0, 0); } else { @@ -513,9 +511,9 @@ void CFX_Graphics::SetDIBitsWithMatrix( m.Concat(*matrix); int32_t left; int32_t top; - CFX_RetainPtr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true); - CFX_RetainPtr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(&m, left, top); - m_renderDevice->SetDIBits(bmp2, left, top); + std::unique_ptr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true); + std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(&m, left, top); + m_renderDevice->SetDIBits(bmp2.get(), left, top); } } |