CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BOOL bInline) { if (!pStream && !pImage) { return NULL; } CFX_Matrix ImageMatrix; ImageMatrix.Copy(m_pCurStates->m_CTM); ImageMatrix.Concat(m_mtContentToUser); CPDF_ImageObject* pImageObj = new CPDF_ImageObject; if (pImage) { pImageObj->m_pImage = m_pDocument->GetPageData()->GetImage(pImage->GetStream()); } else if (pStream->GetObjNum()) { pImageObj->m_pImage = m_pDocument->LoadImageF(pStream); } else { pImageObj->m_pImage = new CPDF_Image(m_pDocument); pImageObj->m_pImage->LoadImageF(pStream, bInline); } SetGraphicStates(pImageObj, pImageObj->m_pImage->IsMask(), FALSE, FALSE); pImageObj->m_Matrix = ImageMatrix; pImageObj->CalcBoundingBox(); m_pObjectList->m_ObjectList.AddTail(pImageObj); return pImageObj; }
FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, const CFX_Matrix* pObj2Device) { #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictBy("OC"); if (pOC && m_Options.m_pOCContext && !m_Options.m_pOCContext->CheckOCGVisible(pOC)) { return TRUE; } CFX_Matrix matrix = pFormObj->m_FormMatrix; matrix.Concat(*pObj2Device); CPDF_Dictionary* pResources = nullptr; if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { pResources = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); } CPDF_RenderStatus status; status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj, &m_Options, m_Transparency, m_bDropObjects, pResources, FALSE); status.m_curBlend = m_curBlend; m_pDevice->SaveState(); status.RenderObjectList(pFormObj->m_pForm.get(), &matrix); m_bStopped = status.m_bStopped; m_pDevice->RestoreState(false); #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif return TRUE; }
IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, FX_FLOAT x, FX_FLOAT y) { if (!parent) return nullptr; FX_FLOAT x1; FX_FLOAT y1; IFWL_Widget* child = GetLastChildWidget(parent); while (child) { if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { x1 = x; y1 = y; CFX_Matrix matrixOnParent; child->GetMatrix(matrixOnParent); CFX_Matrix m; m.SetIdentity(); m.SetReverse(matrixOnParent); m.TransformPoint(x1, y1); CFX_RectF bounds; child->GetWidgetRect(bounds); if (bounds.Contains(x1, y1)) { x1 -= bounds.left; y1 -= bounds.top; return GetWidgetAtPoint(child, x1, y1); } } child = GetPriorSiblingWidget(child); } return parent; }
CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode( const CPDF_TextObject* pTextObj) const { size_t nChars = pTextObj->CountChars(); if (nChars <= 1) return m_TextlineDir; CPDF_TextObjectItem first, last; pTextObj->GetCharInfo(0, &first); pTextObj->GetCharInfo(nChars - 1, &last); CFX_Matrix textMatrix = pTextObj->GetTextMatrix(); first.m_Origin = textMatrix.Transform(first.m_Origin); last.m_Origin = textMatrix.Transform(last.m_Origin); static constexpr float kEpsilon = 0.0001f; float dX = fabs(last.m_Origin.x - first.m_Origin.x); float dY = fabs(last.m_Origin.y - first.m_Origin.y); if (dX <= kEpsilon && dY <= kEpsilon) return TextOrientation::Unknown; static constexpr float kThreshold = 0.0872f; CFX_VectorF v(dX, dY); v.Normalize(); bool bXUnderThreshold = v.x <= kThreshold; if (v.y <= kThreshold) return bXUnderThreshold ? m_TextlineDir : TextOrientation::Horizontal; return bXUnderThreshold ? TextOrientation::Vertical : m_TextlineDir; }
void CFWL_PictureBoxImp::DrawBkground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { IFWL_PictureBoxDP* pPictureDP = static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider); if (!pPictureDP) return; CFX_DIBitmap* pPicture = pPictureDP->GetPicture(m_pInterface); CFX_Matrix matrix; pPictureDP->GetMatrix(m_pInterface, matrix); if (!pPicture) return; matrix.Concat(*pMatrix); FX_FLOAT fx = (FX_FLOAT)pPicture->GetWidth(); FX_FLOAT fy = (FX_FLOAT)pPicture->GetHeight(); if (fx > m_rtClient.width) { fx = m_rtClient.width; } if (fy > m_rtClient.height) { fy = m_rtClient.height; } pGraphics->DrawImage(pPicture, CFX_PointF((m_rtClient.width - fx) / 2, (m_rtClient.height - fy) / 2), &matrix); }
void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern, CPDF_PageObject* pPageObj, const CFX_Matrix* pObj2Device, FX_BOOL bStroke) { if (!pattern->Load()) { return; } m_pDevice->SaveState(); if (pPageObj->m_Type == PDFPAGE_PATH) { if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) { m_pDevice->RestoreState(); return; } } else if (pPageObj->m_Type == PDFPAGE_IMAGE) { FX_RECT rect = pPageObj->GetBBox(pObj2Device); m_pDevice->SetClip_Rect(&rect); } else { return; } FX_RECT rect; if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) { m_pDevice->RestoreState(); return; } CFX_Matrix matrix = pattern->m_Pattern2Form; matrix.Concat(*pObj2Device); GetScaledMatrix(matrix); int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke); DrawShading(pattern, &matrix, rect, alpha, m_Options.m_ColorMode == RENDER_COLOR_ALPHA); m_pDevice->RestoreState(); }
static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc, CPDF_PageRenderCache* pCache, CPDF_TilingPattern* pPattern, const CFX_Matrix* pObject2Device, int width, int height, int flags) { CFX_DIBitmap* pBitmap = new CFX_DIBitmap; if (!pBitmap->Create(width, height, pPattern->m_bColored ? FXDIB_Argb : FXDIB_8bppMask)) { delete pBitmap; return NULL; } CFX_FxgeDevice bitmap_device; bitmap_device.Attach(pBitmap); pBitmap->Clear(0); CFX_FloatRect cell_bbox = pPattern->m_BBox; pPattern->m_Pattern2Form.TransformRect(cell_bbox); pObject2Device->TransformRect(cell_bbox); CFX_FloatRect bitmap_rect(0.0f, 0.0f, (FX_FLOAT)width, (FX_FLOAT)height); CFX_Matrix mtAdjust; mtAdjust.MatchRect(bitmap_rect, cell_bbox); CFX_Matrix mtPattern2Bitmap = *pObject2Device; mtPattern2Bitmap.Concat(mtAdjust); CPDF_RenderOptions options; if (!pPattern->m_bColored) { options.m_ColorMode = RENDER_COLOR_ALPHA; } flags |= RENDER_FORCE_HALFTONE; options.m_Flags = flags; CPDF_RenderContext context(pDoc, pCache); context.DrawObjectList(&bitmap_device, pPattern->m_pForm, &mtPattern2Bitmap, &options); return pBitmap; }
void CXFA_FFPushButton::RenderHighlightCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); CXFA_Caption caption = m_pDataAcc->GetCaption(); if (caption && caption.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); CFX_RectF rtWidget; GetRectWithoutRotate(rtWidget); CFX_RectF rtClip = m_rtCaption; rtClip.Intersect(rtWidget); CFX_Matrix mt; mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); if (pMatrix) { pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); } { uint32_t dwState = m_pNormalWidget->GetStates(); if (m_pDownTextLayout && (dwState & FWL_STATE_PSB_Pressed) && (dwState & FWL_STATE_PSB_Hovered)) { if (m_pDownTextLayout->DrawString(pRenderDevice, mt, rtClip)) { return; } } else if (m_pRolloverTextLayout && (dwState & FWL_STATE_PSB_Hovered)) { if (m_pRolloverTextLayout->DrawString(pRenderDevice, mt, rtClip)) { return; } } } if (pCapTextLayout) { pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); } } }
void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, CFX_Matrix* pMatrix, CPDF_Page* pPage, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions) { if (m_pWidgetDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN) return; CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode); if (!pStream) return; CFX_FloatRect form_bbox = pStream->GetDict()->GetRectBy("BBox"); CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixBy("Matrix"); form_matrix.TransformRect(form_bbox); CFX_FloatRect arect = m_pWidgetDict->GetRectBy("Rect"); CFX_Matrix matrix; matrix.MatchRect(arect, form_bbox); matrix.Concat(*pMatrix); CPDF_Form form(m_pField->m_pForm->m_pDocument, m_pField->m_pForm->m_pFormDict->GetDictBy("DR"), pStream); form.ParseContent(nullptr, nullptr, nullptr); CPDF_RenderContext context(pPage); context.AppendLayer(&form, &matrix); context.Render(pDevice, pOptions, nullptr); }
FX_RECT CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const { CFX_FloatRect rcTemp = rect; CFX_Matrix mt = GetWindowMatrix(); mt.TransformRect(rcTemp); return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5), (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5)); }
void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device) { FX_RECT rect; if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { return; } int res = 300; if (pObj->IsImage() && m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { res = 0; } CPDF_ScaledRenderBuffer buffer; if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) { return; } CFX_Matrix matrix = *pObj2Device; matrix.Concat(*buffer.GetMatrix()); GetScaledMatrix(matrix); CPDF_Dictionary* pFormResource = nullptr; if (pObj->IsForm()) { const CPDF_FormObject* pFormObj = pObj->AsForm(); if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); } } CPDF_RenderStatus status; status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), nullptr, nullptr, nullptr, &m_Options, m_Transparency, m_bDropObjects, pFormResource); status.RenderSingleObject(pObj, &matrix); buffer.OutputToDevice(); }
void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS, CFX_Matrix* pMatrix, uint32_t dwStatus) { if (!IsMatchVisibleStatus(dwStatus)) { return; } CFX_Matrix mtRotate; GetRotateMatrix(mtRotate); if (pMatrix) { mtRotate.Concat(*pMatrix); } CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); DrawBorder(pGS, borderUI, m_rtUI, &mtRotate, m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round ? XFA_DRAWBOX_ForceRound : 0); RenderCaption(pGS, &mtRotate); DrawHighlight(pGS, &mtRotate, dwStatus, m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round); CFX_Matrix mt; mt.Set(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); mt.Concat(mtRotate); GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), pGS, &mt); }
FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { if (m_pRenderDevice == NULL) { return FDE_RENDERSTATUS_Failed; } if (m_pIterator == NULL) { return FDE_RENDERSTATUS_Failed; } Lock(); FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused; CFX_Matrix rm; rm.SetReverse(m_Transform); CFX_RectF rtDocClip = m_pRenderDevice->GetClipRect(); if (rtDocClip.IsEmpty()) { rtDocClip.left = rtDocClip.top = 0; rtDocClip.width = (FX_FLOAT)m_pRenderDevice->GetWidth(); rtDocClip.height = (FX_FLOAT)m_pRenderDevice->GetHeight(); } rm.TransformRect(rtDocClip); IFDE_VisualSet* pVisualSet; FDE_HVISUALOBJ hVisualObj; CFX_RectF rtObj; int32_t iCount = 0; while (TRUE) { hVisualObj = m_pIterator->GetNext(pVisualSet); if (hVisualObj == NULL || pVisualSet == NULL) { eStatus = FDE_RENDERSTATUS_Done; break; } rtObj.Empty(); pVisualSet->GetRect(hVisualObj, rtObj); if (!rtDocClip.IntersectWith(rtObj)) { continue; } switch (pVisualSet->GetType()) { case FDE_VISUALOBJ_Text: RenderText((IFDE_TextSet*)pVisualSet, hVisualObj); iCount += 5; break; case FDE_VISUALOBJ_Path: RenderPath((IFDE_PathSet*)pVisualSet, hVisualObj); iCount += 20; break; case FDE_VISUALOBJ_Widget: iCount += 10; break; case FDE_VISUALOBJ_Canvas: FXSYS_assert(FALSE); break; default: break; } if (iCount >= 100 && pPause != NULL && pPause->NeedToPauseNow()) { eStatus = FDE_RENDERSTATUS_Paused; break; } } Unlock(); return m_eStatus = eStatus; }
CFX_FloatPoint CFFL_FormFiller::PWLtoFFL(const CFX_FloatPoint& point) { CFX_Matrix mt = GetCurMatrix(); CFX_FloatPoint pt = point; mt.Transform(pt.x, pt.y); return pt; }
CFX_FloatRect CFFL_FormFiller::PWLtoFFL(const CFX_FloatRect& rect) { CFX_Matrix mt = GetCurMatrix(); CFX_FloatRect temp = rect; mt.TransformRect(temp); return temp; }
void IFWL_Widget::TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy) { if (m_pWidgetMgr->IsFormDisabled()) { CFX_SizeF szOffset; if (IsParent(pWidget)) { szOffset = GetOffsetFromParent(pWidget); } else { szOffset = pWidget->GetOffsetFromParent(this); szOffset.x = -szOffset.x; szOffset.y = -szOffset.y; } fx += szOffset.x; fy += szOffset.y; return; } CFX_RectF r; CFX_Matrix m; IFWL_Widget* parent = GetParent(); if (parent) { GetWidgetRect(r); fx += r.left; fy += r.top; GetMatrix(m, true); m.TransformPoint(fx, fy); } IFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); if (!form1) return; if (!pWidget) { form1->GetWidgetRect(r); fx += r.left; fy += r.top; return; } IFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); if (!form2) return; if (form1 != form2) { form1->GetWidgetRect(r); fx += r.left; fy += r.top; form2->GetWidgetRect(r); fx -= r.left; fy -= r.top; } parent = pWidget->GetParent(); if (parent) { pWidget->GetMatrix(m, true); CFX_Matrix m1; m1.SetIdentity(); m1.SetReverse(m); m1.TransformPoint(fx, fy); pWidget->GetWidgetRect(r); fx -= r.left; fy -= r.top; } }
CFX_FloatRect CPWL_Wnd::ChildToParent(const CFX_FloatRect& rect) const { CFX_Matrix mt = GetChildMatrix(); if (mt.IsIdentity()) return rect; CFX_FloatRect rc = rect; mt.TransformRect(rc); return rc; }
CFX_FloatPoint CPWL_Wnd::ChildToParent(const CFX_FloatPoint& point) const { CFX_Matrix mt = GetChildMatrix(); if (mt.IsIdentity()) return point; CFX_FloatPoint pt = point; mt.Transform(pt.x, pt.y); return pt; }
CFX_Matrix CPDF_Array::GetMatrix() { CFX_Matrix matrix; if (!IsArray() || m_Objects.size() != 6) return matrix; matrix.Set(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2), GetNumberAt(3), GetNumberAt(4), GetNumberAt(5)); return matrix; }
CFX_FloatRect CFFL_FormFiller::FFLtoPWL(const CFX_FloatRect& rect) { CFX_Matrix mt; mt.SetReverse(GetCurMatrix()); CFX_FloatRect temp = rect; mt.TransformRect(temp); return temp; }
CFX_FloatPoint CFFL_FormFiller::FFLtoPWL(const CFX_FloatPoint& point) { CFX_Matrix mt; mt.SetReverse(GetCurMatrix()); CFX_FloatPoint pt = point; mt.Transform(pt.x, pt.y); return pt; }
void CPWL_Wnd::PWLtoWnd(const CFX_FloatPoint& point, int32_t& x, int32_t& y) const { CFX_Matrix mt = GetWindowMatrix(); CFX_FloatPoint pt = point; mt.Transform(pt.x, pt.y); x = (int32_t)(pt.x + 0.5); y = (int32_t)(pt.y + 0.5); }
void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect) { CFX_RectF rtText(rect.left, rect.top, rect.width, rect.height); CFX_Matrix rm; rm.SetReverse(m_Matrix); rm.TransformRect(rtText); DrawText(pwsStr, iLength, rtText, m_rtClip); }
CFX_Matrix CPWL_Wnd::GetWindowMatrix() const { CFX_Matrix mt = GetChildToRoot(); if (IPWL_Provider* pProvider = GetProvider()) { mt.Concat(pProvider->GetWindowMatrix(GetAttachedData())); return mt; } return mt; }
FX_BOOL CPWL_EditCtrl::IsWndHorV() { CFX_Matrix mt = GetWindowMatrix(); CFX_FloatPoint point1(0, 1); CFX_FloatPoint point2(1, 1); mt.Transform(point1.x, point1.y); mt.Transform(point2.x, point2.y); return point2.y == point1.y; }
CFX_FloatPoint CPWL_Wnd::ParentToChild(const CFX_FloatPoint& point) const { CFX_Matrix mt = GetChildMatrix(); if (mt.IsIdentity()) return point; mt.SetReverse(mt); CFX_FloatPoint pt = point; mt.Transform(pt.x, pt.y); return pt; }
CFX_FloatRect CPWL_Wnd::ParentToChild(const CFX_FloatRect& rect) const { CFX_Matrix mt = GetChildMatrix(); if (mt.IsIdentity()) return rect; mt.SetReverse(mt); CFX_FloatRect rc = rect; mt.TransformRect(rc); return rc; }
void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended) { CFX_Matrix m; m.Set(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0); if (bPrepended) { FXCRT_Matrix_Concat(*this, m, *this); } else { FXCRT_Matrix_Concat(*this, *this, m); } }
void CFX_Matrix::Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended) { FX_FLOAT cosValue = FXSYS_cos(fRadian); FX_FLOAT sinValue = FXSYS_sin(fRadian); CFX_Matrix m; m.Set(cosValue, sinValue, -sinValue, cosValue, 0, 0); if (bPrepended) { FXCRT_Matrix_Concat(*this, m, *this); } else { FXCRT_Matrix_Concat(*this, *this, m); } }
void CFX_Matrix::Concat(FX_FLOAT a_in, FX_FLOAT b_in, FX_FLOAT c_in, FX_FLOAT d_in, FX_FLOAT e_in, FX_FLOAT f_in, FX_BOOL bPrepended) { CFX_Matrix m; m.Set(a_in, b_in, c_in, d_in, e_in, f_in); Concat(m, bPrepended); }