Merge mozilla-central to autoland. CLOSED TREE
[gecko.git] / gfx / ots / ots-lz4.patch
blob96113967759c6ff668735ae652cb1f8f6df2339c
1 diff --git a/src/glat.cc b/src/glat.cc
2 --- a/src/glat.cc
3 +++ b/src/glat.cc
4 @@ -4,9 +4,9 @@
6 #include "glat.h"
8 #include "gloc.h"
9 -#include "lz4.h"
10 +#include "mozilla/Compression.h"
11 #include <list>
12 #include <memory>
14 namespace ots {
15 @@ -214,16 +214,17 @@ bool OpenTypeGLAT_v3::Parse(const uint8_
16 OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
17 decompressed_size / (1024.0 * 1024.0));
19 std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
20 - int ret = LZ4_decompress_safe_partial(
21 + size_t outputSize = 0;
22 + bool ret = mozilla::Compression::LZ4::decompressPartial(
23 reinterpret_cast<const char*>(data + table.offset()),
24 - reinterpret_cast<char*>(decompressed.get()),
25 table.remaining(), // input buffer size (input size + padding)
26 + reinterpret_cast<char*>(decompressed.get()),
27 decompressed_size, // target output size
28 - decompressed_size); // output buffer size
29 - if (ret < 0 || unsigned(ret) != decompressed_size) {
30 - return DropGraphite("Decompression failed with error code %d", ret);
31 + &outputSize); // return output size
32 + if (!ret || outputSize != decompressed_size) {
33 + return DropGraphite("Decompression failed");
35 return this->Parse(decompressed.get(), decompressed_size, true);
37 default:
38 diff --git a/src/silf.cc b/src/silf.cc
39 --- a/src/silf.cc
40 +++ b/src/silf.cc
41 @@ -4,9 +4,9 @@
43 #include "silf.h"
45 #include "name.h"
46 -#include "lz4.h"
47 +#include "mozilla/Compression.h"
48 #include <cmath>
49 #include <memory>
51 namespace ots {
52 @@ -49,16 +49,17 @@ bool OpenTypeSILF::Parse(const uint8_t*
53 OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
54 decompressed_size / (1024.0 * 1024.0));
56 std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
57 - int ret = LZ4_decompress_safe_partial(
58 + size_t outputSize = 0;
59 + bool ret = mozilla::Compression::LZ4::decompressPartial(
60 reinterpret_cast<const char*>(data + table.offset()),
61 - reinterpret_cast<char*>(decompressed.get()),
62 table.remaining(), // input buffer size (input size + padding)
63 + reinterpret_cast<char*>(decompressed.get()),
64 decompressed_size, // target output size
65 - decompressed_size); // output buffer size
66 - if (ret < 0 || unsigned(ret) != decompressed_size) {
67 - return DropGraphite("Decompression failed with error code %d", ret);
68 + &outputSize); // return output size
69 + if (!ret || outputSize != decompressed_size) {
70 + return DropGraphite("Decompression failed");
72 return this->Parse(decompressed.get(), decompressed_size, true);
74 default: