aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2019-03-22 19:09:14 -0700
committerGitHub <noreply@github.com>2019-03-22 19:09:14 -0700
commitafe0881acf57b7185230601200e1e69df587c88d (patch)
tree2e74380263e6615410d13aeb52083256a7f91fb0
parentd1984fef30545e26fd7f6558ee64d0079b26956d (diff)
downloadamber-afe0881acf57b7185230601200e1e69df587c88d.tar.gz
Initialize amber structures. (#408)
This CL adds initializers for the amber::Options and amber::BufferInfo structures.
-rw-r--r--include/amber/amber.h9
-rw-r--r--samples/amber.cc4
-rw-r--r--src/amber.cc16
3 files changed, 27 insertions, 2 deletions
diff --git a/include/amber/amber.h b/include/amber/amber.h
index 8e4b5a3..e0bc794 100644
--- a/include/amber/amber.h
+++ b/include/amber/amber.h
@@ -42,6 +42,12 @@ enum EngineType {
struct EngineConfig {};
struct BufferInfo {
+ BufferInfo();
+ BufferInfo(const BufferInfo&);
+ ~BufferInfo();
+
+ BufferInfo& operator=(const BufferInfo&);
+
/// Holds the buffer name
std::string buffer_name;
/// Holds the buffer width
@@ -68,6 +74,9 @@ class Delegate {
};
struct Options {
+ Options();
+ ~Options();
+
/// Sets the engine to be created. Default Vulkan.
EngineType engine;
/// Holds engine specific configuration. Ownership stays with the caller.
diff --git a/samples/amber.cc b/samples/amber.cc
index 3fcb01d..3b9e263 100644
--- a/samples/amber.cc
+++ b/samples/amber.cc
@@ -399,7 +399,7 @@ int main(int argc, const char** argv) {
auto pos = options.image_filename.find_last_of('.');
bool usePNG = pos != std::string::npos &&
options.image_filename.substr(pos + 1) == "png";
- for (amber::BufferInfo buffer_info : amber_options.extractions) {
+ for (const amber::BufferInfo& buffer_info : amber_options.extractions) {
if (buffer_info.buffer_name == "framebuffer") {
if (usePNG) {
result = png::ConvertToPNG(buffer_info.width, buffer_info.height,
@@ -435,7 +435,7 @@ int main(int argc, const char** argv) {
std::cerr << "Cannot open file for buffer dump: ";
std::cerr << options.buffer_filename << std::endl;
} else {
- for (amber::BufferInfo buffer_info : amber_options.extractions) {
+ for (const amber::BufferInfo& buffer_info : amber_options.extractions) {
if (buffer_info.buffer_name == "framebuffer")
continue;
diff --git a/src/amber.cc b/src/amber.cc
index 53b8db0..1227c81 100644
--- a/src/amber.cc
+++ b/src/amber.cc
@@ -64,6 +64,22 @@ Result GetFrameBuffer(Buffer* buffer, std::vector<Value>* values) {
} // namespace
+Options::Options()
+ : engine(amber::EngineType::kEngineTypeVulkan),
+ config(nullptr),
+ pipeline_create_only(false),
+ delegate(nullptr) {}
+
+Options::~Options() = default;
+
+BufferInfo::BufferInfo() : width(0), height(0) {}
+
+BufferInfo::BufferInfo(const BufferInfo&) = default;
+
+BufferInfo::~BufferInfo() = default;
+
+BufferInfo& BufferInfo::operator=(const BufferInfo&) = default;
+
Delegate::~Delegate() = default;
Amber::Amber() = default;