summaryrefslogtreecommitdiff
path: root/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-04 14:17:57 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-05 10:05:06 +0000
commit39d357e3248f80abea0159765ff39554affb40db (patch)
treeaba0e6bfb76de0244bba0f5fdbd64b830dd6e621 /chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp
parent87778abf5a1f89266f37d1321b92a21851d8244d (diff)
downloadqtwebengine-chromium-39d357e3248f80abea0159765ff39554affb40db.tar.gz
BASELINE: Update Chromium to 55.0.2883.105
And updates ninja to 1.7.2 Change-Id: I20d43c737f82764d857ada9a55586901b18b9243 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp')
-rw-r--r--chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp110
1 files changed, 49 insertions, 61 deletions
diff --git a/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp b/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp
index 2b04b42d19d..d3be763def2 100644
--- a/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp
+++ b/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp
@@ -8,11 +8,17 @@
#include <algorithm>
-#include "core/fxcodec/include/fx_codec.h"
+#include "core/fxcodec/fx_codec.h"
+#include "core/fxcrt/fx_memory.h"
+#include "core/fxge/cfx_fxgedevice.h"
+#include "core/fxge/cfx_gemodule.h"
+#include "core/fxge/cfx_graphstatedata.h"
+#include "core/fxge/cfx_pathdata.h"
+#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/dib/dib_int.h"
+#include "core/fxge/ge/cfx_cliprgn.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/fxge/include/fx_ge.h"
-#include "core/fxge/include/ifx_renderdevicedriver.h"
+#include "core/fxge/ifx_renderdevicedriver.h"
#include "third_party/agg23/agg_conv_dash.h"
#include "third_party/agg23/agg_conv_stroke.h"
#include "third_party/agg23/agg_curves.h"
@@ -21,6 +27,7 @@
#include "third_party/agg23/agg_rasterizer_scanline_aa.h"
#include "third_party/agg23/agg_renderer_scanline.h"
#include "third_party/agg23/agg_scanline_u.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -420,23 +427,19 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer,
CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap,
FX_BOOL bRgbByteOrder,
CFX_DIBitmap* pOriDevice,
- FX_BOOL bGroupKnockout) {
- m_pBitmap = pBitmap;
- m_pClipRgn = nullptr;
- m_pPlatformBitmap = nullptr;
- m_pPlatformGraphics = nullptr;
- m_pDwRenderTartget = nullptr;
- m_bRgbByteOrder = bRgbByteOrder;
- m_pOriDevice = pOriDevice;
- m_bGroupKnockout = bGroupKnockout;
- m_FillFlags = 0;
+ FX_BOOL bGroupKnockout)
+ : m_pBitmap(pBitmap),
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
+ m_pPlatformGraphics(nullptr),
+#endif
+ m_FillFlags(0),
+ m_bRgbByteOrder(bRgbByteOrder),
+ m_pOriDevice(pOriDevice),
+ m_bGroupKnockout(bGroupKnockout) {
InitPlatform();
}
CFX_AggDeviceDriver::~CFX_AggDeviceDriver() {
- delete m_pClipRgn;
- for (int i = 0; i < m_StateStack.GetSize(); i++)
- delete m_StateStack[i];
DestroyPlatform();
}
@@ -444,10 +447,6 @@ uint8_t* CFX_AggDeviceDriver::GetBuffer() const {
return m_pBitmap->GetBuffer();
}
-const CFX_DIBitmap* CFX_AggDeviceDriver::GetBitmap() const {
- return m_pBitmap;
-}
-
#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
void CFX_AggDeviceDriver::InitPlatform() {}
@@ -456,7 +455,6 @@ void CFX_AggDeviceDriver::DestroyPlatform() {}
FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
- CFX_FontCache* pCache,
const CFX_Matrix* pObject2Device,
FX_FLOAT font_size,
uint32_t color) {
@@ -499,29 +497,24 @@ int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) const {
}
void CFX_AggDeviceDriver::SaveState() {
- CFX_ClipRgn* pClip = nullptr;
- if (m_pClipRgn) {
- pClip = new CFX_ClipRgn(*m_pClipRgn);
- }
- m_StateStack.Add(pClip);
+ std::unique_ptr<CFX_ClipRgn> pClip;
+ if (m_pClipRgn)
+ pClip = pdfium::MakeUnique<CFX_ClipRgn>(*m_pClipRgn);
+ m_StateStack.push_back(std::move(pClip));
}
void CFX_AggDeviceDriver::RestoreState(bool bKeepSaved) {
- delete m_pClipRgn;
- m_pClipRgn = nullptr;
+ m_pClipRgn.reset();
- int size = m_StateStack.GetSize();
- if (!size)
+ if (m_StateStack.empty())
return;
- CFX_ClipRgn* pSavedClip = m_StateStack[size - 1];
if (bKeepSaved) {
- if (pSavedClip) {
- m_pClipRgn = new CFX_ClipRgn(*pSavedClip);
- }
+ if (m_StateStack.back())
+ m_pClipRgn = pdfium::MakeUnique<CFX_ClipRgn>(*m_StateStack.back());
} else {
- m_StateStack.RemoveAt(size - 1);
- m_pClipRgn = pSavedClip;
+ m_pClipRgn = std::move(m_StateStack.back());
+ m_StateStack.pop_back();
}
}
@@ -530,10 +523,7 @@ void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) {
rasterizer.max_x() + 1, rasterizer.max_y() + 1);
path_rect.Intersect(m_pClipRgn->GetBox());
CFX_DIBitmapRef mask;
- CFX_DIBitmap* pThisLayer = mask.New();
- if (!pThisLayer) {
- return;
- }
+ CFX_DIBitmap* pThisLayer = mask.Emplace();
pThisLayer->Create(path_rect.Width(), path_rect.Height(), FXDIB_8bppMask);
pThisLayer->Clear(0);
agg::rendering_buffer raw_buf(pThisLayer->GetBuffer(), pThisLayer->GetWidth(),
@@ -555,8 +545,8 @@ FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData,
int fill_mode) {
m_FillFlags = fill_mode;
if (!m_pClipRgn) {
- m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH),
- GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+ m_pClipRgn = pdfium::MakeUnique<CFX_ClipRgn>(
+ GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
}
if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) {
CFX_FloatRect rectf;
@@ -564,7 +554,7 @@ FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData,
rectf.Intersect(
CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH),
(FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
- FX_RECT rect = rectf.GetOutterRect();
+ FX_RECT rect = rectf.GetOuterRect();
m_pClipRgn->IntersectRect(rect);
return TRUE;
}
@@ -588,8 +578,8 @@ FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke(
const CFX_Matrix* pObject2Device,
const CFX_GraphStateData* pGraphState) {
if (!m_pClipRgn) {
- m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH),
- GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+ m_pClipRgn = pdfium::MakeUnique<CFX_ClipRgn>(
+ GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
}
CAgg_PathData path_data;
path_data.BuildPath(pPathData, nullptr);
@@ -1444,7 +1434,7 @@ FX_BOOL CFX_AggDeviceDriver::RenderRasterizer(
void* pIccTransform) {
CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : nullptr;
CFX_Renderer render;
- if (!render.Init(m_pBitmap, pt, m_pClipRgn, color, bFullCover,
+ if (!render.Init(m_pBitmap, pt, m_pClipRgn.get(), color, bFullCover,
m_bRgbByteOrder, alpha_flag, pIccTransform)) {
return FALSE;
}
@@ -1659,14 +1649,14 @@ FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
return TRUE;
if (pBitmap->IsAlphaMask()) {
- return m_pBitmap->CompositeMask(left, top, pSrcRect->Width(),
- pSrcRect->Height(), pBitmap, argb,
- pSrcRect->left, pSrcRect->top, blend_type,
- m_pClipRgn, m_bRgbByteOrder, 0, nullptr);
+ return m_pBitmap->CompositeMask(
+ left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb,
+ pSrcRect->left, pSrcRect->top, blend_type, m_pClipRgn.get(),
+ m_bRgbByteOrder, 0, nullptr);
}
return m_pBitmap->CompositeBitmap(
left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left,
- pSrcRect->top, blend_type, m_pClipRgn, m_bRgbByteOrder, nullptr);
+ pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder, nullptr);
}
FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
@@ -1692,8 +1682,8 @@ FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
FX_RECT dest_clip = dest_rect;
dest_clip.Intersect(*pClipRect);
CFX_BitmapComposer composer;
- composer.Compose(m_pBitmap, m_pClipRgn, 255, argb, dest_clip, FALSE, FALSE,
- FALSE, m_bRgbByteOrder, 0, nullptr, blend_type);
+ composer.Compose(m_pBitmap, m_pClipRgn.get(), 255, argb, dest_clip, FALSE,
+ FALSE, FALSE, m_bRgbByteOrder, 0, nullptr, blend_type);
dest_clip.Offset(-dest_rect.left, -dest_rect.top);
CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height,
dest_clip, flags);
@@ -1713,8 +1703,8 @@ FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
return TRUE;
CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer;
- pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix,
- render_flags, m_bRgbByteOrder, 0, nullptr);
+ pRenderer->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb,
+ pMatrix, render_flags, m_bRgbByteOrder, 0, nullptr);
handle = pRenderer;
return TRUE;
}
@@ -1746,9 +1736,8 @@ bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap,
return false;
SetBitmap(pBitmap);
- IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(
- pBitmap, bRgbByteOrder, pOriDevice, bGroupKnockout);
- SetDeviceDriver(pDriver);
+ SetDeviceDriver(pdfium::MakeUnique<CFX_AggDeviceDriver>(
+ pBitmap, bRgbByteOrder, pOriDevice, bGroupKnockout));
return true;
}
@@ -1763,9 +1752,8 @@ bool CFX_FxgeDevice::Create(int width,
return false;
}
SetBitmap(pBitmap);
- IFX_RenderDeviceDriver* pDriver =
- new CFX_AggDeviceDriver(pBitmap, FALSE, pOriDevice, FALSE);
- SetDeviceDriver(pDriver);
+ SetDeviceDriver(pdfium::MakeUnique<CFX_AggDeviceDriver>(pBitmap, FALSE,
+ pOriDevice, FALSE));
return true;
}