diff options
author | thestig <thestig@chromium.org> | 2016-05-26 20:15:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-26 20:15:19 -0700 |
commit | befa4506dc9d2a679c526aff96c09bcb0e9daecb (patch) | |
tree | 3c1d3e11d9802b2db95e35f4ab81ff449492ee10 | |
parent | 7aed76f53137a71491040c776ab2f8931e91061b (diff) | |
download | pdfium-befa4506dc9d2a679c526aff96c09bcb0e9daecb.tar.xz |
Remove default arguments from CFX_FxgeDevice.
Remove unused dithering code.
Review-Url: https://codereview.chromium.org/2010813003
25 files changed, 216 insertions, 336 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp index b69863b5b0..a3dbbdb3f2 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp @@ -142,7 +142,6 @@ CPDF_RenderStatus::CPDF_RenderStatus() m_HalftoneLimit(0), m_bPrint(FALSE), m_Transparency(0), - m_DitherBits(0), m_bDropObjects(FALSE), m_bStdCS(FALSE), m_GroupFamily(0), @@ -170,7 +169,6 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, FX_BOOL bLoadMask) { m_pContext = pContext; m_pDevice = pDevice; - m_DitherBits = pDevice->GetDeviceCaps(FXDC_DITHER_BITS); m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; if (pDeviceMatrix) { m_DeviceMatrix = *pDeviceMatrix; @@ -320,28 +318,6 @@ FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, rect.Intersect(rtClip); return rect.IsEmpty(); } -void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device) { - CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap(); - if (!pBitmap) { - return; - } - FX_RECT rect; - if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { - return; - } - if (m_DitherBits == 2) { - static FX_ARGB pal[4] = {0, 85, 170, 255}; - pBitmap->DitherFS(pal, 4, &rect); - } else if (m_DitherBits == 3) { - static FX_ARGB pal[8] = {0, 36, 73, 109, 146, 182, 219, 255}; - pBitmap->DitherFS(pal, 8, &rect); - } else if (m_DitherBits == 4) { - static FX_ARGB pal[16] = {0, 17, 34, 51, 68, 85, 102, 119, - 136, 153, 170, 187, 204, 221, 238, 255}; - pBitmap->DitherFS(pal, 16, &rect); - } -} void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device) { @@ -788,7 +764,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); } - if (!bitmap_device.Create(width, height, FXDIB_Argb, 0, oriDevice.get())) + if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice.get())) return TRUE; CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); @@ -804,7 +780,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, pTextMask->Clear(0); CFX_FxgeDevice text_device; - text_device.Attach(pTextMask.get()); + text_device.Attach(pTextMask.get(), false, nullptr, false); for (uint32_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); if (!textobj) { @@ -890,7 +866,7 @@ CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, FinalMatrix.Scale(scaleX, scaleY); pBackdrop->Clear(pBackdrop->HasAlpha() ? 0 : 0xffffffff); CFX_FxgeDevice device; - device.Attach(pBackdrop.get()); + device.Attach(pBackdrop.get(), false, nullptr, false); m_pContext->Render(&device, pObj, &m_Options, &FinalMatrix); return pBackdrop.release(); } @@ -900,7 +876,7 @@ void CPDF_RenderContext::GetBackground(CFX_DIBitmap* pBuffer, const CPDF_RenderOptions* pOptions, CFX_Matrix* pFinalMatrix) { CFX_FxgeDevice device; - device.Attach(pBuffer); + device.Attach(pBuffer, false, nullptr, false); FX_RECT rect(0, 0, device.GetWidth(), device.GetHeight()); device.FillRect(&rect, 0xffffffff); @@ -1282,7 +1258,7 @@ FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, return FALSE; if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && - m_pBitmapDevice->Create(iWidth, iHeight, dibFormat)) { + m_pBitmapDevice->Create(iWidth, iHeight, dibFormat, nullptr)) { break; } m_Matrix.Scale(0.5f, 0.5f); diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index f7e57c0fa6..d3fbb7990c 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -523,9 +523,9 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { int width = rect.Width(); int height = rect.Height(); CFX_FxgeDevice bitmap_device1; - if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32)) { + if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) return TRUE; - } + bitmap_device1.GetBitmap()->Clear(0xffffff); { CPDF_RenderStatus bitmap_render; @@ -545,7 +545,8 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { } { CFX_FxgeDevice bitmap_device2; - if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb)) { + if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb, + nullptr)) { return TRUE; } bitmap_device2.GetBitmap()->Clear(0); @@ -621,9 +622,9 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { int width = rect.Width(); int height = rect.Height(); CFX_FxgeDevice bitmap_device1; - if (!bitmap_device1.Create(width, height, FXDIB_Rgb32)) { + if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) return TRUE; - } + bitmap_device1.GetBitmap()->Clear(0xffffff); { CPDF_RenderStatus bitmap_render; @@ -638,9 +639,9 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { } { CFX_FxgeDevice bitmap_device2; - if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb)) { + if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) return TRUE; - } + bitmap_device2.GetBitmap()->Clear(0); CPDF_RenderStatus bitmap_render; bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, @@ -900,17 +901,15 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha"; int width = pClipRect->right - pClipRect->left; int height = pClipRect->bottom - pClipRect->top; + FXDIB_Format format; #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - if (!bitmap_device.Create(width, height, - bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) { - return NULL; - } + format = bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask; #else - if (!bitmap_device.Create(width, height, - bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask)) { - return NULL; - } + format = bLuminosity ? FXDIB_Rgb : FXDIB_8bppMask; #endif + if (!bitmap_device.Create(width, height, format, nullptr)) + return nullptr; + CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); CPDF_Object* pCSObj = NULL; CPDF_ColorSpace* pCS = NULL; diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index 393b993e35..754394da70 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -752,7 +752,7 @@ void DrawCoonPatchMeshes( ASSERT(pBitmap->GetFormat() == FXDIB_Argb); CFX_FxgeDevice device; - device.Attach(pBitmap); + device.Attach(pBitmap, false, nullptr, false); CPDF_MeshStream stream(funcs, pCS); if (!stream.Load(pShadingStream)) return; @@ -830,7 +830,7 @@ std::unique_ptr<CFX_DIBitmap> DrawPatternBitmap( return std::unique_ptr<CFX_DIBitmap>(); } CFX_FxgeDevice bitmap_device; - bitmap_device.Attach(pBitmap.get()); + bitmap_device.Attach(pBitmap.get(), false, nullptr, false); pBitmap->Clear(0); CFX_FloatRect cell_bbox = pPattern->bbox(); pPattern->pattern_to_form()->TransformRect(cell_bbox); diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp index e4ee49afc9..a3df1c2214 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -437,7 +437,8 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, FX_RECT rect = rect_f.GetOutterRect(); CFX_FxgeDevice bitmap_device; if (!bitmap_device.Create((int)(rect.Width() * sa), - (int)(rect.Height() * sd), FXDIB_Argb)) { + (int)(rect.Height() * sd), FXDIB_Argb, + nullptr)) { return TRUE; } bitmap_device.GetBitmap()->Clear(0); diff --git a/core/fpdfapi/fpdf_render/render_int.h b/core/fpdfapi/fpdf_render/render_int.h index 46689d3b68..98822797b0 100644 --- a/core/fpdfapi/fpdf_render/render_int.h +++ b/core/fpdfapi/fpdf_render/render_int.h @@ -123,6 +123,7 @@ class CPDF_RenderStatus { public: CPDF_RenderStatus(); ~CPDF_RenderStatus(); + FX_BOOL Initialize(class CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice, const CFX_Matrix* pDeviceMatrix, @@ -155,6 +156,7 @@ class CPDF_RenderStatus { protected: friend class CPDF_ImageRenderer; friend class CPDF_RenderContext; + void ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Matrix* pObj2Device); void DrawClipPath(CPDF_ClipPath ClipPath, const CFX_Matrix* pObj2Device); FX_BOOL ProcessTransparency(const CPDF_PageObject* PageObj, @@ -242,20 +244,17 @@ class CPDF_RenderStatus { FX_ARGB GetFillArgb(const CPDF_PageObject* pObj, FX_BOOL bType3 = FALSE) const; FX_ARGB GetStrokeArgb(const CPDF_PageObject* pObj) const; - CPDF_RenderContext* m_pContext; - FX_BOOL m_bStopped; - void DitherObjectArea(const CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device); FX_BOOL GetObjectClippedRect(const CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device, FX_BOOL bLogical, FX_RECT& rect) const; void GetScaledMatrix(CFX_Matrix& matrix) const; - protected: static const int kRenderMaxRecursionDepth = 64; static int s_CurrentRecursionDepth; + CPDF_RenderContext* m_pContext; + FX_BOOL m_bStopped; CFX_RenderDevice* m_pDevice; CFX_Matrix m_DeviceMatrix; CPDF_ClipPath m_LastClipPath; @@ -266,7 +265,6 @@ class CPDF_RenderStatus { std::unique_ptr<CPDF_ImageRenderer> m_pImageRenderer; FX_BOOL m_bPrint; int m_Transparency; - int m_DitherBits; FX_BOOL m_bDropObjects; FX_BOOL m_bStdCS; uint32_t m_GroupFamily; @@ -275,6 +273,7 @@ class CPDF_RenderStatus { FX_ARGB m_T3FillColor; int m_curBlend; }; + class CPDF_ImageLoader { public: CPDF_ImageLoader() diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 86326f6caf..d7a9ddb530 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -189,17 +189,15 @@ IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver( FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) { - return new CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, + return new CFX_AggDeviceDriver(pBitmap, bRgbByteOrder, pOriDevice, bGroupKnockout); } CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, - int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) { m_pBitmap = pBitmap; - m_DitherBits = dither_bits; m_pClipRgn = nullptr; m_pPlatformBitmap = nullptr; m_pPlatformGraphics = nullptr; @@ -270,8 +268,6 @@ int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) { } return flags; } - case FXDC_DITHER_BITS: - return m_DitherBits; } return 0; } @@ -1784,16 +1780,15 @@ CFX_FxgeDevice::CFX_FxgeDevice() { } bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, - int dither_bits, bool bRgbByteOrder, CFX_DIBitmap* pOriDevice, bool bGroupKnockout) { - if (!pBitmap) { + if (!pBitmap) return false; - } + SetBitmap(pBitmap); IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver( - pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); + pBitmap, bRgbByteOrder, pOriDevice, bGroupKnockout); SetDeviceDriver(pDriver); return true; } @@ -1801,7 +1796,6 @@ bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, bool CFX_FxgeDevice::Create(int width, int height, FXDIB_Format format, - int dither_bits, CFX_DIBitmap* pOriDevice) { m_bOwnedBitmap = true; CFX_DIBitmap* pBitmap = new CFX_DIBitmap; @@ -1811,7 +1805,7 @@ bool CFX_FxgeDevice::Create(int width, } SetBitmap(pBitmap); IFX_RenderDeviceDriver* pDriver = - new CFX_AggDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE); + new CFX_AggDeviceDriver(pBitmap, FALSE, pOriDevice, FALSE); SetDeviceDriver(pDriver); return true; } diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index a33bc09937..3462b61bb2 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h @@ -28,7 +28,6 @@ class CAgg_PathData { class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { public: CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, - int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout); @@ -144,7 +143,6 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { void* m_pPlatformBitmap; void* m_pDwRenderTartget; int m_FillFlags; - int m_DitherBits; FX_BOOL m_bRgbByteOrder; CFX_DIBitmap* m_pOriDevice; FX_BOOL m_bGroupKnockout; diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index ad6ee0c4e7..85df71e11d 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -1371,90 +1371,7 @@ FX_BOOL CFX_DIBitmap::ConvertColorScale(uint32_t forecolor, } return TRUE; } -FX_BOOL CFX_DIBitmap::DitherFS(const uint32_t* pPalette, - int pal_size, - const FX_RECT* pRect) { - if (!m_pBuffer) { - return FALSE; - } - if (m_bpp != 8 && m_pPalette && m_AlphaFlag != 0) { - return FALSE; - } - if (m_Width < 4 && m_Height < 4) { - return FALSE; - } - FX_RECT rect(0, 0, m_Width, m_Height); - if (pRect) { - rect.Intersect(*pRect); - } - uint8_t translate[256]; - for (int i = 0; i < 256; i++) { - int err2 = 65536; - for (int j = 0; j < pal_size; j++) { - uint8_t entry = (uint8_t)pPalette[j]; - int err = (int)entry - i; - if (err * err < err2) { - err2 = err * err; - translate[i] = entry; - } - } - } - for (int row = rect.top; row < rect.bottom; row++) { - uint8_t* scan = m_pBuffer + row * m_Pitch; - uint8_t* next_scan = m_pBuffer + (row + 1) * m_Pitch; - for (int col = rect.left; col < rect.right; col++) { - int src_pixel = scan[col]; - int dest_pixel = translate[src_pixel]; - scan[col] = (uint8_t)dest_pixel; - int error = -dest_pixel + src_pixel; - if (col < rect.right - 1) { - int src = scan[col + 1]; - src += error * 7 / 16; - if (src > 255) { - scan[col + 1] = 255; - } else if (src < 0) { - scan[col + 1] = 0; - } else { - scan[col + 1] = src; - } - } - if (col < rect.right - 1 && row < rect.bottom - 1) { - int src = next_scan[col + 1]; - src += error * 1 / 16; - if (src > 255) { - next_scan[col + 1] = 255; - } else if (src < 0) { - next_scan[col + 1] = 0; - } else { - next_scan[col + 1] = src; - } - } - if (row < rect.bottom - 1) { - int src = next_scan[col]; - src += error * 5 / 16; - if (src > 255) { - next_scan[col] = 255; - } else if (src < 0) { - next_scan[col] = 0; - } else { - next_scan[col] = src; - } - } - if (col > rect.left && row < rect.bottom - 1) { - int src = next_scan[col - 1]; - src += error * 3 / 16; - if (src > 255) { - next_scan[col - 1] = 255; - } else if (src < 0) { - next_scan[col - 1] = 0; - } else { - next_scan[col - 1] = src; - } - } - } - } - return TRUE; -} + CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { CFX_DIBitmap* pFlipped = new CFX_DIBitmap; if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp index d6c7b18b47..b9bd133e57 100644 --- a/core/fxge/ge/fx_ge_device.cpp +++ b/core/fxge/ge/fx_ge_device.cpp @@ -261,7 +261,7 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath( Backdrop.Copy(&bitmap); } CFX_FxgeDevice bitmap_device; - bitmap_device.Attach(&bitmap, 0, FALSE, &Backdrop, TRUE); + bitmap_device.Attach(&bitmap, false, &Backdrop, true); CFX_Matrix matrix; if (pObject2Device) { matrix = *pObject2Device; diff --git a/core/fxge/include/fx_dib.h b/core/fxge/include/fx_dib.h index 6504e5fd8f..12ed03c1d3 100644 --- a/core/fxge/include/fx_dib.h +++ b/core/fxge/include/fx_dib.h @@ -256,6 +256,7 @@ class CFX_DIBSource { int FindPalette(uint32_t color) const; void GetPalette(uint32_t* pal, int alpha) const; }; + class CFX_DIBitmap : public CFX_DIBSource { public: CFX_DIBitmap(); @@ -357,17 +358,13 @@ class CFX_DIBitmap : public CFX_DIBSource { FX_BOOL ConvertColorScale(uint32_t forecolor, uint32_t backcolor); - FX_BOOL DitherFS(const uint32_t* pPalette, - int pal_size, - const FX_RECT* pRect = NULL); - protected: - uint8_t* m_pBuffer; + FX_BOOL GetGrayData(void* pIccTransform = NULL); + uint8_t* m_pBuffer; FX_BOOL m_bExtBuf; - - FX_BOOL GetGrayData(void* pIccTransform = NULL); }; + class CFX_DIBExtractor { public: CFX_DIBExtractor(const CFX_DIBSource* pSrc); diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h index c025c1251e..6a3113d070 100644 --- a/core/fxge/include/fx_ge.h +++ b/core/fxge/include/fx_ge.h @@ -161,7 +161,6 @@ class CFX_GraphStateData { #define FXDC_HORZ_SIZE 5 #define FXDC_VERT_SIZE 6 #define FXDC_RENDER_CAPS 7 -#define FXDC_DITHER_BITS 8 #define FXDC_DISPLAY 1 #define FXDC_PRINTER 2 #define FXRC_GET_BITS 0x01 @@ -402,16 +401,13 @@ class CFX_FxgeDevice : public CFX_RenderDevice { ~CFX_FxgeDevice() override; bool Attach(CFX_DIBitmap* pBitmap, - int dither_bits = 0, - bool bRgbByteOrder = false, - CFX_DIBitmap* pOriDevice = NULL, - bool bGroupKnockout = false); - + bool bRgbByteOrder, + CFX_DIBitmap* pOriDevice, + bool bGroupKnockout); bool Create(int width, int height, FXDIB_Format format, - int dither_bits = 0, - CFX_DIBitmap* pOriDevice = NULL); + CFX_DIBitmap* pOriDevice); #ifdef _SKIA_SUPPORT_ bool AttachRecorder(SkPictureRecorder* recorder); diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index e64dfd0a73..452472e40c 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -500,14 +500,12 @@ void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint, } CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, - int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) : m_pBitmap(pBitmap), m_pOriDevice(pOriDevice), m_pRecorder(nullptr), - m_ditherBits(dither_bits), m_bRgbByteOrder(bRgbByteOrder), m_bGroupKnockout(bGroupKnockout) { SkBitmap skBitmap; @@ -526,7 +524,6 @@ CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(int size_x, int size_y) : m_pBitmap(nullptr), m_pOriDevice(nullptr), m_pRecorder(new SkPictureRecorder), - m_ditherBits(0), m_bRgbByteOrder(FALSE), m_bGroupKnockout(FALSE) { m_pRecorder->beginRecording(SkIntToScalar(size_x), SkIntToScalar(size_y)); @@ -537,7 +534,6 @@ CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(SkPictureRecorder* recorder) : m_pBitmap(nullptr), m_pOriDevice(nullptr), m_pRecorder(recorder), - m_ditherBits(0), m_bRgbByteOrder(FALSE), m_bGroupKnockout(FALSE) { m_pCanvas = m_pRecorder->getRecordingCanvas(); @@ -594,8 +590,6 @@ int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) { return FXRC_GET_BITS | FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE | FXRC_BLEND_MODE | FXRC_SOFT_CLIP | FXRC_ALPHA_OUTPUT | FXRC_FILLSTROKE_PATH | FXRC_SHADING; - case FXDC_DITHER_BITS: - return m_ditherBits; } return 0; } @@ -1095,15 +1089,14 @@ SkPictureRecorder* CFX_FxgeDevice::CreateRecorder(int size_x, int size_y) { } bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, - int dither_bits, bool bRgbByteOrder, CFX_DIBitmap* pOriDevice, bool bGroupKnockout) { if (!pBitmap) return false; SetBitmap(pBitmap); - SetDeviceDriver(new CFX_SkiaDeviceDriver(pBitmap, dither_bits, bRgbByteOrder, - pOriDevice, bGroupKnockout)); + SetDeviceDriver(new CFX_SkiaDeviceDriver(pBitmap, bRgbByteOrder, pOriDevice, + bGroupKnockout)); return true; } @@ -1117,7 +1110,6 @@ bool CFX_FxgeDevice::AttachRecorder(SkPictureRecorder* recorder) { bool CFX_FxgeDevice::Create(int width, int height, FXDIB_Format format, - int dither_bits, CFX_DIBitmap* pOriDevice) { m_bOwnedBitmap = TRUE; CFX_DIBitmap* pBitmap = new CFX_DIBitmap; @@ -1127,7 +1119,7 @@ bool CFX_FxgeDevice::Create(int width, } SetBitmap(pBitmap); CFX_SkiaDeviceDriver* pDriver = - new CFX_SkiaDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE); + new CFX_SkiaDeviceDriver(pBitmap, FALSE, pOriDevice, FALSE); SetDeviceDriver(pDriver); return true; } diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index 79097ade18..dd3ba420e8 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -17,11 +17,10 @@ struct SkIRect; class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { public: CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, - int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout); - CFX_SkiaDeviceDriver(SkPictureRecorder* recorder); + explicit CFX_SkiaDeviceDriver(SkPictureRecorder* recorder); CFX_SkiaDeviceDriver(int size_x, int size_y); ~CFX_SkiaDeviceDriver() override; @@ -145,7 +144,6 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { CFX_DIBitmap* m_pOriDevice; SkCanvas* m_pCanvas; SkPictureRecorder* const m_pRecorder; - int m_ditherBits; FX_BOOL m_bRgbByteOrder; FX_BOOL m_bGroupKnockout; }; diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp index c66807cc91..efde1eb029 100644 --- a/fpdfsdk/fpdf_progressive.cpp +++ b/fpdfsdk/fpdf_progressive.cpp @@ -42,13 +42,10 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, CRenderContext* pContext = new CRenderContext; pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); - pContext->m_pDevice = new CFX_FxgeDevice; - if (flags & FPDF_REVERSE_BYTE_ORDER) { - ((CFX_FxgeDevice*)pContext->m_pDevice) - ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); - } else { - ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); - } + CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; + pContext->m_pDevice = pDevice; + CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap); + pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false); IFSDK_PAUSE_Adapter IPauseAdapter(pause); FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 6bcb605794..2631eb3e4f 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -55,6 +55,94 @@ FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) { } #endif // PDF_ENABLE_XFA +void FFLCommon(FPDF_FORMHANDLE hHandle, + FPDF_BITMAP bitmap, + FPDF_RECORDER recorder, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags) { + if (!hHandle) + return; + + UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); + if (!pPage) + return; + +#ifndef PDF_ENABLE_XFA + CPDF_RenderOptions options; + if (flags & FPDF_LCD_TEXT) + options.m_Flags |= RENDER_CLEARTYPE; + else + options.m_Flags &= ~RENDER_CLEARTYPE; + // Grayscale output + if (flags & FPDF_GRAYSCALE) { + options.m_ColorMode = RENDER_COLOR_GRAY; + options.m_ForeColor = 0; + options.m_BackColor = 0xffffff; + } + options.m_AddFlags = flags >> 8; + options.m_pOCContext = + new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View); +#else // PDF_ENABLE_XFA + CPDFXFA_Document* pDocument = pPage->GetDocument(); + if (!pDocument) + return; + CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); + if (!pPDFDoc) + return; + CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; + CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); + if (!pFXDoc) + return; +#endif // PDF_ENABLE_XFA + + CFX_Matrix matrix; + pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); + + FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y); + + std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice); +#ifdef _SKIA_SUPPORT_ + pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder)); +#endif + pDevice->Attach(CFXBitmapFromFPDFBitmap(bitmap), false, nullptr, false); + pDevice->SaveState(); + pDevice->SetClip_Rect(clip); + +#ifndef PDF_ENABLE_XFA + if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) + pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); +#else // PDF_ENABLE_XFA + CPDF_RenderOptions options; + if (flags & FPDF_LCD_TEXT) + options.m_Flags |= RENDER_CLEARTYPE; + else + options.m_Flags &= ~RENDER_CLEARTYPE; + + // Grayscale output + if (flags & FPDF_GRAYSCALE) { + options.m_ColorMode = RENDER_COLOR_GRAY; + options.m_ForeColor = 0; + options.m_BackColor = 0xffffff; + } + options.m_AddFlags = flags >> 8; + options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View); + + if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage)) + pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); +#endif // PDF_ENABLE_XFA + + pDevice->RestoreState(false); + delete options.m_pOCContext; +#ifdef PDF_ENABLE_XFA + options.m_pOCContext = NULL; +#endif // PDF_ENABLE_XFA +} + } // namespace DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, @@ -293,94 +381,6 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) { return pSDKDoc->KillFocusAnnot(0); } -static void FFLCommon(FPDF_FORMHANDLE hHandle, - FPDF_BITMAP bitmap, - FPDF_RECORDER recorder, - FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int flags) { - if (!hHandle) - return; - - UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); - if (!pPage) - return; - -#ifndef PDF_ENABLE_XFA - CPDF_RenderOptions options; - if (flags & FPDF_LCD_TEXT) - options.m_Flags |= RENDER_CLEARTYPE; - else - options.m_Flags &= ~RENDER_CLEARTYPE; - // Grayscale output - if (flags & FPDF_GRAYSCALE) { - options.m_ColorMode = RENDER_COLOR_GRAY; - options.m_ForeColor = 0; - options.m_BackColor = 0xffffff; - } - options.m_AddFlags = flags >> 8; - options.m_pOCContext = - new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View); -#else // PDF_ENABLE_XFA - CPDFXFA_Document* pDocument = pPage->GetDocument(); - if (!pDocument) - return; - CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); - if (!pPDFDoc) - return; - CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; - CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); - if (!pFXDoc) - return; -#endif // PDF_ENABLE_XFA - - CFX_Matrix matrix; - pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); - - FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y); - - std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice); -#ifdef _SKIA_SUPPORT_ - pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder)); -#endif - pDevice->Attach((CFX_DIBitmap*)bitmap); - pDevice->SaveState(); - pDevice->SetClip_Rect(clip); - -#ifndef PDF_ENABLE_XFA - if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) - pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); -#else // PDF_ENABLE_XFA - CPDF_RenderOptions options; - if (flags & FPDF_LCD_TEXT) - options.m_Flags |= RENDER_CLEARTYPE; - else - options.m_Flags &= ~RENDER_CLEARTYPE; - - // Grayscale output - if (flags & FPDF_GRAYSCALE) { - options.m_ColorMode = RENDER_COLOR_GRAY; - options.m_ForeColor = 0; - options.m_BackColor = 0xffffff; - } - options.m_AddFlags = flags >> 8; - options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View); - - if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage)) - pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); -#endif // PDF_ENABLE_XFA - - pDevice->RestoreState(false); - delete options.m_pOCContext; -#ifdef PDF_ENABLE_XFA - options.m_pOCContext = NULL; -#endif // PDF_ENABLE_XFA -} - DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, @@ -464,7 +464,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); - if (wsText == NULL) { + if (!wsText) { *size = len; return; } @@ -483,8 +483,9 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, FPDF_WIDESTRING wsText, FPDF_DWORD* size) { - if (NULL == hWidget || NULL == document) + if (!hWidget || !document) return; + CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static) diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 7797165bc2..24cd8ef5c4 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -74,6 +74,10 @@ CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { #endif // PDF_ENABLE_XFA } +CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) { + return static_cast<CFX_DIBitmap*>(bitmap); +} + #ifdef PDF_ENABLE_XFA CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) { m_pFS = pFS; @@ -544,14 +548,15 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, pBitmap = new CFX_DIBitmap; pBitmap->Create(size_x, size_y, FXDIB_Argb); pBitmap->Clear(0x00ffffff); - pContext->m_pDevice = new CFX_FxgeDevice; - ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); + CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; + pContext->m_pDevice = pDevice; + pDevice->Attach(pBitmap, false, nullptr, false); } else { pContext->m_pDevice = new CFX_WindowsDevice(dc); } FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, - rotate, flags, TRUE, NULL); + rotate, flags, TRUE, nullptr); if (bBackgroundAlphaNeeded || bHasImageMask) { if (pBitmap) { @@ -595,13 +600,10 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, CRenderContext* pContext = new CRenderContext; pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); - pContext->m_pDevice = new CFX_FxgeDevice; - if (flags & FPDF_REVERSE_BYTE_ORDER) { - ((CFX_FxgeDevice*)pContext->m_pDevice) - ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); - } else { - ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); - } + CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; + pContext->m_pDevice = pDevice; + CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap); + pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false); FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, rotate, flags, TRUE, nullptr); @@ -771,32 +773,34 @@ DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, FPDF_DWORD color) { if (!bitmap) return; + CFX_FxgeDevice device; - device.Attach((CFX_DIBitmap*)bitmap); - if (!((CFX_DIBitmap*)bitmap)->HasAlpha()) + CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap); + device.Attach(pBitmap, false, nullptr, false); + if (!pBitmap->HasAlpha()) color |= 0xFF000000; FX_RECT rect(left, top, left + width, top + height); device.FillRect(&rect, color); } DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) { - return bitmap ? ((CFX_DIBitmap*)bitmap)->GetBuffer() : nullptr; + return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetBuffer() : nullptr; } DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap) { - return bitmap ? ((CFX_DIBitmap*)bitmap)->GetWidth() : 0; + return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetWidth() : 0; } DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap) { - return bitmap ? ((CFX_DIBitmap*)bitmap)->GetHeight() : 0; + return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetHeight() : 0; } DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) { - return bitmap ? ((CFX_DIBitmap*)bitmap)->GetPitch() : 0; + return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetPitch() : 0; } DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) { - delete (CFX_DIBitmap*)bitmap; + delete CFXBitmapFromFPDFBitmap(bitmap); } void FPDF_RenderPage_Retail(CRenderContext* pContext, diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h index a8a02d665e..4a470206d3 100644 --- a/fpdfsdk/include/fsdk_define.h +++ b/fpdfsdk/include/fsdk_define.h @@ -108,6 +108,8 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc); CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page); +CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap); + void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy); void FPDF_RenderPage_Retail(CRenderContext* pContext, diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index 3e14b9bf38..c7d82ac0f4 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -125,12 +125,13 @@ void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) { ASSERT(fLineSpace > 1.0f); m_fLineSpace = fLineSpace; } + void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) { ASSERT(pDIB); m_pRenderDevice.reset(); CFX_FxgeDevice* device = new CFX_FxgeDevice; - device->Attach(pDIB, 0, FALSE); + device->Attach(pDIB, false, nullptr, false); m_pRenderDevice.reset(new CFDE_RenderDevice(device, FALSE)); } diff --git a/xfa/fwl/theme/cfwl_formtp.cpp b/xfa/fwl/theme/cfwl_formtp.cpp index 75244373d4..971e738765 100644 --- a/xfa/fwl/theme/cfwl_formtp.cpp +++ b/xfa/fwl/theme/cfwl_formtp.cpp @@ -844,7 +844,7 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) { delete m_pActiveBitmap; m_pActiveBitmap = new CFX_DIBitmap; m_pActiveBitmap->Create(1, kCYCaption, FXDIB_Argb); - dev.Attach(m_pActiveBitmap); + dev.Attach(m_pActiveBitmap, false, nullptr, false); gs.Create(&dev); path.AddRectangle(0, 0, 1, 5); DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0], @@ -865,7 +865,7 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) { delete m_pDeactivebitmap; m_pDeactivebitmap = new CFX_DIBitmap; m_pDeactivebitmap->Create(1, kCYCaption, FXDIB_Argb); - dev.Attach(m_pDeactivebitmap); + dev.Attach(m_pDeactivebitmap, false, nullptr, false); gs.Create(&dev); path.AddRectangle(0, 0, 1, 5); DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0], diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index ae1b237957..7b1cc50d72 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -201,6 +201,7 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); } + void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, const CFX_ByteString str, FX_FLOAT geWidth, @@ -211,7 +212,7 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; CFX_FxgeDevice ge; - ge.Create((int)geWidth, iTextHeight, m_colorSpace); + ge.Create((int)geWidth, iTextHeight, m_colorSpace, nullptr); FX_RECT geRect(0, 0, (int)geWidth, iTextHeight); ge.FillRect(&geRect, m_backgroundColor); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); @@ -219,9 +220,10 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); CFX_FxgeDevice geBitmap; - geBitmap.Attach(pOutBitmap); + geBitmap.Attach(pOutBitmap, false, nullptr, false); geBitmap.SetDIBits(ge.GetBitmap(), (int)locX, (int)locY); } + void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, @@ -229,11 +231,11 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, int32_t barWidth, int32_t multiple, int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { + if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } - if (m_pFont == NULL) { + if (!m_pFont) { e = BCExceptionNullPointer; return; } diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp index bdc5e1f2c7..20b52774e8 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -153,6 +153,7 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, } return result; } + void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, @@ -160,7 +161,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, int32_t barWidth, int32_t multiple, int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { + if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } @@ -171,14 +172,14 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } + if (pOutBitmap) + geBitmap.Attach(pOutBitmap, false, nullptr, false); + int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; CFX_ByteString tempStr = str.Mid(1, 6); int32_t strWidth = multiple * 42; - if (pOutBitmap == NULL) { + if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), @@ -208,7 +209,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, } FX_FLOAT blank = 0.0; iLen = tempStr.GetLength(); - if (pOutBitmap == NULL) { + if (!pOutBitmap) { strWidth = (int32_t)(strWidth * m_outputHScale); } CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize, @@ -216,7 +217,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { - ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); FX_RECT rect(0, 0, strWidth, iTextHeight); ge.FillRect(&rect, m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, @@ -265,14 +266,14 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, tempStr = str.Mid(0, 1); iLen = tempStr.GetLength(); strWidth = multiple * 7; - if (pOutBitmap == NULL) { + if (!pOutBitmap) strWidth = (int32_t)(strWidth * m_outputHScale); - } + CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -292,6 +293,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, } FX_Free(pCharPos); } + void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents, uint8_t* code, int32_t codeLength, diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp index 4427cb8970..2aa57d18d1 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -158,6 +158,7 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, } return result; } + void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, @@ -165,10 +166,11 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, int32_t barWidth, int32_t multiple, int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { + if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } + int32_t leftPosition = 3 * multiple; CFX_ByteString str = FX_UTF8Encode(contents); int32_t iLength = str.GetLength(); @@ -179,12 +181,12 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, int32_t strWidth = 7 * multiple * 4; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } + if (pOutBitmap) + geBitmap.Attach(pOutBitmap, false, nullptr, false); + int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; - if (pOutBitmap == NULL) { + if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), @@ -204,16 +206,16 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, re = rect1.GetOutterRect(); device->FillRect(&re, m_backgroundColor); } - if (pOutBitmap == NULL) { + if (!pOutBitmap) strWidth = (int32_t)(strWidth * m_outputHScale); - } + CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, blank); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -236,7 +238,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, blank); if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -259,6 +261,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, } FX_Free(pCharPos); } + void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, uint8_t* code, int32_t codeLength, diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 943384d55c..f7900d4195 100644 --- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -36,18 +36,16 @@ void CBC_OnedUPCAWriter::Init() { CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() { delete m_subWriter; } + FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity( const CFX_WideStringC& contents) { - int32_t i = 0; - for (i = 0; i < contents.GetLength(); i++) { - if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { - continue; - } else { + for (FX_STRSIZE i = 0; i < contents.GetLength(); ++i) { + if (contents.GetAt(i) < '0' || contents.GetAt(i) > '9') return FALSE; - } } return TRUE; } + CFX_WideString CBC_OnedUPCAWriter::FilterContents( const CFX_WideStringC& contents) { CFX_WideString filtercontents; @@ -106,6 +104,7 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, BC_EXCEPTION_CHECK_ReturnValue(e, NULL); return ret; } + void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, @@ -113,10 +112,11 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, int32_t barWidth, int32_t multiple, int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { + if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } + int32_t leftPadding = 7 * multiple; int32_t leftPosition = 10 * multiple + leftPadding; CFX_ByteString str = FX_UTF8Encode(contents); @@ -127,13 +127,13 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } + if (pOutBitmap) + geBitmap.Attach(pOutBitmap, false, nullptr, false); + iLen = tempStr.GetLength(); int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; - if (pOutBitmap == NULL) { + if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), @@ -178,7 +178,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -231,7 +231,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -254,7 +254,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -277,6 +277,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, } FX_Free(pCharPos); } + void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, uint8_t* code, int32_t codeLength, diff --git a/xfa/fxgraphics/cagg_graphics.cpp b/xfa/fxgraphics/cagg_graphics.cpp index 564a2b14cc..5d1f563613 100644 --- a/xfa/fxgraphics/cagg_graphics.cpp +++ b/xfa/fxgraphics/cagg_graphics.cpp @@ -18,7 +18,7 @@ FWL_Error CAGG_Graphics::Create(CFX_Graphics* owner, return FWL_Error::PropertyInvalid; CFX_FxgeDevice* device = new CFX_FxgeDevice; - device->Create(width, height, format); + device->Create(width, height, format, nullptr); m_owner = owner; m_owner->m_renderDevice = device; m_owner->m_renderDevice->GetBitmap()->Clear(0xFFFFFFFF); diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index 8de0def44f..755bc1eff1 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -1343,7 +1343,7 @@ FWL_Error CFX_Graphics::FillPathWithPattern(CFX_Path* path, FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); CFX_FxgeDevice device; - device.Attach(&bmp); + device.Attach(&bmp, false, nullptr, false); device.FillRect(&rect, m_info.fillColor->m_info.pattern->m_backArgb); for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { |