• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2020 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // frame_capture_utils:
7 //   Helper functions for capture and replay of traces.
8 //
9 
10 #ifndef UTIL_FRAME_CAPTURE_UTILS_H_
11 #define UTIL_FRAME_CAPTURE_UTILS_H_
12 
13 #include <iostream>
14 #include <memory>
15 #include <vector>
16 
17 #include "common/angleutils.h"
18 
19 #define USE_SYSTEM_ZLIB
20 #include "compression_utils_portable.h"
21 
22 namespace angle
23 {
24 
DecompressBinaryData(const std::vector<uint8_t> & compressedData)25 inline uint8_t *DecompressBinaryData(const std::vector<uint8_t> &compressedData)
26 {
27     uint32_t uncompressedSize =
28         zlib_internal::GetGzipUncompressedSize(compressedData.data(), compressedData.size());
29 
30     std::unique_ptr<uint8_t[]> uncompressedData(new uint8_t[uncompressedSize]);
31     uLong destLen = uncompressedSize;
32     int zResult =
33         zlib_internal::GzipUncompressHelper(uncompressedData.get(), &destLen, compressedData.data(),
34                                             static_cast<uLong>(compressedData.size()));
35 
36     if (zResult != Z_OK)
37     {
38         std::cerr << "Failure to decompressed binary data: " << zResult << "\n";
39         return nullptr;
40     }
41 
42     return uncompressedData.release();
43 }
44 
45 }  // namespace angle
46 
47 #endif  // UTIL_FRAME_CAPTURE_UTILS_H_
48