From f8f6a249b84f66e057c1a954eaea05fc5fbfc331 Mon Sep 17 00:00:00 2001 From: Helge Norberg Date: Tue, 17 Feb 2015 13:43:42 +0100 Subject: [PATCH] * Refactored to use enum class instead of enum_class. * Fixed all warnings in psd project and enabled treat warnings as errors --- accelerator/ogl/image/image_kernel.cpp | 20 +- accelerator/ogl/image/image_kernel.h | 11 +- accelerator/ogl/image/image_shader.h | 19 +- accelerator/ogl/util/buffer.h | 11 +- accelerator/ogl/util/device.cpp | 2 +- accelerator/ogl/util/shader.h | 12 + common/enum_class.h | 67 +-- common/executor.h | 19 +- common/filesystem_monitor.h | 4 +- common/polling_filesystem_monitor.cpp | 20 +- core/frame/draw_frame.cpp | 2 +- core/frame/frame_transform.cpp | 2 +- core/frame/geometry.cpp | 4 +- core/frame/geometry.h | 2 +- core/frame/pixel_format.h | 32 +- core/mixer/image/blend_modes.h | 70 ++- core/producer/draw/freehand_producer.cpp | 2 +- core/producer/frame_producer.h | 1 - core/producer/scene/expression_parser.cpp | 38 +- core/producer/text/text_producer.cpp | 8 +- core/producer/text/utils/texture_font.cpp | 440 +++++++++--------- core/producer/text/utils/texture_font.h | 4 +- .../transition/transition_producer.cpp | 2 +- .../producer/transition/transition_producer.h | 31 +- core/thumbnail_generator.cpp | 8 +- core/video_format.cpp | 2 +- core/video_format.h | 91 ++-- modules/bluefish/util/blue_velvet.cpp | 2 +- .../decklink/consumer/decklink_consumer.cpp | 37 +- modules/decklink/util/util.h | 2 +- modules/ffmpeg/producer/muxer/display_mode.h | 18 +- modules/ffmpeg/producer/util/util.cpp | 6 +- modules/psd/descriptor.cpp | 8 +- modules/psd/doc.cpp | 43 +- modules/psd/layer.cpp | 86 ++-- modules/psd/misc.cpp | 129 ++--- modules/psd/misc.h | 6 +- modules/psd/psd.vcxproj | 10 +- .../psd/util/bigendian_file_input_stream.cpp | 36 +- .../psd/util/bigendian_file_input_stream.h | 12 +- modules/psd/util/pdf_reader.cpp | 2 +- modules/screen/consumer/screen_consumer.cpp | 24 +- protocol/amcp/AMCPProtocolStrategy.cpp | 58 +-- protocol/clk/CLKProtocolStrategy.cpp | 16 +- test/psd-test/psd-test.vcxproj | 8 +- 45 files changed, 676 insertions(+), 751 deletions(-) diff --git a/accelerator/ogl/image/image_kernel.cpp b/accelerator/ogl/image/image_kernel.cpp index 6cd866de2..a259e13da 100644 --- a/accelerator/ogl/image/image_kernel.cpp +++ b/accelerator/ogl/image/image_kernel.cpp @@ -84,10 +84,10 @@ struct image_kernel::impl params.textures[n]->bind(n); if(params.local_key) - params.local_key->bind(texture_id::local_key); + params.local_key->bind(static_cast(texture_id::local_key)); if(params.layer_key) - params.layer_key->bind(texture_id::layer_key); + params.layer_key->bind(static_cast(texture_id::layer_key)); // Setup shader @@ -97,7 +97,7 @@ struct image_kernel::impl shader_->set("plane[1]", texture_id::plane1); shader_->set("plane[2]", texture_id::plane2); shader_->set("plane[3]", texture_id::plane3); - for(int n = 0; n < params.textures.size(); ++n) + for (int n = 0; n < params.textures.size(); ++n) shader_->set("plane_size[" + boost::lexical_cast(n) + "]", static_cast(params.textures[n]->width()), static_cast(params.textures[n]->height())); @@ -107,7 +107,7 @@ struct image_kernel::impl shader_->set("is_hd", params.pix_desc.planes.at(0).height > 700 ? 1 : 0); shader_->set("has_local_key", static_cast(params.local_key)); shader_->set("has_layer_key", static_cast(params.layer_key)); - shader_->set("pixel_format", params.pix_desc.format.value()); + shader_->set("pixel_format", params.pix_desc.format); shader_->set("opacity", params.transform.is_key ? 1.0 : params.transform.opacity); @@ -118,17 +118,17 @@ struct image_kernel::impl if(blend_modes_) { - params.background->bind(texture_id::background); + params.background->bind(static_cast(texture_id::background)); shader_->set("background", texture_id::background); - shader_->set("blend_mode", params.blend_mode.value()); - shader_->set("keyer", params.keyer.value()); + shader_->set("blend_mode", params.blend_mode); + shader_->set("keyer", params.keyer); } else { GL(glEnable(GL_BLEND)); - switch(params.keyer.value()) + switch(params.keyer) { case keyer::additive: GL(glBlendFunc(GL_ONE, GL_ONE)); @@ -223,7 +223,7 @@ struct image_kernel::impl switch(params.geometry.type()) { - case core::frame_geometry::quad: + case core::frame_geometry::geometry_type::quad: { const std::vector& data = params.geometry.data(); float v_left = data[0], v_top = data[1], t_left = data[2], t_top = data[3]; @@ -238,7 +238,7 @@ struct image_kernel::impl } break; - case core::frame_geometry::quad_list: + case core::frame_geometry::geometry_type::quad_list: { glClientActiveTexture(GL_TEXTURE0); diff --git a/accelerator/ogl/image/image_kernel.h b/accelerator/ogl/image/image_kernel.h index 318c1a2d5..3a7320ba3 100644 --- a/accelerator/ogl/image/image_kernel.h +++ b/accelerator/ogl/image/image_kernel.h @@ -23,7 +23,6 @@ #include -#include #include #include @@ -32,15 +31,11 @@ namespace caspar { namespace accelerator { namespace ogl { -struct keyer_def +enum class keyer { - enum type - { - linear = 0, - additive, - }; + linear = 0, + additive, }; -typedef enum_class keyer; struct draw_params final { diff --git a/accelerator/ogl/image/image_shader.h b/accelerator/ogl/image/image_shader.h index a09f62ea6..87b9db2b1 100644 --- a/accelerator/ogl/image/image_shader.h +++ b/accelerator/ogl/image/image_shader.h @@ -28,18 +28,15 @@ namespace caspar { namespace accelerator { namespace ogl { class shader; class device; -struct texture_id +enum class texture_id { - enum type - { - plane0 = 0, - plane1, - plane2, - plane3, - local_key, - layer_key, - background, - }; + plane0 = 0, + plane1, + plane2, + plane3, + local_key, + layer_key, + background }; std::shared_ptr get_image_shader( diff --git a/accelerator/ogl/util/buffer.h b/accelerator/ogl/util/buffer.h index cc1fbd73f..136db96e4 100644 --- a/accelerator/ogl/util/buffer.h +++ b/accelerator/ogl/util/buffer.h @@ -22,7 +22,6 @@ #pragma once #include -#include #include @@ -36,15 +35,11 @@ public: // Static Members - struct usage_def + enum class usage { - enum type - { - write_only, - read_only - }; + write_only, + read_only }; - typedef enum_class usage; // Constructors diff --git a/accelerator/ogl/util/device.cpp b/accelerator/ogl/util/device.cpp index e2dc5ba71..ccd1cf74f 100644 --- a/accelerator/ogl/util/device.cpp +++ b/accelerator/ogl/util/device.cpp @@ -154,7 +154,7 @@ struct device::impl : public std::enable_shared_from_this { CASPAR_VERIFY(size > 0); - auto pool = &host_pools_[usage.value()][size]; + auto pool = &host_pools_[static_cast(usage)][size]; std::shared_ptr buf; if(!pool->try_pop(buf)) diff --git a/accelerator/ogl/util/shader.h b/accelerator/ogl/util/shader.h index 8af70914d..bb8976464 100644 --- a/accelerator/ogl/util/shader.h +++ b/accelerator/ogl/util/shader.h @@ -25,6 +25,8 @@ #include +#include + namespace caspar { namespace accelerator { namespace ogl { class shader final @@ -47,6 +49,16 @@ public: void set(const std::string& name, float value); void set(const std::string& name, float value0, float value1); void set(const std::string& name, double value); + + template + typename std::enable_if< + std::is_enum::value, + void + >::type set(const std::string& name, E value) + { + set(name, static_cast::type>(value)); + } + void use() const; // Properties diff --git a/common/enum_class.h b/common/enum_class.h index 725075947..4d919aff2 100644 --- a/common/enum_class.h +++ b/common/enum_class.h @@ -1,57 +1,18 @@ #pragma once -namespace caspar { +#include -template -class enum_class : public def -{ - typedef typename def::type type; - inner val_; -public: - explicit enum_class(int v) : val_(static_cast(v)) {} - enum_class(type v) : val_(v) {} - inner value() const { return val_; } - - bool operator==(const enum_class& s) const { return val_ == s.val_; } - bool operator!=(const enum_class& s) const { return val_ != s.val_; } - bool operator<(const enum_class& s) const { return val_ < s.val_; } - bool operator<=(const enum_class& s) const { return val_ <= s.val_; } - bool operator>(const enum_class& s) const { return val_ > s.val_; } - bool operator>=(const enum_class& s) const { return val_ >= s.val_; } - - bool operator==(const int& val) const { return val_ == val; } - bool operator!=(const int& val) const { return val_ != val; } - bool operator<(const int& val) const { return val_ < val; } - bool operator<=(const int& val) const { return val_ <= val; } - bool operator>(const int& val) const { return val_ > val; } - bool operator>=(const int& val) const { return val_ >= val; } +// Macro that defines & and &= for an enum class. Add more when needed. - enum_class operator&(const enum_class& s) const - { - return enum_class(static_cast(val_ & s.val_)); - } - - enum_class& operator&=(const enum_class& s) - { - val_ = static_cast(val_ & s.val_); - return *this; - } - - enum_class operator|(const enum_class& s) const - { - return enum_class(static_cast(val_ | s.val_)); - } - - enum_class& operator|=(const enum_class& s) - { - val_ = static_cast(val_ | s.val_); - return *this; - } - - //operator inner() - //{ - // return val_; - //} -}; - -} \ No newline at end of file +#define ENUM_ENABLE_BITWISE(enum_class) \ + static enum_class operator&(enum_class lhs, enum_class rhs) \ + { \ + return static_cast( \ + static_cast::type>(lhs) \ + & static_cast::type>(rhs)); \ + }; \ + static enum_class& operator&=(enum_class& lhs, enum_class rhs) \ + { \ + lhs = lhs & rhs; \ + return lhs; \ + }; diff --git a/common/executor.h b/common/executor.h index c2876caad..28d3d3fb8 100644 --- a/common/executor.h +++ b/common/executor.h @@ -22,7 +22,6 @@ #pragma once #include "except.h" -#include "enum_class.h" #include "log.h" #include "blocking_bounded_queue_adapter.h" #include "blocking_priority_queue.h" @@ -39,19 +38,15 @@ namespace caspar { -struct task_priority_def +enum class task_priority { - enum type - { - lowest_priority = 0, - lower_priority, - low_priority, - normal_priority, - high_priority, - higher_priority - }; + lowest_priority = 0, + lower_priority, + low_priority, + normal_priority, + high_priority, + higher_priority }; -typedef enum_class task_priority; class executor final { diff --git a/common/filesystem_monitor.h b/common/filesystem_monitor.h index 4ba435e88..4e90bb4a0 100644 --- a/common/filesystem_monitor.h +++ b/common/filesystem_monitor.h @@ -29,6 +29,7 @@ #include "memory.h" #include "future_fwd.h" +#include "enum_class.h" namespace caspar { @@ -64,7 +65,7 @@ public: /** * The possible filesystem events. */ -enum filesystem_event +enum class filesystem_event { CREATED = 1, REMOVED = 2, @@ -72,6 +73,7 @@ enum filesystem_event // Only used for describing a bitmask where all events are wanted. Never used when calling a handler. ALL = 7 }; +ENUM_ENABLE_BITWISE(filesystem_event); /** * Handles filesystem events. diff --git a/common/polling_filesystem_monitor.cpp b/common/polling_filesystem_monitor.cpp index 409addce1..ccef76741 100644 --- a/common/polling_filesystem_monitor.cpp +++ b/common/polling_filesystem_monitor.cpp @@ -97,20 +97,20 @@ public: void reemmit_all() { - if ((events_mask_ & MODIFIED) == 0) + if (static_cast(events_mask_ & filesystem_event::MODIFIED) == 0) return; for (auto& file : files_) - handler_(MODIFIED, file.first); + handler_(filesystem_event::MODIFIED, file.first); } void reemmit(const boost::filesystem::wpath& file) { - if ((events_mask_ & MODIFIED) == 0) + if (static_cast(events_mask_ & filesystem_event::MODIFIED) == 0) return; if (files_.find(file) != files_.end() && boost::filesystem::exists(file)) - handler_(MODIFIED, file); + handler_(filesystem_event::MODIFIED, file); } void scan(const boost::function& should_abort) @@ -118,9 +118,9 @@ public: static const std::time_t NO_LONGER_WRITING_AGE = 3; // Assume std::time_t is expressed in seconds using namespace boost::filesystem; - bool interested_in_removed = (events_mask_ & REMOVED) > 0; - bool interested_in_created = (events_mask_ & CREATED) > 0; - bool interested_in_modified = (events_mask_ & MODIFIED) > 0; + bool interested_in_removed = static_cast(events_mask_ & filesystem_event::REMOVED) > 0; + bool interested_in_created = static_cast(events_mask_ & filesystem_event::CREATED) > 0; + bool interested_in_modified = static_cast(events_mask_ & filesystem_event::MODIFIED) > 0; std::set removed_files; boost::copy( @@ -164,7 +164,7 @@ public: if (modified && can_read_file(path)) { if (interested_in_modified) - handler_(MODIFIED, path); + handler_(filesystem_event::MODIFIED, path); files_[path] = current_mtime; being_written_sizes_.erase(path); @@ -173,7 +173,7 @@ public: else if (no_longer_being_written_to && can_read_file(path)) { if (interested_in_created && (report_already_existing_ || !first_scan_)) - handler_(CREATED, path); + handler_(filesystem_event::CREATED, path); if (first_scan_) initial_files.insert(path); @@ -191,7 +191,7 @@ public: being_written_sizes_.erase(path); if (interested_in_removed) - handler_(REMOVED, path); + handler_(filesystem_event::REMOVED, path); } if (first_scan_) diff --git a/core/frame/draw_frame.cpp b/core/frame/draw_frame.cpp index 21dcdab26..a986f7c54 100644 --- a/core/frame/draw_frame.cpp +++ b/core/frame/draw_frame.cpp @@ -29,7 +29,7 @@ namespace caspar { namespace core { -enum tags +enum class tags { frame_tag = 0, empty_tag, diff --git a/core/frame/frame_transform.cpp b/core/frame/frame_transform.cpp index f9c14f3aa..6c73f98eb 100644 --- a/core/frame/frame_transform.cpp +++ b/core/frame/frame_transform.cpp @@ -65,7 +65,7 @@ image_transform& image_transform::operator*=(const image_transform &other) levels.min_output = std::max(levels.min_output, other.levels.min_output); levels.max_output = std::min(levels.max_output, other.levels.max_output); levels.gamma *= other.levels.gamma; - field_mode = static_cast(field_mode & other.field_mode); + field_mode = field_mode & other.field_mode; is_key |= other.is_key; is_mix |= other.is_mix; is_still |= other.is_still; diff --git a/core/frame/geometry.cpp b/core/frame/geometry.cpp index cb09caa8e..dda0c136d 100644 --- a/core/frame/geometry.cpp +++ b/core/frame/geometry.cpp @@ -37,7 +37,7 @@ struct frame_geometry::impl frame_geometry::frame_geometry() {} frame_geometry::frame_geometry(geometry_type t, std::vector d) : impl_(new impl(t, std::move(d))) {} -frame_geometry::geometry_type frame_geometry::type() const { return impl_ ? impl_->type_ : none; } +frame_geometry::geometry_type frame_geometry::type() const { return impl_ ? impl_->type_ : geometry_type::none; } const std::vector& frame_geometry::data() const { if (impl_) @@ -49,7 +49,7 @@ const std::vector& frame_geometry::data() const const frame_geometry& frame_geometry::get_default() { const float d[] = {0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f}; - static frame_geometry g(frame_geometry::quad, std::vector(std::begin(d), std::end(d))); + static frame_geometry g(frame_geometry::geometry_type::quad, std::vector(std::begin(d), std::end(d))); return g; } diff --git a/core/frame/geometry.h b/core/frame/geometry.h index 9e3293d96..ffa47902b 100644 --- a/core/frame/geometry.h +++ b/core/frame/geometry.h @@ -29,7 +29,7 @@ namespace caspar { namespace core { class frame_geometry { public: - enum geometry_type + enum class geometry_type { none, quad, diff --git a/core/frame/pixel_format.h b/core/frame/pixel_format.h index 09f2bc61e..b4499e3b1 100644 --- a/core/frame/pixel_format.h +++ b/core/frame/pixel_format.h @@ -23,32 +23,26 @@ #include "../video_format.h" -#include - #include #include namespace caspar { namespace core { -struct pixel_format_def +enum class pixel_format { - enum type - { - gray = 0, - bgra, - rgba, - argb, - abgr, - ycbcr, - ycbcra, - luma, - bgr, - rgb, - count, - invalid, - }; + gray = 0, + bgra, + rgba, + argb, + abgr, + ycbcr, + ycbcra, + luma, + bgr, + rgb, + count, + invalid, }; -typedef enum_class pixel_format; struct pixel_format_desc final { diff --git a/core/mixer/image/blend_modes.h b/core/mixer/image/blend_modes.h index 8d57fa920..04b9ecfd4 100644 --- a/core/mixer/image/blend_modes.h +++ b/core/mixer/image/blend_modes.h @@ -21,48 +21,42 @@ #pragma once -#include - namespace caspar { namespace core { -struct blend_mode_def +enum class blend_mode { - enum type - { - normal = 0, - lighten, - darken, - multiply, - average, - add, - subtract, - difference, - negation, - exclusion, - screen, - overlay, - soft_light, - hard_light, - color_dodge, - color_burn, - linear_dodge, - linear_burn, - linear_light, - vivid_light, - pin_light, - hard_mix, - reflect, - glow, - phoenix, - contrast, - saturation, - color, - luminosity, - mix, - blend_mode_count - }; + normal = 0, + lighten, + darken, + multiply, + average, + add, + subtract, + difference, + negation, + exclusion, + screen, + overlay, + soft_light, + hard_light, + color_dodge, + color_burn, + linear_dodge, + linear_burn, + linear_light, + vivid_light, + pin_light, + hard_mix, + reflect, + glow, + phoenix, + contrast, + saturation, + color, + luminosity, + mix, + blend_mode_count }; -typedef enum_class blend_mode; blend_mode get_blend_mode(const std::wstring& str); diff --git a/core/producer/draw/freehand_producer.cpp b/core/producer/draw/freehand_producer.cpp index 0bb97a890..c0e032aea 100644 --- a/core/producer/draw/freehand_producer.cpp +++ b/core/producer/draw/freehand_producer.cpp @@ -69,7 +69,7 @@ public: draw_frame create_frame() { - pixel_format_desc desc(pixel_format_def::bgra); + pixel_format_desc desc(pixel_format::bgra); desc.planes.push_back(pixel_format_desc::plane( static_cast(constraints_.width.get()), static_cast(constraints_.height.get()), diff --git a/core/producer/frame_producer.h b/core/producer/frame_producer.h index f07852feb..c7ea9db43 100644 --- a/core/producer/frame_producer.h +++ b/core/producer/frame_producer.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/core/producer/scene/expression_parser.cpp b/core/producer/scene/expression_parser.cpp index 3d6c12096..5202bcef1 100644 --- a/core/producer/scene/expression_parser.cpp +++ b/core/producer/scene/expression_parser.cpp @@ -215,7 +215,7 @@ boost::any parse_variable( struct op { - enum op_type + enum class op_type { UNARY, BINARY, @@ -250,16 +250,16 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str) { case L'+': ++cursor; - return op(ch, 6, op::BINARY); + return op(ch, 6, op::op_type::BINARY); case L'*': case L'/': case L'%': ++cursor; - return op(ch, 5, op::BINARY); + return op(ch, 5, op::op_type::BINARY); case L'?': case L':': ++cursor; - return op(ch, 15, op::TERNARY); + return op(ch, 15, op::op_type::TERNARY); case L'-': if (first == L'-') CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info( @@ -300,22 +300,22 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str) if (first == L'=') { ++cursor; - return op(L"==", 9, op::BINARY); + return op(L"==", 9, op::op_type::BINARY); } else if (first == L'!') { ++cursor; - return op(L"!=", 9, op::BINARY); + return op(L"!=", 9, op::op_type::BINARY); } else if (first == L'>') { ++cursor; - return op(L">=", 8, op::BINARY); + return op(L">=", 8, op::op_type::BINARY); } else if (first == L'<') { ++cursor; - return op(L"<=", 8, op::BINARY); + return op(L"<=", 8, op::op_type::BINARY); } else if (first == NONE) { @@ -331,7 +331,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str) if (first == L'|') { ++cursor; - return op(L"||", 14, op::BINARY); + return op(L"||", 14, op::op_type::BINARY); } else if (first == NONE) { @@ -347,7 +347,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str) if (first == L'&') { ++cursor; - return op(L"&&", 13, op::BINARY); + return op(L"&&", 13, op::op_type::BINARY); } else if (first == NONE) { @@ -362,18 +362,18 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str) case L' ': case L'\t': if (first == L'-') - return op(L'-', 6, op::BINARY); + return op(L'-', 6, op::op_type::BINARY); else if (first == L'!') - return op(L'!', 3, op::UNARY); + return op(L'!', 3, op::op_type::UNARY); default: if (first == L'<') - return op(L'<', 8, op::BINARY); + return op(L'<', 8, op::op_type::BINARY); else if (first == L'>') - return op(L'>', 8, op::BINARY); + return op(L'>', 8, op::op_type::BINARY); else if (first == L'-') - return op(L"unary-", 3, op::UNARY); + return op(L"unary-", 3, op::op_type::UNARY); else if (first == L'!') - return op(L'!', 3, op::UNARY); + return op(L'!', 3, op::op_type::UNARY); else CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info( L"Expected second character of operator" @@ -587,7 +587,7 @@ void resolve_operators(int precedence, std::vector& tokens) switch (op_token.type) { - case op::UNARY: + case op::op_type::UNARY: if (op_token.characters == L"unary-") { tokens.at(i) = negative(token_after); @@ -600,7 +600,7 @@ void resolve_operators(int precedence, std::vector& tokens) tokens.erase(tokens.begin() + index_after); break; - case op::BINARY: + case op::op_type::BINARY: { auto& token_before = tokens.at(i - 1); @@ -636,7 +636,7 @@ void resolve_operators(int precedence, std::vector& tokens) --i; break; - case op::TERNARY: + case op::op_type::TERNARY: if (op_token.characters == L"?") { auto& token_before = tokens.at(i - 1); diff --git a/core/producer/text/text_producer.cpp b/core/producer/text/text_producer.cpp index c4c0cba7f..0b0936786 100644 --- a/core/producer/text/text_producer.cpp +++ b/core/producer/text/text_producer.cpp @@ -157,9 +157,9 @@ public: , dirty_(false) { //TODO: examine str to determine which unicode_blocks to load - font_.load_glyphs(text::Basic_Latin, text_info.color); - font_.load_glyphs(text::Latin_1_Supplement, text_info.color); - font_.load_glyphs(text::Latin_Extended_A, text_info.color); + font_.load_glyphs(text::unicode_block::Basic_Latin, text_info.color); + font_.load_glyphs(text::unicode_block::Latin_1_Supplement, text_info.color); + font_.load_glyphs(text::unicode_block::Latin_Extended_A, text_info.color); tracking_.value().set(text_info.tracking); text_subscription_ = text_.value().on_change([this]() @@ -192,7 +192,7 @@ public: auto vertex_stream = font_.create_vertex_stream(text_.value().get(), x_, y_, parent_width_, parent_height_, &metrics); auto frame = frame_factory_->create_frame(vertex_stream.data(), pfd); memcpy(frame.image_data().data(), atlas_.data(), frame.image_data().size()); - frame.set_geometry(frame_geometry(frame_geometry::quad_list, std::move(vertex_stream))); + frame.set_geometry(frame_geometry(frame_geometry::geometry_type::quad_list, std::move(vertex_stream))); this->constraints_.width.set(metrics.width); this->constraints_.height.set(metrics.height); diff --git a/core/producer/text/utils/texture_font.cpp b/core/producer/text/utils/texture_font.cpp index f728cb5e7..4e9cf83ff 100644 --- a/core/producer/text/utils/texture_font.cpp +++ b/core/producer/text/utils/texture_font.cpp @@ -290,226 +290,226 @@ unicode_range get_range(unicode_block block) { switch(block) { - case Basic_Latin: return unicode_range(0x0000, 0x007F); - case Latin_1_Supplement: return unicode_range(0x0080, 0x00FF); - case Latin_Extended_A: return unicode_range(0x0100, 0x017F); - case Latin_Extended_B: return unicode_range(0x0180, 0x024F); - case IPA_Extensions: return unicode_range(0x0250, 0x02AF); - case Spacing_Modifier_Letters: return unicode_range(0x02B0, 0x02FF); - case Combining_Diacritical_Marks: return unicode_range(0x0300, 0x036F); - case Greek_and_Coptic: return unicode_range(0x0370, 0x03FF); - case Cyrillic: return unicode_range(0x0400, 0x04FF); - case Cyrillic_Supplement: return unicode_range(0x0500, 0x052F); - case Armenian: return unicode_range(0x0530, 0x058F); - case Hebrew: return unicode_range(0x0590, 0x05FF); - case Arabic: return unicode_range(0x0600, 0x06FF); - case Syriac: return unicode_range(0x0700, 0x074F); - case Arabic_Supplement: return unicode_range(0x0750, 0x077F); - case Thaana: return unicode_range(0x0780, 0x07BF); - case NKo: return unicode_range(0x07C0, 0x07FF); - case Samaritan: return unicode_range(0x0800, 0x083F); - case Mandaic: return unicode_range(0x0840, 0x085F); - case Arabic_Extended_A: return unicode_range(0x08A0, 0x08FF); - case Devanagari: return unicode_range(0x0900, 0x097F); - case Bengali: return unicode_range(0x0980, 0x09FF); - case Gurmukhi: return unicode_range(0x0A00, 0x0A7F); - case Gujarati: return unicode_range(0x0A80, 0x0AFF); - case Oriya: return unicode_range(0x0B00, 0x0B7F); - case Tamil: return unicode_range(0x0B80, 0x0BFF); - case Telugu: return unicode_range(0x0C00, 0x0C7F); - case Kannada: return unicode_range(0x0C80, 0x0CFF); - case Malayalam: return unicode_range(0x0D00, 0x0D7F); - case Sinhala: return unicode_range(0x0D80, 0x0DFF); - case Thai: return unicode_range(0x0E00, 0x0E7F); - case Lao: return unicode_range(0x0E80, 0x0EFF); - case Tibetan: return unicode_range(0x0F00, 0x0FFF); - case Myanmar: return unicode_range(0x1000, 0x109F); - case Georgian: return unicode_range(0x10A0, 0x10FF); - case Hangul_Jamo: return unicode_range(0x1100, 0x11FF); - case Ethiopic: return unicode_range(0x1200, 0x137F); - case Ethiopic_Supplement: return unicode_range(0x1380, 0x139F); - case Cherokee: return unicode_range(0x13A0, 0x13FF); - case Unified_Canadian_Aboriginal_Syllabics: return unicode_range(0x1400, 0x167F); - case Ogham: return unicode_range(0x1680, 0x169F); - case Runic: return unicode_range(0x16A0, 0x16FF); - case Tagalog: return unicode_range(0x1700, 0x171F); - case Hanunoo: return unicode_range(0x1720, 0x173F); - case Buhid: return unicode_range(0x1740, 0x175F); - case Tagbanwa: return unicode_range(0x1760, 0x177F); - case Khmer: return unicode_range(0x1780, 0x17FF); - case Mongolian: return unicode_range(0x1800, 0x18AF); - case Unified_Canadian_Aboriginal_Syllabics_Extended: return unicode_range(0x18B0, 0x18FF); - case Limbu: return unicode_range(0x1900, 0x194F); - case Tai_Le: return unicode_range(0x1950, 0x197F); - case New_Tai_Lue: return unicode_range(0x1980, 0x19DF); - case Khmer_Symbols: return unicode_range(0x19E0, 0x19FF); - case Buginese: return unicode_range(0x1A00, 0x1A1F); - case Tai_Tham: return unicode_range(0x1A20, 0x1AAF); - case Balinese: return unicode_range(0x1B00, 0x1B7F); - case Sundanese: return unicode_range(0x1B80, 0x1BBF); - case Batak: return unicode_range(0x1BC0, 0x1BFF); - case Lepcha: return unicode_range(0x1C00, 0x1C4F); - case Ol_Chiki: return unicode_range(0x1C50, 0x1C7F); - case Sundanese_Supplement: return unicode_range(0x1CC0, 0x1CCF); - case Vedic_Extensions: return unicode_range(0x1CD0, 0x1CFF); - case Phonetic_Extensions: return unicode_range(0x1D00, 0x1D7F); - case Phonetic_Extensions_Supplement: return unicode_range(0x1D80, 0x1DBF); - case Combining_Diacritical_Marks_Supplement: return unicode_range(0x1DC0, 0x1DFF); - case Latin_Extended_Additional: return unicode_range(0x1E00, 0x1EFF); - case Greek_Extended: return unicode_range(0x1F00, 0x1FFF); - case General_Punctuation: return unicode_range(0x2000, 0x206F); - case Superscripts_and_Subscripts: return unicode_range(0x2070, 0x209F); - case Currency_Symbols: return unicode_range(0x20A0, 0x20CF); - case Combining_Diacritical_Marks_for_Symbols: return unicode_range(0x20D0, 0x20FF); - case Letterlike_Symbols: return unicode_range(0x2100, 0x214F); - case Number_Forms: return unicode_range(0x2150, 0x218F); - case Arrows: return unicode_range(0x2190, 0x21FF); - case Mathematical_Operators: return unicode_range(0x2200, 0x22FF); - case Miscellaneous_Technical: return unicode_range(0x2300, 0x23FF); - case Control_Pictures: return unicode_range(0x2400, 0x243F); - case Optical_Character_Recognition: return unicode_range(0x2440, 0x245F); - case Enclosed_Alphanumerics: return unicode_range(0x2460, 0x24FF); - case Box_Drawing: return unicode_range(0x2500, 0x257F); - case Block_Elements: return unicode_range(0x2580, 0x259F); - case Geometric_Shapes: return unicode_range(0x25A0, 0x25FF); - case Miscellaneous_Symbols: return unicode_range(0x2600, 0x26FF); - case Dingbats: return unicode_range(0x2700, 0x27BF); - case Miscellaneous_Mathematical_Symbols_A: return unicode_range(0x27C0, 0x27EF); - case Supplemental_Arrows_A: return unicode_range(0x27F0, 0x27FF); - case Braille_Patterns: return unicode_range(0x2800, 0x28FF); - case Supplemental_Arrows_B: return unicode_range(0x2900, 0x297F); - case Miscellaneous_Mathematical_Symbols_B: return unicode_range(0x2980, 0x29FF); - case Supplemental_Mathematical_Operators: return unicode_range(0x2A00, 0x2AFF); - case Miscellaneous_Symbols_and_Arrows: return unicode_range(0x2B00, 0x2BFF); - case Glagolitic: return unicode_range(0x2C00, 0x2C5F); - case Latin_Extended_C: return unicode_range(0x2C60, 0x2C7F); - case Coptic: return unicode_range(0x2C80, 0x2CFF); - case Georgian_Supplement: return unicode_range(0x2D00, 0x2D2F); - case Tifinagh: return unicode_range(0x2D30, 0x2D7F); - case Ethiopic_Extended: return unicode_range(0x2D80, 0x2DDF); - case Cyrillic_Extended_A: return unicode_range(0x2DE0, 0x2DFF); - case Supplemental_Punctuation: return unicode_range(0x2E00, 0x2E7F); - case CJK_Radicals_Supplement: return unicode_range(0x2E80, 0x2EFF); - case Kangxi_Radicals: return unicode_range(0x2F00, 0x2FDF); - case Ideographic_Description_Characters: return unicode_range(0x2FF0, 0x2FFF); - case CJK_Symbols_and_Punctuation: return unicode_range(0x3000, 0x303F); - case Hiragana: return unicode_range(0x3040, 0x309F); - case Katakana: return unicode_range(0x30A0, 0x30FF); - case Bopomofo: return unicode_range(0x3100, 0x312F); - case Hangul_Compatibility_Jamo: return unicode_range(0x3130, 0x318F); - case Kanbun: return unicode_range(0x3190, 0x319F); - case Bopomofo_Extended: return unicode_range(0x31A0, 0x31BF); - case CJK_Strokes: return unicode_range(0x31C0, 0x31EF); - case Katakana_Phonetic_Extensions: return unicode_range(0x31F0, 0x31FF); - case Enclosed_CJK_Letters_and_Months: return unicode_range(0x3200, 0x32FF); - case CJK_Compatibility: return unicode_range(0x3300, 0x33FF); - case CJK_Unified_Ideographs_Extension_A: return unicode_range(0x3400, 0x4DBF); - case Yijing_Hexagram_Symbols: return unicode_range(0x4DC0, 0x4DFF); - case CJK_Unified_Ideographs: return unicode_range(0x4E00, 0x9FFF); - case Yi_Syllables: return unicode_range(0xA000, 0xA48F); - case Yi_Radicals: return unicode_range(0xA490, 0xA4CF); - case Lisu: return unicode_range(0xA4D0, 0xA4FF); - case Vai: return unicode_range(0xA500, 0xA63F); - case Cyrillic_Extended_B: return unicode_range(0xA640, 0xA69F); - case Bamum: return unicode_range(0xA6A0, 0xA6FF); - case Modifier_Tone_Letters: return unicode_range(0xA700, 0xA71F); - case Latin_Extended_D: return unicode_range(0xA720, 0xA7FF); - case Syloti_Nagri: return unicode_range(0xA800, 0xA82F); - case Common_Indic_Number_Forms: return unicode_range(0xA830, 0xA83F); - case Phags_pa: return unicode_range(0xA840, 0xA87F); - case Saurashtra: return unicode_range(0xA880, 0xA8DF); - case Devanagari_Extended: return unicode_range(0xA8E0, 0xA8FF); - case Kayah_Li: return unicode_range(0xA900, 0xA92F); - case Rejang: return unicode_range(0xA930, 0xA95F); - case Hangul_Jamo_Extended_A: return unicode_range(0xA960, 0xA97F); - case Javanese: return unicode_range(0xA980, 0xA9DF); - case Cham: return unicode_range(0xAA00, 0xAA5F); - case Myanmar_Extended_A: return unicode_range(0xAA60, 0xAA7F); - case Tai_Viet: return unicode_range(0xAA80, 0xAADF); - case Meetei_Mayek_Extensions: return unicode_range(0xAAE0, 0xAAFF); - case Ethiopic_Extended_A: return unicode_range(0xAB00, 0xAB2F); - case Meetei_Mayek: return unicode_range(0xABC0, 0xABFF); - case Hangul_Syllables: return unicode_range(0xAC00, 0xD7AF); - case Hangul_Jamo_Extended_B: return unicode_range(0xD7B0, 0xD7FF); - case High_Surrogates: return unicode_range(0xD800, 0xDB7F); - case High_Private_Use_Surrogates: return unicode_range(0xDB80, 0xDBFF); - case Low_Surrogates: return unicode_range(0xDC00, 0xDFFF); - case Private_Use_Area: return unicode_range(0xE000, 0xF8FF); - case CJK_Compatibility_Ideographs: return unicode_range(0xF900, 0xFAFF); - case Alphabetic_Presentation_Forms: return unicode_range(0xFB00, 0xFB4F); - case Arabic_Presentation_Forms_A: return unicode_range(0xFB50, 0xFDFF); - case Variation_Selectors: return unicode_range(0xFE00, 0xFE0F); - case Vertical_Forms: return unicode_range(0xFE10, 0xFE1F); - case Combining_Half_Marks: return unicode_range(0xFE20, 0xFE2F); - case CJK_Compatibility_Forms: return unicode_range(0xFE30, 0xFE4F); - case Small_Form_Variants: return unicode_range(0xFE50, 0xFE6F); - case Arabic_Presentation_Forms_B: return unicode_range(0xFE70, 0xFEFF); - case Halfwidth_and_Fullwidth_Forms: return unicode_range(0xFF00, 0xFFEF); - case Specials: return unicode_range(0xFFF0, 0xFFFF); - case Linear_B_Syllabary: return unicode_range(0x10000, 0x1007F); - case Linear_B_Ideograms: return unicode_range(0x10080, 0x100FF); - case Aegean_Numbers: return unicode_range(0x10100, 0x1013F); - case Ancient_Greek_Numbers: return unicode_range(0x10140, 0x1018F); - case Ancient_Symbols: return unicode_range(0x10190, 0x101CF); - case Phaistos_Disc: return unicode_range(0x101D0, 0x101FF); - case Lycian: return unicode_range(0x10280, 0x1029F); - case Carian: return unicode_range(0x102A0, 0x102DF); - case Old_Italic: return unicode_range(0x10300, 0x1032F); - case Gothic: return unicode_range(0x10330, 0x1034F); - case Ugaritic: return unicode_range(0x10380, 0x1039F); - case Old_Persian: return unicode_range(0x103A0, 0x103DF); - case Deseret: return unicode_range(0x10400, 0x1044F); - case Shavian: return unicode_range(0x10450, 0x1047F); - case Osmanya: return unicode_range(0x10480, 0x104AF); - case Cypriot_Syllabary: return unicode_range(0x10800, 0x1083F); - case Imperial_Aramaic: return unicode_range(0x10840, 0x1085F); - case Phoenician: return unicode_range(0x10900, 0x1091F); - case Lydian: return unicode_range(0x10920, 0x1093F); - case Meroitic_Hieroglyphs: return unicode_range(0x10980, 0x1099F); - case Meroitic_Cursive: return unicode_range(0x109A0, 0x109FF); - case Kharoshthi: return unicode_range(0x10A00, 0x10A5F); - case Old_South_Arabian: return unicode_range(0x10A60, 0x10A7F); - case Avestan: return unicode_range(0x10B00, 0x10B3F); - case Inscriptional_Parthian: return unicode_range(0x10B40, 0x10B5F); - case Inscriptional_Pahlavi: return unicode_range(0x10B60, 0x10B7F); - case Old_Turkic: return unicode_range(0x10C00, 0x10C4F); - case Rumi_Numeral_Symbols: return unicode_range(0x10E60, 0x10E7F); - case Brahmi: return unicode_range(0x11000, 0x1107F); - case Kaithi: return unicode_range(0x11080, 0x110CF); - case Sora_Sompeng: return unicode_range(0x110D0, 0x110FF); - case Chakma: return unicode_range(0x11100, 0x1114F); - case Sharada: return unicode_range(0x11180, 0x111DF); - case Takri: return unicode_range(0x11680, 0x116CF); - case Cuneiform: return unicode_range(0x12000, 0x123FF); - case Cuneiform_Numbers_and_Punctuation: return unicode_range(0x12400, 0x1247F); - case Egyptian_Hieroglyphs: return unicode_range(0x13000, 0x1342F); - case Bamum_Supplement: return unicode_range(0x16800, 0x16A3F); - case Miao: return unicode_range(0x16F00, 0x16F9F); - case Kana_Supplement: return unicode_range(0x1B000, 0x1B0FF); - case Byzantine_Musical_Symbols: return unicode_range(0x1D000, 0x1D0FF); - case Musical_Symbols: return unicode_range(0x1D100, 0x1D1FF); - case Ancient_Greek_Musical_Notation: return unicode_range(0x1D200, 0x1D24F); - case Tai_Xuan_Jing_Symbols: return unicode_range(0x1D300, 0x1D35F); - case Counting_Rod_Numerals: return unicode_range(0x1D360, 0x1D37F); - case Mathematical_Alphanumeric_Symbols: return unicode_range(0x1D400, 0x1D7FF); - case Arabic_Mathematical_Alphabetic_Symbols: return unicode_range(0x1EE00, 0x1EEFF); - case Mahjong_Tiles: return unicode_range(0x1F000, 0x1F02F); - case Domino_Tiles: return unicode_range(0x1F030, 0x1F09F); - case Playing_Cards: return unicode_range(0x1F0A0, 0x1F0FF); - case Enclosed_Alphanumeric_Supplement: return unicode_range(0x1F100, 0x1F1FF); - case Enclosed_Ideographic_Supplement: return unicode_range(0x1F200, 0x1F2FF); - case Miscellaneous_Symbols_And_Pictographs: return unicode_range(0x1F300, 0x1F5FF); - case Emoticons: return unicode_range(0x1F600, 0x1F64F); - case Transport_And_Map_Symbols: return unicode_range(0x1F680, 0x1F6FF); - case Alchemical_Symbols: return unicode_range(0x1F700, 0x1F77F); - case CJK_Unified_Ideographs_Extension_B: return unicode_range(0x20000, 0x2A6DF); - case CJK_Unified_Ideographs_Extension_C: return unicode_range(0x2A700, 0x2B73F); - case CJK_Unified_Ideographs_Extension_D: return unicode_range(0x2B740, 0x2B81F); - case CJK_Compatibility_Ideographs_Supplement: return unicode_range(0x2F800, 0x2FA1F); - case Tags: return unicode_range(0xE0000, 0xE007F); - case Variation_Selectors_Supplement: return unicode_range(0xE0100, 0xE01EF); - case Supplementary_Private_Use_Area_A: return unicode_range(0xF0000, 0xFFFFF); - case Supplementary_Private_Use_Area_B: return unicode_range(0x100000, 0x10FFFF); + case unicode_block::Basic_Latin: return unicode_range(0x0000, 0x007F); + case unicode_block::Latin_1_Supplement: return unicode_range(0x0080, 0x00FF); + case unicode_block::Latin_Extended_A: return unicode_range(0x0100, 0x017F); + case unicode_block::Latin_Extended_B: return unicode_range(0x0180, 0x024F); + case unicode_block::IPA_Extensions: return unicode_range(0x0250, 0x02AF); + case unicode_block::Spacing_Modifier_Letters: return unicode_range(0x02B0, 0x02FF); + case unicode_block::Combining_Diacritical_Marks: return unicode_range(0x0300, 0x036F); + case unicode_block::Greek_and_Coptic: return unicode_range(0x0370, 0x03FF); + case unicode_block::Cyrillic: return unicode_range(0x0400, 0x04FF); + case unicode_block::Cyrillic_Supplement: return unicode_range(0x0500, 0x052F); + case unicode_block::Armenian: return unicode_range(0x0530, 0x058F); + case unicode_block::Hebrew: return unicode_range(0x0590, 0x05FF); + case unicode_block::Arabic: return unicode_range(0x0600, 0x06FF); + case unicode_block::Syriac: return unicode_range(0x0700, 0x074F); + case unicode_block::Arabic_Supplement: return unicode_range(0x0750, 0x077F); + case unicode_block::Thaana: return unicode_range(0x0780, 0x07BF); + case unicode_block::NKo: return unicode_range(0x07C0, 0x07FF); + case unicode_block::Samaritan: return unicode_range(0x0800, 0x083F); + case unicode_block::Mandaic: return unicode_range(0x0840, 0x085F); + case unicode_block::Arabic_Extended_A: return unicode_range(0x08A0, 0x08FF); + case unicode_block::Devanagari: return unicode_range(0x0900, 0x097F); + case unicode_block::Bengali: return unicode_range(0x0980, 0x09FF); + case unicode_block::Gurmukhi: return unicode_range(0x0A00, 0x0A7F); + case unicode_block::Gujarati: return unicode_range(0x0A80, 0x0AFF); + case unicode_block::Oriya: return unicode_range(0x0B00, 0x0B7F); + case unicode_block::Tamil: return unicode_range(0x0B80, 0x0BFF); + case unicode_block::Telugu: return unicode_range(0x0C00, 0x0C7F); + case unicode_block::Kannada: return unicode_range(0x0C80, 0x0CFF); + case unicode_block::Malayalam: return unicode_range(0x0D00, 0x0D7F); + case unicode_block::Sinhala: return unicode_range(0x0D80, 0x0DFF); + case unicode_block::Thai: return unicode_range(0x0E00, 0x0E7F); + case unicode_block::Lao: return unicode_range(0x0E80, 0x0EFF); + case unicode_block::Tibetan: return unicode_range(0x0F00, 0x0FFF); + case unicode_block::Myanmar: return unicode_range(0x1000, 0x109F); + case unicode_block::Georgian: return unicode_range(0x10A0, 0x10FF); + case unicode_block::Hangul_Jamo: return unicode_range(0x1100, 0x11FF); + case unicode_block::Ethiopic: return unicode_range(0x1200, 0x137F); + case unicode_block::Ethiopic_Supplement: return unicode_range(0x1380, 0x139F); + case unicode_block::Cherokee: return unicode_range(0x13A0, 0x13FF); + case unicode_block::Unified_Canadian_Aboriginal_Syllabics: return unicode_range(0x1400, 0x167F); + case unicode_block::Ogham: return unicode_range(0x1680, 0x169F); + case unicode_block::Runic: return unicode_range(0x16A0, 0x16FF); + case unicode_block::Tagalog: return unicode_range(0x1700, 0x171F); + case unicode_block::Hanunoo: return unicode_range(0x1720, 0x173F); + case unicode_block::Buhid: return unicode_range(0x1740, 0x175F); + case unicode_block::Tagbanwa: return unicode_range(0x1760, 0x177F); + case unicode_block::Khmer: return unicode_range(0x1780, 0x17FF); + case unicode_block::Mongolian: return unicode_range(0x1800, 0x18AF); + case unicode_block::Unified_Canadian_Aboriginal_Syllabics_Extended: return unicode_range(0x18B0, 0x18FF); + case unicode_block::Limbu: return unicode_range(0x1900, 0x194F); + case unicode_block::Tai_Le: return unicode_range(0x1950, 0x197F); + case unicode_block::New_Tai_Lue: return unicode_range(0x1980, 0x19DF); + case unicode_block::Khmer_Symbols: return unicode_range(0x19E0, 0x19FF); + case unicode_block::Buginese: return unicode_range(0x1A00, 0x1A1F); + case unicode_block::Tai_Tham: return unicode_range(0x1A20, 0x1AAF); + case unicode_block::Balinese: return unicode_range(0x1B00, 0x1B7F); + case unicode_block::Sundanese: return unicode_range(0x1B80, 0x1BBF); + case unicode_block::Batak: return unicode_range(0x1BC0, 0x1BFF); + case unicode_block::Lepcha: return unicode_range(0x1C00, 0x1C4F); + case unicode_block::Ol_Chiki: return unicode_range(0x1C50, 0x1C7F); + case unicode_block::Sundanese_Supplement: return unicode_range(0x1CC0, 0x1CCF); + case unicode_block::Vedic_Extensions: return unicode_range(0x1CD0, 0x1CFF); + case unicode_block::Phonetic_Extensions: return unicode_range(0x1D00, 0x1D7F); + case unicode_block::Phonetic_Extensions_Supplement: return unicode_range(0x1D80, 0x1DBF); + case unicode_block::Combining_Diacritical_Marks_Supplement: return unicode_range(0x1DC0, 0x1DFF); + case unicode_block::Latin_Extended_Additional: return unicode_range(0x1E00, 0x1EFF); + case unicode_block::Greek_Extended: return unicode_range(0x1F00, 0x1FFF); + case unicode_block::General_Punctuation: return unicode_range(0x2000, 0x206F); + case unicode_block::Superscripts_and_Subscripts: return unicode_range(0x2070, 0x209F); + case unicode_block::Currency_Symbols: return unicode_range(0x20A0, 0x20CF); + case unicode_block::Combining_Diacritical_Marks_for_Symbols: return unicode_range(0x20D0, 0x20FF); + case unicode_block::Letterlike_Symbols: return unicode_range(0x2100, 0x214F); + case unicode_block::Number_Forms: return unicode_range(0x2150, 0x218F); + case unicode_block::Arrows: return unicode_range(0x2190, 0x21FF); + case unicode_block::Mathematical_Operators: return unicode_range(0x2200, 0x22FF); + case unicode_block::Miscellaneous_Technical: return unicode_range(0x2300, 0x23FF); + case unicode_block::Control_Pictures: return unicode_range(0x2400, 0x243F); + case unicode_block::Optical_Character_Recognition: return unicode_range(0x2440, 0x245F); + case unicode_block::Enclosed_Alphanumerics: return unicode_range(0x2460, 0x24FF); + case unicode_block::Box_Drawing: return unicode_range(0x2500, 0x257F); + case unicode_block::Block_Elements: return unicode_range(0x2580, 0x259F); + case unicode_block::Geometric_Shapes: return unicode_range(0x25A0, 0x25FF); + case unicode_block::Miscellaneous_Symbols: return unicode_range(0x2600, 0x26FF); + case unicode_block::Dingbats: return unicode_range(0x2700, 0x27BF); + case unicode_block::Miscellaneous_Mathematical_Symbols_A: return unicode_range(0x27C0, 0x27EF); + case unicode_block::Supplemental_Arrows_A: return unicode_range(0x27F0, 0x27FF); + case unicode_block::Braille_Patterns: return unicode_range(0x2800, 0x28FF); + case unicode_block::Supplemental_Arrows_B: return unicode_range(0x2900, 0x297F); + case unicode_block::Miscellaneous_Mathematical_Symbols_B: return unicode_range(0x2980, 0x29FF); + case unicode_block::Supplemental_Mathematical_Operators: return unicode_range(0x2A00, 0x2AFF); + case unicode_block::Miscellaneous_Symbols_and_Arrows: return unicode_range(0x2B00, 0x2BFF); + case unicode_block::Glagolitic: return unicode_range(0x2C00, 0x2C5F); + case unicode_block::Latin_Extended_C: return unicode_range(0x2C60, 0x2C7F); + case unicode_block::Coptic: return unicode_range(0x2C80, 0x2CFF); + case unicode_block::Georgian_Supplement: return unicode_range(0x2D00, 0x2D2F); + case unicode_block::Tifinagh: return unicode_range(0x2D30, 0x2D7F); + case unicode_block::Ethiopic_Extended: return unicode_range(0x2D80, 0x2DDF); + case unicode_block::Cyrillic_Extended_A: return unicode_range(0x2DE0, 0x2DFF); + case unicode_block::Supplemental_Punctuation: return unicode_range(0x2E00, 0x2E7F); + case unicode_block::CJK_Radicals_Supplement: return unicode_range(0x2E80, 0x2EFF); + case unicode_block::Kangxi_Radicals: return unicode_range(0x2F00, 0x2FDF); + case unicode_block::Ideographic_Description_Characters: return unicode_range(0x2FF0, 0x2FFF); + case unicode_block::CJK_Symbols_and_Punctuation: return unicode_range(0x3000, 0x303F); + case unicode_block::Hiragana: return unicode_range(0x3040, 0x309F); + case unicode_block::Katakana: return unicode_range(0x30A0, 0x30FF); + case unicode_block::Bopomofo: return unicode_range(0x3100, 0x312F); + case unicode_block::Hangul_Compatibility_Jamo: return unicode_range(0x3130, 0x318F); + case unicode_block::Kanbun: return unicode_range(0x3190, 0x319F); + case unicode_block::Bopomofo_Extended: return unicode_range(0x31A0, 0x31BF); + case unicode_block::CJK_Strokes: return unicode_range(0x31C0, 0x31EF); + case unicode_block::Katakana_Phonetic_Extensions: return unicode_range(0x31F0, 0x31FF); + case unicode_block::Enclosed_CJK_Letters_and_Months: return unicode_range(0x3200, 0x32FF); + case unicode_block::CJK_Compatibility: return unicode_range(0x3300, 0x33FF); + case unicode_block::CJK_Unified_Ideographs_Extension_A: return unicode_range(0x3400, 0x4DBF); + case unicode_block::Yijing_Hexagram_Symbols: return unicode_range(0x4DC0, 0x4DFF); + case unicode_block::CJK_Unified_Ideographs: return unicode_range(0x4E00, 0x9FFF); + case unicode_block::Yi_Syllables: return unicode_range(0xA000, 0xA48F); + case unicode_block::Yi_Radicals: return unicode_range(0xA490, 0xA4CF); + case unicode_block::Lisu: return unicode_range(0xA4D0, 0xA4FF); + case unicode_block::Vai: return unicode_range(0xA500, 0xA63F); + case unicode_block::Cyrillic_Extended_B: return unicode_range(0xA640, 0xA69F); + case unicode_block::Bamum: return unicode_range(0xA6A0, 0xA6FF); + case unicode_block::Modifier_Tone_Letters: return unicode_range(0xA700, 0xA71F); + case unicode_block::Latin_Extended_D: return unicode_range(0xA720, 0xA7FF); + case unicode_block::Syloti_Nagri: return unicode_range(0xA800, 0xA82F); + case unicode_block::Common_Indic_Number_Forms: return unicode_range(0xA830, 0xA83F); + case unicode_block::Phags_pa: return unicode_range(0xA840, 0xA87F); + case unicode_block::Saurashtra: return unicode_range(0xA880, 0xA8DF); + case unicode_block::Devanagari_Extended: return unicode_range(0xA8E0, 0xA8FF); + case unicode_block::Kayah_Li: return unicode_range(0xA900, 0xA92F); + case unicode_block::Rejang: return unicode_range(0xA930, 0xA95F); + case unicode_block::Hangul_Jamo_Extended_A: return unicode_range(0xA960, 0xA97F); + case unicode_block::Javanese: return unicode_range(0xA980, 0xA9DF); + case unicode_block::Cham: return unicode_range(0xAA00, 0xAA5F); + case unicode_block::Myanmar_Extended_A: return unicode_range(0xAA60, 0xAA7F); + case unicode_block::Tai_Viet: return unicode_range(0xAA80, 0xAADF); + case unicode_block::Meetei_Mayek_Extensions: return unicode_range(0xAAE0, 0xAAFF); + case unicode_block::Ethiopic_Extended_A: return unicode_range(0xAB00, 0xAB2F); + case unicode_block::Meetei_Mayek: return unicode_range(0xABC0, 0xABFF); + case unicode_block::Hangul_Syllables: return unicode_range(0xAC00, 0xD7AF); + case unicode_block::Hangul_Jamo_Extended_B: return unicode_range(0xD7B0, 0xD7FF); + case unicode_block::High_Surrogates: return unicode_range(0xD800, 0xDB7F); + case unicode_block::High_Private_Use_Surrogates: return unicode_range(0xDB80, 0xDBFF); + case unicode_block::Low_Surrogates: return unicode_range(0xDC00, 0xDFFF); + case unicode_block::Private_Use_Area: return unicode_range(0xE000, 0xF8FF); + case unicode_block::CJK_Compatibility_Ideographs: return unicode_range(0xF900, 0xFAFF); + case unicode_block::Alphabetic_Presentation_Forms: return unicode_range(0xFB00, 0xFB4F); + case unicode_block::Arabic_Presentation_Forms_A: return unicode_range(0xFB50, 0xFDFF); + case unicode_block::Variation_Selectors: return unicode_range(0xFE00, 0xFE0F); + case unicode_block::Vertical_Forms: return unicode_range(0xFE10, 0xFE1F); + case unicode_block::Combining_Half_Marks: return unicode_range(0xFE20, 0xFE2F); + case unicode_block::CJK_Compatibility_Forms: return unicode_range(0xFE30, 0xFE4F); + case unicode_block::Small_Form_Variants: return unicode_range(0xFE50, 0xFE6F); + case unicode_block::Arabic_Presentation_Forms_B: return unicode_range(0xFE70, 0xFEFF); + case unicode_block::Halfwidth_and_Fullwidth_Forms: return unicode_range(0xFF00, 0xFFEF); + case unicode_block::Specials: return unicode_range(0xFFF0, 0xFFFF); + case unicode_block::Linear_B_Syllabary: return unicode_range(0x10000, 0x1007F); + case unicode_block::Linear_B_Ideograms: return unicode_range(0x10080, 0x100FF); + case unicode_block::Aegean_Numbers: return unicode_range(0x10100, 0x1013F); + case unicode_block::Ancient_Greek_Numbers: return unicode_range(0x10140, 0x1018F); + case unicode_block::Ancient_Symbols: return unicode_range(0x10190, 0x101CF); + case unicode_block::Phaistos_Disc: return unicode_range(0x101D0, 0x101FF); + case unicode_block::Lycian: return unicode_range(0x10280, 0x1029F); + case unicode_block::Carian: return unicode_range(0x102A0, 0x102DF); + case unicode_block::Old_Italic: return unicode_range(0x10300, 0x1032F); + case unicode_block::Gothic: return unicode_range(0x10330, 0x1034F); + case unicode_block::Ugaritic: return unicode_range(0x10380, 0x1039F); + case unicode_block::Old_Persian: return unicode_range(0x103A0, 0x103DF); + case unicode_block::Deseret: return unicode_range(0x10400, 0x1044F); + case unicode_block::Shavian: return unicode_range(0x10450, 0x1047F); + case unicode_block::Osmanya: return unicode_range(0x10480, 0x104AF); + case unicode_block::Cypriot_Syllabary: return unicode_range(0x10800, 0x1083F); + case unicode_block::Imperial_Aramaic: return unicode_range(0x10840, 0x1085F); + case unicode_block::Phoenician: return unicode_range(0x10900, 0x1091F); + case unicode_block::Lydian: return unicode_range(0x10920, 0x1093F); + case unicode_block::Meroitic_Hieroglyphs: return unicode_range(0x10980, 0x1099F); + case unicode_block::Meroitic_Cursive: return unicode_range(0x109A0, 0x109FF); + case unicode_block::Kharoshthi: return unicode_range(0x10A00, 0x10A5F); + case unicode_block::Old_South_Arabian: return unicode_range(0x10A60, 0x10A7F); + case unicode_block::Avestan: return unicode_range(0x10B00, 0x10B3F); + case unicode_block::Inscriptional_Parthian: return unicode_range(0x10B40, 0x10B5F); + case unicode_block::Inscriptional_Pahlavi: return unicode_range(0x10B60, 0x10B7F); + case unicode_block::Old_Turkic: return unicode_range(0x10C00, 0x10C4F); + case unicode_block::Rumi_Numeral_Symbols: return unicode_range(0x10E60, 0x10E7F); + case unicode_block::Brahmi: return unicode_range(0x11000, 0x1107F); + case unicode_block::Kaithi: return unicode_range(0x11080, 0x110CF); + case unicode_block::Sora_Sompeng: return unicode_range(0x110D0, 0x110FF); + case unicode_block::Chakma: return unicode_range(0x11100, 0x1114F); + case unicode_block::Sharada: return unicode_range(0x11180, 0x111DF); + case unicode_block::Takri: return unicode_range(0x11680, 0x116CF); + case unicode_block::Cuneiform: return unicode_range(0x12000, 0x123FF); + case unicode_block::Cuneiform_Numbers_and_Punctuation: return unicode_range(0x12400, 0x1247F); + case unicode_block::Egyptian_Hieroglyphs: return unicode_range(0x13000, 0x1342F); + case unicode_block::Bamum_Supplement: return unicode_range(0x16800, 0x16A3F); + case unicode_block::Miao: return unicode_range(0x16F00, 0x16F9F); + case unicode_block::Kana_Supplement: return unicode_range(0x1B000, 0x1B0FF); + case unicode_block::Byzantine_Musical_Symbols: return unicode_range(0x1D000, 0x1D0FF); + case unicode_block::Musical_Symbols: return unicode_range(0x1D100, 0x1D1FF); + case unicode_block::Ancient_Greek_Musical_Notation: return unicode_range(0x1D200, 0x1D24F); + case unicode_block::Tai_Xuan_Jing_Symbols: return unicode_range(0x1D300, 0x1D35F); + case unicode_block::Counting_Rod_Numerals: return unicode_range(0x1D360, 0x1D37F); + case unicode_block::Mathematical_Alphanumeric_Symbols: return unicode_range(0x1D400, 0x1D7FF); + case unicode_block::Arabic_Mathematical_Alphabetic_Symbols: return unicode_range(0x1EE00, 0x1EEFF); + case unicode_block::Mahjong_Tiles: return unicode_range(0x1F000, 0x1F02F); + case unicode_block::Domino_Tiles: return unicode_range(0x1F030, 0x1F09F); + case unicode_block::Playing_Cards: return unicode_range(0x1F0A0, 0x1F0FF); + case unicode_block::Enclosed_Alphanumeric_Supplement: return unicode_range(0x1F100, 0x1F1FF); + case unicode_block::Enclosed_Ideographic_Supplement: return unicode_range(0x1F200, 0x1F2FF); + case unicode_block::Miscellaneous_Symbols_And_Pictographs: return unicode_range(0x1F300, 0x1F5FF); + case unicode_block::Emoticons: return unicode_range(0x1F600, 0x1F64F); + case unicode_block::Transport_And_Map_Symbols: return unicode_range(0x1F680, 0x1F6FF); + case unicode_block::Alchemical_Symbols: return unicode_range(0x1F700, 0x1F77F); + case unicode_block::CJK_Unified_Ideographs_Extension_B: return unicode_range(0x20000, 0x2A6DF); + case unicode_block::CJK_Unified_Ideographs_Extension_C: return unicode_range(0x2A700, 0x2B73F); + case unicode_block::CJK_Unified_Ideographs_Extension_D: return unicode_range(0x2B740, 0x2B81F); + case unicode_block::CJK_Compatibility_Ideographs_Supplement: return unicode_range(0x2F800, 0x2FA1F); + case unicode_block::Tags: return unicode_range(0xE0000, 0xE007F); + case unicode_block::Variation_Selectors_Supplement: return unicode_range(0xE0100, 0xE01EF); + case unicode_block::Supplementary_Private_Use_Area_A: return unicode_range(0xF0000, 0xFFFFF); + case unicode_block::Supplementary_Private_Use_Area_B: return unicode_range(0x100000, 0x10FFFF); } return unicode_range(0,0); } diff --git a/core/producer/text/utils/texture_font.h b/core/producer/text/utils/texture_font.h index 2cfcec601..d3e52cebc 100644 --- a/core/producer/text/utils/texture_font.h +++ b/core/producer/text/utils/texture_font.h @@ -10,7 +10,7 @@ namespace caspar { namespace core { namespace text { class texture_atlas; -enum unicode_block; +enum class unicode_block; class texture_font { @@ -30,7 +30,7 @@ private: spl::shared_ptr impl_; }; -enum unicode_block +enum class unicode_block { Basic_Latin, Latin_1_Supplement, diff --git a/core/producer/transition/transition_producer.cpp b/core/producer/transition/transition_producer.cpp index ff179245d..89bd8ed92 100644 --- a/core/producer/transition/transition_producer.cpp +++ b/core/producer/transition/transition_producer.cpp @@ -98,7 +98,7 @@ public: *monitor_subject_ << monitor::message("/transition/frame") % current_frame_ % info_.duration << monitor::message("/transition/type") % [&]() -> std::string { - switch(info_.type.value()) + switch(info_.type) { case transition_type::mix: return "mix"; case transition_type::wipe: return "wipe"; diff --git a/core/producer/transition/transition_producer.h b/core/producer/transition/transition_producer.h index 2992131a2..32bad662d 100644 --- a/core/producer/transition/transition_producer.h +++ b/core/producer/transition/transition_producer.h @@ -23,7 +23,6 @@ #include "../../video_format.h" -#include #include #include @@ -31,30 +30,22 @@ namespace caspar { namespace core { -struct transition_type_def +enum class transition_type { - enum type - { - cut, - mix, - push, - slide, - wipe, - count - }; + cut, + mix, + push, + slide, + wipe, + count }; -typedef enum_class transition_type; -struct transition_direction_def +enum class transition_direction { - enum type - { - from_left, - from_right, - count - }; + from_left, + from_right, + count }; -typedef enum_class transition_direction; struct transition_info { diff --git a/core/thumbnail_generator.cpp b/core/thumbnail_generator.cpp index 014080132..61cce95fc 100644 --- a/core/thumbnail_generator.cpp +++ b/core/thumbnail_generator.cpp @@ -130,7 +130,7 @@ public: , thumbnail_creator_(thumbnail_creator) , monitor_(monitor_factory.create( media_path, - ALL, + filesystem_event::ALL, true, [this] (filesystem_event event, const boost::filesystem::wpath& file) { @@ -200,16 +200,16 @@ public: { switch (event) { - case CREATED: + case filesystem_event::CREATED: if (needs_to_be_generated(file)) generate_thumbnail(file); break; - case MODIFIED: + case filesystem_event::MODIFIED: generate_thumbnail(file); break; - case REMOVED: + case filesystem_event::REMOVED: auto relative_without_extension = get_relative_without_extension(file, media_path_); boost::filesystem::remove(thumbnails_path_ / (relative_without_extension + L".png")); diff --git a/core/video_format.cpp b/core/video_format.cpp index f0c6b04af..0b80917e2 100644 --- a/core/video_format.cpp +++ b/core/video_format.cpp @@ -94,7 +94,7 @@ video_format_desc::video_format_desc(video_format format) : format(video_format::invalid) , field_mode(field_mode::empty) { - *this = format_descs.at(format.value()); + *this = format_descs.at(static_cast(format)); } video_format_desc::video_format_desc(const std::wstring& name) diff --git a/core/video_format.h b/core/video_format.h index 326db5025..9f2b52c79 100644 --- a/core/video_format.h +++ b/core/video_format.h @@ -21,66 +21,59 @@ #pragma once -#include - #include #include #include +#include + namespace caspar { namespace core { -struct video_format_def +enum class video_format { - enum type - { - pal, - ntsc, - x576p2500, - x720p2500, - x720p5000, - x720p2398, - x720p2400, - x720p2997, - x720p5994, - x720p3000, - x720p6000, - x1080p2398, - x1080p2400, - x1080i5000, - x1080i5994, - x1080i6000, - x1080p2500, - x1080p2997, - x1080p3000, - x1080p5000, - x1080p5994, - x1080p6000, - x2k2398, - x2k2400, - x2k2500, - x4k2398, - x4k2400, - x4k2500, - x4k2997, - x4k3000, - invalid, - count - }; + pal, + ntsc, + x576p2500, + x720p2500, + x720p5000, + x720p2398, + x720p2400, + x720p2997, + x720p5994, + x720p3000, + x720p6000, + x1080p2398, + x1080p2400, + x1080i5000, + x1080i5994, + x1080i6000, + x1080p2500, + x1080p2997, + x1080p3000, + x1080p5000, + x1080p5994, + x1080p6000, + x2k2398, + x2k2400, + x2k2500, + x4k2398, + x4k2400, + x4k2500, + x4k2997, + x4k3000, + invalid, + count }; -typedef enum_class video_format; -struct field_mode_def +enum class field_mode { - enum type - { - empty = 0, - lower = 1, - upper = 2, - progressive = 3, // NOTE: progressive == lower | upper; - }; - static_assert((lower | upper) == progressive, ""); + empty = 0, + lower = 1, + upper = 2, + progressive = 3 // NOTE: progressive == lower | upper; }; -typedef enum_class field_mode; +ENUM_ENABLE_BITWISE(field_mode); +//static_assert((field_mode::lower | field_mode::upper) == field_mode::progressive, ""); struct video_format_desc final { diff --git a/modules/bluefish/util/blue_velvet.cpp b/modules/bluefish/util/blue_velvet.cpp index b7b4a7e68..700486e9f 100644 --- a/modules/bluefish/util/blue_velvet.cpp +++ b/modules/bluefish/util/blue_velvet.cpp @@ -84,7 +84,7 @@ void blue_initialize() EVideoMode vid_fmt_from_video_format(const core::video_format& fmt) { - switch(fmt.value()) + switch(fmt) { case core::video_format::pal: return VID_FMT_PAL; case core::video_format::ntsc: return VID_FMT_NTSC; diff --git a/modules/decklink/consumer/decklink_consumer.cpp b/modules/decklink/consumer/decklink_consumer.cpp index 83e35c32e..4822fc6db 100644 --- a/modules/decklink/consumer/decklink_consumer.cpp +++ b/modules/decklink/consumer/decklink_consumer.cpp @@ -53,14 +53,14 @@ namespace caspar { namespace decklink { struct configuration { - enum keyer_t + enum class keyer_t { internal_keyer, external_keyer, default_keyer }; - enum latency_t + enum class latency_t { low_latency, normal_latency, @@ -77,8 +77,8 @@ struct configuration configuration() : device_index(1) , embedded_audio(true) - , keyer(default_keyer) - , latency(default_latency) + , keyer(keyer_t::default_keyer) + , latency(latency_t::default_latency) , key_only(false) , base_buffer_depth(3) { @@ -86,7 +86,7 @@ struct configuration int buffer_depth() const { - return base_buffer_depth + (latency == low_latency ? 0 : 1) + (embedded_audio ? 1 : 0); + return base_buffer_depth + (latency == latency_t::low_latency ? 0 : 1) + (embedded_audio ? 1 : 0); } }; @@ -279,12 +279,12 @@ public: void set_latency(configuration::latency_t latency) { - if(latency == configuration::low_latency) + if(latency == configuration::latency_t::low_latency) { configuration_->SetFlag(bmdDeckLinkConfigLowLatencyVideoOutput, true); CASPAR_LOG(info) << print() << L" Enabled low-latency mode."; } - else if(latency == configuration::normal_latency) + else if(latency == configuration::latency_t::normal_latency) { configuration_->SetFlag(bmdDeckLinkConfigLowLatencyVideoOutput, false); CASPAR_LOG(info) << print() << L" Disabled low-latency mode."; @@ -293,7 +293,7 @@ public: void set_keyer(configuration::keyer_t keyer) { - if(keyer == configuration::internal_keyer) + if(keyer == configuration::keyer_t::internal_keyer) { BOOL value = true; if(SUCCEEDED(attributes_->GetFlag(BMDDeckLinkSupportsInternalKeying, &value)) && !value) @@ -305,7 +305,7 @@ public: else CASPAR_LOG(info) << print() << L" Enabled internal keyer."; } - else if(keyer == configuration::external_keyer) + else if(keyer == configuration::keyer_t::external_keyer) { BOOL value = true; if(SUCCEEDED(attributes_->GetFlag(BMDDeckLinkSupportsExternalKeying, &value)) && !value) @@ -573,9 +573,8 @@ public: info.add(L"type", L"decklink"); info.add(L"key-only", config_.key_only); info.add(L"device", config_.device_index); - info.add(L"low-latency", config_.low_latency); + info.add(L"low-latency", config_.latency == configuration::latency_t::low_latency); info.add(L"embedded-audio", config_.embedded_audio); - info.add(L"low-latency", config_.low_latency); //info.add(L"internal-key", config_.internal_key); return info; } @@ -607,14 +606,14 @@ spl::shared_ptr create_consumer(const std::vector(params[1]); if(std::find(params.begin(), params.end(), L"INTERNAL_KEY") != params.end()) - config.keyer = configuration::internal_keyer; + config.keyer = configuration::keyer_t::internal_keyer; else if(std::find(params.begin(), params.end(), L"EXTERNAL_KEY") != params.end()) - config.keyer = configuration::external_keyer; + config.keyer = configuration::keyer_t::external_keyer; else - config.keyer = configuration::default_keyer; + config.keyer = configuration::keyer_t::default_keyer; if(std::find(params.begin(), params.end(), L"LOW_LATENCY") != params.end()) - config.latency = configuration::low_latency; + config.latency = configuration::latency_t::low_latency; config.embedded_audio = std::find(params.begin(), params.end(), L"EMBEDDED_AUDIO") != params.end(); config.key_only = std::find(params.begin(), params.end(), L"KEY_ONLY") != params.end(); @@ -628,15 +627,15 @@ spl::shared_ptr create_consumer(const boost::property_tree auto keyer = ptree.get(L"keyer", L"default"); if(keyer == L"external") - config.keyer = configuration::external_keyer; + config.keyer = configuration::keyer_t::external_keyer; else if(keyer == L"internal") - config.keyer = configuration::internal_keyer; + config.keyer = configuration::keyer_t::internal_keyer; auto latency = ptree.get(L"latency", L"normal"); if(latency == L"low") - config.latency = configuration::low_latency; + config.latency = configuration::latency_t::low_latency; else if(latency == L"normal") - config.latency = configuration::normal_latency; + config.latency = configuration::latency_t::normal_latency; config.key_only = ptree.get(L"key-only", config.key_only); config.device_index = ptree.get(L"device", config.device_index); diff --git a/modules/decklink/util/util.h b/modules/decklink/util/util.h index dbe22acd3..a8c46c3bd 100644 --- a/modules/decklink/util/util.h +++ b/modules/decklink/util/util.h @@ -37,7 +37,7 @@ namespace caspar { namespace decklink { static BMDDisplayMode get_decklink_video_format(core::video_format fmt) { - switch(fmt.value()) + switch(fmt) { case core::video_format::pal: return bmdModePAL; case core::video_format::ntsc: return bmdModeNTSC; diff --git a/modules/ffmpeg/producer/muxer/display_mode.h b/modules/ffmpeg/producer/muxer/display_mode.h index 78d4fd1f7..3a469d8e1 100644 --- a/modules/ffmpeg/producer/muxer/display_mode.h +++ b/modules/ffmpeg/producer/muxer/display_mode.h @@ -27,7 +27,7 @@ namespace caspar { namespace ffmpeg { -enum display_mode +enum class display_mode { simple, duplicate, @@ -45,14 +45,14 @@ std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream make_av_frame(std::array data, const core: avcodec_get_frame_defaults(av_frame.get()); auto planes = pix_desc.planes; - auto format = pix_desc.format.value(); + auto format = pix_desc.format; av_frame->width = planes[0].width; av_frame->height = planes[0].height; @@ -394,7 +394,7 @@ double read_fps(AVFormatContext& context, double fail_value) double fps = static_cast(time_base.den) / static_cast(time_base.num); double closest_fps = 0.0; - for(int n = 0; n < core::video_format::count; ++n) + for(int n = 0; n < static_cast(core::video_format::count); ++n) { auto format = core::video_format_desc(core::video_format(n)); diff --git a/modules/psd/descriptor.cpp b/modules/psd/descriptor.cpp index 7e96fdb90..f9a8dce89 100644 --- a/modules/psd/descriptor.cpp +++ b/modules/psd/descriptor.cpp @@ -66,13 +66,13 @@ bool descriptor::populate(BEFileInputStream& stream) stream.read_unicode_string(); stream.read_id_string(); unsigned long element_count = stream.read_long(); - for(int element_index = 0; element_index < element_count; ++element_index) + for (unsigned long element_index = 0; element_index < element_count; ++element_index) { std::wstring key = stream.read_id_string(); read_value(key, stream); } } - catch(std::exception& ex) + catch(std::exception&) { result = false; } @@ -126,8 +126,8 @@ void descriptor::read_value(const std::wstring& key, BEFileInputStream& stream) case 'VlLs': { context::scoped_holder list(key, context_); - unsigned long count = stream.read_long(); - for(int i = 0; i < count; ++i) + auto count = stream.read_long(); + for(unsigned long i = 0; i < count; ++i) { read_value(L"li", stream); } diff --git a/modules/psd/doc.cpp b/modules/psd/doc.cpp index 857b34fb3..046162299 100644 --- a/modules/psd/doc.cpp +++ b/modules/psd/doc.cpp @@ -25,7 +25,7 @@ namespace caspar { namespace psd { -psd_document::psd_document() : channels_(0), width_(0), height_(0), depth_(0), color_mode_(InvalidColorMode) +psd_document::psd_document() : channels_(0), width_(0), height_(0), depth_(0), color_mode_(color_mode::InvalidColorMode) { } @@ -43,7 +43,7 @@ bool psd_document::parse(const std::wstring& filename) read_image_resources(); read_layers(); } - catch(std::exception& ex) + catch(std::exception&) { result = false; } @@ -53,8 +53,8 @@ bool psd_document::parse(const std::wstring& filename) void psd_document::read_header() { - unsigned long signature = input_.read_long(); - unsigned short version = input_.read_short(); + auto signature = input_.read_long(); + auto version = input_.read_short(); if(!(signature == '8BPS' && version == 1)) throw PSDFileFormatException(); @@ -69,7 +69,7 @@ void psd_document::read_header() void psd_document::read_color_mode() { - unsigned long length = input_.read_long(); + auto length = input_.read_long(); input_.discard_bytes(length); } @@ -79,22 +79,22 @@ void psd_document::read_image_resources() if(section_length > 0) { - unsigned long end_of_section = input_.current_position() + section_length; + std::streamoff end_of_section = input_.current_position() + section_length; try { while(input_.current_position() < end_of_section) { - unsigned long signature = input_.read_long(); + auto signature = input_.read_long(); if(signature != '8BIM') throw PSDFileFormatException(); - unsigned short resource_id = input_.read_short(); + auto resource_id = input_.read_short(); std::wstring name = input_.read_pascal_string(2); - unsigned long resource_length = input_.read_long(); - unsigned long end_of_chunk = input_.current_position() + resource_length; + auto resource_length = input_.read_long(); + auto end_of_chunk = input_.current_position() + resource_length; try { @@ -118,7 +118,7 @@ void psd_document::read_image_resources() break; case 1075: //timeline information { - int desc_ver = input_.read_long(); //descriptor version, should be 16 + input_.read_long(); //descriptor version, should be 16 descriptor timeline_descriptor; if(!timeline_descriptor.populate(input_)) throw PSDFileFormatException(); @@ -179,7 +179,7 @@ void psd_document::read_image_resources() } } } - catch(PSDFileFormatException& ex) + catch(PSDFileFormatException&) { //if an error occurs, just skip this section input_.set_position(end_of_section); @@ -191,20 +191,20 @@ void psd_document::read_image_resources() void psd_document::read_layers() { //"Layer And Mask information" - unsigned long total_length = input_.read_long(); //length of "Layer and Mask information" - unsigned long end_of_layers = input_.current_position() + total_length; + auto total_length = input_.read_long(); //length of "Layer and Mask information" + auto end_of_layers = input_.current_position() + total_length; try { //"Layer info section" { - unsigned long layer_info_length = input_.read_long(); //length of "Layer info" section - unsigned long end_of_layers_info = input_.current_position() + layer_info_length; + auto layer_info_length = input_.read_long(); //length of "Layer info" section + auto end_of_layers_info = input_.current_position() + layer_info_length; - short layers_count = abs(static_cast(input_.read_short())); + auto layers_count = std::abs(static_cast(input_.read_short())); //std::clog << "Expecting " << layers_count << " layers" << std::endl; - for(short layer_index = 0; layer_index < layers_count; ++layer_index) + for(int layer_index = 0; layer_index < layers_count; ++layer_index) { if(layer_index == layers_.size()) layers_.push_back(std::make_shared()); @@ -213,8 +213,6 @@ void psd_document::read_layers() //std::clog << "Added layer: " << std::string(layers_[layerIndex]->name().begin(), layers_[layerIndex]->name().end()) << std::endl; } - unsigned long channel_data_start = input_.current_position(); //TODO: remove. For debug purposes only - auto end = layers_.end(); for(auto layer_it = layers_.begin(); layer_it != end; ++layer_it) { @@ -224,13 +222,12 @@ void psd_document::read_layers() input_.set_position(end_of_layers_info); } - unsigned long cp = input_.current_position(); //global layer mask info - unsigned long global_layer_mask_length = input_.read_long(); + auto global_layer_mask_length = input_.read_long(); input_.discard_bytes(global_layer_mask_length); } - catch(std::exception& ex) + catch(std::exception&) { input_.set_position(end_of_layers); } diff --git a/modules/psd/layer.cpp b/modules/psd/layer.cpp index 58ffe8394..5f2193460 100644 --- a/modules/psd/layer.cpp +++ b/modules/psd/layer.cpp @@ -75,7 +75,7 @@ struct layer::impl { friend class layer; - impl() : blend_mode_(InvalidBlendMode), link_group_id_(0), opacity_(255), sheet_color_(0), baseClipping_(false), flags_(0), protection_flags_(0), masks_count_(0), text_scale_(1.0f) + impl() : blend_mode_(blend_mode::InvalidBlendMode), link_group_id_(0), opacity_(255), sheet_color_(0), baseClipping_(false), flags_(0), protection_flags_(0), masks_count_(0), text_scale_(1.0f) {} private: @@ -135,13 +135,13 @@ public: stream.discard_bytes(1); //padding unsigned long extras_size = stream.read_long(); - long position = stream.current_position(); + auto position = stream.current_position(); mask_.read_mask_data(stream); read_blending_ranges(stream); name_ = stream.read_pascal_string(4); //Aditional Layer Information - long end_of_layer_info = position + extras_size; + auto end_of_layer_info = position + extras_size; try { while(stream.current_position() < end_of_layer_info) @@ -157,16 +157,16 @@ public: void read_chunk(BEFileInputStream& stream, const psd_document& doc, bool isMetadata = false) { - unsigned long signature = stream.read_long(); + auto signature = stream.read_long(); if(signature != '8BIM' && signature != '8B64') throw PSDFileFormatException(); - unsigned long key = stream.read_long(); + auto key = stream.read_long(); if(isMetadata) stream.read_long(); - unsigned long length = stream.read_long(); - unsigned long end_of_chunk = stream.current_position() + length; + auto length = stream.read_long(); + auto end_of_chunk = stream.current_position() + length; try { @@ -249,28 +249,28 @@ public: { typedef std::pair path_point; - unsigned long version = stream.read_long(); - unsigned long flags = stream.read_long(); + stream.read_long(); // version + stream.read_long(); // flags int path_records = (length-8) / 26; - long position = stream.current_position(); + auto position = stream.current_position(); std::vector knots; for(int i=1; i <= path_records; ++i) { - unsigned short selector = stream.read_short(); + auto selector = stream.read_short(); if(selector == 2) //we only concern ourselves with closed paths { - unsigned long p_y = stream.read_long(); - unsigned long p_x = stream.read_long(); + auto p_y = stream.read_long(); + auto p_x = stream.read_long(); path_point cp_prev(p_x, p_y); - unsigned long a_y = stream.read_long(); - unsigned long a_x = stream.read_long(); + auto a_y = stream.read_long(); + auto a_x = stream.read_long(); path_point anchor(a_x, a_y); - unsigned long n_y = stream.read_long(); - unsigned long n_x = stream.read_long(); + auto n_y = stream.read_long(); + auto n_x = stream.read_long(); path_point cp_next(n_x, n_y); if(anchor == cp_prev && anchor == cp_next) @@ -302,7 +302,7 @@ public: void read_metadata(BEFileInputStream& stream, const psd_document& doc) { - unsigned long count = stream.read_long(); + auto count = stream.read_long(); for(unsigned long index = 0; index < count; ++index) read_chunk(stream, doc, true); } @@ -328,12 +328,12 @@ public: stream.read_short(); //should be 1 //transformation info - double xx = stream.read_double(); - double xy = stream.read_double(); - double yx = stream.read_double(); - double yy = stream.read_double(); - double tx = stream.read_double(); - double ty = stream.read_double(); + auto xx = stream.read_double(); + auto xy = stream.read_double(); + auto yx = stream.read_double(); + auto yy = stream.read_double(); + stream.read_double(); // tx + stream.read_double(); // ty if(xx != yy || (xy != 0 && yx != 0)) throw PSDFileFormatException("Rotation and non-uniform scaling of dynamic textfields is not supported yet"); @@ -369,23 +369,23 @@ public: throw PSDFileFormatException("Failed to read text warp-data"); else { - double w_top = stream.read_double(); - double w_left = stream.read_double(); - double w_right = stream.read_double(); - double w_bottom = stream.read_double(); + stream.read_double(); // w_top + stream.read_double(); // w_left + stream.read_double(); // w_right + stream.read_double(); // w_bottom } } //TODO: implement void read_blending_ranges(BEFileInputStream& stream) { - unsigned long length = stream.read_long(); + auto length = stream.read_long(); stream.discard_bytes(length); } bool has_channel(channel_type type) { - return std::find_if(channels_.begin(), channels_.end(), [=](const channel& c) { return c.id == type; }) != channels_.end(); + return std::find_if(channels_.begin(), channels_.end(), [=](const channel& c) { return c.id == static_cast(type); }) != channels_.end(); } void read_channel_data(BEFileInputStream& stream) @@ -393,7 +393,7 @@ public: image8bit_ptr bitmap; image8bit_ptr mask; - bool has_transparency = has_channel(psd::transparency); + bool has_transparency = has_channel(channel_type::transparency); rect clip_rect; if(!bitmap_rect_.empty()) @@ -418,7 +418,7 @@ public: { psd::rect src_rect; image8bit_ptr target; - unsigned char offset; + unsigned char offset = 0; bool discard_channel = false; //determine target bitmap and offset @@ -427,7 +427,7 @@ public: else if((*it).id >= -1) //BGRA-data { target = bitmap; - offset = ((*it).id >= 0) ? 2 - (*it).id : 3; + offset = static_cast(((*it).id >= 0) ? 2 - (*it).id : 3); src_rect = bitmap_rect_; } else if(mask) //mask @@ -445,10 +445,10 @@ public: if(!target || src_rect.empty()) discard_channel = true; - unsigned long end_of_data = stream.current_position() + (*it).data_length; + auto end_of_data = stream.current_position() + (*it).data_length; if(!discard_channel) { - unsigned short encoding = stream.read_short(); + auto encoding = stream.read_short(); if(target) { if(encoding == 0) @@ -479,9 +479,9 @@ public: if(total_length != data_length) throw PSDFileFormatException(); - unsigned char* data = target->data(); + auto data = target->data(); - unsigned char stride = target->channel_count(); + auto stride = target->channel_count(); if(stride == 1) stream.read(reinterpret_cast(data + offset), total_length); else @@ -493,9 +493,9 @@ public: void read_rle_image_data(BEFileInputStream& stream, const rect&src_rect, const rect&clip_rect, image8bit_ptr target, unsigned char offset) { - unsigned long width = src_rect.size.width; - unsigned long height = src_rect.size.height; - unsigned char stride = target->channel_count(); + auto width = src_rect.size.width; + auto height = src_rect.size.height; + auto stride = target->channel_count(); int offset_x = clip_rect.location.x - src_rect.location.x; int offset_y = clip_rect.location.y - src_rect.location.y; @@ -503,10 +503,10 @@ public: std::vector scanline_lengths; scanline_lengths.reserve(height); - for(unsigned long scanlineIndex=0; scanlineIndex < height; ++scanlineIndex) + for (long scanlineIndex = 0; scanlineIndex < height; ++scanlineIndex) scanline_lengths.push_back(stream.read_short()); - unsigned char *target_data = target->data(); + auto target_data = target->data(); std::vector line(width); @@ -515,7 +515,7 @@ public: if(scanlineIndex >= target->height()+offset_y) break; - unsigned long colIndex = 0; + long colIndex = 0; do { diff --git a/modules/psd/misc.cpp b/modules/psd/misc.cpp index fcc886746..8f83410db 100644 --- a/modules/psd/misc.cpp +++ b/modules/psd/misc.cpp @@ -26,91 +26,92 @@ namespace caspar { namespace psd { blend_mode int_to_blend_mode(unsigned long x) { - blend_mode retVal = InvalidBlendMode; - switch(x) + blend_mode mode = static_cast(x); + + switch (mode) { - case Normal: retVal = Normal; break; - case Darken: retVal = Darken; break; - case Lighten: retVal = Lighten; break; - case Hue: retVal = Hue; break; - case Saturation: retVal = Saturation; break; - case Color: retVal = Color; break; - case Luminosity: retVal = Luminosity; break; - case Multiply: retVal = Multiply; break; - case Screen: retVal = Screen; break; - case Dissolve: retVal = Dissolve; break; - case Overlay: retVal = Overlay; break; - case HardLight: retVal = HardLight; break; - case SoftLight: retVal = SoftLight; break; - case Difference: retVal = Difference; break; - case Exclusion: retVal = Exclusion; break; - case ColorDodge: retVal = ColorDodge; break; - case ColorBurn: retVal = ColorBurn; break; + case blend_mode::Normal: + case blend_mode::Darken: + case blend_mode::Lighten: + case blend_mode::Hue: + case blend_mode::Saturation: + case blend_mode::Color: + case blend_mode::Luminosity: + case blend_mode::Multiply: + case blend_mode::Screen: + case blend_mode::Dissolve: + case blend_mode::Overlay: + case blend_mode::HardLight: + case blend_mode::SoftLight: + case blend_mode::Difference: + case blend_mode::Exclusion: + case blend_mode::ColorDodge: + case blend_mode::ColorBurn: + return mode; + default: + return blend_mode::InvalidBlendMode; } - - return retVal; } std::wstring blend_mode_to_string(blend_mode b) { - std::wstring retVal = L"Invalid"; switch(b) { - case Normal: retVal = L"Normal"; break; - case Darken: retVal = L"Darken"; break; - case Lighten: retVal = L"Lighten"; break; - case Hue: retVal = L"Hue"; break; - case Saturation: retVal = L"Saturation"; break; - case Color: retVal = L"Color"; break; - case Luminosity: retVal = L"Luminosity"; break; - case Multiply: retVal = L"Multiply"; break; - case Screen: retVal = L"Screen"; break; - case Dissolve: retVal = L"Dissolve"; break; - case Overlay: retVal = L"Overlay"; break; - case HardLight: retVal = L"HardLight"; break; - case SoftLight: retVal = L"SoftLight"; break; - case Difference: retVal = L"Difference"; break; - case Exclusion: retVal = L"Exclusion"; break; - case ColorDodge: retVal = L"ColorDodge"; break; - case ColorBurn: retVal = L"ColorBurn"; break; + case blend_mode::Normal: return L"Normal"; + case blend_mode::Darken: return L"Darken"; + case blend_mode::Lighten: return L"Lighten"; + case blend_mode::Hue: return L"Hue"; + case blend_mode::Saturation: return L"Saturation"; + case blend_mode::Color: return L"Color"; + case blend_mode::Luminosity: return L"Luminosity"; + case blend_mode::Multiply: return L"Multiply"; + case blend_mode::Screen: return L"Screen"; + case blend_mode::Dissolve: return L"Dissolve"; + case blend_mode::Overlay: return L"Overlay"; + case blend_mode::HardLight: return L"HardLight"; + case blend_mode::SoftLight: return L"SoftLight"; + case blend_mode::Difference: return L"Difference"; + case blend_mode::Exclusion: return L"Exclusion"; + case blend_mode::ColorDodge: return L"ColorDodge"; + case blend_mode::ColorBurn: return L"ColorBurn"; + default: return L"Invalid"; } - - return retVal; } color_mode int_to_color_mode(unsigned short x) { - color_mode retVal = InvalidColorMode; - switch(x) + color_mode mode = static_cast(x); + + switch(mode) { - case Bitmap: retVal = Bitmap; break; - case Grayscale: retVal = Grayscale; break; - case Indexed: retVal = Indexed; break; - case RGB: retVal = RGB; break; - case CMYK: retVal = CMYK; break; - case Multichannel: retVal = Multichannel; break; - case Duotone: retVal = Duotone; break; - case Lab: retVal = Lab; break; + case color_mode::Bitmap: + case color_mode::Grayscale: + case color_mode::Indexed: + case color_mode::RGB: + case color_mode::CMYK: + case color_mode::Multichannel: + case color_mode::Duotone: + case color_mode::Lab: + return mode; + default: + return color_mode::InvalidColorMode; }; - - return retVal; } + std::wstring color_mode_to_string(color_mode c) { - std::wstring retVal = L"Invalid"; switch(c) { - case Bitmap: retVal = L"Bitmap"; break; - case Grayscale: retVal = L"Grayscale"; break; - case Indexed: retVal = L"Indexed"; break; - case RGB: retVal = L"RGB"; break; - case CMYK: retVal = L"CMYK"; break; - case Multichannel: retVal = L"Multichannel"; break; - case Duotone: retVal = L"Duotone"; break; - case Lab: retVal = L"Lab"; break; + case color_mode::Bitmap: return L"Bitmap"; + case color_mode::Grayscale: return L"Grayscale"; + case color_mode::Indexed: return L"Indexed"; + case color_mode::RGB: return L"RGB"; + case color_mode::CMYK: return L"CMYK"; + case color_mode::Multichannel: return L"Multichannel"; + case color_mode::Duotone: return L"Duotone"; + case color_mode::Lab: return L"Lab"; + default: return L"Invalid"; }; - - return retVal; } } //namespace psd diff --git a/modules/psd/misc.h b/modules/psd/misc.h index 886c91bbe..079a49708 100644 --- a/modules/psd/misc.h +++ b/modules/psd/misc.h @@ -88,7 +88,7 @@ public: } }; -enum channel_type +enum class channel_type { total_user_mask = -3, user_mask = -2, @@ -98,7 +98,7 @@ enum channel_type color_blue = 2 }; -enum blend_mode +enum class blend_mode { InvalidBlendMode = -1, Normal = 'norm', @@ -123,7 +123,7 @@ enum blend_mode blend_mode int_to_blend_mode(unsigned long x); std::wstring blend_mode_to_string(blend_mode b); -enum color_mode +enum class color_mode { InvalidColorMode = -1, Bitmap = 0, diff --git a/modules/psd/psd.vcxproj b/modules/psd/psd.vcxproj index 3cfb4a3fc..1360e0bf2 100644 --- a/modules/psd/psd.vcxproj +++ b/modules/psd/psd.vcxproj @@ -87,11 +87,14 @@ - Level3 + Level4 Disabled SFML_STATIC;BOOST_THREAD_VERSION=4;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) Async Fast + true + true + common/compiler/vs/disable_silly_warnings.h Windows @@ -100,7 +103,7 @@ - Level3 + Level4 MaxSpeed @@ -113,6 +116,9 @@ true Async Fast + true + true + common/compiler/vs/disable_silly_warnings.h Windows diff --git a/modules/psd/util/bigendian_file_input_stream.cpp b/modules/psd/util/bigendian_file_input_stream.cpp index 70848fce2..8adb0eaa8 100644 --- a/modules/psd/util/bigendian_file_input_stream.cpp +++ b/modules/psd/util/bigendian_file_input_stream.cpp @@ -56,22 +56,12 @@ unsigned char BEFileInputStream::read_byte() return out; } -unsigned short SWAP16(unsigned short inVal) -{ - return caspar::swap_byte_order(inVal); -} - -unsigned long SWAP32(unsigned long inVal) -{ - return caspar::swap_byte_order(inVal); -} - unsigned short BEFileInputStream::read_short() { unsigned short out; read((char*)&out, 2); - return SWAP16(out); + return caspar::swap_byte_order(out); } unsigned long BEFileInputStream::read_long() @@ -79,7 +69,7 @@ unsigned long BEFileInputStream::read_long() unsigned long in; read((char*)&in, 4); - return SWAP32(in); + return caspar::swap_byte_order(in); } double BEFileInputStream::read_double() { @@ -90,33 +80,33 @@ double BEFileInputStream::read_double() return *reinterpret_cast(data); } -void BEFileInputStream::read(char* buf, unsigned long length) +void BEFileInputStream::read(char* buf, std::streamsize length) { if(length > 0) { if(ifs_.eof()) throw UnexpectedEOFException(); - ifs_.read(buf, (std::streamsize)length); + ifs_.read(buf, length); - if(ifs_.gcount() < (std::streamsize)length) + if(ifs_.gcount() < length) throw UnexpectedEOFException(); } } -long BEFileInputStream::current_position() +std::streamoff BEFileInputStream::current_position() { return ifs_.tellg(); } -void BEFileInputStream::set_position(unsigned long offset) +void BEFileInputStream::set_position(std::streamoff offset) { - ifs_.seekg(static_cast(offset), std::ios_base::beg); + ifs_.seekg(offset, std::ios_base::beg); } -void BEFileInputStream::discard_bytes(unsigned long length) +void BEFileInputStream::discard_bytes(std::streamoff length) { - ifs_.seekg(static_cast(length), std::ios_base::cur); + ifs_.seekg(length, std::ios_base::cur); } void BEFileInputStream::discard_to_next_word() { @@ -157,7 +147,7 @@ std::wstring BEFileInputStream::read_unicode_string() result.reserve(length); //can be optimized. Reads and swaps byte-order, one char at the time - for(int i=0;i(read_short())); } @@ -173,13 +163,13 @@ std::wstring BEFileInputStream::read_id_string() { result.reserve(length); - for(int i=0;icurrent_position(); pStream_->set_position(newPos); @@ -94,7 +94,7 @@ public: pStream_->set_position(oldPosition_); } private: - unsigned long oldPosition_; + std::streamoff oldPosition_; BEFileInputStream* pStream_; }; diff --git a/modules/psd/util/pdf_reader.cpp b/modules/psd/util/pdf_reader.cpp index 6bd926c21..17c4ac15b 100644 --- a/modules/psd/util/pdf_reader.cpp +++ b/modules/psd/util/pdf_reader.cpp @@ -259,7 +259,7 @@ bool read_pdf(boost::property_tree::wptree& tree, const std::string& s) if(result) tree.swap(g.context.root); } - catch(std::exception& ex) + catch(std::exception&) {} return result; diff --git a/modules/screen/consumer/screen_consumer.cpp b/modules/screen/consumer/screen_consumer.cpp index 768ea0a50..4ce6ef3cb 100644 --- a/modules/screen/consumer/screen_consumer.cpp +++ b/modules/screen/consumer/screen_consumer.cpp @@ -74,7 +74,7 @@ extern "C" namespace caspar { namespace screen { -enum stretch +enum class stretch { none, uniform, @@ -84,7 +84,7 @@ enum stretch struct configuration { - enum aspect_ratio + enum class aspect_ratio { aspect_4_3 = 0, aspect_16_9, @@ -104,11 +104,11 @@ struct configuration configuration() : name(L"ogl") , screen_index(0) - , stretch(fill) + , stretch(stretch::fill) , windowed(true) , auto_deinterlace(true) , key_only(false) - , aspect(aspect_invalid) + , aspect(aspect_ratio::aspect_invalid) , vsync(true) , interactive(true) { @@ -185,15 +185,15 @@ public: format_desc.field_mode == core::field_mode::progressive || !config.auto_deinterlace ? "" : "YADIF=1:-1"); }()) { - if(format_desc_.format == core::video_format::ntsc && config_.aspect == configuration::aspect_4_3) + if (format_desc_.format == core::video_format::ntsc && config_.aspect == configuration::aspect_ratio::aspect_4_3) { // Use default values which are 4:3. } else { - if(config_.aspect == configuration::aspect_16_9) + if (config_.aspect == configuration::aspect_ratio::aspect_16_9) square_width_ = (format_desc.height*16)/9; - else if(config_.aspect == configuration::aspect_4_3) + else if (config_.aspect == configuration::aspect_ratio::aspect_4_3) square_width_ = (format_desc.height*4)/3; } @@ -526,11 +526,11 @@ public: GL(glViewport(0, 0, screen_width_, screen_height_)); std::pair target_ratio = None(); - if(config_.stretch == fill) + if (config_.stretch == stretch::fill) target_ratio = Fill(); - else if(config_.stretch == uniform) + else if (config_.stretch == stretch::uniform) target_ratio = Uniform(); - else if(config_.stretch == uniform_to_fill) + else if (config_.stretch == stretch::uniform_to_fill) target_ratio = UniformToFill(); width_ = target_ratio.first; @@ -680,9 +680,9 @@ spl::shared_ptr create_consumer(const boost::property_tree auto aspect_str = ptree.get(L"aspect-ratio", L"default"); if(aspect_str == L"16:9") - config.aspect = configuration::aspect_16_9; + config.aspect = configuration::aspect_ratio::aspect_16_9; else if(aspect_str == L"4:3") - config.aspect = configuration::aspect_4_3; + config.aspect = configuration::aspect_ratio::aspect_4_3; return spl::make_shared(config, sink); } diff --git a/protocol/amcp/AMCPProtocolStrategy.cpp b/protocol/amcp/AMCPProtocolStrategy.cpp index 6fdb807f8..1495402dd 100644 --- a/protocol/amcp/AMCPProtocolStrategy.cpp +++ b/protocol/amcp/AMCPProtocolStrategy.cpp @@ -74,13 +74,13 @@ public: ~impl() {} - enum parser_state { + enum class parser_state { New = 0, GetSwitch, GetCommand, GetParameters }; - enum error_state { + enum class error_state { no_error = 0, command_error, channel_error, @@ -91,7 +91,7 @@ public: struct command_interpreter_result { - command_interpreter_result() : error(no_error) {} + command_interpreter_result() : error(error_state::no_error) {} std::shared_ptr lock; std::wstring command_name; @@ -110,28 +110,28 @@ public: if(interpret_command_string(message, result, client)) { if(result.lock && !result.lock->check_access(client)) - result.error = access_error; + result.error = error_state::access_error; else result.queue->AddCommand(result.command); } - if(result.error != no_error) + if (result.error != error_state::no_error) { std::wstringstream answer; boost::to_upper(result.command_name); switch(result.error) { - case command_error: + case error_state::command_error: answer << L"400 ERROR\r\n" << message << "\r\n"; break; - case channel_error: + case error_state::channel_error: answer << L"401 " << result.command_name << " ERROR\r\n"; break; - case parameters_error: + case error_state::parameters_error: answer << L"402 " << result.command_name << " ERROR\r\n"; break; - case access_error: + case error_state::access_error: answer << L"503 " << result.command_name << " FAILED\r\n"; break; default: @@ -150,38 +150,38 @@ private: try { std::vector tokens; - parser_state state = New; + parser_state state = parser_state::New; tokenize(message, &tokens); //parse the message one token at the time auto end = tokens.end(); auto it = tokens.begin(); - while(it != end && result.error == no_error) + while (it != end && result.error == error_state::no_error) { switch(state) { - case New: + case parser_state::New: if((*it)[0] == TEXT('/')) - state = GetSwitch; + state = parser_state::GetSwitch; else - state = GetCommand; + state = parser_state::GetCommand; break; - case GetSwitch: + case parser_state::GetSwitch: //command_switch = (*it); //we dont care for the switch anymore - state = GetCommand; + state = parser_state::GetCommand; ++it; break; - case GetCommand: + case parser_state::GetCommand: { result.command_name = (*it); result.command = create_command(result.command_name, client); if(result.command) //the command doesn't need a channel { result.queue = commandQueues_[0]; - state = GetParameters; + state = parser_state::GetParameters; } else { @@ -193,9 +193,9 @@ private: if(it == end) { if(create_channel_command(result.command_name, client, channels_.at(0), 0, 0)) //check if there is a command like this - result.error = channel_error; + result.error = error_state::channel_error; else - result.error = command_error; + result.error = error_state::command_error; break; } @@ -213,7 +213,7 @@ private: } catch(...) { - result.error = channel_error; + result.error = error_state::channel_error; break; } } @@ -228,23 +228,23 @@ private: } else { - result.error = command_error; + result.error = error_state::command_error; break; } } else { - result.error = channel_error; + result.error = error_state::channel_error; break; } } - state = GetParameters; + state = parser_state::GetParameters; ++it; } break; - case GetParameters: + case parser_state::GetParameters: { int parameterCount=0; while(it != end) @@ -258,17 +258,17 @@ private: } } - if(result.command && result.error == no_error && result.command->parameters().size() < result.command->minimum_parameters()) { - result.error = parameters_error; + if(result.command && result.error == error_state::no_error && result.command->parameters().size() < result.command->minimum_parameters()) { + result.error = error_state::parameters_error; } } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); - result.error = unknown_error; + result.error = error_state::unknown_error; } - return result.error == no_error; + return result.error == error_state::no_error; } std::size_t tokenize(const std::wstring& message, std::vector* pTokenVector) diff --git a/protocol/clk/CLKProtocolStrategy.cpp b/protocol/clk/CLKProtocolStrategy.cpp index 30b5f7d9a..c89246a71 100644 --- a/protocol/clk/CLKProtocolStrategy.cpp +++ b/protocol/clk/CLKProtocolStrategy.cpp @@ -41,7 +41,7 @@ public: CLKProtocolStrategy( const IO::client_connection::ptr& client_connection, clk_command_processor& command_processor) - : currentState_(ExpectingNewCommand) + : currentState_(ParserState::ExpectingNewCommand) , command_processor_(command_processor) , client_connection_(client_connection) { @@ -62,18 +62,18 @@ public: { switch (currentState_) { - case ExpectingNewCommand: + case ParserState::ExpectingNewCommand: if (currentByte == 1) - currentState_ = ExpectingCommand; + currentState_ = ParserState::ExpectingCommand; //just throw anything else away break; - case ExpectingCommand: + case ParserState::ExpectingCommand: if (currentByte == 2) - currentState_ = ExpectingParameter; + currentState_ = ParserState::ExpectingParameter; else command_name_ += currentByte; break; - case ExpectingParameter: + case ParserState::ExpectingParameter: //allocate new parameter if (parameters_.size() == 0 || currentByte == 2) parameters_.push_back(std::wstring()); @@ -124,13 +124,13 @@ public: private: void reset() { - currentState_ = ExpectingNewCommand; + currentState_ = ParserState::ExpectingNewCommand; currentCommandString_.str(L""); command_name_.clear(); parameters_.clear(); } - enum ParserState + enum class ParserState { ExpectingNewCommand, ExpectingCommand, diff --git a/test/psd-test/psd-test.vcxproj b/test/psd-test/psd-test.vcxproj index 17c1bef17..c63452576 100644 --- a/test/psd-test/psd-test.vcxproj +++ b/test/psd-test/psd-test.vcxproj @@ -53,11 +53,13 @@ - Level3 + Level4 Disabled SFML_STATIC;BOOST_THREAD_VERSION=4;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) Async Fast + true + true Console @@ -66,7 +68,7 @@ - Level3 + Level4 MaxSpeed @@ -75,6 +77,8 @@ SFML_STATIC;BOOST_THREAD_VERSION=4;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) Async Fast + true + true Console -- 2.39.5