summaryrefslogtreecommitdiff
path: root/xfa/src/fxfa/app/xfa_rendercontext.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-08 13:49:22 -0500
committerDan Sinclair <dsinclair@chromium.org>2016-03-08 13:49:22 -0500
commit6cdf084fa40a62eb33185171622ad12d95c6009e (patch)
treedaeea24a81365ed27582f280b7f19add0cb7b0d7 /xfa/src/fxfa/app/xfa_rendercontext.cpp
parent653e0797debddb4e9aecbc6cde65748d43b18b79 (diff)
downloadpdfium-6cdf084fa40a62eb33185171622ad12d95c6009e.tar.xz
Remove xfa/src/fxfa/src/common and xfa/src/fxfa/src
This Cl moves the code in xfa/src/fxfa/src/common to the diretory which contains the respective implementations and removes the xfa/src/fxfa/src/common directory. It them moves all of the code in xfa/src/fxfa/src up one level and removes the xfa/src/fxfa/src directory. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1770073003 .
Diffstat (limited to 'xfa/src/fxfa/app/xfa_rendercontext.cpp')
-rw-r--r--xfa/src/fxfa/app/xfa_rendercontext.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/xfa/src/fxfa/app/xfa_rendercontext.cpp b/xfa/src/fxfa/app/xfa_rendercontext.cpp
new file mode 100644
index 0000000000..cc5402eb99
--- /dev/null
+++ b/xfa/src/fxfa/app/xfa_rendercontext.cpp
@@ -0,0 +1,77 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/src/fxfa/app/xfa_rendercontext.h"
+
+#include "xfa/include/fxgraphics/fx_graphics.h"
+#include "xfa/src/fxfa/app/xfa_ffwidget.h"
+
+#define XFA_RENDERCONTEXT_MaxCount 30
+
+IXFA_RenderContext* XFA_RenderContext_Create() {
+ return new CXFA_RenderContext;
+}
+CXFA_RenderContext::CXFA_RenderContext() {
+ m_pWidgetIterator = NULL;
+ m_pWidget = NULL;
+ m_pPageView = NULL;
+ m_pGS = NULL;
+ m_dwStatus = 0;
+ m_matrix.SetIdentity();
+ m_rtClipRect.Reset();
+}
+CXFA_RenderContext::~CXFA_RenderContext() {
+ StopRender();
+}
+int32_t CXFA_RenderContext::StartRender(IXFA_PageView* pPageView,
+ CFX_Graphics* pGS,
+ const CFX_Matrix& matrix,
+ const CXFA_RenderOptions& options) {
+ m_pPageView = pPageView;
+ m_pGS = pGS;
+ m_matrix = matrix;
+ m_options = options;
+ CFX_RectF rtPage;
+ pGS->GetClipRect(rtPage);
+ CFX_Matrix mtRes;
+ mtRes.SetReverse(matrix);
+ m_rtClipRect.Set(rtPage.left, rtPage.top, rtPage.width, rtPage.height);
+ mtRes.TransformRect(m_rtClipRect);
+ m_dwStatus = m_options.m_bHighlight ? XFA_WIDGETSTATUS_Highlight : 0;
+ FX_DWORD dwFilterType = XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_AllType |
+ (m_options.m_bPrint ? XFA_WIDGETSTATUS_Printable
+ : XFA_WIDGETSTATUS_Viewable);
+ m_pWidgetIterator =
+ m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType);
+ m_pWidget = m_pWidgetIterator->MoveToNext();
+ return XFA_RENDERSTATUS_Ready;
+}
+int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) {
+ int32_t iCount = 0;
+ while (m_pWidget) {
+ CXFA_FFWidget* pWidget = (CXFA_FFWidget*)m_pWidget;
+ CFX_RectF rtWidgetBox;
+ pWidget->GetBBox(rtWidgetBox, XFA_WIDGETSTATUS_Visible);
+ rtWidgetBox.width += 1;
+ rtWidgetBox.height += 1;
+ if (rtWidgetBox.IntersectWith(m_rtClipRect)) {
+ pWidget->RenderWidget(m_pGS, &m_matrix, m_dwStatus);
+ }
+ m_pWidget = m_pWidgetIterator->MoveToNext();
+ iCount++;
+ if (iCount > XFA_RENDERCONTEXT_MaxCount && pPause &&
+ pPause->NeedToPauseNow()) {
+ return XFA_RENDERSTATUS_ToBeContinued;
+ }
+ }
+ return XFA_RENDERSTATUS_Done;
+}
+void CXFA_RenderContext::StopRender() {
+ if (m_pWidgetIterator) {
+ m_pWidgetIterator->Release();
+ m_pWidgetIterator = NULL;
+ }
+}