blob: 559812eaaeb558a3571efcf50ae3bbae9a8e7ef7 [file] [log] [blame]
Samuel Huang06f1ae92018-03-13 18:19:34 +00001// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_
6#define COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_
7
8#include <vector>
9
10#include "components/zucchini/image_utils.h"
11#include "components/zucchini/patch_reader.h"
12#include "components/zucchini/zucchini.h"
13
14namespace zucchini {
15
16// Reads equivalences from |patch_reader| to form preliminary |new_image|,
17// copying regions from |old_image| and writing extra data from |patch_reader|.
18bool ApplyEquivalenceAndExtraData(ConstBufferView old_image,
19 const PatchElementReader& patch_reader,
20 MutableBufferView new_image);
21
22// Reads raw delta from |patch_reader| and applies corrections to |new_image|.
23bool ApplyRawDelta(const PatchElementReader& patch_reader,
24 MutableBufferView new_image);
25
26// Corrects references in |new_image| by projecting references from |old_image|
27// and applying corrections from |patch_reader|. Both |old_image| and
28// |new_image| are matching elements associated with |exe_type|.
29bool ApplyReferencesCorrection(ExecutableType exe_type,
30 ConstBufferView old_image,
31 const PatchElementReader& patch_reader,
32 MutableBufferView new_image);
33
34// Applies patch element with type |exe_type| from |patch_reader| on |old_image|
35// to produce |new_image|.
36bool ApplyElement(ExecutableType exe_type,
37 ConstBufferView old_image,
38 const PatchElementReader& patch_reader,
39 MutableBufferView new_image);
40
41} // namespace zucchini
42
43#endif // COMPONENTS_ZUCCHINI_ZUCCHINI_APPLY_H_