summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render.cpp8
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp25
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp12
-rw-r--r--core/fxge/ge/fx_ge_device.cpp239
-rw-r--r--core/fxge/ge/fx_ge_text.cpp99
-rw-r--r--core/fxge/include/fx_dib.h4
-rw-r--r--core/fxge/include/fx_ge.h167
-rw-r--r--xfa/fxfa/app/xfa_ffwidget.cpp31
8 files changed, 269 insertions, 316 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index 3144191469..365e4c0464 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -455,6 +455,7 @@ FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) {
}
return TRUE;
}
+
FX_BOOL CPDF_RenderStatus::ProcessPath(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device) {
int FillType = pPathObj->m_FillType;
@@ -500,10 +501,11 @@ FX_BOOL CPDF_RenderStatus::ProcessPath(const CPDF_PathObject* pPathObj,
if (m_Options.m_Flags & RENDER_THINLINE) {
graphState.m_LineWidth = 0;
}
- return m_pDevice->DrawPath(pPathObj->m_Path, &path_matrix, &graphState,
- fill_argb, stroke_argb, FillType, 0, NULL,
- m_curBlend);
+ return m_pDevice->DrawPathWithBlend(pPathObj->m_Path, &path_matrix,
+ &graphState, fill_argb, stroke_argb,
+ FillType, m_curBlend);
}
+
CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const {
ASSERT(pObj);
CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData();
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index d84c0037fd..f7e57c0fa6 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -76,7 +76,7 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
if (pDIBitmap->IsAlphaMask()) {
return;
}
- m_pDevice->SetDIBits(pDIBitmap, left, top, blend_mode);
+ m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode);
} else {
FX_RECT rect(left, top, left + pDIBitmap->GetWidth(),
top + pDIBitmap->GetHeight());
@@ -106,7 +106,8 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
if (pDIBitmap->IsAlphaMask()) {
return;
}
- m_pDevice->SetDIBits(pDIBitmap, rect.left, rect.top, blend_mode);
+ m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top,
+ blend_mode);
}
if (bClone) {
delete pClone;
@@ -600,8 +601,8 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) {
bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap());
bitmap_device1.GetBitmap()->MultiplyAlpha(255);
}
- m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left,
- rect.top, m_BlendType);
+ m_pRenderStatus->m_pDevice->SetDIBitsWithBlend(
+ bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType);
return FALSE;
}
FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() {
@@ -695,8 +696,8 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() {
bitmap_device1.GetBitmap()->MultiplyAlpha(m_BitmapAlpha);
}
}
- m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left,
- rect.top, m_BlendType);
+ m_pRenderStatus->m_pDevice->SetDIBitsWithBlend(
+ bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType);
return FALSE;
}
@@ -709,9 +710,9 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
m_Flags |= RENDER_FORCE_DOWNSAMPLE;
}
}
- if (m_pRenderStatus->m_pDevice->StartDIBits(
+ if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend(
m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
- m_DeviceHandle, 0, nullptr, m_BlendType)) {
+ m_DeviceHandle, m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
return TRUE;
@@ -746,16 +747,16 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
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(
+ if (m_pRenderStatus->m_pDevice->StretchDIBitsWithFlagsAndBlend(
m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags,
- nullptr, m_BlendType)) {
+ m_BlendType)) {
return FALSE;
}
}
if (m_pDIBSource->IsAlphaMask()) {
if (m_BitmapAlpha != 255)
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
- if (m_pRenderStatus->m_pDevice->StretchBitMask(
+ if (m_pRenderStatus->m_pDevice->StretchBitMaskWithFlags(
m_pDIBSource, dest_left, dest_top, dest_width, dest_height,
m_FillArgb, m_Flags)) {
return FALSE;
@@ -845,7 +846,7 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) {
} else {
if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
- m_Result = m_pRenderStatus->m_pDevice->SetDIBits(
+ m_Result = m_pRenderStatus->m_pDevice->SetDIBitsWithBlend(
pBitmap.get(), m_pTransformer->result().left,
m_pTransformer->result().top, m_BlendType);
}
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 5bd7c35059..7c2fec7c78 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -589,6 +589,7 @@ void CPDF_CharPosList::Load(int nChars,
}
}
}
+
FX_BOOL CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice,
int nChars,
uint32_t* pCharCodes,
@@ -604,14 +605,15 @@ FX_BOOL CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice,
int nFlag) {
CFX_FontCache* pCache =
pFont->m_pDocument ? pFont->m_pDocument->GetRenderData()->GetFontCache()
- : NULL;
+ : nullptr;
CPDF_CharPosList CharPosList;
CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size);
- return pDevice->DrawTextPath(CharPosList.m_nChars, CharPosList.m_pCharPos,
- &pFont->m_Font, pCache, font_size, pText2User,
- pUser2Device, pGraphState, fill_argb,
- stroke_argb, pClippingPath, nFlag);
+ return pDevice->DrawTextPathWithFlags(
+ CharPosList.m_nChars, CharPosList.m_pCharPos, &pFont->m_Font, pCache,
+ font_size, pText2User, pUser2Device, pGraphState, fill_argb, stroke_argb,
+ pClippingPath, nFlag);
}
+
void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
int left,
int top,
diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp
index 2d3ba566be..d6c7b18b47 100644
--- a/core/fxge/ge/fx_ge_device.cpp
+++ b/core/fxge/ge/fx_ge_device.cpp
@@ -112,29 +112,16 @@ void CFX_RenderDevice::UpdateClipBox() {
m_ClipBox.bottom = m_Height;
}
-FX_BOOL CFX_RenderDevice::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) {
- uint8_t fill_alpha, stroke_alpha;
- if (FXGETFLAG_COLORTYPE(alpha_flag)) {
- fill_alpha = FXGETFLAG_ALPHA_FILL(alpha_flag);
- stroke_alpha = FXGETFLAG_ALPHA_STROKE(alpha_flag);
- } else {
- fill_alpha = FXARGB_A(fill_color);
- stroke_alpha = FXARGB_A(stroke_color);
- }
- if ((fill_mode & 3) == 0) {
- fill_alpha = 0;
- }
- if (!pGraphState) {
- stroke_alpha = 0;
- }
+FX_BOOL CFX_RenderDevice::DrawPathWithBlend(
+ const CFX_PathData* pPathData,
+ const CFX_Matrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState,
+ uint32_t fill_color,
+ uint32_t stroke_color,
+ int fill_mode,
+ int blend_type) {
+ uint8_t stroke_alpha = pGraphState ? FXARGB_A(stroke_color) : 0;
+ uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0;
if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) {
FX_PATHPOINT* pPoints = pPathData->GetPoints();
FX_FLOAT x1, x2, y1, y2;
@@ -149,8 +136,8 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData,
x2 = pPoints[1].m_PointX;
y2 = pPoints[1].m_PointY;
}
- DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, alpha_flag,
- pIccTransform, blend_type);
+ DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, fill_color, fill_mode,
+ blend_type);
return TRUE;
}
if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) &&
@@ -189,8 +176,7 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData,
rect_i.bottom--;
}
}
- if (FillRect(&rect_i, fill_color, alpha_flag, pIccTransform,
- blend_type)) {
+ if (FillRectWithBlend(&rect_i, fill_color, blend_type)) {
return TRUE;
}
}
@@ -205,12 +191,7 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData,
graphState.m_LineWidth = 0.0f;
uint32_t strokecolor = fill_color;
if (bThin) {
- if (FXGETFLAG_COLORTYPE(alpha_flag)) {
- FXSETFLAG_ALPHA_STROKE(alpha_flag, fill_alpha >> 2);
- } else {
- strokecolor =
- (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff));
- }
+ strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff));
}
CFX_Matrix* pMatrix = NULL;
if (pObject2Device && !pObject2Device->IsIdentity()) {
@@ -221,24 +202,22 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData,
smooth_path |= FXFILL_NOPATHSMOOTH;
}
m_pDeviceDriver->DrawPath(&newPath, pMatrix, &graphState, 0, strokecolor,
- smooth_path, alpha_flag, pIccTransform,
- blend_type);
+ smooth_path, 0, nullptr, blend_type);
}
}
if ((fill_mode & 3) && fill_alpha && stroke_alpha < 0xff &&
(fill_mode & FX_FILL_STROKE)) {
if (m_RenderCaps & FXRC_FILLSTROKE_PATH) {
return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState,
- fill_color, stroke_color, fill_mode,
- alpha_flag, pIccTransform, blend_type);
+ fill_color, stroke_color, fill_mode, 0,
+ nullptr, blend_type);
}
return DrawFillStrokePath(pPathData, pObject2Device, pGraphState,
- fill_color, stroke_color, fill_mode, alpha_flag,
- pIccTransform, blend_type);
+ fill_color, stroke_color, fill_mode, blend_type);
}
return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState,
- fill_color, stroke_color, fill_mode,
- alpha_flag, pIccTransform, blend_type);
+ fill_color, stroke_color, fill_mode, 0,
+ nullptr, blend_type);
}
// This can be removed once PDFium entirely relies on Skia
@@ -249,8 +228,6 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath(
uint32_t fill_color,
uint32_t stroke_color,
int fill_mode,
- int alpha_flag,
- void* pIccTransform,
int blend_type) {
if (!(m_RenderCaps & FXRC_GET_BITS)) {
return FALSE;
@@ -293,7 +270,7 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath(
matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0);
if (!bitmap_device.GetDeviceDriver()->DrawPath(
pPathData, &matrix, pGraphState, fill_color, stroke_color,
- fill_mode, alpha_flag, pIccTransform, blend_type)) {
+ fill_mode, 0, nullptr, blend_type)) {
return FALSE;
}
FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX),
@@ -302,38 +279,32 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath(
rect.top, FXDIB_BLEND_NORMAL);
}
-FX_BOOL CFX_RenderDevice::SetPixel(int x,
- int y,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform) {
- if (m_pDeviceDriver->SetPixel(x, y, color, alpha_flag, pIccTransform)) {
+FX_BOOL CFX_RenderDevice::SetPixel(int x, int y, uint32_t color) {
+ if (m_pDeviceDriver->SetPixel(x, y, color, 0, nullptr))
return TRUE;
- }
+
FX_RECT rect(x, y, x + 1, y + 1);
- return FillRect(&rect, color, alpha_flag, pIccTransform);
+ return FillRectWithBlend(&rect, color, FXDIB_BLEND_NORMAL);
}
-FX_BOOL CFX_RenderDevice::FillRect(const FX_RECT* pRect,
- uint32_t fill_color,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) {
- if (m_pDeviceDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform,
- blend_type)) {
+
+FX_BOOL CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect,
+ uint32_t fill_color,
+ int blend_type) {
+ if (m_pDeviceDriver->FillRect(pRect, fill_color, 0, nullptr, blend_type))
return TRUE;
- }
- if (!(m_RenderCaps & FXRC_GET_BITS)) {
+
+ if (!(m_RenderCaps & FXRC_GET_BITS))
return FALSE;
- }
+
CFX_DIBitmap bitmap;
- if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) {
+ if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height()))
return FALSE;
- }
- if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) {
+
+ if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top))
return FALSE;
- }
+
if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color,
- alpha_flag, pIccTransform)) {
+ 0, nullptr)) {
return FALSE;
}
FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height());
@@ -341,50 +312,42 @@ FX_BOOL CFX_RenderDevice::FillRect(const FX_RECT* pRect,
FXDIB_BLEND_NORMAL);
return TRUE;
}
-FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1,
- FX_FLOAT y1,
- FX_FLOAT x2,
- FX_FLOAT y2,
- uint32_t color,
- int fill_mode,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) {
- if (((m_RenderCaps & FXRC_ALPHA_PATH) &&
- (FXGETFLAG_COLORTYPE(alpha_flag) &&
- FXGETFLAG_ALPHA_FILL(alpha_flag) == 0xff)) ||
- color >= 0xff000000) {
- if (m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, alpha_flag,
- pIccTransform, blend_type)) {
- return TRUE;
- }
+
+FX_BOOL CFX_RenderDevice::DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ uint32_t color,
+ int fill_mode,
+ int blend_type) {
+ if ((color >= 0xff000000) &&
+ m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, 0, nullptr,
+ blend_type)) {
+ return TRUE;
}
CFX_GraphStateData graph_state;
CFX_PathData path;
path.SetPointCount(2);
path.SetPoint(0, x1, y1, FXPT_MOVETO);
path.SetPoint(1, x2, y2, FXPT_LINETO);
- return m_pDeviceDriver->DrawPath(&path, NULL, &graph_state, 0, color,
- fill_mode, alpha_flag, pIccTransform,
- blend_type);
+ return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color,
+ fill_mode, 0, nullptr, blend_type);
}
-FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap,
- int left,
- int top,
- void* pIccTransform) {
- if (!(m_RenderCaps & FXRC_GET_BITS)) {
+
+FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) {
+ if (!(m_RenderCaps & FXRC_GET_BITS))
return FALSE;
- }
- return m_pDeviceDriver->GetDIBits(pBitmap, left, top, pIccTransform);
+ return m_pDeviceDriver->GetDIBits(pBitmap, left, top, nullptr);
}
+
CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() {
return m_pDeviceDriver->GetBackDrop();
}
-FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap,
- int left,
- int top,
- int blend_mode,
- void* pIccTransform) {
+
+FX_BOOL CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap,
+ int left,
+ int top,
+ int blend_mode) {
ASSERT(!pBitmap->IsAlphaMask());
CFX_Matrix ctm = GetCTM();
FX_FLOAT fScaleX = FXSYS_fabs(ctm.a);
@@ -422,7 +385,7 @@ FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap,
}
if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height,
pBitmap, src_rect.left, src_rect.top,
- blend_mode, NULL, FALSE, pIccTransform)) {
+ blend_mode, nullptr, FALSE, nullptr)) {
return FALSE;
}
FX_RECT src_rect(0, 0, bg_pixel_width, bg_pixel_height);
@@ -430,70 +393,66 @@ FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap,
dest_rect.top, FXDIB_BLEND_NORMAL);
}
return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left,
- dest_rect.top, blend_mode, 0,
- pIccTransform);
+ dest_rect.top, blend_mode, 0, nullptr);
}
-FX_BOOL CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap,
- int left,
- int top,
- int dest_width,
- int dest_height,
- uint32_t flags,
- void* pIccTransform,
- int blend_mode) {
+
+FX_BOOL CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend(
+ const CFX_DIBSource* pBitmap,
+ int left,
+ int top,
+ int dest_width,
+ int dest_height,
+ uint32_t flags,
+ int blend_mode) {
FX_RECT dest_rect(left, top, left + dest_width, top + dest_height);
FX_RECT clip_box = m_ClipBox;
clip_box.Intersect(dest_rect);
- if (clip_box.IsEmpty()) {
+ if (clip_box.IsEmpty())
return TRUE;
- }
return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width,
dest_height, &clip_box, flags, 0,
- pIccTransform, blend_mode);
+ nullptr, blend_mode);
}
+
FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap,
int left,
int top,
- uint32_t argb,
- int alpha_flag,
- void* pIccTransform) {
+ uint32_t argb) {
FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top,
- FXDIB_BLEND_NORMAL, alpha_flag,
- pIccTransform);
+ FXDIB_BLEND_NORMAL, 0, nullptr);
}
-FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap,
- int left,
- int top,
- int dest_width,
- int dest_height,
- uint32_t argb,
- uint32_t flags,
- int alpha_flag,
- void* pIccTransform) {
+
+FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap,
+ int left,
+ int top,
+ int dest_width,
+ int dest_height,
+ uint32_t argb,
+ uint32_t flags) {
FX_RECT dest_rect(left, top, left + dest_width, top + dest_height);
FX_RECT clip_box = m_ClipBox;
clip_box.Intersect(dest_rect);
return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width,
- dest_height, &clip_box, flags,
- alpha_flag, pIccTransform);
+ dest_height, &clip_box, flags, 0,
+ nullptr);
}
-FX_BOOL CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap,
- int bitmap_alpha,
- uint32_t argb,
- const CFX_Matrix* pMatrix,
- uint32_t flags,
- void*& handle,
- int alpha_flag,
- void* pIccTransform,
- int blend_mode) {
+
+FX_BOOL CFX_RenderDevice::StartDIBitsWithBlend(const CFX_DIBSource* pBitmap,
+ int bitmap_alpha,
+ uint32_t argb,
+ const CFX_Matrix* pMatrix,
+ uint32_t flags,
+ void*& handle,
+ int blend_mode) {
return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix,
- flags, handle, alpha_flag, pIccTransform,
- blend_mode);
+ flags, handle, 0, nullptr, blend_mode);
}
+
FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) {
return m_pDeviceDriver->ContinueDIBits(handle, pPause);
}
+
void CFX_RenderDevice::CancelDIBits(void* handle) {
m_pDeviceDriver->CancelDIBits(handle);
}
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index f2867aaf11..aeac66b4b0 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -427,9 +427,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
FX_FLOAT font_size,
const CFX_Matrix* pText2Device,
uint32_t fill_color,
- uint32_t text_flags,
- int alpha_flag,
- void* pIccTransform) {
+ uint32_t text_flags) {
int nativetext_flags = text_flags;
if (m_DeviceClass != FXDC_DISPLAY) {
if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) {
@@ -445,16 +443,12 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
if (should_call_draw_device_text &&
m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache,
pText2Device, font_size, fill_color,
- alpha_flag, pIccTransform)) {
+ 0, nullptr)) {
return TRUE;
}
}
- int alpha = FXGETFLAG_COLORTYPE(alpha_flag)
- ? FXGETFLAG_ALPHA_FILL(alpha_flag)
- : FXARGB_A(fill_color);
- if (alpha < 255) {
+ if (FXARGB_A(fill_color) < 255)
return FALSE;
- }
} else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) {
bool should_call_draw_device_text = true;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
@@ -465,8 +459,8 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
#endif
if (should_call_draw_device_text &&
m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCache,
- pText2Device, font_size, fill_color,
- alpha_flag, pIccTransform)) {
+ pText2Device, font_size, fill_color, 0,
+ nullptr)) {
return TRUE;
}
}
@@ -484,9 +478,9 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) {
int nPathFlags =
(text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NOPATHSMOOTH;
- return DrawTextPath(nChars, pCharPos, pFont, pCache, font_size,
- pText2Device, NULL, NULL, fill_color, 0, NULL,
- nPathFlags, alpha_flag, pIccTransform);
+ return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size,
+ pText2Device, nullptr, nullptr, fill_color,
+ 0, nullptr, nPathFlags);
}
}
int anti_alias = FXFT_RENDER_MODE_MONO;
@@ -621,7 +615,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
int g = 0;
int b = 0;
if (anti_alias == FXFT_RENDER_MODE_LCD) {
- Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform);
+ Color2Argb(fill_color, fill_color, (1 << 24), nullptr);
ArgbDecode(fill_color, a, r, g, b);
}
for (const FXTEXT_GLYPHPOS& glyph : glyphs) {
@@ -635,8 +629,8 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
int nrows = pGlyph->GetHeight();
if (anti_alias == FXFT_RENDER_MODE_NORMAL) {
if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_color, 0,
- 0, FXDIB_BLEND_NORMAL, nullptr, FALSE,
- alpha_flag, pIccTransform)) {
+ 0, FXDIB_BLEND_NORMAL, nullptr, FALSE, 0,
+ nullptr)) {
return FALSE;
}
continue;
@@ -653,34 +647,29 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
DrawNormalTextHelper(&bitmap, pGlyph, nrows, left, top, start_col, end_col,
bNormal, bBGRStripe, x_subpixel, a, r, g, b);
}
- if (bitmap.IsAlphaMask()) {
- SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color, alpha_flag,
- pIccTransform);
- } else {
+ if (bitmap.IsAlphaMask())
+ SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color);
+ else
SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top);
- }
-
return TRUE;
}
-FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars,
- const FXTEXT_CHARPOS* pCharPos,
- CFX_Font* pFont,
- CFX_FontCache* pCache,
- FX_FLOAT font_size,
- const CFX_Matrix* pText2User,
- const CFX_Matrix* pUser2Device,
- const CFX_GraphStateData* pGraphState,
- uint32_t fill_color,
- FX_ARGB stroke_color,
- CFX_PathData* pClippingPath,
- int nFlag,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) {
- if (!pCache) {
+FX_BOOL CFX_RenderDevice::DrawTextPathWithFlags(
+ int nChars,
+ const FXTEXT_CHARPOS* pCharPos,
+ CFX_Font* pFont,
+ CFX_FontCache* pCache,
+ FX_FLOAT font_size,
+ const CFX_Matrix* pText2User,
+ const CFX_Matrix* pUser2Device,
+ const CFX_GraphStateData* pGraphState,
+ uint32_t fill_color,
+ FX_ARGB stroke_color,
+ CFX_PathData* pClippingPath,
+ int nFlag) {
+ if (!pCache)
pCache = CFX_GEModule::Get()->GetFontCache();
- }
+
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
FX_FONTCACHE_DEFINE(pCache, pFont);
for (int iChar = 0; iChar < nChars; iChar++) {
@@ -693,37 +682,25 @@ FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars,
charpos.m_OriginY);
const CFX_PathData* pPath = pFaceCache->LoadGlyphPath(
pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
- if (!pPath) {
+ if (!pPath)
continue;
- }
+
matrix.Concat(*pText2User);
CFX_PathData TransformedPath(*pPath);
TransformedPath.Transform(&matrix);
- FX_BOOL bHasAlpha = FXGETFLAG_COLORTYPE(alpha_flag)
- ? (FXGETFLAG_ALPHA_FILL(alpha_flag) ||
- FXGETFLAG_ALPHA_STROKE(alpha_flag))
- : (fill_color || stroke_color);
- if (bHasAlpha) {
+ if (fill_color || stroke_color) {
int fill_mode = nFlag;
- if (FXGETFLAG_COLORTYPE(alpha_flag)) {
- if (FXGETFLAG_ALPHA_FILL(alpha_flag)) {
- fill_mode |= FXFILL_WINDING;
- }
- } else {
- if (fill_color) {
- fill_mode |= FXFILL_WINDING;
- }
- }
+ if (fill_color)
+ fill_mode |= FXFILL_WINDING;
fill_mode |= FX_FILL_TEXT_MODE;
- if (!DrawPath(&TransformedPath, pUser2Device, pGraphState, fill_color,
- stroke_color, fill_mode, alpha_flag, pIccTransform,
- blend_type)) {
+ if (!DrawPathWithBlend(&TransformedPath, pUser2Device, pGraphState,
+ fill_color, stroke_color, fill_mode,
+ FXDIB_BLEND_NORMAL)) {
return FALSE;
}
}
- if (pClippingPath) {
+ if (pClippingPath)
pClippingPath->Append(&TransformedPath, pUser2Device);
- }
}
return TRUE;
}
diff --git a/core/fxge/include/fx_dib.h b/core/fxge/include/fx_dib.h
index a09f88453f..6504e5fd8f 100644
--- a/core/fxge/include/fx_dib.h
+++ b/core/fxge/include/fx_dib.h
@@ -154,11 +154,7 @@ FX_ARGB ArgbEncode(int a, FX_COLORREF rgb);
#define FXGETFLAG_COLORTYPE(flag) (uint8_t)((flag) >> 8)
#define FXGETFLAG_ALPHA_FILL(flag) (uint8_t)(flag)
#define FXGETFLAG_ALPHA_STROKE(flag) (uint8_t)((flag) >> 16)
-#define FXSETFLAG_COLORTYPE(flag, val) \
- flag = (((val) << 8) | (flag & 0xffff00ff))
#define FXSETFLAG_ALPHA_FILL(flag, val) flag = ((val) | (flag & 0xffffff00))
-#define FXSETFLAG_ALPHA_STROKE(flag, val) \
- flag = (((val) << 16) | (flag & 0xff00ffff))
class CFX_DIBSource {
public:
diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h
index 6efd5177bc..c025c1251e 100644
--- a/core/fxge/include/fx_ge.h
+++ b/core/fxge/include/fx_ge.h
@@ -217,7 +217,6 @@ class CFX_RenderDevice {
void EndRendering();
void SaveState();
void RestoreState(bool bKeepSaved);
-
int GetWidth() const { return m_Width; }
int GetHeight() const { return m_Height; }
int GetDeviceClass() const { return m_DeviceClass; }
@@ -225,108 +224,119 @@ class CFX_RenderDevice {
int GetRenderCaps() const { return m_RenderCaps; }
int GetDeviceCaps(int id) const;
CFX_Matrix GetCTM() const;
-
CFX_DIBitmap* GetBitmap() const { return m_pBitmap; }
void SetBitmap(CFX_DIBitmap* pBitmap) { m_pBitmap = pBitmap; }
-
FX_BOOL CreateCompatibleBitmap(CFX_DIBitmap* pDIB,
int width,
int height) const;
-
const FX_RECT& GetClipBox() const { return m_ClipBox; }
-
FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode);
-
FX_BOOL SetClip_Rect(const FX_RECT& pRect);
FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
const CFX_GraphStateData* pGraphState);
-
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 = 0,
- void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL);
-
- FX_BOOL SetPixel(int x,
- int y,
- uint32_t color,
- int alpha_flag = 0,
- void* pIccTransform = NULL);
-
- FX_BOOL FillRect(const FX_RECT* pRect,
- uint32_t color,
- int alpha_flag = 0,
- void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL);
-
+ int fill_mode) {
+ return DrawPathWithBlend(pPathData, pObject2Device, pGraphState, fill_color,
+ stroke_color, fill_mode, FXDIB_BLEND_NORMAL);
+ }
+ FX_BOOL DrawPathWithBlend(const CFX_PathData* pPathData,
+ const CFX_Matrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState,
+ uint32_t fill_color,
+ uint32_t stroke_color,
+ int fill_mode,
+ int blend_type);
+ FX_BOOL SetPixel(int x, int y, uint32_t color);
+ FX_BOOL FillRect(const FX_RECT* pRect, uint32_t color) {
+ return FillRectWithBlend(pRect, color, FXDIB_BLEND_NORMAL);
+ }
+ FX_BOOL FillRectWithBlend(const FX_RECT* pRect,
+ uint32_t color,
+ int blend_type);
FX_BOOL DrawCosmeticLine(FX_FLOAT x1,
FX_FLOAT y1,
FX_FLOAT x2,
FX_FLOAT y2,
- uint32_t color,
- int fill_mode = 0,
- int alpha_flag = 0,
- void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL);
-
- FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap,
- int left,
- int top,
- void* pIccTransform = NULL);
-
+ uint32_t color) {
+ return DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, color, 0,
+ FXDIB_BLEND_NORMAL);
+ }
+ FX_BOOL DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ uint32_t color,
+ int fill_mode,
+ int blend_type);
+
+ FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top);
CFX_DIBitmap* GetBackDrop();
-
- FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
- int left,
- int top,
- int blend_type = FXDIB_BLEND_NORMAL,
- void* pIccTransform = NULL);
-
+ FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, int left, int top) {
+ return SetDIBitsWithBlend(pBitmap, left, top, FXDIB_BLEND_NORMAL);
+ }
+ FX_BOOL SetDIBitsWithBlend(const CFX_DIBSource* pBitmap,
+ int left,
+ int top,
+ int blend_type);
FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
int left,
int top,
int dest_width,
- int dest_height,
- uint32_t flags = 0,
- void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL);
-
+ int dest_height) {
+ return StretchDIBitsWithFlagsAndBlend(pBitmap, left, top, dest_width,
+ dest_height, 0, FXDIB_BLEND_NORMAL);
+ }
+ FX_BOOL StretchDIBitsWithFlagsAndBlend(const CFX_DIBSource* pBitmap,
+ int left,
+ int top,
+ int dest_width,
+ int dest_height,
+ uint32_t flags,
+ int blend_type);
FX_BOOL SetBitMask(const CFX_DIBSource* pBitmap,
int left,
int top,
- uint32_t color,
- int alpha_flag = 0,
- void* pIccTransform = NULL);
-
+ uint32_t color);
FX_BOOL StretchBitMask(const CFX_DIBSource* pBitmap,
int left,
int top,
int dest_width,
int dest_height,
- uint32_t color,
- uint32_t flags = 0,
- int alpha_flag = 0,
- void* pIccTransform = NULL);
-
+ uint32_t color) {
+ return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height,
+ color, 0);
+ }
+ FX_BOOL StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap,
+ int left,
+ int top,
+ int dest_width,
+ int dest_height,
+ uint32_t color,
+ uint32_t flags);
FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
int bitmap_alpha,
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t flags,
- void*& handle,
- int alpha_flag = 0,
- void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL);
-
+ void*& handle) {
+ return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, pMatrix, flags,
+ handle, FXDIB_BLEND_NORMAL);
+ }
+ FX_BOOL StartDIBitsWithBlend(const CFX_DIBSource* pBitmap,
+ int bitmap_alpha,
+ uint32_t color,
+ const CFX_Matrix* pMatrix,
+ uint32_t flags,
+ void*& handle,
+ int blend_type);
FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause);
-
void CancelDIBits(void* handle);
FX_BOOL DrawNormalText(int nChars,
@@ -336,10 +346,7 @@ class CFX_RenderDevice {
FX_FLOAT font_size,
const CFX_Matrix* pText2Device,
uint32_t fill_color,
- uint32_t text_flags,
- int alpha_flag = 0,
- void* pIccTransform = NULL);
-
+ uint32_t text_flags);
FX_BOOL DrawTextPath(int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
@@ -350,13 +357,23 @@ class CFX_RenderDevice {
const CFX_GraphStateData* pGraphState,
uint32_t fill_color,
uint32_t stroke_color,
- CFX_PathData* pClippingPath,
- int nFlag = 0,
- int alpha_flag = 0,
- void* pIccTransform = NULL,
- int blend_type = FXDIB_BLEND_NORMAL);
- virtual void Begin() {}
- virtual void End() {}
+ CFX_PathData* pClippingPath) {
+ return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size,
+ pText2User, pUser2Device, pGraphState,
+ fill_color, stroke_color, pClippingPath, 0);
+ }
+ FX_BOOL DrawTextPathWithFlags(int nChars,
+ const FXTEXT_CHARPOS* pCharPos,
+ CFX_Font* pFont,
+ CFX_FontCache* pCache,
+ FX_FLOAT font_size,
+ const CFX_Matrix* pText2User,
+ const CFX_Matrix* pUser2Device,
+ const CFX_GraphStateData* pGraphState,
+ uint32_t fill_color,
+ uint32_t stroke_color,
+ CFX_PathData* pClippingPath,
+ int nFlag);
private:
void InitDeviceInfo();
@@ -367,8 +384,6 @@ class CFX_RenderDevice {
uint32_t fill_color,
uint32_t stroke_color,
int fill_mode,
- int alpha_flag,
- void* pIccTransform,
int blend_type);
CFX_DIBitmap* m_pBitmap;
@@ -416,8 +431,6 @@ class IFX_RenderDeviceDriver {
FX_BOOL bGroupKnockout = FALSE);
virtual ~IFX_RenderDeviceDriver() {}
- virtual void Begin() {}
- virtual void End() {}
virtual int GetDeviceCaps(int caps_id) = 0;
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index 957a31f584..2a9638e817 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -558,10 +558,11 @@ FX_BOOL CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice,
m_BlendType = blendType;
return StartDIBSource();
}
+
FX_BOOL CXFA_ImageRenderer::StartDIBSource() {
- if (m_pDevice->StartDIBits(m_pDIBSource, m_BitmapAlpha, m_FillArgb,
- &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL,
- m_BlendType)) {
+ if (m_pDevice->StartDIBitsWithBlend(m_pDIBSource, m_BitmapAlpha, m_FillArgb,
+ &m_ImageMatrix, m_Flags, m_DeviceHandle,
+ m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
return TRUE;
@@ -607,8 +608,9 @@ FX_BOOL CXFA_ImageRenderer::StartDIBSource() {
dest_left = dest_width > 0 ? image_rect.left : image_rect.right;
dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) {
- if (m_pDevice->StretchDIBits(m_pDIBSource, dest_left, dest_top, dest_width,
- dest_height, m_Flags, NULL, m_BlendType)) {
+ if (m_pDevice->StretchDIBitsWithFlagsAndBlend(
+ m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags,
+ m_BlendType)) {
return FALSE;
}
}
@@ -616,8 +618,9 @@ FX_BOOL CXFA_ImageRenderer::StartDIBSource() {
if (m_BitmapAlpha != 255) {
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
}
- if (m_pDevice->StretchBitMask(m_pDIBSource, dest_left, dest_top, dest_width,
- dest_height, m_FillArgb, m_Flags)) {
+ if (m_pDevice->StretchBitMaskWithFlags(m_pDIBSource, dest_left, dest_top,
+ dest_width, dest_height, m_FillArgb,
+ m_Flags)) {
return FALSE;
}
}
@@ -658,9 +661,9 @@ FX_BOOL CXFA_ImageRenderer::Continue(IFX_Pause* pPause) {
} else {
if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
- m_Result =
- m_pDevice->SetDIBits(pBitmap.get(), m_pTransformer->result().left,
- m_pTransformer->result().top, m_BlendType);
+ m_Result = m_pDevice->SetDIBitsWithBlend(
+ pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_BlendType);
}
return FALSE;
}
@@ -711,7 +714,7 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
if (pDIBitmap->IsAlphaMask()) {
return;
}
- m_pDevice->SetDIBits(pDIBitmap, left, top, blend_mode);
+ m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode);
} else {
FX_RECT rect(left, top, left + pDIBitmap->GetWidth(),
top + pDIBitmap->GetHeight());
@@ -738,10 +741,10 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
if (m_pDevice->GetBackDrop()) {
m_pDevice->SetDIBits(pClone, rect.left, rect.top);
} else {
- if (pDIBitmap->IsAlphaMask()) {
+ if (pDIBitmap->IsAlphaMask())
return;
- }
- m_pDevice->SetDIBits(pDIBitmap, rect.left, rect.top, blend_mode);
+ m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top,
+ blend_mode);
}
if (bClone) {
delete pClone;