-
Notifications
You must be signed in to change notification settings - Fork 6
/
surface.hpp
61 lines (48 loc) · 1.37 KB
/
surface.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// surface.hpp
// Simpleton Engine
//
// Created by Indi Kernick on 27/12/17.
// Copyright © 2017 Indi Kernick. All rights reserved.
//
#ifndef engine_graphics_2d_surface_hpp
#define engine_graphics_2d_surface_hpp
#include <memory>
#include <cstdint>
namespace G2D {
class Surface {
public:
using Byte = uint8_t;
using Size = uint32_t;
using BytesPerPixel = uint32_t;
using Pitch = int32_t;
using Data = std::unique_ptr<Byte>;
Surface(Surface &&) = default;
Surface &operator=(Surface &&) = default;
Surface();
Surface(Size, Size, BytesPerPixel);
Surface(Size, Size, BytesPerPixel, Byte);
Surface(Size, Size, BytesPerPixel, Pitch, Byte *);
Byte *data();
Byte *data(Size, Size);
Byte *dataEnd();
const Byte *data() const;
const Byte *data(Size, Size) const;
const Byte *dataEnd() const;
size_t size() const;
Pitch pitch() const;
Size padding() const;
Size width() const;
Size widthBytes() const;
Size height() const;
BytesPerPixel bytesPerPixel() const;
private:
Data mData;
Pitch mPitch; //number of bytes between (x, y) and (x, y+1)
Size mWidth; //width in pixels
Size mHeight; //height in pixels
BytesPerPixel mBytesPerPixel; //bytes per pixel
};
}
#include "surface.inl"
#endif