summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibPDF
AgeCommit message (Collapse)Author
2021-09-21LibPDF: Rely on default-constructor of VariantBen Wiederhake
2021-09-20LibPDF: Replace Value class by AK::VariantBen Wiederhake
This decreases the memory consumption by LibPDF by 4 bytes per Value, compensating exactly for the increase in an earlier commit. :^)
2021-09-20LibPDF: Extract reference bitpacking into dedicated classBen Wiederhake
2021-09-20LibPDF: Move inline function definitionBen Wiederhake
This breaks the dependency cycle between Parser and Document.
2021-09-20LibPDF: Break weird dependency cycleBen Wiederhake
Old situation: Object.h defines Object Object.h defines ArrayObject ArrayObject requires the definition of Object ArrayObject requires the definition of Value Value.h defines Value Value requires the definition of Object Therefore, a file with the single line "#include <Value.h>" used to raise compilation errors; certainly not something that one might expect from a library. This patch splits up the definitions in Object.h to break the cycle. Now, Object.h only defines Object, Value.h still only defines Value (and includes Object.h), and the new header ObjectDerivatives.h defines ArrayObject (and includes both Object.h and Value.h).
2021-09-20LibPDF: Add missing headers in Value.hBen Wiederhake
2021-09-20LibPDF: Fix math error in commentsBen Wiederhake
2021-09-20LibPDF: Switch to automatic ref counting, fix memory leakBen Wiederhake
At least `Value::operator=` didn't properly unref the `PDF::Object` when it was called. This type of problem is removed by just letting `RefPtr` do its thing. This patch increases the memory consumption by LibPDF by 4 bytes (the other union objects) per value.
2021-09-20LibPDF: Add missing headers to XRefTable.hBen Wiederhake
2021-09-20LibPDF: Add missing headers to Reader.hBen Wiederhake
2021-09-20LibPDF: Add missing headers to Forward.hBen Wiederhake
2021-09-16LibPDF: Use move to avoid unnecessary ref/unref of network device RefPtrBrian Gianforcaro
Flagged by pvs-studio as a potential perf optimization.
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-09-06Everywhere: Use OOM-safe ByteBuffer APIs where possibleAli Mohammad Pur
If we can easily communicate failure, let's avoid asserting and report failure instead.
2021-09-03Everywhere: Prevent risky implicit casts of (Nonnull)RefPtrDaniel Bertalan
Our existing implementation did not check the element type of the other pointer in the constructors and move assignment operators. This meant that some operations that would require explicit casting on raw pointers were done implicitly, such as: - downcasting a base class to a derived class (e.g. `Kernel::Inode` => `Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp), - casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>` in LibIMAP/Client.cpp) This, of course, allows gross violations of the type system, and makes the need to type-check less obvious before downcasting. Luckily, while adding the `static_ptr_cast`s, only two truly incorrect usages were found; in the other instances, our casts just needed to be made explicit.
2021-07-19Everywhere: Use AK/Math.h if applicableHendiadyoin1
AK's version should see better inlining behaviors, than the LibM one. We avoid mixed usage for now though. Also clean up some stale math includes and improper floatingpoint usage.
2021-07-16LibPDF: Fix treating not finding the linearized dict as a fatal errorWesley Moret
We now try to parse the first indirect value and see if it's the `Linearization Parameter Dictionary`. if it's not, we fallback to reading the xref table from the end of the document
2021-07-16LibPDF: Fix checking `minor_ver` instead of `major_ver`Wesley Moret
2021-06-12LibPDF: Convert to east-const to comply with the recent style changesMatthew Olsson
2021-06-12LibPDF: Bake the flipped y-axis directly into the CTM matrixMatthew Olsson
2021-06-12LibPDF: Avoid calculating rendering matrix for every glyphMatthew Olsson
2021-06-12LibPDF: Handle the TJ graphical operatorMatthew Olsson
2021-06-12LibPDF: Handle the gs graphical operatorMatthew Olsson
2021-06-12LibPDF: Add support for the CalRGB ColorSpaceMatthew Olsson
This isn't tested all that well, as the PDF I am testing with only uses it for black (which is trivial). It can be tested further when LibPDF is able to process more complex PDFs that actually use this color space non-trivially.
2021-06-12LibPDF: Split ColorSpace into a different class for each color spaceMatthew Olsson
While unnecessary at the moment, this will allow for more fine-grained control when complex color spaces get added.
2021-06-12LibPDF: Parse hint tablesMatthew Olsson
This code isn't _actually_ used as of right now, but I wrote it at the same time as all of the code in the previous commit. I realized after I wrote it that these hint tables aren't super useful if the parser already has access to the full file. However, this will be useful if we ever want to stream PDFs from the web (and possibly view them in the browser).
2021-06-12LibPDF: Parse linearized PDF filesMatthew Olsson
This is a big step, as most PDFs which are downloaded online will be linearized. Pretty much the only difference is that the xref structure is slightly different.
2021-06-12LibPDF: Fix two parser bugsMatthew Olsson
- A newline was assumed to follow the "stream" keyword, when it can also be a windows-style line break - Fix not consuming the "endobj" at the end of every indirect object
2021-06-12LibPDF: Refine the distinction between the Document and ParserMatthew Olsson
The Parser should hold information relevant for parsing, whereas the Document should hold information relevant for displaying pages. With this in mind, there is no reason for the Document to hold the xref table and trailer. These objects have been moved to the Parser, which allows the Parser to expose less public methods (which will be even more evident once linearized PDFs are supported).
2021-06-12LibPDF: Account for inverted y axis when rendering textMatthew Olsson
2021-06-12LibPDF: Harden the document/parser against errorsMatthew Olsson
2021-06-12LibPDF: Differentiate Value's null and empty statesMatthew Olsson
2021-06-06AK+Everywhere: Disallow constructing Functions from incompatible typesAli Mohammad Pur
Previously, AK::Function would accept _any_ callable type, and try to call it when called, first with the given set of arguments, then with zero arguments, and if all of those failed, it would simply not call the function and **return a value-constructed Out type**. This lead to many, many, many hard to debug situations when someone forgot a `const` in their lambda argument types, and many cases of people taking zero arguments in their lambdas to ignore them. This commit reworks the Function interface to not include any such surprising behaviour, if your function instance is not callable with the declared argument set of the Function, it can simply not be assigned to that Function instance, end of story.
2021-06-01Everywhere: codepoint => code pointAndreas Kling
2021-05-25LibPDF: Pre-initialize common FlyStrings in CommonNames.hMatthew Olsson
2021-05-25LibPDF: Handle string encodingsMatthew Olsson
Strings can be encoded in either UTF16-BE or UTF8. In either case, there are a few initial bytes which specify the encoding that must be checked and also removed from the final string.
2021-05-25LibPDF: Parse outline structuresMatthew Olsson
2021-05-25LibPDF: Store indirect value refs in Value objectsMatthew Olsson
IndirectValueRef is so simple that it can be stored directly in the Value class instead of being heap allocated. As the comment in Value says, however, in theory the max bits needed to store is 48 (16 for the generation index and 32(?) for the object index), but 32 should be good enough for now. We can increase it to u64 later if necessary.
2021-05-25LibPDF: Add basic color space support to the rendererMatthew Olsson
This commit only supports the three most basic color spaces: DeviceGray, DeviceRGB, and DeviceCMYK
2021-05-25LibPDF: Add a very poor path clipping implementationMatthew Olsson
This completely ignores the actual path and just uses its bounding box, since our painter doesn't support clipping to paths.
2021-05-25LibPDF: Implement stubs for all graphical commandsMatthew Olsson
2021-05-25LibPDF: Add support for stream filtersMatthew Olsson
This commit also splits up StreamObject into PlainTextStreamObject and EncodedStreamObject, which is essentially just a stream object which does not own its bytes vs one which does.
2021-05-25LibPDF: Make Reader::dump_state a bit more readableMatthew Olsson
2021-05-25LibPDF: Do not assume value is an object in parse_indirect_valueMatthew Olsson
2021-05-18LibPDF/PDFViewer: Support rotated pagesMatthew Olsson
2021-05-18Applications: Add a very simple PDFViewerMatthew Olsson
2021-05-18LibPDF: Fix bad resolve_to calls in DocumentMatthew Olsson
We can't call resolve_to with IndirectValue{,Ref}, since the values will obviously be resolved, and will not give us the object of the correct type.
2021-05-18LibPDF: Add a bitmap rendererMatthew Olsson
This commit adds the Renderer class, which is responsible for rendering a page into a Gfx::Bitmap. There are many improvements to make here, but this is a great start!
2021-05-18LibPDF: Parse page crop box and user unitsMatthew Olsson
2021-05-18LibPDF: Parse graphics commandsMatthew Olsson