Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / courgette / image_utils.h
blobc016357732d05745c3487a317b1eab98d91fa840
1 // Copyright 2015 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.
5 #ifndef COURGETTE_IMAGE_UTILS_H_
6 #define COURGETTE_IMAGE_UTILS_H_
8 #include "base/basictypes.h"
10 // COURGETTE_HISTOGRAM_TARGETS prints out a histogram of how frequently
11 // different target addresses are referenced. Purely for debugging.
12 #define COURGETTE_HISTOGRAM_TARGETS 0
14 namespace courgette {
16 typedef uint32 RVA;
18 // These helper functions avoid the need for casts in the main code.
19 inline uint16 ReadU16(const uint8* address, size_t offset) {
20 return *reinterpret_cast<const uint16*>(address + offset);
23 inline uint32 ReadU32(const uint8* address, size_t offset) {
24 return *reinterpret_cast<const uint32*>(address + offset);
27 inline uint64 ReadU64(const uint8* address, size_t offset) {
28 return *reinterpret_cast<const uint64*>(address + offset);
31 inline uint16 Read16LittleEndian(const void* address) {
32 return *reinterpret_cast<const uint16*>(address);
35 inline uint32 Read32LittleEndian(const void* address) {
36 return *reinterpret_cast<const uint32*>(address);
39 inline uint64 Read64LittleEndian(const void* address) {
40 return *reinterpret_cast<const uint64*>(address);
43 } // namespace courgette
45 #endif // COURGETTE_IMAGE_UTILS_H_