• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkPDFTag_DEFINED
9 #define SkPDFTag_DEFINED
10 
11 #include "include/docs/SkPDFDocument.h"
12 #include "include/private/SkTArray.h"
13 #include "include/private/SkTHash.h"
14 #include "src/core/SkArenaAlloc.h"
15 
16 class SkPDFDocument;
17 struct SkPDFIndirectReference;
18 struct SkPDFTagNode;
19 
20 class SkPDFTagTree {
21 public:
22     SkPDFTagTree();
23     ~SkPDFTagTree();
24     void init(SkPDF::StructureElementNode*);
25     void reset();
26     int getMarkIdForNodeId(int nodeId, unsigned pageIndex);
27     SkPDFIndirectReference makeStructTreeRoot(SkPDFDocument* doc);
28 
29 private:
30     static void Copy(SkPDF::StructureElementNode& node,
31                      SkPDFTagNode* dst,
32                      SkArenaAlloc* arena,
33                      SkTHashMap<int, SkPDFTagNode*>* nodeMap);
34 
35     SkArenaAlloc fArena;
36     SkTHashMap<int, SkPDFTagNode*> fNodeMap;
37     SkPDFTagNode* fRoot = nullptr;
38     SkTArray<SkTArray<SkPDFTagNode*>> fMarksPerPage;
39 
40     SkPDFTagTree(const SkPDFTagTree&) = delete;
41     SkPDFTagTree& operator=(const SkPDFTagTree&) = delete;
42 };
43 
44 #endif
45