summaryrefslogtreecommitdiff
path: root/xfa/fxgraphics
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxgraphics')
-rw-r--r--xfa/fxgraphics/cxfa_graphics.cpp50
-rw-r--r--xfa/fxgraphics/cxfa_graphics.h28
2 files changed, 38 insertions, 40 deletions
diff --git a/xfa/fxgraphics/cxfa_graphics.cpp b/xfa/fxgraphics/cxfa_graphics.cpp
index 4975a83251..7cad380802 100644
--- a/xfa/fxgraphics/cxfa_graphics.cpp
+++ b/xfa/fxgraphics/cxfa_graphics.cpp
@@ -178,7 +178,7 @@ void CXFA_Graphics::SetFillColor(const CXFA_Color& color) {
m_info.fillColor = color;
}
-void CXFA_Graphics::StrokePath(CXFA_Path* path, CFX_Matrix* matrix) {
+void CXFA_Graphics::StrokePath(CXFA_Path* path, const CFX_Matrix* matrix) {
if (!path)
return;
if (m_type == FX_CONTEXT_Device && m_renderDevice)
@@ -187,7 +187,7 @@ void CXFA_Graphics::StrokePath(CXFA_Path* path, CFX_Matrix* matrix) {
void CXFA_Graphics::FillPath(CXFA_Path* path,
FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+ const CFX_Matrix* matrix) {
if (!path)
return;
if (m_type == FX_CONTEXT_Device && m_renderDevice)
@@ -196,7 +196,7 @@ void CXFA_Graphics::FillPath(CXFA_Path* path,
void CXFA_Graphics::StretchImage(const CFX_RetainPtr<CFX_DIBSource>& source,
const CFX_RectF& rect,
- CFX_Matrix* matrix) {
+ const CFX_Matrix& matrix) {
if (!source)
return;
if (m_type == FX_CONTEXT_Device && m_renderDevice)
@@ -211,7 +211,7 @@ void CXFA_Graphics::ConcatMatrix(const CFX_Matrix* matrix) {
}
}
-CFX_Matrix* CXFA_Graphics::GetMatrix() {
+const CFX_Matrix* CXFA_Graphics::GetMatrix() const {
if (m_type == FX_CONTEXT_Device && m_renderDevice)
return &m_info.CTM;
return nullptr;
@@ -268,8 +268,8 @@ void CXFA_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) {
}
}
-void CXFA_Graphics::RenderDeviceStrokePath(CXFA_Path* path,
- CFX_Matrix* matrix) {
+void CXFA_Graphics::RenderDeviceStrokePath(const CXFA_Path* path,
+ const CFX_Matrix* matrix) {
if (m_info.strokeColor.GetType() != CXFA_Color::Solid)
return;
@@ -281,9 +281,9 @@ void CXFA_Graphics::RenderDeviceStrokePath(CXFA_Path* path,
m_info.strokeColor.GetArgb(), 0);
}
-void CXFA_Graphics::RenderDeviceFillPath(CXFA_Path* path,
+void CXFA_Graphics::RenderDeviceFillPath(const CXFA_Path* path,
FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+ const CFX_Matrix* matrix) {
CFX_Matrix m = m_info.CTM;
if (matrix)
m.Concat(*matrix);
@@ -294,10 +294,10 @@ void CXFA_Graphics::RenderDeviceFillPath(CXFA_Path* path,
m_info.fillColor.GetArgb(), 0x0, fillMode);
return;
case CXFA_Color::Pattern:
- FillPathWithPattern(path, fillMode, &m);
+ FillPathWithPattern(path, fillMode, m);
return;
case CXFA_Color::Shading:
- FillPathWithShading(path, fillMode, &m);
+ FillPathWithShading(path, fillMode, m);
return;
default:
return;
@@ -307,12 +307,11 @@ void CXFA_Graphics::RenderDeviceFillPath(CXFA_Path* path,
void CXFA_Graphics::RenderDeviceStretchImage(
const CFX_RetainPtr<CFX_DIBSource>& source,
const CFX_RectF& rect,
- CFX_Matrix* matrix) {
+ const 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);
- }
+ m1.Concat(matrix);
+
CFX_RetainPtr<CFX_DIBitmap> bmp1 =
source->StretchTo(static_cast<int32_t>(rect.Width()),
static_cast<int32_t>(rect.Height()), 0, nullptr);
@@ -330,9 +329,9 @@ void CXFA_Graphics::RenderDeviceStretchImage(
FXSYS_round(r.left - left), FXSYS_round(r.top - top));
}
-void CXFA_Graphics::FillPathWithPattern(CXFA_Path* path,
+void CXFA_Graphics::FillPathWithPattern(const CXFA_Path* path,
FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+ const CFX_Matrix& matrix) {
CXFA_Pattern* pattern = m_info.fillColor.GetPattern();
CFX_RetainPtr<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
@@ -348,8 +347,7 @@ void CXFA_Graphics::FillPathWithPattern(CXFA_Path* path,
mask->Create(data.width, data.height, FXDIB_1bppMask);
memcpy(mask->GetBuffer(), data.maskBits, mask->GetPitch() * data.height);
CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox();
- if (matrix)
- matrix->TransformRect(rectf);
+ matrix.TransformRect(rectf);
FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top),
FXSYS_round(rectf.right), FXSYS_round(rectf.bottom));
@@ -361,13 +359,13 @@ void CXFA_Graphics::FillPathWithPattern(CXFA_Path* path,
device.SetBitMask(mask, i, j, m_info.fillColor.GetPattern()->m_foreArgb);
}
CFX_RenderDevice::StateRestorer restorer(m_renderDevice);
- m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode);
- SetDIBitsWithMatrix(bmp, &pattern->m_matrix);
+ m_renderDevice->SetClip_PathFill(path->GetPathData(), &matrix, fillMode);
+ SetDIBitsWithMatrix(bmp, pattern->m_matrix);
}
-void CXFA_Graphics::FillPathWithShading(CXFA_Path* path,
+void CXFA_Graphics::FillPathWithShading(const CXFA_Path* path,
FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+ const CFX_Matrix& matrix) {
CFX_RetainPtr<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
int32_t height = bitmap->GetHeight();
@@ -478,20 +476,20 @@ void CXFA_Graphics::FillPathWithShading(CXFA_Path* path,
}
if (result) {
CFX_RenderDevice::StateRestorer restorer(m_renderDevice);
- m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode);
+ m_renderDevice->SetClip_PathFill(path->GetPathData(), &matrix, fillMode);
SetDIBitsWithMatrix(bmp, matrix);
}
}
void CXFA_Graphics::SetDIBitsWithMatrix(
const CFX_RetainPtr<CFX_DIBSource>& source,
- CFX_Matrix* matrix) {
- if (matrix->IsIdentity()) {
+ const CFX_Matrix& matrix) {
+ if (matrix.IsIdentity()) {
m_renderDevice->SetDIBits(source, 0, 0);
} else {
CFX_Matrix m((float)source->GetWidth(), 0, 0, (float)source->GetHeight(), 0,
0);
- m.Concat(*matrix);
+ m.Concat(matrix);
int32_t left;
int32_t top;
CFX_RetainPtr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true);
diff --git a/xfa/fxgraphics/cxfa_graphics.h b/xfa/fxgraphics/cxfa_graphics.h
index 05f9640ca8..99f86870c3 100644
--- a/xfa/fxgraphics/cxfa_graphics.h
+++ b/xfa/fxgraphics/cxfa_graphics.h
@@ -50,7 +50,7 @@ class CXFA_Graphics {
void RestoreGraphState();
CFX_RectF GetClipRect() const;
- CFX_Matrix* GetMatrix();
+ const CFX_Matrix* GetMatrix() const;
CFX_RenderDevice* GetRenderDevice();
void SetLineCap(CFX_GraphStateData::LineCap lineCap);
@@ -61,13 +61,13 @@ class CXFA_Graphics {
void SetStrokeColor(const CXFA_Color& color);
void SetFillColor(const CXFA_Color& color);
void SetClipRect(const CFX_RectF& rect);
- void StrokePath(CXFA_Path* path, CFX_Matrix* matrix = nullptr);
+ void StrokePath(CXFA_Path* path, const CFX_Matrix* matrix);
void FillPath(CXFA_Path* path,
- FX_FillMode fillMode = FXFILL_WINDING,
- CFX_Matrix* matrix = nullptr);
+ FX_FillMode fillMode,
+ const CFX_Matrix* matrix);
void StretchImage(const CFX_RetainPtr<CFX_DIBSource>& source,
const CFX_RectF& rect,
- CFX_Matrix* matrix = nullptr);
+ const CFX_Matrix& matrix);
void ConcatMatrix(const CFX_Matrix* matrix);
protected:
@@ -87,23 +87,23 @@ class CXFA_Graphics {
} m_info;
void RenderDeviceSetLineDash(FX_DashStyle dashStyle);
- void RenderDeviceStrokePath(CXFA_Path* path, CFX_Matrix* matrix);
- void RenderDeviceFillPath(CXFA_Path* path,
+ void RenderDeviceStrokePath(const CXFA_Path* path, const CFX_Matrix* matrix);
+ void RenderDeviceFillPath(const CXFA_Path* path,
FX_FillMode fillMode,
- CFX_Matrix* matrix);
+ const CFX_Matrix* matrix);
void RenderDeviceStretchImage(const CFX_RetainPtr<CFX_DIBSource>& source,
const CFX_RectF& rect,
- CFX_Matrix* matrix);
+ const CFX_Matrix& matrix);
- void FillPathWithPattern(CXFA_Path* path,
+ void FillPathWithPattern(const CXFA_Path* path,
FX_FillMode fillMode,
- CFX_Matrix* matrix);
- void FillPathWithShading(CXFA_Path* path,
+ const CFX_Matrix& matrix);
+ void FillPathWithShading(const CXFA_Path* path,
FX_FillMode fillMode,
- CFX_Matrix* matrix);
+ const CFX_Matrix& matrix);
void SetDIBitsWithMatrix(const CFX_RetainPtr<CFX_DIBSource>& source,
- CFX_Matrix* matrix);
+ const CFX_Matrix& matrix);
CFX_RenderDevice* const m_renderDevice; // Not owned.
std::vector<std::unique_ptr<TInfo>> m_infoStack;