summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-05-12 15:35:00 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-12 15:35:00 -0700
commit39fbb7e1c2282a46d9bd3adfd030916dcb0155ef (patch)
tree096b3687e8641d73c8513b4805f046b59b0102eb
parenta0a3bc3482e78a545e8f8290f7d35f42aa968814 (diff)
downloadpdfium-39fbb7e1c2282a46d9bd3adfd030916dcb0155ef.tar.xz
Clean up CFX_ImageTransformer.
Review-Url: https://codereview.chromium.org/1973913002
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_type3char.cpp38
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_type3char.h6
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_type3font.cpp6
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp66
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp31
-rw-r--r--core/fxge/dib/fx_dib_main.cpp76
-rw-r--r--core/fxge/dib/fx_dib_transform.cpp155
-rw-r--r--core/fxge/include/fx_dib.h37
-rw-r--r--xfa/fxfa/app/xfa_ffwidget.cpp56
9 files changed, 231 insertions, 240 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_type3char.cpp b/core/fpdfapi/fpdf_font/cpdf_type3char.cpp
index 44219ee02d..9bfda99fd1 100644
--- a/core/fpdfapi/fpdf_font/cpdf_type3char.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_type3char.cpp
@@ -13,31 +13,27 @@
#include "core/fxge/include/fx_dib.h"
CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm)
- : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {}
+ : m_pForm(pForm), m_bColored(FALSE) {}
CPDF_Type3Char::~CPDF_Type3Char() {
- delete m_pForm;
- delete m_pBitmap;
}
FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) {
- if (m_pBitmap || !m_pForm) {
+ if (m_pBitmap || !m_pForm)
return TRUE;
- }
- if (m_pForm->GetPageObjectList()->size() == 1 && !m_bColored) {
- auto& pPageObj = m_pForm->GetPageObjectList()->front();
- if (pPageObj->IsImage()) {
- m_ImageMatrix = pPageObj->AsImage()->m_Matrix;
- const CFX_DIBSource* pSource =
- pPageObj->AsImage()->m_pImage->LoadDIBSource();
- if (pSource) {
- m_pBitmap = pSource->Clone();
- delete pSource;
- }
- delete m_pForm;
- m_pForm = NULL;
- return TRUE;
- }
- }
- return FALSE;
+
+ if (m_pForm->GetPageObjectList()->size() != 1 || m_bColored)
+ return FALSE;
+
+ auto& pPageObj = m_pForm->GetPageObjectList()->front();
+ if (!pPageObj->IsImage())
+ return FALSE;
+
+ m_ImageMatrix = pPageObj->AsImage()->m_Matrix;
+ std::unique_ptr<CFX_DIBSource> pSource(
+ pPageObj->AsImage()->m_pImage->LoadDIBSource());
+ if (pSource)
+ m_pBitmap.reset(pSource->Clone());
+ m_pForm.reset();
+ return TRUE;
}
diff --git a/core/fpdfapi/fpdf_font/cpdf_type3char.h b/core/fpdfapi/fpdf_font/cpdf_type3char.h
index c67620b5f6..7b101d3172 100644
--- a/core/fpdfapi/fpdf_font/cpdf_type3char.h
+++ b/core/fpdfapi/fpdf_font/cpdf_type3char.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_FPDF_FONT_CPDF_TYPE3CHAR_H_
#define CORE_FPDFAPI_FPDF_FONT_CPDF_TYPE3CHAR_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
@@ -22,8 +24,8 @@ class CPDF_Type3Char {
FX_BOOL LoadBitmap(CPDF_RenderContext* pContext);
- CPDF_Form* m_pForm;
- CFX_DIBitmap* m_pBitmap;
+ std::unique_ptr<CPDF_Form> m_pForm;
+ std::unique_ptr<CFX_DIBitmap> m_pBitmap;
FX_BOOL m_bColored;
int m_Width;
CFX_Matrix m_ImageMatrix;
diff --git a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
index be280948ae..6c339ea5a7 100644
--- a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
@@ -136,10 +136,8 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) {
ASSERT(!pdfium::ContainsKey(m_CacheMap, charcode));
CPDF_Type3Char* pCachedChar = pNewChar.release();
m_CacheMap[charcode] = pCachedChar;
- if (pCachedChar->m_pForm->GetPageObjectList()->empty()) {
- delete pCachedChar->m_pForm;
- pCachedChar->m_pForm = nullptr;
- }
+ if (pCachedChar->m_pForm->GetPageObjectList()->empty())
+ pCachedChar->m_pForm.reset();
return pCachedChar;
}
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 17851b8b4b..53c40b66ee 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -699,6 +699,7 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() {
rect.top, m_BlendType);
return FALSE;
}
+
FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) {
int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() *
@@ -710,7 +711,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
}
if (m_pRenderStatus->m_pDevice->StartDIBits(
m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
- m_DeviceHandle, 0, NULL, m_BlendType)) {
+ m_DeviceHandle, 0, nullptr, m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
return TRUE;
@@ -731,30 +732,29 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox();
clip_box.Intersect(image_rect);
m_Status = 2;
- m_pTransformer = new CFX_ImageTransformer;
- m_pTransformer->Start(m_pDIBSource, &m_ImageMatrix, m_Flags, &clip_box);
+ m_pTransformer = new CFX_ImageTransformer(m_pDIBSource, &m_ImageMatrix,
+ m_Flags, &clip_box);
+ m_pTransformer->Start();
return TRUE;
}
- if (m_ImageMatrix.a < 0) {
+ if (m_ImageMatrix.a < 0)
dest_width = -dest_width;
- }
- if (m_ImageMatrix.d > 0) {
+
+ if (m_ImageMatrix.d > 0)
dest_height = -dest_height;
- }
- int dest_left, dest_top;
- dest_left = dest_width > 0 ? image_rect.left : image_rect.right;
- dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
+
+ int dest_left = dest_width > 0 ? image_rect.left : image_rect.right;
+ int dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) {
if (m_pRenderStatus->m_pDevice->StretchDIBits(
m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags,
- NULL, m_BlendType)) {
+ nullptr, m_BlendType)) {
return FALSE;
}
}
if (m_pDIBSource->IsAlphaMask()) {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
- }
if (m_pRenderStatus->m_pDevice->StretchBitMask(
m_pDIBSource, dest_left, dest_top, dest_width, dest_height,
m_FillArgb, m_Flags)) {
@@ -766,6 +766,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
m_Result = FALSE;
return TRUE;
}
+
FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox();
FX_RECT dest_rect = clip_box;
dest_rect.Intersect(image_rect);
@@ -781,6 +782,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
}
return FALSE;
}
+
FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() {
if (m_pDIBSource->IsOpaqueImage()) {
CFX_PathData path;
@@ -824,46 +826,44 @@ FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() {
}
return FALSE;
}
+
FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) {
if (m_Status == 2) {
- if (m_pTransformer->Continue(pPause)) {
+ if (m_pTransformer->Continue(pPause))
return TRUE;
- }
- CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (!pBitmap) {
+
+ std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap());
+ if (!pBitmap)
return FALSE;
- }
+
if (pBitmap->IsAlphaMask()) {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
- }
m_Result = m_pRenderStatus->m_pDevice->SetBitMask(
- pBitmap, m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop,
- m_FillArgb);
+ pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_FillArgb);
} else {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
- }
m_Result = m_pRenderStatus->m_pDevice->SetDIBits(
- pBitmap, m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop,
- m_BlendType);
+ pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_BlendType);
}
- delete pBitmap;
return FALSE;
}
- if (m_Status == 3) {
+ if (m_Status == 3)
return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
- }
+
if (m_Status == 4) {
- if (m_Loader.Continue(m_LoadHandle, pPause)) {
+ if (m_Loader.Continue(m_LoadHandle, pPause))
return TRUE;
- }
- if (StartRenderDIBSource()) {
+
+ if (StartRenderDIBSource())
return Continue(pPause);
- }
}
return FALSE;
}
+
CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index acc70c001e..33ad21351e 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -149,6 +149,7 @@ static int _DetectFirstLastScan(const CFX_DIBitmap* pBitmap, FX_BOOL bFirst) {
}
return -1;
}
+
CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
uint32_t charcode,
const CFX_Matrix* pMatrix,
@@ -158,12 +159,12 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
if (!pChar || !pChar->m_pBitmap)
return nullptr;
- CFX_DIBitmap* pBitmap = pChar->m_pBitmap;
+ CFX_DIBitmap* pBitmap = pChar->m_pBitmap.get();
CFX_Matrix image_matrix, text_matrix;
image_matrix = pChar->m_ImageMatrix;
text_matrix.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0);
image_matrix.Concat(text_matrix);
- CFX_DIBitmap* pResBitmap = NULL;
+ std::unique_ptr<CFX_DIBitmap> pResBitmap;
int left = 0;
int top = 0;
if (FXSYS_fabs(image_matrix.b) < FXSYS_fabs(image_matrix.a) / 100 &&
@@ -180,10 +181,10 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
bottom_y = temp;
}
pSize->AdjustBlue(top_y, bottom_y, top_line, bottom_line);
- pResBitmap = pBitmap->StretchTo(
+ pResBitmap.reset(pBitmap->StretchTo(
(int)(FXSYS_round(image_matrix.a) * retinaScaleX),
(int)((bFlipped ? top_line - bottom_line : bottom_line - top_line) *
- retinaScaleY));
+ retinaScaleY)));
top = top_line;
if (image_matrix.a < 0) {
image_matrix.Scale(retinaScaleX, retinaScaleY);
@@ -195,16 +196,15 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
}
if (!pResBitmap) {
image_matrix.Scale(retinaScaleX, retinaScaleY);
- pResBitmap = pBitmap->TransformTo(&image_matrix, left, top);
- }
- if (!pResBitmap) {
- return NULL;
+ pResBitmap.reset(pBitmap->TransformTo(&image_matrix, left, top));
}
+ if (!pResBitmap)
+ return nullptr;
+
CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap;
pGlyph->m_Left = left;
pGlyph->m_Top = -top;
- pGlyph->m_Bitmap.TakeOver(pResBitmap);
- delete pResBitmap;
+ pGlyph->m_Bitmap.TakeOver(pResBitmap.get());
return pGlyph;
}
@@ -423,7 +423,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
status.m_Type3FontCache.Append(m_Type3FontCache);
status.m_Type3FontCache.Add(pType3Font);
m_pDevice->SaveState();
- status.RenderObjectList(pType3Char->m_pForm, &matrix);
+ status.RenderObjectList(pType3Char->m_pForm.get(), &matrix);
m_pDevice->RestoreState();
} else {
CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox();
@@ -444,7 +444,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
status.m_Type3FontCache.Add(pType3Font);
matrix.TranslateI(-rect.left, -rect.top);
matrix.Scale(sa, sd);
- status.RenderObjectList(pType3Char->m_pForm, &matrix);
+ status.RenderObjectList(pType3Char->m_pForm.get(), &matrix);
m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top);
}
delete pStates;
@@ -470,13 +470,12 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
CFX_Matrix image_matrix = pType3Char->m_ImageMatrix;
image_matrix.Concat(matrix);
CPDF_ImageRenderer renderer;
- if (renderer.Start(this, pType3Char->m_pBitmap, fill_argb, 255,
+ if (renderer.Start(this, pType3Char->m_pBitmap.get(), fill_argb, 255,
&image_matrix, 0, FALSE)) {
- renderer.Continue(NULL);
+ renderer.Continue(nullptr);
}
- if (!renderer.m_Result) {
+ if (!renderer.m_Result)
return FALSE;
- }
}
}
}
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index bf8dd4ecd5..ad6ee0c4e7 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -1591,6 +1591,7 @@ CFX_ImageRenderer::CFX_ImageRenderer() {
CFX_ImageRenderer::~CFX_ImageRenderer() {
delete m_pTransformer;
}
+
FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice,
const CFX_ClipRgn* pClipRgn,
const CFX_DIBSource* pSource,
@@ -1646,8 +1647,9 @@ FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice,
return TRUE;
}
m_Status = 2;
- m_pTransformer = new CFX_ImageTransformer;
- m_pTransformer->Start(pSource, &m_Matrix, dib_flags, &m_ClipBox);
+ m_pTransformer =
+ new CFX_ImageTransformer(pSource, &m_Matrix, dib_flags, &m_ClipBox);
+ m_pTransformer->Start();
return TRUE;
}
@@ -1678,17 +1680,13 @@ FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) {
return m_Stretcher->Continue(pPause);
if (m_Status == 2) {
- if (m_pTransformer->Continue(pPause)) {
+ if (m_pTransformer->Continue(pPause))
return TRUE;
- }
- CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (!pBitmap) {
- return FALSE;
- }
- if (!pBitmap->GetBuffer()) {
- delete pBitmap;
+
+ std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap());
+ if (!pBitmap || !pBitmap->GetBuffer())
return FALSE;
- }
+
if (pBitmap->IsAlphaMask()) {
if (m_BitmapAlpha != 255) {
if (m_AlphaFlag >> 8) {
@@ -1699,51 +1697,49 @@ FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) {
m_MaskColor = FXARGB_MUL_ALPHA(m_MaskColor, m_BitmapAlpha);
}
}
- m_pDevice->CompositeMask(m_pTransformer->m_ResultLeft,
- m_pTransformer->m_ResultTop, pBitmap->GetWidth(),
- pBitmap->GetHeight(), pBitmap, m_MaskColor, 0, 0,
- m_BlendType, m_pClipRgn, m_bRgbByteOrder,
- m_AlphaFlag, m_pIccTransform);
+ m_pDevice->CompositeMask(
+ m_pTransformer->result().left, m_pTransformer->result().top,
+ pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap.get(), m_MaskColor,
+ 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_AlphaFlag,
+ m_pIccTransform);
} else {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
- }
m_pDevice->CompositeBitmap(
- m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop,
- pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, 0, 0, m_BlendType,
- m_pClipRgn, m_bRgbByteOrder, m_pIccTransform);
+ m_pTransformer->result().left, m_pTransformer->result().top,
+ pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap.get(), 0, 0,
+ m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_pIccTransform);
}
- delete pBitmap;
return FALSE;
}
return FALSE;
}
+
CFX_BitmapStorer::CFX_BitmapStorer() {
- m_pBitmap = NULL;
}
+
CFX_BitmapStorer::~CFX_BitmapStorer() {
- delete m_pBitmap;
}
-CFX_DIBitmap* CFX_BitmapStorer::Detach() {
- CFX_DIBitmap* pBitmap = m_pBitmap;
- m_pBitmap = NULL;
- return pBitmap;
+
+std::unique_ptr<CFX_DIBitmap> CFX_BitmapStorer::Detach() {
+ return std::move(m_pBitmap);
}
-void CFX_BitmapStorer::Replace(CFX_DIBitmap* pBitmap) {
- delete m_pBitmap;
- m_pBitmap = pBitmap;
+
+void CFX_BitmapStorer::Replace(std::unique_ptr<CFX_DIBitmap> pBitmap) {
+ m_pBitmap = std::move(pBitmap);
}
+
void CFX_BitmapStorer::ComposeScanline(int line,
const uint8_t* scanline,
const uint8_t* scan_extra_alpha) {
- uint8_t* dest_buf = (uint8_t*)m_pBitmap->GetScanline(line);
+ uint8_t* dest_buf = const_cast<uint8_t*>(m_pBitmap->GetScanline(line));
uint8_t* dest_alpha_buf =
m_pBitmap->m_pAlphaMask
- ? (uint8_t*)m_pBitmap->m_pAlphaMask->GetScanline(line)
- : NULL;
- if (dest_buf) {
+ ? const_cast<uint8_t*>(m_pBitmap->m_pAlphaMask->GetScanline(line))
+ : nullptr;
+ if (dest_buf)
FXSYS_memcpy(dest_buf, scanline, m_pBitmap->GetPitch());
- }
+
if (dest_alpha_buf) {
FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha,
m_pBitmap->m_pAlphaMask->GetPitch());
@@ -1753,14 +1749,12 @@ FX_BOOL CFX_BitmapStorer::SetInfo(int width,
int height,
FXDIB_Format src_format,
uint32_t* pSrcPalette) {
- m_pBitmap = new CFX_DIBitmap;
+ m_pBitmap.reset(new CFX_DIBitmap);
if (!m_pBitmap->Create(width, height, src_format)) {
- delete m_pBitmap;
- m_pBitmap = NULL;
+ m_pBitmap.reset();
return FALSE;
}
- if (pSrcPalette) {
+ if (pSrcPalette)
m_pBitmap->CopyPalette(pSrcPalette);
- }
return TRUE;
}
diff --git a/core/fxge/dib/fx_dib_transform.cpp b/core/fxge/dib/fx_dib_transform.cpp
index 6aaaac2cb7..f9b4250deb 100644
--- a/core/fxge/dib/fx_dib_transform.cpp
+++ b/core/fxge/dib/fx_dib_transform.cpp
@@ -296,18 +296,18 @@ FX_RECT FXDIB_SwapClipBox(FX_RECT& clip,
rect.Normalize();
return rect;
}
+
CFX_DIBitmap* CFX_DIBSource::TransformTo(const CFX_Matrix* pDestMatrix,
int& result_left,
int& result_top,
uint32_t flags,
const FX_RECT* pDestClip) const {
- CFX_ImageTransformer transformer;
- transformer.Start(this, pDestMatrix, flags, pDestClip);
- transformer.Continue(NULL);
- result_left = transformer.m_ResultLeft;
- result_top = transformer.m_ResultTop;
- CFX_DIBitmap* pTransformed = transformer.m_Storer.Detach();
- return pTransformed;
+ CFX_ImageTransformer transformer(this, pDestMatrix, flags, pDestClip);
+ transformer.Start();
+ transformer.Continue(nullptr);
+ result_left = transformer.result().left;
+ result_top = transformer.result().top;
+ return transformer.DetachBitmap().release();
}
CFX_DIBitmap* CFX_DIBSource::StretchTo(int dest_width,
@@ -329,79 +329,75 @@ CFX_DIBitmap* CFX_DIBSource::StretchTo(int dest_width,
clip_rect, flags);
if (stretcher.Start())
stretcher.Continue(nullptr);
- return storer.Detach();
+ return storer.Detach().release();
}
-CFX_ImageTransformer::CFX_ImageTransformer() {
- m_Status = 0;
- m_pMatrix = NULL;
-}
+CFX_ImageTransformer::CFX_ImageTransformer(const CFX_DIBSource* pSrc,
+ const CFX_Matrix* pMatrix,
+ int flags,
+ const FX_RECT* pClip)
+ : m_pSrc(pSrc),
+ m_pMatrix(pMatrix),
+ m_pClip(pClip),
+ m_Flags(flags),
+ m_Status(0) {}
CFX_ImageTransformer::~CFX_ImageTransformer() {}
-FX_BOOL CFX_ImageTransformer::Start(const CFX_DIBSource* pSrc,
- const CFX_Matrix* pDestMatrix,
- int flags,
- const FX_RECT* pDestClip) {
- m_pMatrix = (CFX_Matrix*)pDestMatrix;
- CFX_FloatRect unit_rect = pDestMatrix->GetUnitRect();
+FX_BOOL CFX_ImageTransformer::Start() {
+ CFX_FloatRect unit_rect = m_pMatrix->GetUnitRect();
FX_RECT result_rect = unit_rect.GetClosestRect();
FX_RECT result_clip = result_rect;
- if (pDestClip)
- result_clip.Intersect(*pDestClip);
+ if (m_pClip)
+ result_clip.Intersect(*m_pClip);
if (result_clip.IsEmpty())
return FALSE;
- m_ResultLeft = result_clip.left;
- m_ResultTop = result_clip.top;
- m_ResultWidth = result_clip.Width();
- m_ResultHeight = result_clip.Height();
- m_Flags = flags;
- if (FXSYS_fabs(pDestMatrix->a) < FXSYS_fabs(pDestMatrix->b) / 20 &&
- FXSYS_fabs(pDestMatrix->d) < FXSYS_fabs(pDestMatrix->c) / 20 &&
- FXSYS_fabs(pDestMatrix->a) < 0.5f && FXSYS_fabs(pDestMatrix->d) < 0.5f) {
+ m_result = result_clip;
+ if (FXSYS_fabs(m_pMatrix->a) < FXSYS_fabs(m_pMatrix->b) / 20 &&
+ FXSYS_fabs(m_pMatrix->d) < FXSYS_fabs(m_pMatrix->c) / 20 &&
+ FXSYS_fabs(m_pMatrix->a) < 0.5f && FXSYS_fabs(m_pMatrix->d) < 0.5f) {
int dest_width = result_rect.Width();
int dest_height = result_rect.Height();
result_clip.Offset(-result_rect.left, -result_rect.top);
result_clip = FXDIB_SwapClipBox(result_clip, dest_width, dest_height,
- pDestMatrix->c > 0, pDestMatrix->b < 0);
- m_Stretcher.reset(new CFX_ImageStretcher(&m_Storer, pSrc, dest_height,
- dest_width, result_clip, flags));
+ m_pMatrix->c > 0, m_pMatrix->b < 0);
+ m_Stretcher.reset(new CFX_ImageStretcher(&m_Storer, m_pSrc, dest_height,
+ dest_width, result_clip, m_Flags));
m_Stretcher->Start();
m_Status = 1;
return TRUE;
}
- if (FXSYS_fabs(pDestMatrix->b) < FIX16_005 &&
- FXSYS_fabs(pDestMatrix->c) < FIX16_005) {
- int dest_width = pDestMatrix->a > 0 ? (int)FXSYS_ceil(pDestMatrix->a)
- : (int)FXSYS_floor(pDestMatrix->a);
- int dest_height = pDestMatrix->d > 0 ? (int)-FXSYS_ceil(pDestMatrix->d)
- : (int)-FXSYS_floor(pDestMatrix->d);
+ if (FXSYS_fabs(m_pMatrix->b) < FIX16_005 &&
+ FXSYS_fabs(m_pMatrix->c) < FIX16_005) {
+ int dest_width = m_pMatrix->a > 0 ? (int)FXSYS_ceil(m_pMatrix->a)
+ : (int)FXSYS_floor(m_pMatrix->a);
+ int dest_height = m_pMatrix->d > 0 ? (int)-FXSYS_ceil(m_pMatrix->d)
+ : (int)-FXSYS_floor(m_pMatrix->d);
result_clip.Offset(-result_rect.left, -result_rect.top);
- m_Stretcher.reset(new CFX_ImageStretcher(&m_Storer, pSrc, dest_width,
- dest_height, result_clip, flags));
+ m_Stretcher.reset(new CFX_ImageStretcher(
+ &m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags));
m_Stretcher->Start();
m_Status = 2;
return TRUE;
}
- int stretch_width =
- (int)FXSYS_ceil(FXSYS_sqrt2(pDestMatrix->a, pDestMatrix->b));
- int stretch_height =
- (int)FXSYS_ceil(FXSYS_sqrt2(pDestMatrix->c, pDestMatrix->d));
+ int stretch_width = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b));
+ int stretch_height = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d));
CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f,
(FX_FLOAT)(stretch_height));
stretch2dest.Concat(
- pDestMatrix->a / stretch_width, pDestMatrix->b / stretch_width,
- pDestMatrix->c / stretch_height, pDestMatrix->d / stretch_height,
- pDestMatrix->e, pDestMatrix->f);
+ m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width,
+ m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height,
+ m_pMatrix->e, m_pMatrix->f);
m_dest2stretch.SetReverse(stretch2dest);
CFX_FloatRect clip_rect_f(result_clip);
clip_rect_f.Transform(&m_dest2stretch);
m_StretchClip = clip_rect_f.GetOutterRect();
m_StretchClip.Intersect(0, 0, stretch_width, stretch_height);
- m_Stretcher.reset(new CFX_ImageStretcher(
- &m_Storer, pSrc, stretch_width, stretch_height, m_StretchClip, flags));
+ m_Stretcher.reset(new CFX_ImageStretcher(&m_Storer, m_pSrc, stretch_width,
+ stretch_height, m_StretchClip,
+ m_Flags));
m_Stretcher->Start();
m_Status = 3;
return TRUE;
@@ -413,8 +409,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
return TRUE;
if (m_Storer.GetBitmap()) {
- m_Storer.Replace(
+ std::unique_ptr<CFX_DIBitmap> swapped(
m_Storer.GetBitmap()->SwapXY(m_pMatrix->c > 0, m_pMatrix->b < 0));
+ m_Storer.Replace(std::move(swapped));
}
return FALSE;
}
@@ -441,15 +438,15 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
int stretch_pitch = m_Storer.GetBitmap()->GetPitch();
std::unique_ptr<CFX_DIBitmap> pTransformed(new CFX_DIBitmap);
FXDIB_Format transformF = GetTransformedFormat(m_Stretcher->source());
- if (!pTransformed->Create(m_ResultWidth, m_ResultHeight, transformF))
+ if (!pTransformed->Create(m_result.Width(), m_result.Height(), transformF))
return FALSE;
pTransformed->Clear(0);
if (pTransformed->m_pAlphaMask)
pTransformed->m_pAlphaMask->Clear(0);
- CFX_Matrix result2stretch(1.0f, 0.0f, 0.0f, 1.0f, (FX_FLOAT)(m_ResultLeft),
- (FX_FLOAT)(m_ResultTop));
+ CFX_Matrix result2stretch(1.0f, 0.0f, 0.0f, 1.0f, (FX_FLOAT)(m_result.left),
+ (FX_FLOAT)(m_result.top));
result2stretch.Concat(m_dest2stretch);
result2stretch.TranslateI(-m_StretchClip.left, -m_StretchClip.top);
if (!stretch_buf_mask && pTransformed->m_pAlphaMask) {
@@ -458,10 +455,10 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
int stretch_pitch_mask = m_Storer.GetBitmap()->m_pAlphaMask->GetPitch();
if (!(m_Flags & FXDIB_DOWNSAMPLE) && !(m_Flags & FXDIB_BICUBIC_INTERPOL)) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos_mask =
(uint8_t*)pTransformed->m_pAlphaMask->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -492,10 +489,10 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos_mask =
(uint8_t*)pTransformed->m_pAlphaMask->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -520,10 +517,10 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else {
CPDF_FixedMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos_mask =
(uint8_t*)pTransformed->m_pAlphaMask->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col, src_row;
result2stretch_fix.Transform(col, row, src_col, src_row);
if (src_col >= 0 && src_col <= stretch_width && src_row >= 0 &&
@@ -545,9 +542,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
if (m_Storer.GetBitmap()->IsAlphaMask()) {
if (!(m_Flags & FXDIB_DOWNSAMPLE) && !(m_Flags & FXDIB_BICUBIC_INTERPOL)) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_scan = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -578,9 +575,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_scan = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -604,9 +601,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else {
CPDF_FixedMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_scan = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col, src_row;
result2stretch_fix.Transform(col, row, src_col, src_row);
if (src_col >= 0 && src_col <= stretch_width && src_row >= 0 &&
@@ -649,9 +646,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
if (!(m_Flags & FXDIB_DOWNSAMPLE) &&
!(m_Flags & FXDIB_BICUBIC_INTERPOL)) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -689,9 +686,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -724,9 +721,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else {
CPDF_FixedMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col, src_row;
result2stretch_fix.Transform(col, row, src_col, src_row);
if (src_col >= 0 && src_col <= stretch_width && src_row >= 0 &&
@@ -757,9 +754,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
if (!(m_Flags & FXDIB_DOWNSAMPLE) &&
!(m_Flags & FXDIB_BICUBIC_INTERPOL)) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y, r_pos_k_r = 0;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -833,9 +830,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y, r_pos_k_r = 0;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -904,9 +901,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else {
CPDF_FixedMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col, src_row;
result2stretch_fix.Transform(col, row, src_col, src_row);
if (src_col >= 0 && src_col <= stretch_width && src_row >= 0 &&
@@ -949,6 +946,10 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
}
}
- m_Storer.Replace(pTransformed.release());
+ m_Storer.Replace(std::move(pTransformed));
return FALSE;
}
+
+std::unique_ptr<CFX_DIBitmap> CFX_ImageTransformer::DetachBitmap() {
+ return m_Storer.Detach();
+}
diff --git a/core/fxge/include/fx_dib.h b/core/fxge/include/fx_dib.h
index fe185eba21..a09f88453f 100644
--- a/core/fxge/include/fx_dib.h
+++ b/core/fxge/include/fx_dib.h
@@ -558,20 +558,17 @@ class CFX_BitmapStorer : public IFX_ScanlineComposer {
void ComposeScanline(int line,
const uint8_t* scanline,
const uint8_t* scan_extra_alpha) override;
-
FX_BOOL SetInfo(int width,
int height,
FXDIB_Format src_format,
uint32_t* pSrcPalette) override;
- CFX_DIBitmap* GetBitmap() { return m_pBitmap; }
-
- CFX_DIBitmap* Detach();
-
- void Replace(CFX_DIBitmap* pBitmap);
+ CFX_DIBitmap* GetBitmap() { return m_pBitmap.get(); }
+ std::unique_ptr<CFX_DIBitmap> Detach();
+ void Replace(std::unique_ptr<CFX_DIBitmap> pBitmap);
private:
- CFX_DIBitmap* m_pBitmap;
+ std::unique_ptr<CFX_DIBitmap> m_pBitmap;
};
class CFX_ImageStretcher {
@@ -613,26 +610,28 @@ class CFX_ImageStretcher {
class CFX_ImageTransformer {
public:
- CFX_ImageTransformer();
+ CFX_ImageTransformer(const CFX_DIBSource* pSrc,
+ const CFX_Matrix* pMatrix,
+ int flags,
+ const FX_RECT* pClip);
~CFX_ImageTransformer();
- FX_BOOL Start(const CFX_DIBSource* pSrc,
- const CFX_Matrix* pMatrix,
- int flags,
- const FX_RECT* pClip);
-
+ FX_BOOL Start();
FX_BOOL Continue(IFX_Pause* pPause);
- CFX_Matrix* m_pMatrix;
+ const FX_RECT& result() const { return m_result; }
+ std::unique_ptr<CFX_DIBitmap> DetachBitmap();
+
+ private:
+ const CFX_DIBSource* const m_pSrc;
+ const CFX_Matrix* const m_pMatrix;
+ const FX_RECT* const m_pClip;
FX_RECT m_StretchClip;
- int m_ResultLeft;
- int m_ResultTop;
- int m_ResultWidth;
- int m_ResultHeight;
+ FX_RECT m_result;
CFX_Matrix m_dest2stretch;
std::unique_ptr<CFX_ImageStretcher> m_Stretcher;
CFX_BitmapStorer m_Storer;
- uint32_t m_Flags;
+ const uint32_t m_Flags;
int m_Status;
};
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index ed29996010..5f141e4e84 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/include/xfa_ffwidget.h"
#include <algorithm>
+#include <memory>
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h"
#include "core/fxcodec/codec/include/ccodec_progressivedecoder.h"
@@ -480,10 +481,12 @@ CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap) {
}
return CFX_GraphStateData::LineCapSquare;
}
+
class CXFA_ImageRenderer {
public:
CXFA_ImageRenderer();
~CXFA_ImageRenderer();
+
FX_BOOL Start(CFX_RenderDevice* pDevice,
CFX_DIBSource* pDIBSource,
FX_ARGB bitmap_argb,
@@ -502,7 +505,7 @@ class CXFA_ImageRenderer {
int m_BitmapAlpha;
FX_ARGB m_FillArgb;
uint32_t m_Flags;
- CFX_ImageTransformer* m_pTransformer;
+ std::unique_ptr<CFX_ImageTransformer> m_pTransformer;
void* m_DeviceHandle;
int32_t m_BlendType;
FX_BOOL m_Result;
@@ -524,7 +527,6 @@ CXFA_ImageRenderer::CXFA_ImageRenderer() {
m_BitmapAlpha = 255;
m_FillArgb = 0;
m_Flags = 0;
- m_pTransformer = NULL;
m_DeviceHandle = NULL;
m_BlendType = FXDIB_BLEND_NORMAL;
m_Result = TRUE;
@@ -533,7 +535,6 @@ CXFA_ImageRenderer::CXFA_ImageRenderer() {
CXFA_ImageRenderer::~CXFA_ImageRenderer() {
delete m_pCloneConvert;
- delete m_pTransformer;
if (m_DeviceHandle)
m_pDevice->CancelDIBits(m_DeviceHandle);
}
@@ -588,8 +589,9 @@ FX_BOOL CXFA_ImageRenderer::StartDIBSource() {
FX_RECT clip_box = m_pDevice->GetClipBox();
clip_box.Intersect(image_rect);
m_Status = 2;
- m_pTransformer = new CFX_ImageTransformer;
- m_pTransformer->Start(pDib, &m_ImageMatrix, m_Flags, &clip_box);
+ m_pTransformer.reset(
+ new CFX_ImageTransformer(pDib, &m_ImageMatrix, m_Flags, &clip_box));
+ m_pTransformer->Start();
return TRUE;
}
if (m_ImageMatrix.a < 0) {
@@ -626,45 +628,45 @@ FX_BOOL CXFA_ImageRenderer::StartDIBSource() {
FX_RECT dest_clip(
dest_rect.left - image_rect.left, dest_rect.top - image_rect.top,
dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top);
- CFX_DIBitmap* pStretched =
- m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip);
+ std::unique_ptr<CFX_DIBitmap> pStretched(
+ m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip));
if (pStretched) {
- CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top, m_FillArgb,
- m_BitmapAlpha, m_BlendType, FALSE);
- delete pStretched;
- pStretched = NULL;
+ CompositeDIBitmap(pStretched.get(), dest_rect.left, dest_rect.top,
+ m_FillArgb, m_BitmapAlpha, m_BlendType, FALSE);
}
return FALSE;
}
+
FX_BOOL CXFA_ImageRenderer::Continue(IFX_Pause* pPause) {
if (m_Status == 2) {
- if (m_pTransformer->Continue(pPause)) {
+ if (m_pTransformer->Continue(pPause))
return TRUE;
- }
- CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (pBitmap == NULL) {
+
+ std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap());
+ if (!pBitmap)
return FALSE;
- }
+
if (pBitmap->IsAlphaMask()) {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
- }
- m_Result = m_pDevice->SetBitMask(pBitmap, m_pTransformer->m_ResultLeft,
- m_pTransformer->m_ResultTop, m_FillArgb);
+ m_Result =
+ m_pDevice->SetBitMask(pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_FillArgb);
} else {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
- }
- m_Result = m_pDevice->SetDIBits(pBitmap, m_pTransformer->m_ResultLeft,
- m_pTransformer->m_ResultTop, m_BlendType);
+ m_Result =
+ m_pDevice->SetDIBits(pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_BlendType);
}
- delete pBitmap;
return FALSE;
- } else if (m_Status == 3) {
- return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
}
+ if (m_Status == 3)
+ return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
+
return FALSE;
}
+
void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
int left,
int top,