| Index: core/fxge/win32/cfx_psrenderer.cpp
|
| diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
|
| index 0cd24faf83fe84db9c2bea471e475a8c1508e398..45d7e153b7210c0361b10ecbf63c287b723095fa 100644
|
| --- a/core/fxge/win32/cfx_psrenderer.cpp
|
| +++ b/core/fxge/win32/cfx_psrenderer.cpp
|
| @@ -43,7 +43,7 @@ CFX_PSRenderer::~CFX_PSRenderer() {
|
| }
|
| }
|
|
|
| -#define OUTPUT_PS(str) m_pOutput->OutputPS(str, sizeof str - 1)
|
| +#define OUTPUT_PS(str) m_pOutput->OutputPS(str, sizeof(str) - 1)
|
|
|
| void CFX_PSRenderer::Init(CPSOutput* pOutput,
|
| int pslevel,
|
| @@ -130,11 +130,9 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
|
| buf << " m ";
|
| break;
|
| case FXPT_LINETO:
|
| - if (flag & FXPT_CLOSEFIGURE) {
|
| - buf << " l h ";
|
| - } else {
|
| - buf << " l ";
|
| - }
|
| + buf << " l ";
|
| + if (flag & FXPT_CLOSEFIGURE)
|
| + buf << "h ";
|
| break;
|
| case FXPT_BEZIERTO: {
|
| FX_FLOAT x1 = pPathData->GetPointX(i + 1);
|
| @@ -145,12 +143,10 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
|
| pObject2Device->Transform(x1, y1);
|
| pObject2Device->Transform(x2, y2);
|
| }
|
| - buf << " " << x1 << " " << y1 << " " << x2 << " " << y2;
|
| - if (flag & FXPT_CLOSEFIGURE) {
|
| - buf << " c h\n";
|
| - } else {
|
| - buf << " c\n";
|
| - }
|
| + buf << " " << x1 << " " << y1 << " " << x2 << " " << y2 << " c";
|
| + if (flag & FXPT_CLOSEFIGURE)
|
| + buf << " h";
|
| + buf << "\n";
|
| i += 2;
|
| break;
|
| }
|
| @@ -165,10 +161,12 @@ void CFX_PSRenderer::SetClip_PathFill(const CFX_PathData* pPathData,
|
| StartRendering();
|
| OutputPath(pPathData, pObject2Device);
|
| CFX_FloatRect rect = pPathData->GetBoundingBox();
|
| - if (pObject2Device) {
|
| + if (pObject2Device)
|
| rect.Transform(pObject2Device);
|
| - }
|
| - m_ClipBox.Intersect(rect.GetOuterRect());
|
| + m_ClipBox.left = static_cast<int>(rect.left);
|
| + m_ClipBox.right = static_cast<int>(rect.left + rect.right);
|
| + m_ClipBox.top = static_cast<int>(rect.top + rect.bottom);
|
| + m_ClipBox.bottom = static_cast<int>(rect.bottom);
|
| if ((fill_mode & 3) == FXFILL_WINDING) {
|
| OUTPUT_PS("W n\n");
|
| } else {
|
| @@ -268,7 +266,7 @@ void CFX_PSRenderer::SetGraphState(const CFX_GraphStateData* pGraphState) {
|
| FXSYS_memcmp(m_CurGraphState.m_DashArray, pGraphState->m_DashArray,
|
| sizeof(FX_FLOAT) * m_CurGraphState.m_DashCount)) {
|
| buf << "[";
|
| - for (int i = 0; i < pGraphState->m_DashCount; i++) {
|
| + for (int i = 0; i < pGraphState->m_DashCount; ++i) {
|
| buf << pGraphState->m_DashArray[i] << " ";
|
| }
|
| buf << "]" << pGraphState->m_DashPhase << " d\n";
|
| @@ -286,7 +284,7 @@ void CFX_PSRenderer::SetGraphState(const CFX_GraphStateData* pGraphState) {
|
| buf << pGraphState->m_MiterLimit << " M\n";
|
| }
|
| m_CurGraphState.Copy(*pGraphState);
|
| - m_bGraphStateSet = TRUE;
|
| + m_bGraphStateSet = true;
|
| if (buf.GetSize()) {
|
| m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize());
|
| }
|
| @@ -302,7 +300,7 @@ static void FaxCompressData(uint8_t* src_buf,
|
| dest_buf, dest_size);
|
| FX_Free(src_buf);
|
| } else {
|
| - (*dest_buf).reset(src_buf);
|
| + dest_buf->reset(src_buf);
|
| *dest_size = (width + 7) / 8 * height;
|
| }
|
| }
|
| @@ -320,7 +318,7 @@ static void PSCompressData(int PSLevel,
|
| return;
|
| }
|
| CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
|
| - uint8_t* dest_buf = NULL;
|
| + uint8_t* dest_buf = nullptr;
|
| uint32_t dest_size = src_size;
|
| if (PSLevel >= 3) {
|
| if (pEncoders &&
|
| @@ -339,7 +337,7 @@ static void PSCompressData(int PSLevel,
|
| *output_buf = dest_buf;
|
| *output_size = dest_size;
|
| } else {
|
| - *filter = NULL;
|
| + *filter = nullptr;
|
| FX_Free(dest_buf);
|
| }
|
| }
|
| @@ -412,9 +410,10 @@ bool CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
|
| }
|
| buf << width << " 0 0 -" << height << " 0 " << height
|
| << "]currentfile/ASCII85Decode filter ";
|
| - if (output_buf.get() != src_buf)
|
| + if (output_buf.get() != src_buf) {
|
| buf << "<</K -1/EndOfBlock false/Columns " << width << "/Rows " << height
|
| << ">>/CCITTFaxDecode filter ";
|
| + }
|
| if (pSource->IsAlphaMask()) {
|
| buf << "iM\n";
|
| } else {
|
| @@ -424,23 +423,26 @@ bool CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
|
| WritePSBinary(output_buf.get(), output_size);
|
| output_buf.release();
|
| } else {
|
| - CFX_MaybeOwned<CFX_DIBSource> pConverted((CFX_DIBSource*)pSource);
|
| + CFX_DIBExtractor source_extractor(pSource);
|
| + CFX_MaybeOwned<CFX_DIBSource> pConverted(source_extractor.GetBitmap());
|
| + if (!pConverted.Get())
|
| + return false;
|
| switch (pSource->GetFormat()) {
|
| case FXDIB_1bppRgb:
|
| case FXDIB_Rgb32:
|
| - pConverted = pSource->CloneConvert(FXDIB_Rgb);
|
| + pConverted = pConverted->CloneConvert(FXDIB_Rgb).release();
|
| break;
|
| case FXDIB_8bppRgb:
|
| if (pSource->GetPalette()) {
|
| - pConverted = pSource->CloneConvert(FXDIB_Rgb);
|
| + pConverted = pConverted->CloneConvert(FXDIB_Rgb).release();
|
| }
|
| break;
|
| case FXDIB_1bppCmyk:
|
| - pConverted = pSource->CloneConvert(FXDIB_Cmyk);
|
| + pConverted = pConverted->CloneConvert(FXDIB_Cmyk).release();
|
| break;
|
| case FXDIB_8bppCmyk:
|
| if (pSource->GetPalette()) {
|
| - pConverted = pSource->CloneConvert(FXDIB_Cmyk);
|
| + pConverted = pConverted->CloneConvert(FXDIB_Cmyk).release();
|
| }
|
| break;
|
| default:
|
| @@ -450,26 +452,23 @@ bool CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
|
| OUTPUT_PS("\nQ\n");
|
| return false;
|
| }
|
| - int Bpp = pConverted->GetBPP() / 8;
|
| + int bpp = pConverted->GetBPP() / 8;
|
| uint8_t* output_buf = nullptr;
|
| FX_STRSIZE output_size = 0;
|
| const FX_CHAR* filter = nullptr;
|
| - if (flags & FXRENDER_IMAGE_LOSSY) {
|
| - CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
|
| - if (pEncoders &&
|
| - pEncoders->GetJpegModule()->JpegEncode(pConverted.Get(), &output_buf,
|
| - &output_size)) {
|
| - filter = "/DCTDecode filter ";
|
| - }
|
| + if ((m_PSLevel == 2 || flags & FXRENDER_IMAGE_LOSSY) &&
|
| + CCodec_JpegModule::JpegEncode(pConverted.Get(), &output_buf,
|
| + &output_size)) {
|
| + filter = "/DCTDecode filter ";
|
| }
|
| if (!filter) {
|
| - int src_pitch = width * Bpp;
|
| + int src_pitch = width * bpp;
|
| output_size = height * src_pitch;
|
| output_buf = FX_Alloc(uint8_t, output_size);
|
| for (int row = 0; row < height; row++) {
|
| const uint8_t* src_scan = pConverted->GetScanline(row);
|
| uint8_t* dest_scan = output_buf + row * src_pitch;
|
| - if (Bpp == 3) {
|
| + if (bpp == 3) {
|
| for (int col = 0; col < width; col++) {
|
| *dest_scan++ = src_scan[2];
|
| *dest_scan++ = src_scan[1];
|
| @@ -490,18 +489,13 @@ bool CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
|
| output_buf = compressed_buf;
|
| output_size = compressed_size;
|
| }
|
| - CFX_DIBSource* converted = pConverted.Get();
|
| - if (converted != pSource) {
|
| - delete converted;
|
| - pConverted.Reset();
|
| - }
|
| buf << " 8[";
|
| buf << width << " 0 0 -" << height << " 0 " << height << "]";
|
| buf << "currentfile/ASCII85Decode filter ";
|
| if (filter) {
|
| buf << filter;
|
| }
|
| - buf << "false " << Bpp;
|
| + buf << "false " << bpp;
|
| buf << " colorimage\n";
|
| m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize());
|
| WritePSBinary(output_buf, output_size);
|
| @@ -537,7 +531,7 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache,
|
| const FXTEXT_CHARPOS& charpos,
|
| int* ps_fontnum,
|
| int* ps_glyphindex) {
|
| - for (int i = 0; i < m_PSFontList.GetSize(); i++) {
|
| + for (int i = 0; i < (int)m_PSFontList.GetSize(); i++) {
|
| CPSFont* pPSFont = m_PSFontList[i];
|
| for (int j = 0; j < pPSFont->m_nGlyphs; j++)
|
| if (pPSFont->m_Glyphs[j].m_pFont == pFont &&
|
|
|