Drawable Renderer (#1570), Custom layer (issue #1272)

This commit is contained in:
Stefan Karschti
2023-07-07 21:24:10 +03:00
committed by Bart Louwers
parent 7e7fa37fd0
commit a42b559fbe
35 changed files with 264 additions and 77 deletions

View File

@@ -129,6 +129,10 @@ public:
bool getIs3D() const { return is3D; }
void setIs3D(bool value) { is3D = value; }
/// Is custom
bool getIsCustom() const { return isCustom; }
void setIsCustom(bool value) { isCustom = value; }
/// The ID of the tile that this drawable represents, if any
const std::optional<OverscaledTileID>& getTileID() const { return tileID; }
void setTileID(const OverscaledTileID& value) { tileID = value; }
@@ -175,6 +179,7 @@ protected:
bool enableColor = true;
bool enableStencil = false;
bool is3D = false;
bool isCustom = false;
std::string name;
util::SimpleIdentity uniqueID;
gfx::ShaderProgramBasePtr shader;

View File

@@ -32,7 +32,7 @@ public:
virtual ~DrawableBuilder();
/// Get the drawable we're currently working on, if any
const UniqueDrawable& getCurrentDrawable(bool createIfNone);
UniqueDrawable& getCurrentDrawable(bool createIfNone);
/// Close the current drawable, using a new one for any further work
void flush();

View File

@@ -0,0 +1,31 @@
#pragma once
#include <mbgl/gfx/drawable_tweaker.hpp>
#include <mbgl/style/layers/custom_layer.hpp>
#include <memory>
#include <string>
namespace mbgl {
namespace gfx {
class Drawable;
/**
Tweaker that enables drawing a CustomLayer via their CustomLayerHost
*/
class DrawableCustomLayerHostTweaker : public gfx::DrawableTweaker {
public:
DrawableCustomLayerHostTweaker(std::shared_ptr<style::CustomLayerHost> host_)
: host(host_) {}
~DrawableCustomLayerHostTweaker() override = default;
void execute(Drawable&, const PaintParameters&) override;
protected:
std::shared_ptr<style::CustomLayerHost> host;
};
} // namespace gfx
} // namespace mbgl

View File

@@ -16,6 +16,8 @@ public:
virtual ~RenderableResource() = default;
RenderableResource(const RenderableResource&) = delete;
RenderableResource& operator=(const RenderableResource&) = delete;
virtual void bind() = 0;
};
class Renderable {