summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-29 13:23:13 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-29 13:23:13 -0800
commitbec4ea1e64b8049c572dd088c9c09a94f49b2353 (patch)
tree14470b439a7f963beea6aff17c72ac3321dc2e0a
parent3f157c7c6a5cdb92dd5df2a0b06c10ed83b472e8 (diff)
downloadpdfium-bec4ea1e64b8049c572dd088c9c09a94f49b2353.tar.xz
Pass rect by const reference in SetClip_Rect().
R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1745243002 .
-rw-r--r--core/include/fxge/fx_ge.h32
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp6
-rw-r--r--core/src/fxge/ge/fx_ge_device.cpp9
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp8
-rw-r--r--fpdfsdk/src/fpdfview.cpp8
-rw-r--r--fpdfsdk/src/fxedit/fxet_pageobjs.cpp27
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp6
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Utils.cpp9
-rw-r--r--xfa/src/fdp/src/fde/fde_gedevice.cpp9
-rw-r--r--xfa/src/fxgraphics/src/fx_graphics.cpp8
10 files changed, 38 insertions, 84 deletions
diff --git a/core/include/fxge/fx_ge.h b/core/include/fxge/fx_ge.h
index ebcdea1483..c5d409c41c 100644
--- a/core/include/fxge/fx_ge.h
+++ b/core/include/fxge/fx_ge.h
@@ -239,36 +239,26 @@ typedef struct {
FX_DWORD m_ExtGID;
FX_BOOL m_bFontStyle;
} FXTEXT_CHARPOS;
+
class CFX_RenderDevice {
public:
CFX_RenderDevice();
-
virtual ~CFX_RenderDevice();
void SetDeviceDriver(IFX_RenderDeviceDriver* pDriver);
-
IFX_RenderDeviceDriver* GetDeviceDriver() const { return m_pDeviceDriver; }
FX_BOOL StartRendering();
-
void EndRendering();
-
void SaveState();
-
void RestoreState(FX_BOOL bKeepSaved = FALSE);
int GetWidth() const { return m_Width; }
-
int GetHeight() const { return m_Height; }
-
int GetDeviceClass() const { return m_DeviceClass; }
-
int GetBPP() const { return m_bpp; }
-
int GetRenderCaps() const { return m_RenderCaps; }
-
int GetDeviceCaps(int id) const;
-
CFX_Matrix GetCTM() const;
CFX_DIBitmap* GetBitmap() const { return m_pBitmap; }
@@ -284,8 +274,7 @@ class CFX_RenderDevice {
const CFX_Matrix* pObject2Device,
int fill_mode);
- FX_BOOL SetClip_Rect(const FX_RECT* pRect);
-
+ FX_BOOL SetClip_Rect(const FX_RECT& pRect);
FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
const CFX_GraphStateData* pGraphState);
@@ -405,28 +394,19 @@ class CFX_RenderDevice {
virtual void End() {}
private:
- CFX_DIBitmap* m_pBitmap;
+ void InitDeviceInfo();
+ void UpdateClipBox();
+ CFX_DIBitmap* m_pBitmap;
int m_Width;
-
int m_Height;
-
int m_bpp;
-
int m_RenderCaps;
-
int m_DeviceClass;
-
FX_RECT m_ClipBox;
-
- protected:
IFX_RenderDeviceDriver* m_pDeviceDriver;
-
- private:
- void InitDeviceInfo();
-
- void UpdateClipBox();
};
+
class CFX_FxgeDevice : public CFX_RenderDevice {
public:
CFX_FxgeDevice();
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index 5998a9236c..e4876a0d26 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -914,8 +914,7 @@ void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
return;
}
} else if (pPageObj->IsImage()) {
- FX_RECT rect = pPageObj->GetBBox(pObj2Device);
- m_pDevice->SetClip_Rect(&rect);
+ m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device));
} else {
return;
}
@@ -996,8 +995,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
return;
}
} else if (pPageObj->IsImage()) {
- FX_RECT rect = pPageObj->GetBBox(pObj2Device);
- m_pDevice->SetClip_Rect(&rect);
+ m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device));
} else {
return;
}
diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp
index 268001b285..c4f7735957 100644
--- a/core/src/fxge/ge/fx_ge_device.cpp
+++ b/core/src/fxge/ge/fx_ge_device.cpp
@@ -91,13 +91,12 @@ FX_BOOL CFX_RenderDevice::SetClip_PathStroke(
UpdateClipBox();
return TRUE;
}
-FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT* pRect) {
+FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) {
CFX_PathData path;
- path.AppendRect((FX_FLOAT)(pRect->left), (FX_FLOAT)(pRect->bottom),
- (FX_FLOAT)(pRect->right), (FX_FLOAT)(pRect->top));
- if (!SetClip_PathFill(&path, NULL, FXFILL_WINDING)) {
+ path.AppendRect(rect.left, rect.bottom, rect.right, rect.top);
+ if (!SetClip_PathFill(&path, nullptr, FXFILL_WINDING))
return FALSE;
- }
+
UpdateClipBox();
return TRUE;
}
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index a14c66fbc6..c2e75c34d5 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -332,11 +332,7 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
CFX_Matrix matrix;
pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
- FX_RECT clip;
- clip.left = start_x;
- clip.right = start_x + size_x;
- clip.top = start_y;
- clip.bottom = start_y + size_y;
+ FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
#ifdef _SKIA_SUPPORT_
std::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice);
@@ -345,7 +341,7 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
#endif
pDevice->Attach((CFX_DIBitmap*)bitmap);
pDevice->SaveState();
- pDevice->SetClip_Rect(&clip);
+ pDevice->SetClip_Rect(clip);
#ifndef PDF_ENABLE_XFA
if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index a535866889..05c69acb99 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -891,13 +891,9 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext,
CFX_Matrix matrix;
pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
- FX_RECT clip;
- clip.left = start_x;
- clip.right = start_x + size_x;
- clip.top = start_y;
- clip.bottom = start_y + size_y;
pContext->m_pDevice->SaveState();
- pContext->m_pDevice->SetClip_Rect(&clip);
+ pContext->m_pDevice->SetClip_Rect(
+ FX_RECT(start_x, start_y, start_x + size_x, start_y + size_y));
pContext->m_pContext = new CPDF_RenderContext(pPage);
pContext->m_pContext->AppendLayer(pPage, &matrix);
diff --git a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
index d7803311a5..63ab467ebe 100644
--- a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
@@ -100,12 +100,9 @@ void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice,
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
- FX_RECT rcDevClip;
- rcDevClip.left = (int32_t)rcTemp.left;
- rcDevClip.right = (int32_t)rcTemp.right;
- rcDevClip.top = (int32_t)rcTemp.top;
- rcDevClip.bottom = (int32_t)rcTemp.bottom;
- pDevice->SetClip_Rect(&rcDevClip);
+ pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.top,
+ (int32_t)rcTemp.right,
+ (int32_t)rcTemp.bottom));
}
if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
@@ -174,12 +171,9 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
- FX_RECT rcDevClip;
- rcDevClip.left = (int32_t)rcTemp.left;
- rcDevClip.right = (int32_t)rcTemp.right;
- rcDevClip.top = (int32_t)rcTemp.top;
- rcDevClip.bottom = (int32_t)rcTemp.bottom;
- pDevice->SetClip_Rect(&rcDevClip);
+ pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.top,
+ (int32_t)rcTemp.right,
+ (int32_t)rcTemp.bottom));
}
if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
@@ -299,12 +293,9 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
- FX_RECT rcDevClip;
- rcDevClip.left = (int32_t)rcTemp.left;
- rcDevClip.right = (int32_t)rcTemp.right;
- rcDevClip.top = (int32_t)rcTemp.top;
- rcDevClip.bottom = (int32_t)rcTemp.bottom;
- pDevice->SetClip_Rect(&rcDevClip);
+ pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.top,
+ (int32_t)rcTemp.right,
+ (int32_t)rcTemp.bottom));
}
if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
diff --git a/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp b/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
index 1c32ceb251..7c2c1f4d17 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
@@ -141,10 +141,8 @@ void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice,
CFX_FloatRect rcClient = GetClientRect();
CFX_FloatRect rcTemp = rcClient;
pUser2Device->TransformRect(rcTemp);
- FX_RECT rcClip((int32_t)rcTemp.left, (int32_t)rcTemp.bottom,
- (int32_t)rcTemp.right, (int32_t)rcTemp.top);
-
- pDevice->SetClip_Rect(&rcClip);
+ pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.bottom,
+ (int32_t)rcTemp.right, (int32_t)rcTemp.top));
for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
diff --git a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
index 6cd5786e2e..db1323e78a 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
@@ -1696,12 +1696,9 @@ void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice,
if (!rcClip.IsEmpty()) {
CFX_FloatRect rcTemp = rcClip;
pUser2Device->TransformRect(rcTemp);
- FX_RECT rcDevClip;
- rcDevClip.left = (int32_t)rcTemp.left;
- rcDevClip.right = (int32_t)rcTemp.right;
- rcDevClip.top = (int32_t)rcTemp.top;
- rcDevClip.bottom = (int32_t)rcTemp.bottom;
- pDevice->SetClip_Rect(&rcDevClip);
+ pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.top,
+ (int32_t)rcTemp.right,
+ (int32_t)rcTemp.bottom));
}
if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
diff --git a/xfa/src/fdp/src/fde/fde_gedevice.cpp b/xfa/src/fdp/src/fde/fde_gedevice.cpp
index b2be47c659..c0d665d6a5 100644
--- a/xfa/src/fdp/src/fde/fde_gedevice.cpp
+++ b/xfa/src/fdp/src/fde/fde_gedevice.cpp
@@ -71,11 +71,10 @@ void CFDE_FxgeDevice::RestoreState(FDE_HDEVICESTATE hState) {
}
FX_BOOL CFDE_FxgeDevice::SetClipRect(const CFX_RectF& rtClip) {
m_rtClip = rtClip;
- FX_RECT rt((int32_t)FXSYS_floor(rtClip.left),
- (int32_t)FXSYS_floor(rtClip.top),
- (int32_t)FXSYS_ceil(rtClip.right()),
- (int32_t)FXSYS_ceil(rtClip.bottom()));
- return m_pDevice->SetClip_Rect(&rt);
+ return m_pDevice->SetClip_Rect(FX_RECT((int32_t)FXSYS_floor(rtClip.left),
+ (int32_t)FXSYS_floor(rtClip.top),
+ (int32_t)FXSYS_ceil(rtClip.right()),
+ (int32_t)FXSYS_ceil(rtClip.bottom())));
}
const CFX_RectF& CFDE_FxgeDevice::GetClipRect() {
return m_rtClip;
diff --git a/xfa/src/fxgraphics/src/fx_graphics.cpp b/xfa/src/fxgraphics/src/fx_graphics.cpp
index 301bd7c356..602382725f 100644
--- a/xfa/src/fxgraphics/src/fx_graphics.cpp
+++ b/xfa/src/fxgraphics/src/fx_graphics.cpp
@@ -485,11 +485,11 @@ FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) {
case FX_CONTEXT_Device: {
if (!_renderDevice)
return FX_ERR_Property_Invalid;
- FX_RECT r(FXSYS_round(rect.left), FXSYS_round(rect.top),
- FXSYS_round(rect.right()), FXSYS_round(rect.bottom()));
- FX_BOOL result = _renderDevice->SetClip_Rect(&r);
- if (!result)
+ if (!_renderDevice->SetClip_Rect(
+ FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top),
+ FXSYS_round(rect.right()), FXSYS_round(rect.bottom())))) {
return FX_ERR_Method_Not_Supported;
+ }
return FX_ERR_Succeeded;
}
default: { return FX_ERR_Property_Invalid; }