Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_tilingpattern.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "core/fpdfapi/page/cpdf_tilingpattern.h"
8
9#include <math.h>
10
11#include <utility>
12
13#include "core/fpdfapi/page/cpdf_allstates.h"
14#include "core/fpdfapi/page/cpdf_form.h"
15#include "core/fpdfapi/page/cpdf_pageobject.h"
16#include "core/fpdfapi/parser/cpdf_dictionary.h"
17#include "core/fpdfapi/parser/cpdf_object.h"
18#include "core/fpdfapi/parser/cpdf_stream.h"
19#include "third_party/base/check.h"
20
21CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
22 RetainPtr<CPDF_Object> pPatternObj,
23 const CFX_Matrix& parentMatrix)
24 : CPDF_Pattern(pDoc, std::move(pPatternObj), parentMatrix) {
25 DCHECK(document());
26 m_bColored = pattern_obj()->GetDict()->GetIntegerFor("PaintType") == 1;
28}
29
30CPDF_TilingPattern::~CPDF_TilingPattern() = default;
31
32CPDF_TilingPattern* CPDF_TilingPattern::AsTilingPattern() {
33 return this;
34}
35
36std::unique_ptr<CPDF_Form> CPDF_TilingPattern::Load(CPDF_PageObject* pPageObj) {
37 RetainPtr<const CPDF_Dictionary> pDict = pattern_obj()->GetDict();
38 m_bColored = pDict->GetIntegerFor("PaintType") == 1;
39 m_XStep = fabsf(pDict->GetFloatFor("XStep"));
40 m_YStep = fabsf(pDict->GetFloatFor("YStep"));
41
42 RetainPtr<CPDF_Stream> pStream = ToStream(pattern_obj());
43 if (!pStream)
44 return nullptr;
45
46 const CFX_Matrix& matrix = parent_matrix();
47 auto form =
48 std::make_unique<CPDF_Form>(document(), nullptr, std::move(pStream));
49
50 CPDF_AllStates all_states;
55 form->ParseContent(&all_states, &matrix, nullptr);
56 m_BBox = pDict->GetRectFor("BBox");
57 return form;
58}
CPDF_TextState & mutable_text_state()
CFX_GraphState & mutable_graph_state()
CPDF_ColorState & mutable_color_state()
CPDF_GeneralState & mutable_general_state()
const CPDF_GeneralState & general_state() const
const CFX_Matrix & parent_matrix() const
void SetPatternToFormMatrix()
CPDF_Document * document() const
std::unique_ptr< CPDF_Form > Load(CPDF_PageObject *pPageObj)
~CPDF_TilingPattern() override
CPDF_TilingPattern * AsTilingPattern() override