summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render.cpp16
-rw-r--r--core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h2
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp25
-rw-r--r--core/fpdfdoc/include/cpdf_annot.h1
4 files changed, 39 insertions, 5 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index 887ea30a42..fbb0745506 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -100,7 +100,21 @@ CPDF_RenderOptions::CPDF_RenderOptions()
m_AddFlags(0),
m_pOCContext(nullptr),
m_dwLimitCacheSize(1024 * 1024 * 100),
- m_HalftoneLimit(-1) {}
+ m_HalftoneLimit(-1),
+ m_bDrawAnnots(false) {}
+
+CPDF_RenderOptions::CPDF_RenderOptions(const CPDF_RenderOptions& rhs)
+ : m_ColorMode(rhs.m_ColorMode),
+ m_BackColor(rhs.m_BackColor),
+ m_ForeColor(rhs.m_ForeColor),
+ m_Flags(rhs.m_Flags),
+ m_Interpolation(rhs.m_Interpolation),
+ m_AddFlags(rhs.m_AddFlags),
+ m_pOCContext(rhs.m_pOCContext),
+ m_dwLimitCacheSize(rhs.m_dwLimitCacheSize),
+ m_HalftoneLimit(rhs.m_HalftoneLimit),
+ m_bDrawAnnots(rhs.m_bDrawAnnots) {}
+
FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const {
if (m_ColorMode == RENDER_COLOR_NORMAL) {
return argb;
diff --git a/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h b/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h
index 2590dbbd2d..7c513aea9e 100644
--- a/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h
+++ b/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h
@@ -36,6 +36,7 @@ class CPDF_OCContext;
class CPDF_RenderOptions {
public:
CPDF_RenderOptions();
+ CPDF_RenderOptions(const CPDF_RenderOptions& rhs);
FX_ARGB TranslateColor(FX_ARGB argb) const;
int m_ColorMode;
@@ -47,6 +48,7 @@ class CPDF_RenderOptions {
CPDF_OCContext* m_pOCContext;
uint32_t m_dwLimitCacheSize;
int m_HalftoneLimit;
+ bool m_bDrawAnnots;
};
#endif // CORE_FPDFAPI_FPDF_RENDER_INCLUDE_CPDF_RENDEROPTIONS_H_
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 4e0b04e9b6..0cc3596a4d 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -73,6 +73,16 @@ void CPDF_Annot::GenerateAPIfNeeded() {
CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict);
}
+bool CPDF_Annot::ShouldDrawAnnotation() {
+ if (IsAnnotationHidden(m_pAnnotDict))
+ return false;
+
+ if (m_nSubtype == CPDF_Annot::Subtype::POPUP && !m_bOpenState)
+ return false;
+
+ return true;
+}
+
void CPDF_Annot::ClearCachedAP() {
m_APMap.clear();
}
@@ -294,10 +304,7 @@ FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage,
const CFX_Matrix* pUser2Device,
AppearanceMode mode,
const CPDF_RenderOptions* pOptions) {
- if (IsAnnotationHidden(m_pAnnotDict))
- return FALSE;
-
- if (m_nSubtype == CPDF_Annot::Subtype::POPUP && !m_bOpenState)
+ if (!ShouldDrawAnnotation())
return FALSE;
// It might happen that by the time this annotation instance was created,
@@ -322,6 +329,16 @@ FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage,
CPDF_RenderContext* pContext,
const CFX_Matrix* pUser2Device,
AppearanceMode mode) {
+ if (!ShouldDrawAnnotation())
+ return FALSE;
+
+ // It might happen that by the time this annotation instance was created,
+ // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided
+ // to not "generate" its AP.
+ // If for a reason the object is no longer hidden, but still does not have
+ // its "AP" generated, generate it now.
+ GenerateAPIfNeeded();
+
CFX_Matrix matrix;
CPDF_Form* pForm =
FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix);
diff --git a/core/fpdfdoc/include/cpdf_annot.h b/core/fpdfdoc/include/cpdf_annot.h
index eb9f02a717..c16decc7d6 100644
--- a/core/fpdfdoc/include/cpdf_annot.h
+++ b/core/fpdfdoc/include/cpdf_annot.h
@@ -100,6 +100,7 @@ class CPDF_Annot {
private:
void GenerateAPIfNeeded();
+ bool ShouldDrawAnnotation();
// For regular annotations, |m_pAnnotDict| is not owned. For
// our artificially created popup annotations, |m_pAnnotDict|