mirror of
https://pdfium.googlesource.com/pdfium
synced 2026-07-31 04:29:37 +08:00
Replace UNSAFE_TODO() raw pointer loops with compile-time fixed stride loops using GetScanlineAs<>() and fxcrt::Zip() by templating for 24 or 32 BPP and updating caller. TAG=agy CONV=79149323-9e55-44bc-a43a-b9aedc44a81b Change-Id: I0e92603cd6a082de393988130a6b00dabcb3be8b Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/153410 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
core/
This directory contains the internal C++ implementation of the PDF specification. These modules are for internal use and may change without notice.
Subdirectories
PDFium's core is divided into several subdirectories, each with a specific responsibility:
- fdrm/ (Rights Management): Provides cryptography primitives used for PDF security and encryption handling.
- fpdfapi/ (PDF spec implementation): The central module that understands the PDF format, covering parsing, logical page representation, rendering coordination, and document editing.
- fpdfdoc/ (Document Logic): Implements higher-level document features such as Bookmarks, Annotations, Interactive Forms (AcroForms), and Links.
- fpdftext/ (Text Extraction): Specialized logic for extracting text, identifying reading order, and performing text searches within a page.
- fxcodec/ (Codecs): Responsible for decoding various PDF
stream formats. It depends on
fxgefor managing target bitmaps. - fxcrt/ (Common Runtime): The foundational layer providing base types, string handling, custom containers, and memory management utilities. It has no dependencies on other core modules.
- fxge/ (Graphics Engine): Handles rendering primitives (paths, glyphs, bitmaps), font management abstractions (FreeType, Skia, AGG), and device drivers for different platforms.
Architectural Flow: Life of a Page
Building a rendered page involves several layers working in concert:
- Parsing:
fpdfapi/parserreads raw bytes and builds the PDF object graph (Dictionaries, Streams, etc.). - Decoding: As content is accessed,
fxcodecdecodes compressed data streams. - Logical Representation:
fpdfapi/pageinterprets the objects into higher-level constructs like paths, text objects, and images. - Rendering:
fpdfapi/rendertraverses the page objects and issues drawing commands tofxge. - Rasterization:
fxgeuses its rendering backend (e.g., AGG or Skia) to convert these primitives into final pixels in a device buffer.
Coordinate Systems
PDF documents use User Space, a coordinate system where the origin (0,0) is
typically at the bottom-left of the page. Rendering devices (managed by fxge)
usually use Device Space, where the origin is at the top-left.
core/ handles the complex affine transformations needed to map between these
spaces, taking into account page rotation, scaling, and the specific
transformation matrices (CTM) defined within content streams.