fix some missing public headers referenced by other public headers (macos) (#3791)

This commit is contained in:
Sargun Vohra
2025-09-08 06:50:33 -07:00
committed by GitHub
parent a28dd1b788
commit 9d638f2ffe
9 changed files with 14 additions and 14 deletions

View File

@@ -0,0 +1,89 @@
#pragma once
#include <mbgl/gfx/types.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/hash.hpp>
namespace mbgl {
namespace gfx {
class ColorMode {
public:
template <ColorBlendEquationType E>
struct ConstantBlend {
static constexpr ColorBlendEquationType equation = E;
static constexpr ColorBlendFactorType srcFactor = ColorBlendFactorType::One;
static constexpr ColorBlendFactorType dstFactor = ColorBlendFactorType::One;
};
template <ColorBlendEquationType E>
struct LinearBlend {
static constexpr ColorBlendEquationType equation = E;
ColorBlendFactorType srcFactor;
ColorBlendFactorType dstFactor;
};
struct Replace {
static constexpr ColorBlendEquationType equation = ColorBlendEquationType::Add;
static constexpr ColorBlendFactorType srcFactor = ColorBlendFactorType::One;
static constexpr ColorBlendFactorType dstFactor = ColorBlendFactorType::Zero;
};
using Add = LinearBlend<ColorBlendEquationType::Add>;
using Subtract = LinearBlend<ColorBlendEquationType::Subtract>;
using ReverseSubtract = LinearBlend<ColorBlendEquationType::ReverseSubtract>;
using BlendFunction = variant<Replace, Add, Subtract, ReverseSubtract>;
BlendFunction blendFunction;
Color blendColor;
struct Mask {
bool r;
bool g;
bool b;
bool a;
};
Mask mask;
static ColorMode disabled() {
return {.blendFunction = Replace{}, .blendColor = {}, .mask = {.r = false, .g = false, .b = false, .a = false}};
}
static ColorMode unblended() {
return {.blendFunction = Replace{}, .blendColor = {}, .mask = {.r = true, .g = true, .b = true, .a = true}};
}
static ColorMode alphaBlended() {
return {.blendFunction = Add{ColorBlendFactorType::One, ColorBlendFactorType::OneMinusSrcAlpha},
.blendColor = {},
.mask = {.r = true, .g = true, .b = true, .a = true}};
}
static ColorMode additive() {
return {.blendFunction = Add{ColorBlendFactorType::One, ColorBlendFactorType::One},
.blendColor = {},
.mask = {.r = true, .g = true, .b = true, .a = true}};
}
std::size_t hash() const {
return mbgl::util::hash(blendFunction.which(),
blendColor.r,
blendColor.g,
blendColor.b,
blendColor.a,
mask.r,
mask.g,
mask.b,
mask.a);
}
};
constexpr bool operator!=(const ColorMode::Mask& a, const ColorMode::Mask& b) {
return a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a;
}
} // namespace gfx
} // namespace mbgl

View File

@@ -0,0 +1,27 @@
#pragma once
#include <mbgl/gfx/types.hpp>
#include <mbgl/util/range.hpp>
namespace mbgl {
namespace gfx {
class DepthMode {
public:
DepthFunctionType func;
DepthMaskType mask;
#if MLN_RENDER_BACKEND_OPENGL
Range<float> range;
#endif
#if MLN_RENDER_BACKEND_OPENGL
static DepthMode disabled() { return DepthMode{DepthFunctionType::Always, DepthMaskType::ReadOnly, {0.0, 1.0}}; }
#else
static DepthMode disabled() {
return DepthMode{.func = DepthFunctionType::Always, .mask = DepthMaskType::ReadOnly};
}
#endif
};
} // namespace gfx
} // namespace mbgl

View File

@@ -0,0 +1,94 @@
#pragma once
#include <mbgl/gfx/types.hpp>
#include <cassert>
#include <cstddef>
#include <type_traits>
namespace mbgl {
namespace gfx {
class DrawMode {
protected:
DrawMode(DrawModeType type_, float size_)
: type(type_),
size(size_) {}
public:
const DrawModeType type;
const float size;
};
template <class>
struct BufferGroupSizeOf;
template <class>
struct PrimitiveTypeOf;
class Points : public DrawMode {
public:
explicit Points(float pointSize_)
: DrawMode(DrawModeType::Points, pointSize_) {
assert(size > 0);
}
};
template <>
struct BufferGroupSizeOf<Points> : std::integral_constant<std::size_t, 1> {};
template <>
struct PrimitiveTypeOf<Points> : std::integral_constant<PrimitiveType, PrimitiveType::Point> {};
class Lines : public DrawMode {
public:
explicit Lines(float lineWidth_)
: DrawMode(DrawModeType::Lines, lineWidth_) {
assert(size > 0);
}
};
template <>
struct BufferGroupSizeOf<Lines> : std::integral_constant<std::size_t, 2> {};
template <>
struct PrimitiveTypeOf<Lines> : std::integral_constant<PrimitiveType, PrimitiveType::Line> {};
// LineStrip is a form of "Line" rendering, but the element buffer
// cannot be grouped into logical elements beyond a single Point.
class LineStrip : public DrawMode {
public:
explicit LineStrip(float lineWidth_)
: DrawMode(DrawModeType::LineStrip, lineWidth_) {
assert(size > 0);
}
};
template <>
struct BufferGroupSizeOf<LineStrip> : std::integral_constant<std::size_t, 1> {};
template <>
struct PrimitiveTypeOf<LineStrip> : std::integral_constant<PrimitiveType, PrimitiveType::Line> {};
class Triangles : public DrawMode {
public:
explicit Triangles()
: DrawMode(DrawModeType::Triangles, 0) {}
};
template <>
struct BufferGroupSizeOf<Triangles> : std::integral_constant<std::size_t, 3> {};
template <>
struct PrimitiveTypeOf<Triangles> : std::integral_constant<PrimitiveType, PrimitiveType::Triangle> {};
// TriangleStrip is a form of "Triangle" rendering, but the element buffer
// cannot be grouped into logical elements beyond a single Point.
class TriangleStrip : public DrawMode {
public:
explicit TriangleStrip()
: DrawMode(DrawModeType::TriangleStrip, 0) {}
};
template <>
struct BufferGroupSizeOf<TriangleStrip> : std::integral_constant<std::size_t, 1> {};
template <>
struct PrimitiveTypeOf<TriangleStrip> : std::integral_constant<PrimitiveType, PrimitiveType::Triangle> {};
} // namespace gfx
} // namespace mbgl

View File

@@ -0,0 +1,33 @@
#pragma once
#include <memory>
#include <cassert>
namespace mbgl {
namespace gfx {
class DrawScopeResource {
protected:
DrawScopeResource() = default;
public:
virtual ~DrawScopeResource() = default;
};
class DrawScope {
public:
explicit DrawScope(std::unique_ptr<DrawScopeResource> resource_)
: resource(std::move(resource_)) {}
template <typename T = DrawScopeResource>
T& getResource() const {
assert(resource);
return static_cast<T&>(*resource);
}
protected:
std::unique_ptr<DrawScopeResource> resource;
};
} // namespace gfx
} // namespace mbgl

View File

@@ -0,0 +1,46 @@
#pragma once
#include <mbgl/gfx/types.hpp>
#include <mbgl/util/size.hpp>
#include <memory>
#include <cassert>
namespace mbgl {
namespace gfx {
class RenderbufferResource {
protected:
RenderbufferResource() = default;
public:
virtual ~RenderbufferResource() = default;
};
template <RenderbufferPixelType renderbufferType>
class Renderbuffer final {
public:
Renderbuffer(const Size size_, std::unique_ptr<RenderbufferResource> resource_)
: size(size_),
resource(std::move(resource_)) {}
void setShouldClear(bool clear) { dirty = clear; }
bool needsClearing() const { return dirty; }
const Size& getSize() const { return size; }
template <typename T = RenderbufferResource>
T& getResource() const {
assert(resource);
return static_cast<T&>(*resource);
}
protected:
Size size;
bool dirty = false;
std::unique_ptr<RenderbufferResource> resource;
};
} // namespace gfx
} // namespace mbgl

View File

@@ -0,0 +1,53 @@
#pragma once
#include <mbgl/gfx/types.hpp>
#include <mbgl/util/variant.hpp>
namespace mbgl {
namespace gfx {
class StencilMode {
public:
template <StencilFunctionType F>
struct SimpleTest {
static constexpr StencilFunctionType func = F;
static constexpr uint32_t mask = 0;
};
template <StencilFunctionType F>
struct MaskedTest {
static constexpr StencilFunctionType func = F;
uint32_t mask;
};
using Never = SimpleTest<StencilFunctionType::Never>;
using Less = MaskedTest<StencilFunctionType::Less>;
using Equal = MaskedTest<StencilFunctionType::Equal>;
using LessEqual = MaskedTest<StencilFunctionType::LessEqual>;
using Greater = MaskedTest<StencilFunctionType::Greater>;
using NotEqual = MaskedTest<StencilFunctionType::NotEqual>;
using GreaterEqual = MaskedTest<StencilFunctionType::GreaterEqual>;
using Always = SimpleTest<StencilFunctionType::Always>;
using Test = variant<Never, Less, Equal, LessEqual, Greater, NotEqual, GreaterEqual, Always>;
Test test;
int32_t ref;
uint32_t mask;
StencilOpType fail;
StencilOpType depthFail;
StencilOpType pass;
static StencilMode disabled() {
return StencilMode{.test = Always(),
.ref = 0,
.mask = 0,
.fail = StencilOpType::Keep,
.depthFail = StencilOpType::Keep,
.pass = StencilOpType::Keep};
}
};
} // namespace gfx
} // namespace mbgl

View File

@@ -0,0 +1,42 @@
#pragma once
#include <memory>
#include <cassert>
namespace mbgl {
namespace gfx {
class VertexBufferResource {
protected:
VertexBufferResource() noexcept = default;
public:
virtual ~VertexBufferResource() noexcept = default;
};
using UniqueVertexBufferResource = std::unique_ptr<VertexBufferResource>;
// This class has a template argument that we use to specify the vertex type. It
// is not used by the implementation, but serves type checking purposes during
// build time.
template <class>
class VertexBuffer {
public:
VertexBuffer(const std::size_t elements_, UniqueVertexBufferResource&& resource_)
: elements(elements_),
resource(std::move(resource_)) {}
std::size_t elements;
template <typename T = VertexBufferResource>
T& getResource() const {
assert(resource);
return static_cast<T&>(*resource);
}
protected:
UniqueVertexBufferResource resource;
};
} // namespace gfx
} // namespace mbgl