Move libopenjpeg to third_party/

We get to delete a whole bunch of fx_foo.c files that did nothing
but #include "foo.c" after defining _CRT_SECURE_NO_WARNINGS. Do this
from the .gyp/.gn files instead.

Also sort some "config"s in .gn file.

R=thestig@chromium.org

Committed: https://pdfium.googlesource.com/pdfium/+/c7a17bf9cdb0d646aa8b653e6ab2678a1837ed6a

Review URL: https://codereview.chromium.org/1185373010.
diff --git a/BUILD.gn b/BUILD.gn
index 97a475d..61e72b9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -16,10 +16,9 @@
   cflags = []
   include_dirs = [ "third_party/freetype/include" ]
   defines = [
-    "_FPDFSDK_LIB",
-    "_NO_GDIPLUS_",  # workaround text rendering issues on Windows
     "OPJ_STATIC",
     "V8_DEPRECATION_WARNINGS",
+    "_CRT_SECURE_NO_WARNINGS",
   ]
 
   if (pdf_use_skia) {
@@ -338,6 +337,7 @@
   deps = [
     "third_party:fx_lcms2",
     "third_party:fx_libjpeg",
+    "third_party:fx_libopenjpeg",
   ]
   sources = [
     "core/include/fxcodec/fx_codec.h",
@@ -352,28 +352,6 @@
     "core/src/fxcodec/codec/fx_codec_jbig_enc.cpp",
     "core/src/fxcodec/codec/fx_codec_jpeg.cpp",
     "core/src/fxcodec/codec/fx_codec_jpx_opj.cpp",
-    "core/src/fxcodec/fx_libopenjpeg/include/fx_openjpeg.h",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_bio.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_cio.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_dwt.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_event.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_function_list.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_image.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_invert.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_j2k.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_j2k_lib.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_jpt.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_mct.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_mqc.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg_jp2.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_opj_clock.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_pi.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_raw.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_t1.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_t2.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_tcd.c",
-    "core/src/fxcodec/fx_libopenjpeg/src/fx_tgt.c",
     "core/src/fxcodec/fx_zlib/include/fx_zlib.h",
     "core/src/fxcodec/fx_zlib/src/fx_zlib_adler32.c",
     "core/src/fxcodec/fx_zlib/src/fx_zlib_compress.c",
diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h
index 1c70c12..d0d969c 100644
--- a/core/src/fxcodec/codec/codec_int.h
+++ b/core/src/fxcodec/codec/codec_int.h
@@ -10,9 +10,9 @@
 #include <limits.h>
 #include <list>
 
+#include "../../../../third_party/libopenjpeg20/openjpeg.h"  // For OPJ_SIZE_T.
 #include "../../../include/fxcodec/fx_codec.h"
 #include "../jbig2/JBig2_Context.h"
-#include "../fx_libopenjpeg/libopenjpeg20/openjpeg.h"  // For OPJ_SIZE_T.
 
 class CCodec_BasicModule : public ICodec_BasicModule
 {
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index 4457f18..8b1759e 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -7,8 +7,8 @@
 #include <algorithm>
 #include <limits>
 
+#include "../../../../third_party/libopenjpeg20/openjpeg.h"
 #include "../../../include/fxcodec/fx_codec.h"
-#include "../fx_libopenjpeg/libopenjpeg20/openjpeg.h"
 #include "../lcms2/fx_lcms2.h"
 #include "codec_int.h"
 
diff --git a/core/src/fxcodec/fx_libopenjpeg/include/fx_openjpeg.h b/core/src/fxcodec/fx_libopenjpeg/include/fx_openjpeg.h
deleted file mode 100644
index 5725a57..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/include/fx_openjpeg.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_SRC_FXCODEC_FX_LIBOPENJPEG_INCLUDE_FX_OPENJPEG_H_
-#define CORE_SRC_FXCODEC_FX_LIBOPENJPEG_INCLUDE_FX_OPENJPEG_H_
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-
-#include "../libopenjpeg20/openjpeg.h"
-
-#endif  // CORE_SRC_FXCODEC_FX_LIBOPENJPEG_INCLUDE_FX_OPENJPEG_H_
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_bio.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_bio.c
deleted file mode 100644
index 57ed6f8..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_bio.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/bio.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_cio.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_cio.c
deleted file mode 100644
index 5f70ee5..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_cio.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/cio.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_dwt.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_dwt.c
deleted file mode 100644
index 2dd428f..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_dwt.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/dwt.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_event.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_event.c
deleted file mode 100644
index a7d9bca..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_event.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/event.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_function_list.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_function_list.c
deleted file mode 100644
index 499b141..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_function_list.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/function_list.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_image.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_image.c
deleted file mode 100644
index 46b0faa..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_image.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/image.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_invert.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_invert.c
deleted file mode 100644
index daa89ab..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_invert.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/invert.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_j2k.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_j2k.c
deleted file mode 100644
index c3ae6d4..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_j2k.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/j2k.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_j2k_lib.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_j2k_lib.c
deleted file mode 100644
index 0aa62a0..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_j2k_lib.c
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_jpt.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_jpt.c
deleted file mode 100644
index 0aa62a0..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_jpt.c
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_mct.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_mct.c
deleted file mode 100644
index d2a3861..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_mct.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/mct.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_mqc.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_mqc.c
deleted file mode 100644
index bda851d..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_mqc.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/mqc.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg.c
deleted file mode 100644
index 8addb90..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/openjpeg.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg_jp2.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg_jp2.c
deleted file mode 100644
index 4271dd0..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg_jp2.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/jp2.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_opj_clock.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_opj_clock.c
deleted file mode 100644
index 1aed471..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_opj_clock.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/opj_clock.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_pi.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_pi.c
deleted file mode 100644
index 034a120..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_pi.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/pi.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_raw.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_raw.c
deleted file mode 100644
index c475df2..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_raw.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/raw.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_t1.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_t1.c
deleted file mode 100644
index ada8ae2..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_t1.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/t1.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_t1_generate_luts.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_t1_generate_luts.c
deleted file mode 100644
index a4b8890..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_t1_generate_luts.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/t1_generate_luts.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_t2.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_t2.c
deleted file mode 100644
index 4e5ca50..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_t2.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/t2.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_tcd.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_tcd.c
deleted file mode 100644
index 8d57570..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_tcd.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/tcd.c"
diff --git a/core/src/fxcodec/fx_libopenjpeg/src/fx_tgt.c b/core/src/fxcodec/fx_libopenjpeg/src/fx_tgt.c
deleted file mode 100644
index 283dc54..0000000
--- a/core/src/fxcodec/fx_libopenjpeg/src/fx_tgt.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
- 
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#include "../libopenjpeg20/tgt.c"
diff --git a/pdfium.gyp b/pdfium.gyp
index 8b19c83..6d9dbf3 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -7,14 +7,14 @@
       }, {  # On Android there's no system FreeType. On Windows and Mac, only a
             # few methods are used from it.
         'bundle_freetype%': 1,
-      }],    
+      }],
     ],
   },
   'target_defaults': {
     'defines' : [
-      '_FPDFSDK_LIB',
-      '_NO_GDIPLUS_',  # workaround text rendering issues on Windows
       'OPJ_STATIC',
+      'V8_DEPRECATION_WARNINGS',
+      '_CRT_SECURE_NO_WARNINGS',
     ],
     'include_dirs': [
       'third_party/freetype/include',
@@ -327,6 +327,7 @@
       'dependencies': [
         'third_party/third_party.gyp:fx_lcms2',
         'third_party/third_party.gyp:fx_libjpeg',
+        'third_party/third_party.gyp:fx_libopenjpeg',
       ],
       'ldflags': [ '-L<(PRODUCT_DIR)',],
       'sources': [
@@ -342,28 +343,6 @@
         'core/src/fxcodec/codec/fx_codec_jbig_enc.cpp',
         'core/src/fxcodec/codec/fx_codec_jpeg.cpp',
         'core/src/fxcodec/codec/fx_codec_jpx_opj.cpp',
-        'core/src/fxcodec/fx_libopenjpeg/include/fx_openjpeg.h',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_bio.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_cio.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_dwt.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_event.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_function_list.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_image.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_invert.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_j2k.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_j2k_lib.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_jpt.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_mct.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_mqc.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_openjpeg_jp2.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_opj_clock.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_pi.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_raw.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_t1.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_t2.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_tcd.c',
-        'core/src/fxcodec/fx_libopenjpeg/src/fx_tgt.c',
         'core/src/fxcodec/fx_zlib/include/fx_zlib.h',
         'core/src/fxcodec/fx_zlib/src/fx_zlib_adler32.c',
         'core/src/fxcodec/fx_zlib/src/fx_zlib_compress.c',
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index 11da543..be6538e 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -13,8 +13,8 @@
 source_set("bigint") {
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
-    "//third_party/pdfium:pdfium_config",
     "//build/config/compiler:no_chromium_code",
+    "//third_party/pdfium:pdfium_config",
   ]
   sources = [
     "bigint/BigInteger.cc",
@@ -33,8 +33,8 @@
 source_set("freetype") {
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
-    "//third_party/pdfium:pdfium_config",
     "//build/config/compiler:no_chromium_code",
+    "//third_party/pdfium:pdfium_config",
   ]
   defines = [ "FT2_BUILD_LIBRARY" ]
   sources = [
@@ -196,11 +196,40 @@
   ]
 }
 
+source_set("fx_libopenjpeg") {
+  configs -= [ "//build/config/compiler:chromium_code" ]
+  configs += [
+    "//build/config/compiler:no_chromium_code",
+    "//third_party/pdfium:pdfium_config",
+  ]
+  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/raw.c",
+    "libopenjpeg20/t1.c",
+    "libopenjpeg20/t2.c",
+    "libopenjpeg20/tcd.c",
+    "libopenjpeg20/tgt.c",
+  ]
+}
+
 source_set("pdfium_base") {
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
-    "//third_party/pdfium:pdfium_config",
     "//build/config/compiler:no_chromium_code",
+    "//third_party/pdfium:pdfium_config",
   ]
   sources = [
     "base/logging.h",
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/CMakeLists.txt b/third_party/libopenjpeg20/CMakeLists.txt
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/CMakeLists.txt
rename to third_party/libopenjpeg20/CMakeLists.txt
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/bio.c b/third_party/libopenjpeg20/bio.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/bio.c
rename to third_party/libopenjpeg20/bio.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/bio.h b/third_party/libopenjpeg20/bio.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/bio.h
rename to third_party/libopenjpeg20/bio.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/cio.c b/third_party/libopenjpeg20/cio.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/cio.c
rename to third_party/libopenjpeg20/cio.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/cio.h b/third_party/libopenjpeg20/cio.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/cio.h
rename to third_party/libopenjpeg20/cio.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.c b/third_party/libopenjpeg20/dwt.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.c
rename to third_party/libopenjpeg20/dwt.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.h b/third_party/libopenjpeg20/dwt.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.h
rename to third_party/libopenjpeg20/dwt.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/event.c b/third_party/libopenjpeg20/event.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/event.c
rename to third_party/libopenjpeg20/event.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/event.h b/third_party/libopenjpeg20/event.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/event.h
rename to third_party/libopenjpeg20/event.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/function_list.c b/third_party/libopenjpeg20/function_list.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/function_list.c
rename to third_party/libopenjpeg20/function_list.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/function_list.h b/third_party/libopenjpeg20/function_list.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/function_list.h
rename to third_party/libopenjpeg20/function_list.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/image.c b/third_party/libopenjpeg20/image.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/image.c
rename to third_party/libopenjpeg20/image.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/image.h b/third_party/libopenjpeg20/image.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/image.h
rename to third_party/libopenjpeg20/image.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/indexbox_manager.h b/third_party/libopenjpeg20/indexbox_manager.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/indexbox_manager.h
rename to third_party/libopenjpeg20/indexbox_manager.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/invert.c b/third_party/libopenjpeg20/invert.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/invert.c
rename to third_party/libopenjpeg20/invert.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/invert.h b/third_party/libopenjpeg20/invert.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/invert.h
rename to third_party/libopenjpeg20/invert.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c b/third_party/libopenjpeg20/j2k.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c
rename to third_party/libopenjpeg20/j2k.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.h b/third_party/libopenjpeg20/j2k.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.h
rename to third_party/libopenjpeg20/j2k.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/jp2.c b/third_party/libopenjpeg20/jp2.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/jp2.c
rename to third_party/libopenjpeg20/jp2.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/jp2.h b/third_party/libopenjpeg20/jp2.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/jp2.h
rename to third_party/libopenjpeg20/jp2.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/mct.c b/third_party/libopenjpeg20/mct.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/mct.c
rename to third_party/libopenjpeg20/mct.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/mct.h b/third_party/libopenjpeg20/mct.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/mct.h
rename to third_party/libopenjpeg20/mct.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/mqc.c b/third_party/libopenjpeg20/mqc.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/mqc.c
rename to third_party/libopenjpeg20/mqc.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/mqc.h b/third_party/libopenjpeg20/mqc.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/mqc.h
rename to third_party/libopenjpeg20/mqc.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.c b/third_party/libopenjpeg20/openjpeg.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.c
rename to third_party/libopenjpeg20/openjpeg.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.h b/third_party/libopenjpeg20/openjpeg.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.h
rename to third_party/libopenjpeg20/openjpeg.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_clock.c b/third_party/libopenjpeg20/opj_clock.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_clock.c
rename to third_party/libopenjpeg20/opj_clock.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_clock.h b/third_party/libopenjpeg20/opj_clock.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_clock.h
rename to third_party/libopenjpeg20/opj_clock.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_codec.h b/third_party/libopenjpeg20/opj_codec.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_codec.h
rename to third_party/libopenjpeg20/opj_codec.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_config.h b/third_party/libopenjpeg20/opj_config.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_config.h
rename to third_party/libopenjpeg20/opj_config.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_config.h.cmake.in b/third_party/libopenjpeg20/opj_config.h.cmake.in
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_config.h.cmake.in
rename to third_party/libopenjpeg20/opj_config.h.cmake.in
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_config_private.h b/third_party/libopenjpeg20/opj_config_private.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_config_private.h
rename to third_party/libopenjpeg20/opj_config_private.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_includes.h b/third_party/libopenjpeg20/opj_includes.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_includes.h
rename to third_party/libopenjpeg20/opj_includes.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_intmath.h b/third_party/libopenjpeg20/opj_intmath.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_intmath.h
rename to third_party/libopenjpeg20/opj_intmath.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_inttypes.h b/third_party/libopenjpeg20/opj_inttypes.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_inttypes.h
rename to third_party/libopenjpeg20/opj_inttypes.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_malloc.h b/third_party/libopenjpeg20/opj_malloc.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_malloc.h
rename to third_party/libopenjpeg20/opj_malloc.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_stdint.h b/third_party/libopenjpeg20/opj_stdint.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_stdint.h
rename to third_party/libopenjpeg20/opj_stdint.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.c b/third_party/libopenjpeg20/pi.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.c
rename to third_party/libopenjpeg20/pi.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.h b/third_party/libopenjpeg20/pi.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.h
rename to third_party/libopenjpeg20/pi.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/raw.c b/third_party/libopenjpeg20/raw.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/raw.c
rename to third_party/libopenjpeg20/raw.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/raw.h b/third_party/libopenjpeg20/raw.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/raw.h
rename to third_party/libopenjpeg20/raw.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t1.c b/third_party/libopenjpeg20/t1.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t1.c
rename to third_party/libopenjpeg20/t1.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t1.h b/third_party/libopenjpeg20/t1.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t1.h
rename to third_party/libopenjpeg20/t1.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t1_generate_luts.c b/third_party/libopenjpeg20/t1_generate_luts.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t1_generate_luts.c
rename to third_party/libopenjpeg20/t1_generate_luts.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t1_luts.h b/third_party/libopenjpeg20/t1_luts.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t1_luts.h
rename to third_party/libopenjpeg20/t1_luts.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t2.c b/third_party/libopenjpeg20/t2.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t2.c
rename to third_party/libopenjpeg20/t2.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t2.h b/third_party/libopenjpeg20/t2.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/t2.h
rename to third_party/libopenjpeg20/t2.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.c b/third_party/libopenjpeg20/tcd.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.c
rename to third_party/libopenjpeg20/tcd.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.h b/third_party/libopenjpeg20/tcd.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tcd.h
rename to third_party/libopenjpeg20/tcd.h
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tgt.c b/third_party/libopenjpeg20/tgt.c
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tgt.c
rename to third_party/libopenjpeg20/tgt.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tgt.h b/third_party/libopenjpeg20/tgt.h
similarity index 100%
rename from core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/tgt.h
rename to third_party/libopenjpeg20/tgt.h
diff --git a/third_party/third_party.gyp b/third_party/third_party.gyp
index 6dbff56..240d65b 100644
--- a/third_party/third_party.gyp
+++ b/third_party/third_party.gyp
@@ -3,6 +3,15 @@
 # found in the LICENSE file.
 
 {
+  'target_defaults': {
+    'defines': [
+      'OPJ_STATIC',
+      '_CRT_SECURE_NO_WARNINGS',
+    ],
+    'msvs_disabled_warnings': [
+      4005, 4018, 4146, 4333, 4345, 4267
+    ],
+  },
   'targets': [
     {
       'target_name': 'bigint',
@@ -200,6 +209,31 @@
       ],
     },
     {
+      'target_name': 'fx_libopenjpeg',
+      'type': 'static_library',
+      '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/raw.c',
+        'libopenjpeg20/t1.c',
+        'libopenjpeg20/t2.c',
+        'libopenjpeg20/tcd.c',
+        'libopenjpeg20/tgt.c',
+      ],
+    },
+    {
       'target_name': 'pdfium_base',
       'type': 'none',
       'sources': [