summaryrefslogtreecommitdiff
path: root/core/fxge/win32
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge/win32')
-rw-r--r--core/fxge/win32/fx_win32_device.cpp24
-rw-r--r--core/fxge/win32/fx_win32_print.cpp195
-rw-r--r--core/fxge/win32/win32_int.h92
3 files changed, 6 insertions, 305 deletions
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 240fb30e9e..b791217052 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -1408,31 +1408,19 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
return FALSE;
}
-// static
-int CFX_WindowsDevice::m_psLevel = 2;
-
-CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC,
- FX_BOOL bCmykOutput,
- FX_BOOL bForcePSOutput,
- int psLevel) {
- m_bForcePSOutput = bForcePSOutput;
- m_psLevel = psLevel;
- if (bForcePSOutput) {
- IFX_RenderDeviceDriver* pDriver = new CPSPrinterDriver;
- ((CPSPrinterDriver*)pDriver)->Init(hDC, psLevel, bCmykOutput);
- SetDeviceDriver(pDriver);
- return;
- }
- SetDeviceDriver(CreateDriver(hDC, bCmykOutput));
+CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) {
+ SetDeviceDriver(CreateDriver(hDC));
}
+CFX_WindowsDevice::~CFX_WindowsDevice() {}
+
HDC CFX_WindowsDevice::GetDC() const {
IFX_RenderDeviceDriver* pRDD = GetDeviceDriver();
return pRDD ? reinterpret_cast<HDC>(pRDD->GetPlatformSurface()) : nullptr;
}
-IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC,
- FX_BOOL bCmykOutput) {
+// static
+IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC) {
int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY);
int obj_type = ::GetObjectType(hDC);
bool use_printer = device_type == DT_RASPRINTER ||
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index e46beeefbd..08029bc351 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -276,199 +276,4 @@ FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource,
return ret;
}
-CPSOutput::CPSOutput(HDC hDC) {
- m_hDC = hDC;
- m_pBuf = NULL;
-}
-CPSOutput::~CPSOutput() {
- FX_Free(m_pBuf);
-}
-void CPSOutput::Init() {
- m_pBuf = FX_Alloc(FX_CHAR, 1026);
-}
-void CPSOutput::OutputPS(const FX_CHAR* str, int len) {
- if (len < 0) {
- len = (int)FXSYS_strlen(str);
- }
- int sent_len = 0;
- while (len > 0) {
- int send_len = len > 1024 ? 1024 : len;
- *(uint16_t*)m_pBuf = send_len;
- FXSYS_memcpy(m_pBuf + 2, str + sent_len, send_len);
- ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, m_pBuf, 0, NULL);
- sent_len += send_len;
- len -= send_len;
- }
-}
-CPSPrinterDriver::CPSPrinterDriver() {
- m_pPSOutput = NULL;
- m_bCmykOutput = FALSE;
-}
-CPSPrinterDriver::~CPSPrinterDriver() {
- EndRendering();
- delete m_pPSOutput;
-}
-FX_BOOL CPSPrinterDriver::Init(HDC hDC, int pslevel, FX_BOOL bCmykOutput) {
- m_hDC = hDC;
- m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE);
- m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE);
- m_Width = ::GetDeviceCaps(m_hDC, HORZRES);
- m_Height = ::GetDeviceCaps(m_hDC, VERTRES);
- m_nBitsPerPixel = ::GetDeviceCaps(m_hDC, BITSPIXEL);
- m_pPSOutput = new CPSOutput(hDC);
- ((CPSOutput*)m_pPSOutput)->Init();
- m_PSRenderer.Init(m_pPSOutput, pslevel, m_Width, m_Height, bCmykOutput);
- m_bCmykOutput = bCmykOutput;
- HRGN hRgn = ::CreateRectRgn(0, 0, 1, 1);
- int ret = ::GetClipRgn(hDC, hRgn);
- if (ret == 1) {
- ret = ::GetRegionData(hRgn, 0, NULL);
- if (ret) {
- RGNDATA* pData = (RGNDATA*)FX_Alloc(uint8_t, ret);
- ret = ::GetRegionData(hRgn, ret, pData);
- if (ret) {
- CFX_PathData path;
- path.AllocPointCount(pData->rdh.nCount * 5);
- for (uint32_t i = 0; i < pData->rdh.nCount; i++) {
- RECT* pRect = (RECT*)(pData->Buffer + pData->rdh.nRgnSize * i);
- path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bottom,
- (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top);
- }
- m_PSRenderer.SetClip_PathFill(&path, NULL, FXFILL_WINDING);
- }
- FX_Free(pData);
- }
- }
- ::DeleteObject(hRgn);
- return TRUE;
-}
-int CPSPrinterDriver::GetDeviceCaps(int caps_id) {
- switch (caps_id) {
- case FXDC_DEVICE_CLASS:
- return FXDC_PRINTER;
- case FXDC_PIXEL_WIDTH:
- return m_Width;
- case FXDC_PIXEL_HEIGHT:
- return m_Height;
- case FXDC_BITS_PIXEL:
- return m_nBitsPerPixel;
- case FXDC_RENDER_CAPS:
- return m_bCmykOutput ? FXRC_BIT_MASK | FXRC_CMYK_OUTPUT : FXRC_BIT_MASK;
- case FXDC_HORZ_SIZE:
- return m_HorzSize;
- case FXDC_VERT_SIZE:
- return m_VertSize;
- }
- return 0;
-}
-FX_BOOL CPSPrinterDriver::StartRendering() {
- return m_PSRenderer.StartRendering();
-}
-void CPSPrinterDriver::EndRendering() {
- m_PSRenderer.EndRendering();
-}
-void CPSPrinterDriver::SaveState() {
- m_PSRenderer.SaveState();
-}
-
-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) {
- m_PSRenderer.SetClip_PathFill(pPathData, pObject2Device, fill_mode);
- return TRUE;
-}
-FX_BOOL CPSPrinterDriver::SetClip_PathStroke(
- const CFX_PathData* pPathData,
- const CFX_Matrix* pObject2Device,
- const CFX_GraphStateData* pGraphState) {
- m_PSRenderer.SetClip_PathStroke(pPathData, pObject2Device, pGraphState);
- return TRUE;
-}
-FX_BOOL CPSPrinterDriver::DrawPath(const CFX_PathData* pPathData,
- const CFX_Matrix* pObject2Device,
- const CFX_GraphStateData* pGraphState,
- FX_ARGB fill_color,
- FX_ARGB stroke_color,
- int fill_mode,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) {
- if (blend_type != FXDIB_BLEND_NORMAL) {
- return FALSE;
- }
- return m_PSRenderer.DrawPath(pPathData, pObject2Device, pGraphState,
- fill_color, stroke_color, fill_mode & 3,
- alpha_flag, pIccTransform);
-}
-FX_BOOL CPSPrinterDriver::GetClipBox(FX_RECT* pRect) {
- *pRect = m_PSRenderer.GetClipBox();
- return TRUE;
-}
-FX_BOOL CPSPrinterDriver::SetDIBits(const CFX_DIBSource* pBitmap,
- uint32_t color,
- const FX_RECT* pSrcRect,
- int left,
- int top,
- int blend_type,
- int alpha_flag,
- void* pIccTransform) {
- if (blend_type != FXDIB_BLEND_NORMAL) {
- return FALSE;
- }
- return m_PSRenderer.SetDIBits(pBitmap, color, left, top, alpha_flag,
- pIccTransform);
-}
-FX_BOOL CPSPrinterDriver::StretchDIBits(const CFX_DIBSource* pBitmap,
- uint32_t color,
- int dest_left,
- int dest_top,
- int dest_width,
- int dest_height,
- const FX_RECT* pClipRect,
- uint32_t flags,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) {
- if (blend_type != FXDIB_BLEND_NORMAL) {
- return FALSE;
- }
- return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top,
- dest_width, dest_height, flags, alpha_flag,
- pIccTransform);
-}
-FX_BOOL CPSPrinterDriver::StartDIBits(const CFX_DIBSource* pBitmap,
- int bitmap_alpha,
- uint32_t color,
- const CFX_Matrix* pMatrix,
- uint32_t render_flags,
- void*& handle,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) {
- if (blend_type != FXDIB_BLEND_NORMAL) {
- return FALSE;
- }
- if (bitmap_alpha < 255) {
- return FALSE;
- }
- handle = NULL;
- return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags,
- alpha_flag, pIccTransform);
-}
-FX_BOOL CPSPrinterDriver::DrawDeviceText(int nChars,
- const FXTEXT_CHARPOS* pCharPos,
- CFX_Font* pFont,
- CFX_FontCache* pCache,
- const CFX_Matrix* pObject2Device,
- FX_FLOAT font_size,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform) {
- return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pCache, pObject2Device,
- font_size, color, alpha_flag, pIccTransform);
-}
#endif
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index 9d62b41a8e..08253b33de 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -273,96 +273,4 @@ class CGdiPrinterDriver : public CGdiDeviceDriver {
const int m_VertSize;
};
-class CPSOutput : public IFX_PSOutput {
- public:
- explicit CPSOutput(HDC hDC);
- ~CPSOutput() override;
-
- // IFX_PSOutput
- void Release() override { delete this; }
- void OutputPS(const FX_CHAR* str, int len) override;
-
- void Init();
-
- HDC m_hDC;
- FX_CHAR* m_pBuf;
-};
-
-class CPSPrinterDriver : public IFX_RenderDeviceDriver {
- public:
- CPSPrinterDriver();
- FX_BOOL Init(HDC hDC, int ps_level, FX_BOOL bCmykOutput);
- ~CPSPrinterDriver() override;
-
- protected:
- // IFX_RenderDeviceDriver
- int GetDeviceCaps(int caps_id) override;
- FX_BOOL IsPSPrintDriver() override { return TRUE; }
- FX_BOOL StartRendering() override;
- void EndRendering() override;
- void SaveState() override;
- void RestoreState(bool bKeepSaved) override;
- FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
- const CFX_Matrix* pObject2Device,
- int fill_mode) override;
- FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
- const CFX_Matrix* pObject2Device,
- const CFX_GraphStateData* pGraphState) override;
- FX_BOOL DrawPath(const CFX_PathData* pPathData,
- const CFX_Matrix* pObject2Device,
- const CFX_GraphStateData* pGraphState,
- uint32_t fill_color,
- uint32_t stroke_color,
- int fill_mode,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) override;
- FX_BOOL GetClipBox(FX_RECT* pRect) override;
- FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
- uint32_t color,
- const FX_RECT* pSrcRect,
- int left,
- int top,
- int blend_type,
- int alpha_flag,
- void* pIccTransform) override;
- FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
- uint32_t color,
- int dest_left,
- int dest_top,
- int dest_width,
- int dest_height,
- const FX_RECT* pClipRect,
- uint32_t flags,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) override;
- FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
- int bitmap_alpha,
- uint32_t color,
- const CFX_Matrix* pMatrix,
- uint32_t render_flags,
- void*& handle,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) override;
- FX_BOOL DrawDeviceText(int nChars,
- const FXTEXT_CHARPOS* pCharPos,
- CFX_Font* pFont,
- CFX_FontCache* pCache,
- const CFX_Matrix* pObject2Device,
- FX_FLOAT font_size,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform) override;
- void* GetPlatformSurface() const override { return (void*)m_hDC; }
-
- HDC m_hDC;
- FX_BOOL m_bCmykOutput;
- int m_Width, m_Height, m_nBitsPerPixel;
- int m_HorzSize, m_VertSize;
- CPSOutput* m_pPSOutput;
- CFX_PSRenderer m_PSRenderer;
-};
-
#endif // CORE_FXGE_WIN32_WIN32_INT_H_