summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_pathobject.cpp
blob: 7dd91598c6a903c9c98e9e94b2dbb7c54abda696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2016 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 "core/fpdfapi/page/cpdf_pathobject.h"

CPDF_PathObject::CPDF_PathObject() : m_FillType(0), m_bStroke(false) {}

CPDF_PathObject::~CPDF_PathObject() {}

CPDF_PageObject::Type CPDF_PathObject::GetType() const {
  return PATH;
}

void CPDF_PathObject::Transform(const CFX_Matrix& matrix) {
  m_Matrix.Concat(matrix);
  CalcBoundingBox();
  SetDirty(true);
}

bool CPDF_PathObject::IsPath() const {
  return true;
}

CPDF_PathObject* CPDF_PathObject::AsPath() {
  return this;
}

const CPDF_PathObject* CPDF_PathObject::AsPath() const {
  return this;
}

void CPDF_PathObject::CalcBoundingBox() {
  if (!m_Path.HasRef())
    return;
  CFX_FloatRect rect;
  float width = m_GraphState.GetLineWidth();
  if (m_bStroke && width != 0) {
    rect = m_Path.GetBoundingBox(width, m_GraphState.GetMiterLimit());
  } else {
    rect = m_Path.GetBoundingBox();
  }
  m_Matrix.TransformRect(rect);

  if (width == 0 && m_bStroke) {
    rect.left += -0.5f;
    rect.right += 0.5f;
    rect.bottom += -0.5f;
    rect.top += 0.5f;
  }
  m_Left = rect.left;
  m_Right = rect.right;
  m_Top = rect.top;
  m_Bottom = rect.bottom;
}