Commit d3db9d99 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Change //pdf:pdf target's type to component.

The existing target is a static_library, which generated libpdf.a, and
libpdf.a has to be linked into the chrome target. With a component
target, it generates libpdf.so, and the chrome target does not need to
change. This makes rebuilding the chrome target much faster in component
builds.

Change-Id: I0a6f2fde66c7a3a2e46968b5ff387de8e73a5eb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2293325
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789768}
parent dc167b99
...@@ -22,11 +22,13 @@ if (enable_pdf) { ...@@ -22,11 +22,13 @@ if (enable_pdf) {
include_dirs = [ "//third_party/pdfium" ] include_dirs = [ "//third_party/pdfium" ]
} }
static_library("pdf") { component("pdf") {
sources = [ "pdf.cc" ] sources = [ "pdf.cc" ]
configs += [ ":pdf_common_config" ] configs += [ ":pdf_common_config" ]
defines = [ "IS_PDF_IMPL" ]
public = [ "pdf.h" ] public = [ "pdf.h" ]
deps = [ deps = [
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include "base/component_export.h"
#include "base/containers/span.h" #include "base/containers/span.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/values.h" #include "base/values.h"
...@@ -33,6 +34,7 @@ namespace chrome_pdf { ...@@ -33,6 +34,7 @@ namespace chrome_pdf {
// Create a flattened PDF document from an existing PDF document. // Create a flattened PDF document from an existing PDF document.
// |input_buffer| is the buffer that contains the entire PDF document to be // |input_buffer| is the buffer that contains the entire PDF document to be
// flattened. // flattened.
COMPONENT_EXPORT(PDF)
std::vector<uint8_t> CreateFlattenedPdf(base::span<const uint8_t> input_buffer); std::vector<uint8_t> CreateFlattenedPdf(base::span<const uint8_t> input_buffer);
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -75,6 +77,7 @@ enum PrintingMode { ...@@ -75,6 +77,7 @@ enum PrintingMode {
// the output bound. // the output bound.
// |use_color| specifies color or grayscale. // |use_color| specifies color or grayscale.
// Returns false if the document or the page number are not valid. // Returns false if the document or the page number are not valid.
COMPONENT_EXPORT(PDF)
bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer, bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer,
int page_number, int page_number,
HDC dc, HDC dc,
...@@ -91,16 +94,20 @@ bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer, ...@@ -91,16 +94,20 @@ bool RenderPDFPageToDC(base::span<const uint8_t> pdf_buffer,
bool autorotate, bool autorotate,
bool use_color); bool use_color);
COMPONENT_EXPORT(PDF)
void SetPDFEnsureTypefaceCharactersAccessible( void SetPDFEnsureTypefaceCharactersAccessible(
PDFEnsureTypefaceCharactersAccessible func); PDFEnsureTypefaceCharactersAccessible func);
COMPONENT_EXPORT(PDF)
void SetPDFUseGDIPrinting(bool enable); void SetPDFUseGDIPrinting(bool enable);
COMPONENT_EXPORT(PDF)
void SetPDFUsePrintMode(int mode); void SetPDFUsePrintMode(int mode);
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
// |page_count| and |max_page_width| are optional and can be NULL. // |page_count| and |max_page_width| are optional and can be NULL.
// Returns false if the document is not valid. // Returns false if the document is not valid.
COMPONENT_EXPORT(PDF)
bool GetPDFDocInfo(base::span<const uint8_t> pdf_buffer, bool GetPDFDocInfo(base::span<const uint8_t> pdf_buffer,
int* page_count, int* page_count,
double* max_page_width); double* max_page_width);
...@@ -108,10 +115,12 @@ bool GetPDFDocInfo(base::span<const uint8_t> pdf_buffer, ...@@ -108,10 +115,12 @@ bool GetPDFDocInfo(base::span<const uint8_t> pdf_buffer,
// Whether the PDF is Tagged (see 10.7 "Tagged PDF" in PDF Reference 1.7). // Whether the PDF is Tagged (see 10.7 "Tagged PDF" in PDF Reference 1.7).
// Returns true if it's a tagged (accessible) PDF, false if it's a valid // Returns true if it's a tagged (accessible) PDF, false if it's a valid
// PDF but untagged, and nullopt if the PDF can't be parsed. // PDF but untagged, and nullopt if the PDF can't be parsed.
COMPONENT_EXPORT(PDF)
base::Optional<bool> IsPDFDocTagged(base::span<const uint8_t> pdf_buffer); base::Optional<bool> IsPDFDocTagged(base::span<const uint8_t> pdf_buffer);
// Given a tagged PDF (see IsPDFDocTagged, above), return the portion of // Given a tagged PDF (see IsPDFDocTagged, above), return the portion of
// the structure tree for a given page as a hierarchical tree of base::Values. // the structure tree for a given page as a hierarchical tree of base::Values.
COMPONENT_EXPORT(PDF)
base::Value GetPDFStructTreeForPage(base::span<const uint8_t> pdf_buffer, base::Value GetPDFStructTreeForPage(base::span<const uint8_t> pdf_buffer,
int page_index); int page_index);
...@@ -123,6 +132,7 @@ base::Value GetPDFStructTreeForPage(base::span<const uint8_t> pdf_buffer, ...@@ -123,6 +132,7 @@ base::Value GetPDFStructTreeForPage(base::span<const uint8_t> pdf_buffer,
// |width| is the output for the width of the page in points. // |width| is the output for the width of the page in points.
// |height| is the output for the height of the page in points. // |height| is the output for the height of the page in points.
// Returns false if the document or the page number are not valid. // Returns false if the document or the page number are not valid.
COMPONENT_EXPORT(PDF)
bool GetPDFPageSizeByIndex(base::span<const uint8_t> pdf_buffer, bool GetPDFPageSizeByIndex(base::span<const uint8_t> pdf_buffer,
int page_number, int page_number,
double* width, double* width,
...@@ -140,6 +150,7 @@ bool GetPDFPageSizeByIndex(base::span<const uint8_t> pdf_buffer, ...@@ -140,6 +150,7 @@ bool GetPDFPageSizeByIndex(base::span<const uint8_t> pdf_buffer,
// the output bound. // the output bound.
// |use_color| specifies color or grayscale. // |use_color| specifies color or grayscale.
// Returns false if the document or the page number are not valid. // Returns false if the document or the page number are not valid.
COMPONENT_EXPORT(PDF)
bool RenderPDFPageToBitmap(base::span<const uint8_t> pdf_buffer, bool RenderPDFPageToBitmap(base::span<const uint8_t> pdf_buffer,
int page_number, int page_number,
void* bitmap_buffer, void* bitmap_buffer,
...@@ -168,6 +179,7 @@ bool RenderPDFPageToBitmap(base::span<const uint8_t> pdf_buffer, ...@@ -168,6 +179,7 @@ bool RenderPDFPageToBitmap(base::span<const uint8_t> pdf_buffer,
// See printing::NupParameters for more details on how the output page // See printing::NupParameters for more details on how the output page
// orientation is determined, to understand why |page_size| may be swapped in // orientation is determined, to understand why |page_size| may be swapped in
// some cases. // some cases.
COMPONENT_EXPORT(PDF)
std::vector<uint8_t> ConvertPdfPagesToNupPdf( std::vector<uint8_t> ConvertPdfPagesToNupPdf(
std::vector<base::span<const uint8_t>> input_buffers, std::vector<base::span<const uint8_t>> input_buffers,
size_t pages_per_sheet, size_t pages_per_sheet,
...@@ -185,6 +197,7 @@ std::vector<uint8_t> ConvertPdfPagesToNupPdf( ...@@ -185,6 +197,7 @@ std::vector<uint8_t> ConvertPdfPagesToNupPdf(
// Refer to the description of ConvertPdfPagesToNupPdf to understand how the // Refer to the description of ConvertPdfPagesToNupPdf to understand how the
// output page size will be calculated. // output page size will be calculated.
// The algorithm used to determine the output page size is the same. // The algorithm used to determine the output page size is the same.
COMPONENT_EXPORT(PDF)
std::vector<uint8_t> ConvertPdfDocumentToNupPdf( std::vector<uint8_t> ConvertPdfDocumentToNupPdf(
base::span<const uint8_t> input_buffer, base::span<const uint8_t> input_buffer,
size_t pages_per_sheet, size_t pages_per_sheet,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment