summarylogtreecommitdiffstats
path: root/openjpeg.patch
blob: 24e1a6bca60c06766d7e833e0001d12d108de923 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
description: build using system openjpeg
author: Michael Gilbert <mgilbert@debian.org>

--- a/third_party/pdfium/third_party/BUILD.gn
+++ b/third_party/pdfium/third_party/BUILD.gn
@@ -367,39 +367,11 @@ config("fx_libopenjpeg_warnings") {
   }
 }
 
-source_set("fx_libopenjpeg") {
-  configs -= [ "//build/config/compiler:chromium_code" ]
-  configs += [
-    "//build/config/compiler:no_chromium_code",
-    "//build/config/sanitizers:cfi_icall_generalize_pointers",
-    ":pdfium_third_party_config",
-
-    # Must be after no_chromium_code for warning flags to be ordered correctly.
-    ":fx_libopenjpeg_warnings",
-  ]
-  sources = [
-    "libopenjpeg20/bio.c",
-    "libopenjpeg20/cio.c",
-    "libopenjpeg20/dwt.c",
-    "libopenjpeg20/event.c",
-    "libopenjpeg20/function_list.c",
-    "libopenjpeg20/image.c",
-    "libopenjpeg20/invert.c",
-    "libopenjpeg20/j2k.c",
-    "libopenjpeg20/jp2.c",
-    "libopenjpeg20/mct.c",
-    "libopenjpeg20/mqc.c",
-    "libopenjpeg20/openjpeg.c",
-    "libopenjpeg20/opj_clock.c",
-    "libopenjpeg20/pi.c",
-    "libopenjpeg20/sparse_array.c",
-    "libopenjpeg20/sparse_array.h",
-    "libopenjpeg20/t1.c",
-    "libopenjpeg20/t2.c",
-    "libopenjpeg20/tcd.c",
-    "libopenjpeg20/tgt.c",
-    "libopenjpeg20/thread.c",
-  ]
+pkg_config("libopenjpeg_from_pkgconfig") {
+  packages = [ "libopenjp2" ]
+}
+group("fx_libopenjpeg") {
+  public_configs = [ ":libopenjpeg_from_pkgconfig" ]
 }
 
 config("system_libpng_config") {
--- a/third_party/pdfium/core/fxcodec/codec/codec_int.h
+++ b/third_party/pdfium/core/fxcodec/codec/codec_int.h
@@ -10,7 +10,7 @@
 #include <limits.h>
 
 #include "core/fxcodec/jbig2/JBig2_Context.h"
-#include "third_party/libopenjpeg20/openjpeg.h"
+#include <openjpeg-2.3/openjpeg.h>
 
 class CPDF_ColorSpace;
 
--- a/third_party/pdfium/core/fxcodec/codec/ccodec_jpxmodule.cpp
+++ b/third_party/pdfium/core/fxcodec/codec/ccodec_jpxmodule.cpp
@@ -17,8 +17,6 @@
 #include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "third_party/base/ptr_util.h"
-#include "third_party/libopenjpeg20/openjpeg.h"
-#include "third_party/libopenjpeg20/opj_malloc.h"
 
 namespace {
 
@@ -515,7 +513,6 @@ bool CJPX_Decoder::Init(pdfium::span<con
     return false;
 
   m_Image = pTempImage;
-  m_Image->pdfium_use_colorspace = !!m_ColorSpace;
 
   if (!m_Parameters.nb_tile_to_decode) {
     if (!opj_set_decode_area(m_Codec.Get(), m_Image.Get(), m_Parameters.DA_x0,
@@ -549,7 +546,7 @@ bool CJPX_Decoder::Init(pdfium::span<con
     // TODO(palmer): Using |opj_free| here resolves the crash described in
     // https://crbug.com/737033, but ultimately we need to harmonize the
     // memory allocation strategy across OpenJPEG and its PDFium callers.
-    opj_free(m_Image->icc_profile_buf);
+    free(m_Image->icc_profile_buf);
     m_Image->icc_profile_buf = nullptr;
     m_Image->icc_profile_len = 0;
   }
--- a/third_party/pdfium/core/fxcodec/codec/cjpx_decoder.h
+++ b/third_party/pdfium/core/fxcodec/codec/cjpx_decoder.h
@@ -13,7 +13,7 @@
 #include "core/fxcodec/codec/codec_int.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "third_party/base/span.h"
-#include "third_party/libopenjpeg20/openjpeg.h"
+#include <openjpeg-2.3/openjpeg.h>
 
 class CPDF_ColorSpace;
 
--- a/third_party/pdfium/BUILD.gn
+++ b/third_party/pdfium/BUILD.gn
@@ -21,7 +21,6 @@ config("pdfium_common_config") {
   ldflags = []
   include_dirs = [ "." ]
   defines = [
-    "OPJ_STATIC",
     "PNG_PREFIX",
     "PNG_USE_READ_MACROS",
   ]
@@ -78,7 +77,6 @@ config("pdfium_core_config") {
   if (is_linux) {
     if (current_cpu == "x64") {
       defines += [ "_FX_CPU_=_FX_X64_" ]
-      cflags += [ "-fPIC" ]
     } else if (current_cpu == "x86") {
       defines += [ "_FX_CPU_=_FX_X86_" ]
     }