• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MEDIAPROVIDER_PDF_JNI_PDFCLIENT_PATH_OBJECT_H_
18 #define MEDIAPROVIDER_PDF_JNI_PDFCLIENT_PATH_OBJECT_H_
19 
20 #include <stdint.h>
21 
22 #include <vector>
23 
24 #include "cpp/fpdf_scopers.h"
25 #include "fpdfview.h"
26 #include "page_object.h"
27 
28 typedef unsigned int uint;
29 
30 namespace pdfClient {
31 
32 class PathObject : public PageObject {
33   public:
34     PathObject();
35 
36     ScopedFPDFPageObject CreateFPDFInstance(FPDF_DOCUMENT document, FPDF_PAGE page) override;
37     bool UpdateFPDFInstance(FPDF_PAGEOBJECT path_object, FPDF_PAGE page) override;
38     bool PopulateFromFPDFInstance(FPDF_PAGEOBJECT path_object, FPDF_PAGE page) override;
39 
40     ~PathObject();
41 
42     class Segment {
43       public:
44         enum class Command {
45             Unknown = 0,
46             Move,
47             Line,
48         };
49 
50         Command command;
51         float x;
52         float y;
53         bool is_closed;  // Checks if the path_segment is closed
54 
55         Segment(Command command, float x, float y, bool is_closed = false)
command(command)56             : command(command), x(x), y(y), is_closed(is_closed) {}
57     };
58 
59     bool is_fill_ = false;
60     bool is_stroke_ = false;
61 
62     std::vector<Segment> segments_;
63 
64   protected:
65     bool GetPageToDeviceMatrix(FPDF_PAGEOBJECT path_object, FPDF_PAGE page) override;
66     bool SetDeviceToPageMatrix(FPDF_PAGEOBJECT path_object, FPDF_PAGE page) override;
67 };
68 
69 }  // namespace pdfClient
70 
71 #endif  // MEDIAPROVIDER_PDF_JNI_PDFCLIENT_PATH_OBJECT_H_