CXFA_Graphics::m_renderDevice is always present.
Hence m_type is not required (it was redundant with
!!m_renderDevice anyways). Remove unreachable code.
Change-Id: Ibf9258eb9a0f425b7ce27747aabb15b5c992231b
Reviewed-on: https://pdfium-review.googlesource.com/c/48512
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fxgraphics/cxfa_graphics.cpp b/xfa/fxgraphics/cxfa_graphics.cpp
index 5e4c556..96ab7a0 100644
--- a/xfa/fxgraphics/cxfa_graphics.cpp
+++ b/xfa/fxgraphics/cxfa_graphics.cpp
@@ -20,11 +20,6 @@
namespace {
-enum {
- FX_CONTEXT_None = 0,
- FX_CONTEXT_Device,
-};
-
struct FX_HATCHDATA {
int32_t width;
int32_t height;
@@ -114,28 +109,20 @@
} // namespace
CXFA_Graphics::CXFA_Graphics(CFX_RenderDevice* renderDevice)
- : m_type(FX_CONTEXT_None), m_renderDevice(renderDevice) {
- if (!renderDevice)
- return;
- m_type = FX_CONTEXT_Device;
+ : m_renderDevice(renderDevice) {
+ ASSERT(m_renderDevice);
}
-CXFA_Graphics::~CXFA_Graphics() {}
+CXFA_Graphics::~CXFA_Graphics() = default;
void CXFA_Graphics::SaveGraphState() {
- if (m_type != FX_CONTEXT_Device || !m_renderDevice)
- return;
-
m_renderDevice->SaveState();
m_infoStack.push_back(pdfium::MakeUnique<TInfo>(m_info));
}
void CXFA_Graphics::RestoreGraphState() {
- if (m_type != FX_CONTEXT_Device || !m_renderDevice)
- return;
-
m_renderDevice->RestoreState(false);
- if (m_infoStack.empty() || !m_infoStack.back())
+ if (m_infoStack.empty())
return;
m_info = *m_infoStack.back();
@@ -144,9 +131,7 @@
}
void CXFA_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) {
- if (m_type == FX_CONTEXT_Device && m_renderDevice) {
- m_info.graphState.m_LineCap = lineCap;
- }
+ m_info.graphState.m_LineCap = lineCap;
}
void CXFA_Graphics::SetLineDash(float dashPhase,
@@ -155,9 +140,6 @@
ASSERT(dashArray);
ASSERT(dashCount);
- if (m_type != FX_CONTEXT_Device || !m_renderDevice)
- return;
-
float scale = m_info.isActOnDash ? m_info.graphState.m_LineWidth : 1.0;
m_info.graphState.m_DashPhase = dashPhase;
m_info.graphState.m_DashArray.resize(dashCount);
@@ -166,74 +148,55 @@
}
void CXFA_Graphics::SetSolidLineDash() {
- if (m_type == FX_CONTEXT_Device && m_renderDevice)
- m_info.graphState.m_DashArray.clear();
+ m_info.graphState.m_DashArray.clear();
}
void CXFA_Graphics::SetLineWidth(float lineWidth) {
- if (m_type == FX_CONTEXT_Device && m_renderDevice)
- m_info.graphState.m_LineWidth = lineWidth;
+ m_info.graphState.m_LineWidth = lineWidth;
}
void CXFA_Graphics::EnableActOnDash() {
- if (m_type == FX_CONTEXT_Device && m_renderDevice)
- m_info.isActOnDash = true;
+ m_info.isActOnDash = true;
}
void CXFA_Graphics::SetStrokeColor(const CXFA_GEColor& color) {
- if (m_type == FX_CONTEXT_Device && m_renderDevice)
- m_info.strokeColor = color;
+ m_info.strokeColor = color;
}
void CXFA_Graphics::SetFillColor(const CXFA_GEColor& color) {
- if (m_type == FX_CONTEXT_Device && m_renderDevice)
m_info.fillColor = color;
}
void CXFA_Graphics::StrokePath(CXFA_GEPath* path, const CFX_Matrix* matrix) {
- if (!path)
- return;
- if (m_type == FX_CONTEXT_Device && m_renderDevice)
+ if (path)
RenderDeviceStrokePath(path, matrix);
}
void CXFA_Graphics::FillPath(CXFA_GEPath* path,
FX_FillMode fillMode,
const CFX_Matrix* matrix) {
- if (!path)
- return;
- if (m_type == FX_CONTEXT_Device && m_renderDevice)
+ if (path)
RenderDeviceFillPath(path, fillMode, matrix);
}
void CXFA_Graphics::ConcatMatrix(const CFX_Matrix* matrix) {
- if (!matrix)
- return;
- if (m_type == FX_CONTEXT_Device && m_renderDevice) {
+ if (matrix)
m_info.CTM.Concat(*matrix);
- }
}
const CFX_Matrix* CXFA_Graphics::GetMatrix() const {
- if (m_type == FX_CONTEXT_Device && m_renderDevice)
- return &m_info.CTM;
- return nullptr;
+ return &m_info.CTM;
}
CFX_RectF CXFA_Graphics::GetClipRect() const {
- if (m_type != FX_CONTEXT_Device || !m_renderDevice)
- return CFX_RectF();
-
FX_RECT r = m_renderDevice->GetClipBox();
return CFX_RectF(r.left, r.top, r.Width(), r.Height());
}
void CXFA_Graphics::SetClipRect(const CFX_RectF& rect) {
- if (m_type == FX_CONTEXT_Device && m_renderDevice) {
- m_renderDevice->SetClip_Rect(
- FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top),
- FXSYS_round(rect.right()), FXSYS_round(rect.bottom())));
- }
+ m_renderDevice->SetClip_Rect(
+ FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top),
+ FXSYS_round(rect.right()), FXSYS_round(rect.bottom())));
}
CFX_RenderDevice* CXFA_Graphics::GetRenderDevice() {
diff --git a/xfa/fxgraphics/cxfa_graphics.h b/xfa/fxgraphics/cxfa_graphics.h
index 37da034..d6ab7de 100644
--- a/xfa/fxgraphics/cxfa_graphics.h
+++ b/xfa/fxgraphics/cxfa_graphics.h
@@ -82,9 +82,8 @@
void SetDIBitsWithMatrix(const RetainPtr<CFX_DIBBase>& source,
const CFX_Matrix& matrix);
- int32_t m_type;
- TInfo m_info;
CFX_RenderDevice* const m_renderDevice; // Not owned.
+ TInfo m_info;
std::vector<std::unique_ptr<TInfo>> m_infoStack;
};