summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp16
-rw-r--r--core/fxge/agg/fx_agg_driver.h2
-rw-r--r--core/fxge/apple/apple_int.h2
-rw-r--r--core/fxge/apple/fx_quartz_device.cpp38
-rw-r--r--core/fxge/ge/fx_ge_device.cpp4
-rw-r--r--core/fxge/ge/fx_ge_ps.cpp18
-rw-r--r--core/fxge/include/fx_ge.h6
-rw-r--r--core/fxge/skia/fx_skia_device.cpp2
-rw-r--r--core/fxge/skia/fx_skia_device.h2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp12
-rw-r--r--core/fxge/win32/fx_win32_print.cpp6
-rw-r--r--core/fxge/win32/win32_int.h11
12 files changed, 69 insertions, 50 deletions
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 6726877d99..86326f6caf 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -284,21 +284,21 @@ void CFX_AggDeviceDriver::SaveState() {
m_StateStack.Add(pClip);
}
-void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) {
- if (m_StateStack.GetSize() == 0) {
- delete m_pClipRgn;
- m_pClipRgn = nullptr;
- return;
- }
- CFX_ClipRgn* pSavedClip = m_StateStack[m_StateStack.GetSize() - 1];
+void CFX_AggDeviceDriver::RestoreState(bool bKeepSaved) {
delete m_pClipRgn;
m_pClipRgn = nullptr;
+
+ int size = m_StateStack.GetSize();
+ if (!size)
+ return;
+
+ CFX_ClipRgn* pSavedClip = m_StateStack[size - 1];
if (bKeepSaved) {
if (pSavedClip) {
m_pClipRgn = new CFX_ClipRgn(*pSavedClip);
}
} else {
- m_StateStack.RemoveAt(m_StateStack.GetSize() - 1);
+ m_StateStack.RemoveAt(size - 1);
m_pClipRgn = pSavedClip;
}
}
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 18f8d348ce..a33bc09937 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -40,7 +40,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
// IFX_RenderDeviceDriver
int GetDeviceCaps(int caps_id) override;
void SaveState() override;
- void RestoreState(FX_BOOL bKeepSaved) override;
+ void RestoreState(bool bKeepSaved) override;
FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode) override;
diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h
index 02754cc309..ddfa792cf4 100644
--- a/core/fxge/apple/apple_int.h
+++ b/core/fxge/apple/apple_int.h
@@ -91,7 +91,7 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver {
FX_BOOL StartRendering() override { return TRUE; }
void EndRendering() override {}
void SaveState() override;
- void RestoreState(FX_BOOL bKeepSaved) override;
+ void RestoreState(bool bKeepSaved) override;
FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode) override;
diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp
index 6669899300..5bdffa9409 100644
--- a/core/fxge/apple/fx_quartz_device.cpp
+++ b/core/fxge/apple/fx_quartz_device.cpp
@@ -218,7 +218,8 @@ void CFX_QuartzDeviceDriver::SaveState() {
CGContextSaveGState(m_context);
m_saveCount++;
}
-void CFX_QuartzDeviceDriver::RestoreState(FX_BOOL isKeepSaved) {
+
+void CFX_QuartzDeviceDriver::RestoreState(bool isKeepSaved) {
CGContextRestoreGState(m_context);
if (isKeepSaved) {
CGContextSaveGState(m_context);
@@ -226,6 +227,7 @@ void CFX_QuartzDeviceDriver::RestoreState(FX_BOOL isKeepSaved) {
m_saveCount--;
}
}
+
FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData,
const CFX_Matrix* matrix,
int fillMode) {
@@ -238,7 +240,7 @@ FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData,
m = CGAffineTransformConcat(m, m_foxitDevice2User);
CGContextConcatCTM(m_context, m);
setPathToContext(pathData);
- RestoreState(FALSE);
+ RestoreState(false);
if ((fillMode & 3) == FXFILL_WINDING) {
CGContextClip(m_context);
} else {
@@ -277,7 +279,7 @@ FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathStroke(
setStrokeInfo(graphState, 0xFF000000, lineWidth);
setPathToContext(pathData);
CGContextReplacePathWithStrokedPath(m_context);
- RestoreState(FALSE);
+ RestoreState(false);
CGContextClip(m_context);
return TRUE;
}
@@ -389,7 +391,7 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData,
} else if (pathMode == 6) {
CGContextDrawPath(m_context, kCGPathEOFillStroke);
}
- RestoreState(FALSE);
+ RestoreState(false);
return TRUE;
}
FX_BOOL CFX_QuartzDeviceDriver::FillRect(const FX_RECT* rect,
@@ -553,7 +555,7 @@ FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
pBitmap1 = pBitmap->Clone();
}
if (NULL == pBitmap1) {
- RestoreState(FALSE);
+ RestoreState(false);
return FALSE;
}
CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(
@@ -576,7 +578,7 @@ FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
if (pBitmap1 != pBitmap) {
delete pBitmap1;
}
- RestoreState(FALSE);
+ RestoreState(false);
return TRUE;
}
if (pBitmap->GetBPP() < 32) {
@@ -589,14 +591,14 @@ FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
}
}
if (NULL == pBitmap1) {
- RestoreState(FALSE);
+ RestoreState(false);
return FALSE;
}
if (pBitmap1->HasAlpha()) {
if (pBitmap1 == pBitmap) {
pBitmap1 = pBitmap->Clone();
if (!pBitmap1) {
- RestoreState(FALSE);
+ RestoreState(false);
return FALSE;
}
}
@@ -630,7 +632,7 @@ FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
if (pBitmap1 != pBitmap) {
delete pBitmap1;
}
- RestoreState(FALSE);
+ RestoreState(false);
return TRUE;
}
FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap,
@@ -671,7 +673,7 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap,
pBitmap1 = pBitmap->Clone();
}
if (NULL == pBitmap1) {
- RestoreState(FALSE);
+ RestoreState(false);
return FALSE;
}
CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(
@@ -694,7 +696,7 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap,
if (pBitmap1 != pBitmap) {
delete pBitmap1;
}
- RestoreState(FALSE);
+ RestoreState(false);
return TRUE;
}
if (pBitmap->GetBPP() < 32) {
@@ -707,14 +709,14 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap,
}
}
if (NULL == pBitmap1) {
- RestoreState(FALSE);
+ RestoreState(false);
return FALSE;
}
if (pBitmap1->HasAlpha()) {
if (pBitmap1 == pBitmap) {
pBitmap1 = pBitmap->Clone();
if (!pBitmap1) {
- RestoreState(FALSE);
+ RestoreState(false);
return FALSE;
}
}
@@ -736,7 +738,7 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap,
if (pBitmap1 != pBitmap) {
delete pBitmap1;
}
- RestoreState(FALSE);
+ RestoreState(false);
return TRUE;
}
FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars,
@@ -803,7 +805,7 @@ FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars,
}
CGContextShowGlyphsAtPositions(m_context, (CGGlyph*)glyph_indices,
glyph_positions, nChars);
- RestoreState(FALSE);
+ RestoreState(false);
return TRUE;
}
FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars,
@@ -833,7 +835,7 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars,
ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device,
font_size, color, alpha_flag, pIccTransform);
if (!ret) {
- RestoreState(FALSE);
+ RestoreState(false);
return ret;
}
}
@@ -851,7 +853,7 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars,
pObject2Device, font_size, color, alpha_flag,
pIccTransform);
if (!ret) {
- RestoreState(FALSE);
+ RestoreState(false);
return ret;
}
i++;
@@ -866,7 +868,7 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars,
ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device,
font_size, color, alpha_flag, pIccTransform);
}
- RestoreState(FALSE);
+ RestoreState(false);
return ret;
}
void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState,
diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp
index 0d6addab75..2d3ba566be 100644
--- a/core/fxge/ge/fx_ge_device.cpp
+++ b/core/fxge/ge/fx_ge_device.cpp
@@ -40,10 +40,12 @@ void CFX_RenderDevice::EndRendering() {
void CFX_RenderDevice::SaveState() {
m_pDeviceDriver->SaveState();
}
-void CFX_RenderDevice::RestoreState(FX_BOOL bKeepSaved) {
+
+void CFX_RenderDevice::RestoreState(bool bKeepSaved) {
m_pDeviceDriver->RestoreState(bKeepSaved);
UpdateClipBox();
}
+
int CFX_RenderDevice::GetDeviceCaps(int caps_id) const {
return m_pDeviceDriver->GetDeviceCaps(caps_id);
}
diff --git a/core/fxge/ge/fx_ge_ps.cpp b/core/fxge/ge/fx_ge_ps.cpp
index 98253336a1..b112cf3630 100644
--- a/core/fxge/ge/fx_ge_ps.cpp
+++ b/core/fxge/ge/fx_ge_ps.cpp
@@ -77,19 +77,25 @@ void CFX_PSRenderer::SaveState() {
OUTPUT_PS("q\n");
m_ClipBoxStack.Add(m_ClipBox);
}
-void CFX_PSRenderer::RestoreState(FX_BOOL bKeepSaved) {
+
+void CFX_PSRenderer::RestoreState(bool bKeepSaved) {
StartRendering();
if (bKeepSaved) {
OUTPUT_PS("Q\nq\n");
} else {
OUTPUT_PS("Q\n");
}
- m_bColorSet = m_bGraphStateSet = FALSE;
- m_ClipBox = m_ClipBoxStack.GetAt(m_ClipBoxStack.GetSize() - 1);
- if (!bKeepSaved) {
- m_ClipBoxStack.RemoveAt(m_ClipBoxStack.GetSize() - 1);
- }
+ m_bColorSet = FALSE;
+ m_bGraphStateSet = FALSE;
+ int size = m_ClipBoxStack.GetSize();
+ if (!size)
+ return;
+
+ m_ClipBox = m_ClipBoxStack.GetAt(size - 1);
+ if (!bKeepSaved)
+ m_ClipBoxStack.RemoveAt(size - 1);
}
+
void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device) {
int nPoints = pPathData->GetPointCount();
diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h
index 8f6b10debc..6efd5177bc 100644
--- a/core/fxge/include/fx_ge.h
+++ b/core/fxge/include/fx_ge.h
@@ -216,7 +216,7 @@ class CFX_RenderDevice {
FX_BOOL StartRendering();
void EndRendering();
void SaveState();
- void RestoreState(FX_BOOL bKeepSaved = FALSE);
+ void RestoreState(bool bKeepSaved);
int GetWidth() const { return m_Width; }
int GetHeight() const { return m_Height; }
@@ -431,7 +431,7 @@ class IFX_RenderDeviceDriver {
virtual void SaveState() = 0;
- virtual void RestoreState(FX_BOOL bKeepSaved = FALSE) = 0;
+ virtual void RestoreState(bool bKeepSaved) = 0;
virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
@@ -575,7 +575,7 @@ class CFX_PSRenderer {
FX_BOOL StartRendering();
void EndRendering();
void SaveState();
- void RestoreState(FX_BOOL bKeepSaved = FALSE);
+ void RestoreState(bool bKeepSaved);
void SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode);
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 6646eedd0f..c4ca6f9223 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -604,7 +604,7 @@ void CFX_SkiaDeviceDriver::SaveState() {
m_pCanvas->save();
}
-void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved) {
+void CFX_SkiaDeviceDriver::RestoreState(bool bKeepSaved) {
m_pCanvas->restore();
if (bKeepSaved)
m_pCanvas->save();
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index ef66b94ae2..79097ade18 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -30,7 +30,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
/** Save and restore all graphic states */
void SaveState() override;
- void RestoreState(FX_BOOL bKeepSaved) override;
+ void RestoreState(bool bKeepSaved) override;
/** Set clipping path using filled region */
FX_BOOL SetClip_PathFill(
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index caf271dff3..b71f3ae97a 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -507,6 +507,7 @@ CGdiDeviceDriver::CGdiDeviceDriver(HDC hDC, int device_class) {
m_RenderCaps = FXRC_GET_BITS | FXRC_BIT_MASK;
}
}
+
int CGdiDeviceDriver::GetDeviceCaps(int caps_id) {
switch (caps_id) {
case FXDC_DEVICE_CLASS:
@@ -522,6 +523,17 @@ int CGdiDeviceDriver::GetDeviceCaps(int caps_id) {
}
return 0;
}
+
+void CGdiDeviceDriver::SaveState() {
+ SaveDC(m_hDC);
+}
+
+void CGdiDeviceDriver::RestoreState(bool bKeepSaved) {
+ RestoreDC(m_hDC, -1);
+ if (bKeepSaved)
+ SaveDC(m_hDC);
+}
+
void* CGdiDeviceDriver::GetClipRgn() {
HRGN hClipRgn = CreateRectRgn(0, 0, 1, 1);
if (::GetClipRgn(m_hDC, hClipRgn) == 0) {
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index d0359138de..9fd1683a80 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -270,7 +270,7 @@ FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource,
FX_BOOL ret = StretchDIBits(
pTransformed, color, full_rect.left, full_rect.top, full_rect.Width(),
full_rect.Height(), NULL, 0, alpha_flag, pIccTransform, blend_type);
- RestoreState();
+ RestoreState(false);
delete pTransformed;
handle = NULL;
return ret;
@@ -371,9 +371,11 @@ void CPSPrinterDriver::EndRendering() {
void CPSPrinterDriver::SaveState() {
m_PSRenderer.SaveState();
}
-void CPSPrinterDriver::RestoreState(FX_BOOL bKeepSaved) {
+
+void CPSPrinterDriver::RestoreState(bool bKeepSaved) {
m_PSRenderer.RestoreState(bKeepSaved);
}
+
FX_BOOL CPSPrinterDriver::SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode) {
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index 619ac2fdae..d2d091bc19 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -109,13 +109,8 @@ class CGdiDeviceDriver : public IFX_RenderDeviceDriver {
protected:
// IFX_RenderDeviceDriver
int GetDeviceCaps(int caps_id) override;
- void SaveState() override { SaveDC(m_hDC); }
- void RestoreState(FX_BOOL bKeepSaved = FALSE) override {
- RestoreDC(m_hDC, -1);
- if (bKeepSaved) {
- SaveDC(m_hDC);
- }
- }
+ void SaveState() override;
+ void RestoreState(bool bKeepSaved) override;
FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode) override;
@@ -298,7 +293,7 @@ class CPSPrinterDriver : public IFX_RenderDeviceDriver {
FX_BOOL StartRendering() override;
void EndRendering() override;
void SaveState() override;
- void RestoreState(FX_BOOL bKeepSaved = FALSE) override;
+ void RestoreState(bool bKeepSaved) override;
FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode) override;