summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-06-08 11:51:23 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-08 11:51:23 -0700
commit7d2a8d966643ebc77c1aa0f0c53a0ffd2d681c4c (patch)
tree5f2823bb9e2a575e39044ebea114f4ed4e5a9368 /core
parentb7a5179a7cd73d33355e1cece763caf238b7dc22 (diff)
downloadpdfium-7d2a8d966643ebc77c1aa0f0c53a0ffd2d681c4c.tar.xz
Remove implicit CFX_CountedRef::operator T*()
Explicitly invoke GetObject() method instead. This avoids having code where it looks like non-pointers are assigned to pointers but works due to the cast operator. Review-Url: https://codereview.chromium.org/2045083003
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render.cpp54
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp3
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp6
-rw-r--r--core/fpdfdoc/doc_ocg.cpp2
-rw-r--r--core/fxcrt/include/fx_basic.h24
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp6
-rw-r--r--core/fxge/apple/fx_apple_platform.cpp2
-rw-r--r--core/fxge/dib/fx_dib_composite.cpp6
-rw-r--r--core/fxge/ge/fx_ge_path.cpp6
9 files changed, 51 insertions, 58 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index 7e8c8348a5..a675dfe09c 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -188,12 +188,10 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext,
if (pInitialStates && !m_pType3Char) {
m_InitialStates.CopyStates(*pInitialStates);
if (pParentState) {
- CPDF_ColorStateData* pColorData =
- (CPDF_ColorStateData*)(const CPDF_ColorStateData*)
- m_InitialStates.m_ColorState;
- CPDF_ColorStateData* pParentData =
- (CPDF_ColorStateData*)(const CPDF_ColorStateData*)
- pParentState->m_InitialStates.m_ColorState;
+ const CPDF_ColorStateData* pColorData =
+ m_InitialStates.m_ColorState.GetObject();
+ const CPDF_ColorStateData* pParentData =
+ pParentState->m_InitialStates.m_ColorState.GetObject();
if (!pColorData || pColorData->m_FillColor.IsNull()) {
CPDF_ColorStateData* pData = m_InitialStates.m_ColorState.GetModify();
pData->m_FillRGB = pParentData->m_FillRGB;
@@ -466,20 +464,20 @@ FX_BOOL CPDF_RenderStatus::ProcessPath(const CPDF_PathObject* pPathObj,
FillType |= FX_FILL_STROKE;
}
const CPDF_GeneralStateData* pGeneralData =
- ((CPDF_PageObject*)pPathObj)->m_GeneralState;
+ static_cast<const CPDF_PageObject*>(pPathObj)->m_GeneralState.GetObject();
if (pGeneralData && pGeneralData->m_StrokeAdjust) {
FillType |= FX_STROKE_ADJUST;
}
if (m_pType3Char) {
FillType |= FX_FILL_TEXT_MODE;
}
- CFX_GraphStateData graphState(*pPathObj->m_GraphState);
+ CFX_GraphStateData graphState(*pPathObj->m_GraphState.GetObject());
if (m_Options.m_Flags & RENDER_THINLINE) {
graphState.m_LineWidth = 0;
}
- return m_pDevice->DrawPathWithBlend(pPathObj->m_Path, &path_matrix,
- &graphState, fill_argb, stroke_argb,
- FillType, m_curBlend);
+ return m_pDevice->DrawPathWithBlend(pPathObj->m_Path.GetObject(),
+ &path_matrix, &graphState, fill_argb,
+ stroke_argb, FillType, m_curBlend);
}
CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const {
@@ -489,8 +487,7 @@ CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const {
}
FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj,
FX_BOOL bType3) const {
- CPDF_ColorStateData* pColorData =
- (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState;
+ const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject();
if (m_pType3Char && !bType3 &&
(!m_pType3Char->m_bColored ||
(m_pType3Char->m_bColored &&
@@ -498,14 +495,13 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj,
return m_T3FillColor;
}
if (!pColorData || pColorData->m_FillColor.IsNull()) {
- pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)
- m_InitialStates.m_ColorState;
+ pColorData = m_InitialStates.m_ColorState.GetObject();
}
FX_COLORREF rgb = pColorData->m_FillRGB;
if (rgb == (uint32_t)-1) {
return 0;
}
- const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState;
+ const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState.GetObject();
int alpha;
if (pGeneralData) {
alpha = (int32_t)(pGeneralData->m_FillAlpha * 255);
@@ -524,22 +520,20 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj,
return m_Options.TranslateColor(ArgbEncode(alpha, rgb));
}
FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const {
- CPDF_ColorStateData* pColorData =
- (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState;
+ const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject();
if (m_pType3Char && (!m_pType3Char->m_bColored ||
(m_pType3Char->m_bColored &&
(!pColorData || pColorData->m_StrokeColor.IsNull())))) {
return m_T3FillColor;
}
if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
- pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)
- m_InitialStates.m_ColorState;
+ pColorData = m_InitialStates.m_ColorState.GetObject();
}
FX_COLORREF rgb = pColorData->m_StrokeRGB;
if (rgb == (uint32_t)-1) {
return 0;
}
- const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState;
+ const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState.GetObject();
int alpha;
if (pGeneralData) {
alpha = (int32_t)(pGeneralData->m_StrokeAlpha * 255);
@@ -573,7 +567,7 @@ void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath,
m_pDevice->RestoreState(true);
int nClipPath = ClipPath.GetPathCount();
for (int i = 0; i < nClipPath; ++i) {
- const CFX_PathData* pPathData = ClipPath.GetPath(i);
+ const CFX_PathData* pPathData = ClipPath.GetPath(i).GetObject();
if (!pPathData)
continue;
@@ -629,7 +623,7 @@ void CPDF_RenderStatus::DrawClipPath(CPDF_ClipPath ClipPath,
int nClipPath = ClipPath.GetPathCount();
int i;
for (i = 0; i < nClipPath; i++) {
- const CFX_PathData* pPathData = ClipPath.GetPath(i);
+ const CFX_PathData* pPathData = ClipPath.GetPath(i).GetObject();
if (!pPathData) {
continue;
}
@@ -647,22 +641,24 @@ FX_BOOL CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj,
CFX_Matrix path_matrix = pPathObj->m_Matrix;
path_matrix.Concat(*pObj2Device);
if (bStroke) {
- CFX_GraphStateData graphState(*pPathObj->m_GraphState);
+ CFX_GraphStateData graphState(*pPathObj->m_GraphState.GetObject());
if (m_Options.m_Flags & RENDER_THINLINE) {
graphState.m_LineWidth = 0;
}
- return m_pDevice->SetClip_PathStroke(pPathObj->m_Path, &path_matrix,
- &graphState);
+ return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(),
+ &path_matrix, &graphState);
}
int fill_mode = pPathObj->m_FillType;
if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) {
fill_mode |= FXFILL_NOPATHSMOOTH;
}
- return m_pDevice->SetClip_PathFill(pPathObj->m_Path, &path_matrix, fill_mode);
+ return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix,
+ fill_mode);
}
FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
const CFX_Matrix* pObj2Device) {
- const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState;
+ const CPDF_GeneralStateData* pGeneralState =
+ pPageObj->m_GeneralState.GetObject();
int blend_type =
pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL;
if (blend_type == FXDIB_BLEND_UNSUPPORTED) {
@@ -792,7 +788,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
&text_device, textobj->m_nChars, textobj->m_pCharCodes,
textobj->m_pCharPos, textobj->m_TextState.GetFont(),
textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix,
- textobj->m_GraphState, (FX_ARGB)-1, 0, nullptr, 0);
+ textobj->m_GraphState.GetObject(), (FX_ARGB)-1, 0, nullptr, 0);
}
}
CPDF_RenderStatus bitmap_render;
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 76a6d4e764..16a06f8f3b 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -365,7 +365,8 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
return FALSE;
}
m_BitmapAlpha = 255;
- const CPDF_GeneralStateData* pGeneralState = m_pImageObject->m_GeneralState;
+ const CPDF_GeneralStateData* pGeneralState =
+ m_pImageObject->m_GeneralState.GetObject();
if (pGeneralState) {
m_BitmapAlpha = FXSYS_round(pGeneralState->m_FillAlpha * 255);
}
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 43816c4d99..9e3a6c6587 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -308,7 +308,8 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj,
flag |= FX_STROKE_TEXT_MODE;
}
const CPDF_GeneralStateData* pGeneralData =
- ((CPDF_PageObject*)textobj)->m_GeneralState;
+ static_cast<const CPDF_PageObject*>(textobj)
+ ->m_GeneralState.GetObject();
if (pGeneralData && pGeneralData->m_StrokeAdjust) {
flag |= FX_STROKE_ADJUST;
}
@@ -318,7 +319,8 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj,
return CPDF_TextRenderer::DrawTextPath(
m_pDevice, textobj->m_nChars, textobj->m_pCharCodes,
textobj->m_pCharPos, pFont, font_size, &text_matrix, pDeviceMatrix,
- textobj->m_GraphState, fill_argb, stroke_argb, pClippingPath, flag);
+ textobj->m_GraphState.GetObject(), fill_argb, stroke_argb,
+ pClippingPath, flag);
}
text_matrix.Concat(*pObj2Device);
return CPDF_TextRenderer::DrawNormalText(
diff --git a/core/fpdfdoc/doc_ocg.cpp b/core/fpdfdoc/doc_ocg.cpp
index dc49ab0fd7..1251cb20e3 100644
--- a/core/fpdfdoc/doc_ocg.cpp
+++ b/core/fpdfdoc/doc_ocg.cpp
@@ -185,7 +185,7 @@ bool CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) {
}
bool CPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) {
- const CPDF_ContentMarkData* pData = pObj->m_ContentMark;
+ const CPDF_ContentMarkData* pData = pObj->m_ContentMark.GetObject();
for (int i = 0; i < pData->CountItems(); i++) {
const CPDF_ContentMarkItem& item = pData->GetItem(i);
if (item.GetName() == "OC" &&
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h
index 8e39f5577a..bc05a3479d 100644
--- a/core/fxcrt/include/fx_basic.h
+++ b/core/fxcrt/include/fx_basic.h
@@ -648,27 +648,24 @@ class CFX_BitStream {
const uint8_t* m_pData;
};
+
template <class ObjClass>
class CFX_CountRef {
public:
- typedef CFX_CountRef<ObjClass> Ref;
+ using Ref = CFX_CountRef<ObjClass>;
class CountedObj : public ObjClass {
public:
CountedObj() {}
-
CountedObj(const CountedObj& src) : ObjClass(src) {}
int m_RefCount;
};
- CFX_CountRef() { m_pObject = nullptr; }
-
- CFX_CountRef(const Ref& ref) {
- m_pObject = ref.m_pObject;
- if (m_pObject) {
+ CFX_CountRef() : m_pObject(nullptr) {}
+ CFX_CountRef(const Ref& ref) : m_pObject(ref.m_pObject) {
+ if (m_pObject)
m_pObject->m_RefCount++;
- }
}
~CFX_CountRef() { SetNull(); }
@@ -687,14 +684,10 @@ class CFX_CountRef {
m_pObject = ref.m_pObject;
}
- const ObjClass* GetObject() const { return m_pObject; }
-
- operator const ObjClass*() const { return m_pObject; }
-
- FX_BOOL IsNull() const { return !m_pObject; }
-
- FX_BOOL NotNull() const { return !IsNull(); }
+ bool IsNull() const { return !m_pObject; }
+ bool NotNull() const { return !IsNull(); }
+ const ObjClass* GetObject() const { return m_pObject; }
ObjClass* GetModify() {
if (!m_pObject) {
m_pObject = new CountedObj;
@@ -724,6 +717,7 @@ class CFX_CountRef {
protected:
CountedObj* m_pObject;
};
+
class IFX_Pause {
public:
virtual ~IFX_Pause() {}
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index d7a9ddb530..7d197f8c21 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1096,7 +1096,7 @@ class CFX_Renderer {
}
m_pClipMask = nullptr;
if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) {
- m_pClipMask = m_pClipRgn->GetMask();
+ m_pClipMask = m_pClipRgn->GetMask().GetObject();
}
m_bFullCover = bFullCover;
FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
@@ -1562,7 +1562,7 @@ FX_BOOL CFX_AggDeviceDriver::SetPixel(int x,
return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransform);
}
} else if (m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) {
- const CFX_DIBitmap* pMask = m_pClipRgn->GetMask();
+ const CFX_DIBitmap* pMask = m_pClipRgn->GetMask().GetObject();
FX_BOOL bCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
int new_alpha =
bCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
@@ -1617,7 +1617,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
}
m_pBitmap->CompositeMask(
draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(),
- (const CFX_DIBitmap*)m_pClipRgn->GetMask(), fill_color,
+ m_pClipRgn->GetMask().GetObject(), fill_color,
draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top,
FXDIB_BLEND_NORMAL, nullptr, m_bRgbByteOrder, alpha_flag, pIccTransform);
return TRUE;
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp
index b25bb5875d..4204e7e6a5 100644
--- a/core/fxge/apple/fx_apple_platform.cpp
+++ b/core/fxge/apple/fx_apple_platform.cpp
@@ -138,7 +138,7 @@ FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars,
rect_cg =
CGRectMake(m_pClipRgn->GetBox().left, m_pClipRgn->GetBox().top,
m_pClipRgn->GetBox().Width(), m_pClipRgn->GetBox().Height());
- const CFX_DIBitmap* pClipMask = m_pClipRgn->GetMask();
+ const CFX_DIBitmap* pClipMask = m_pClipRgn->GetMask().GetObject();
if (pClipMask) {
CGDataProviderRef pClipMaskDataProvider = CGDataProviderCreateWithData(
nullptr, pClipMask->GetBuffer(),
diff --git a/core/fxge/dib/fx_dib_composite.cpp b/core/fxge/dib/fx_dib_composite.cpp
index 28f6e49044..afb0551b98 100644
--- a/core/fxge/dib/fx_dib_composite.cpp
+++ b/core/fxge/dib/fx_dib_composite.cpp
@@ -4508,7 +4508,7 @@ FX_BOOL CFX_DIBitmap::CompositeBitmap(int dest_left,
FX_RECT clip_box;
if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) {
ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF);
- pClipMask = pClipRgn->GetMask();
+ pClipMask = pClipRgn->GetMask().GetObject();
clip_box = pClipRgn->GetBox();
}
CFX_ScanlineCompositor compositor;
@@ -4587,7 +4587,7 @@ FX_BOOL CFX_DIBitmap::CompositeMask(int dest_left,
FX_RECT clip_box;
if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) {
ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF);
- pClipMask = pClipRgn->GetMask();
+ pClipMask = pClipRgn->GetMask().GetObject();
clip_box = pClipRgn->GetBox();
}
int src_bpp = pMask->GetBPP();
@@ -4870,7 +4870,7 @@ void CFX_BitmapComposer::Compose(CFX_DIBitmap* pDest,
m_MaskColor = mask_color;
m_pClipMask = nullptr;
if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) {
- m_pClipMask = pClipRgn->GetMask();
+ m_pClipMask = pClipRgn->GetMask().GetObject();
}
m_bVertical = bVertical;
m_bFlipX = bFlipX;
diff --git a/core/fxge/ge/fx_ge_path.cpp b/core/fxge/ge/fx_ge_path.cpp
index 2abc45f499..6eb41d3094 100644
--- a/core/fxge/ge/fx_ge_path.cpp
+++ b/core/fxge/ge/fx_ge_path.cpp
@@ -42,7 +42,7 @@ void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) {
void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect,
FX_RECT mask_rect,
CFX_DIBitmapRef Mask) {
- const CFX_DIBitmap* mask_dib = Mask;
+ const CFX_DIBitmap* mask_dib = Mask.GetObject();
m_Type = MaskF;
m_Box = rect;
m_Box.Intersect(mask_rect);
@@ -70,7 +70,7 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect,
}
}
void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
- const CFX_DIBitmap* mask_dib = Mask;
+ const CFX_DIBitmap* mask_dib = Mask.GetObject();
ASSERT(mask_dib->GetFormat() == FXDIB_8bppMask);
FX_RECT mask_box(left, top, left + mask_dib->GetWidth(),
top + mask_dib->GetHeight());
@@ -93,7 +93,7 @@ void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
return;
}
new_dib->Create(new_box.Width(), new_box.Height(), FXDIB_8bppMask);
- const CFX_DIBitmap* old_dib = m_Mask;
+ const CFX_DIBitmap* old_dib = m_Mask.GetObject();
for (int row = new_box.top; row < new_box.bottom; row++) {
uint8_t* old_scan =
old_dib->GetBuffer() + (row - m_Box.top) * old_dib->GetPitch();