[core] Bitmask operations for enums
This commit is contained in:
@@ -456,6 +456,7 @@
|
||||
"mbgl/tile/tile_necessity.hpp": "include/mbgl/tile/tile_necessity.hpp",
|
||||
"mbgl/util/async_request.hpp": "include/mbgl/util/async_request.hpp",
|
||||
"mbgl/util/async_task.hpp": "include/mbgl/util/async_task.hpp",
|
||||
"mbgl/util/bitmask_operations.hpp": "include/mbgl/util/bitmask_operations.hpp",
|
||||
"mbgl/util/char_array_buffer.hpp": "include/mbgl/util/char_array_buffer.hpp",
|
||||
"mbgl/util/chrono.hpp": "include/mbgl/util/chrono.hpp",
|
||||
"mbgl/util/color.hpp": "include/mbgl/util/color.hpp",
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include <mbgl/text/glyph_atlas.hpp>
|
||||
#include <mbgl/text/collision_feature.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer_properties.hpp>
|
||||
#include <mbgl/util/traits.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
#include <mbgl/util/bitmask_operations.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -50,18 +49,6 @@ enum class SymbolContent : uint8_t {
|
||||
IconSDF = 1 << 2
|
||||
};
|
||||
|
||||
MBGL_CONSTEXPR SymbolContent operator|(SymbolContent a, SymbolContent b) {
|
||||
return SymbolContent(mbgl::underlying_type(a) | mbgl::underlying_type(b));
|
||||
}
|
||||
|
||||
MBGL_CONSTEXPR SymbolContent& operator|=(SymbolContent& a, SymbolContent b) {
|
||||
return (a = a | b);
|
||||
}
|
||||
|
||||
MBGL_CONSTEXPR SymbolContent operator&(SymbolContent a, SymbolContent b) {
|
||||
return SymbolContent(mbgl::underlying_type(a) & mbgl::underlying_type(b));
|
||||
}
|
||||
|
||||
class SymbolInstance {
|
||||
public:
|
||||
SymbolInstance(Anchor& anchor_,
|
||||
|
||||
@@ -32,7 +32,7 @@ const std::string& RenderLayer::getID() const {
|
||||
}
|
||||
|
||||
bool RenderLayer::hasRenderPass(RenderPass pass) const {
|
||||
return bool(passes & pass);
|
||||
return passes & pass;
|
||||
}
|
||||
|
||||
bool RenderLayer::needsRendering() const {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/traits.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
#include <mbgl/util/bitmask_operations.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -14,18 +13,6 @@ enum class RenderPass : uint8_t {
|
||||
Pass3D = 1 << 2,
|
||||
};
|
||||
|
||||
MBGL_CONSTEXPR RenderPass operator|(RenderPass a, RenderPass b) {
|
||||
return RenderPass(mbgl::underlying_type(a) | mbgl::underlying_type(b));
|
||||
}
|
||||
|
||||
MBGL_CONSTEXPR RenderPass& operator|=(RenderPass& a, RenderPass b) {
|
||||
return (a = a | b);
|
||||
}
|
||||
|
||||
MBGL_CONSTEXPR RenderPass operator&(RenderPass a, RenderPass b) {
|
||||
return RenderPass(mbgl::underlying_type(a) & mbgl::underlying_type(b));
|
||||
}
|
||||
|
||||
// Defines whether the overdraw shaders should be used instead of the regular shaders.
|
||||
enum class PaintMode : bool {
|
||||
Regular = false,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/text/glyph_range.hpp>
|
||||
#include <mbgl/util/bitmask_operations.hpp>
|
||||
#include <mbgl/util/font_stack.hpp>
|
||||
#include <mbgl/util/rect.hpp>
|
||||
#include <mbgl/util/traits.hpp>
|
||||
@@ -99,26 +100,6 @@ enum class WritingModeType : uint8_t {
|
||||
Vertical = 1 << 1,
|
||||
};
|
||||
|
||||
MBGL_CONSTEXPR WritingModeType operator|(WritingModeType a, WritingModeType b) {
|
||||
return WritingModeType(mbgl::underlying_type(a) | mbgl::underlying_type(b));
|
||||
}
|
||||
|
||||
MBGL_CONSTEXPR WritingModeType& operator|=(WritingModeType& a, WritingModeType b) {
|
||||
return (a = a | b);
|
||||
}
|
||||
|
||||
MBGL_CONSTEXPR bool operator&(WritingModeType lhs, WritingModeType rhs) {
|
||||
return mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs);
|
||||
}
|
||||
|
||||
MBGL_CONSTEXPR WritingModeType& operator&=(WritingModeType& lhs, WritingModeType rhs) {
|
||||
return (lhs = WritingModeType(mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs)));
|
||||
}
|
||||
|
||||
MBGL_CONSTEXPR WritingModeType operator~(WritingModeType value) {
|
||||
return WritingModeType(~mbgl::underlying_type(value));
|
||||
}
|
||||
|
||||
using GlyphDependencies = std::map<FontStack, GlyphIDs>;
|
||||
using GlyphRangeDependencies = std::map<FontStack, std::unordered_set<GlyphRange>>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user