Edit

kc3-lang/angle/util/frame_capture_test_utils.h

Branch :

  • Show log

    Commit

  • Author : Manh Nguyen
    Date : 2020-06-29 13:47:13
    Hash : bdf91e5f
    Message : Refactor frame_capture_utils.h to frame_capture_test_utils.h frame_capture_utils.h is only used in tests so changing the name to be frame_capture_test_utils.h is more appropriate. Also frame_capture_utils.h will now be a file in libANGLE_with_capture library where serialization code is stored. Bug: angleproject:4806 Change-Id: I7482693a75b2d0edda7e84ae9b777fd3f46f1855 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2273917 Commit-Queue: Manh Nguyen <nguyenmh@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>

  • util/frame_capture_test_utils.h
  • //
    // Copyright 2020 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    // frame_capture_test_utils:
    //   Helper functions for capture and replay of traces.
    //
    
    #ifndef UTIL_FRAME_CAPTURE_TEST_UTILS_H_
    #define UTIL_FRAME_CAPTURE_TEST_UTILS_H_
    
    #include <iostream>
    #include <memory>
    #include <vector>
    
    #include "common/angleutils.h"
    
    #define USE_SYSTEM_ZLIB
    #include "compression_utils_portable.h"
    
    #define ANGLE_MACRO_STRINGIZE_AUX(a) #a
    #define ANGLE_MACRO_STRINGIZE(a) ANGLE_MACRO_STRINGIZE_AUX(a)
    #define ANGLE_MACRO_CONCAT_AUX(a, b) a##b
    #define ANGLE_MACRO_CONCAT(a, b) ANGLE_MACRO_CONCAT_AUX(a, b)
    
    namespace angle
    {
    
    inline uint8_t *DecompressBinaryData(const std::vector<uint8_t> &compressedData)
    {
        uint32_t uncompressedSize =
            zlib_internal::GetGzipUncompressedSize(compressedData.data(), compressedData.size());
    
        std::unique_ptr<uint8_t[]> uncompressedData(new uint8_t[uncompressedSize]);
        uLong destLen = uncompressedSize;
        int zResult =
            zlib_internal::GzipUncompressHelper(uncompressedData.get(), &destLen, compressedData.data(),
                                                static_cast<uLong>(compressedData.size()));
    
        if (zResult != Z_OK)
        {
            std::cerr << "Failure to decompressed binary data: " << zResult << "\n";
            return nullptr;
        }
    
        return uncompressedData.release();
    }
    
    }  // namespace angle
    
    #endif  // UTIL_FRAME_CAPTURE_TEST_UTILS_H_