[core] use abstract Context interface where possible
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include <mbgl/geometry/line_atlas.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/platform.hpp>
|
||||
#include <mbgl/util/hash.hpp>
|
||||
@@ -126,7 +126,7 @@ Size LineAtlas::getSize() const {
|
||||
return image.size;
|
||||
}
|
||||
|
||||
void LineAtlas::upload(gl::Context& context, uint8_t unit) {
|
||||
void LineAtlas::upload(gfx::Context& context, uint8_t unit) {
|
||||
if (!texture) {
|
||||
texture = context.createTexture(image, unit);
|
||||
} else if (dirty) {
|
||||
@@ -136,7 +136,7 @@ void LineAtlas::upload(gl::Context& context, uint8_t unit) {
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
void LineAtlas::bind(gl::Context& context, uint8_t unit) {
|
||||
void LineAtlas::bind(gfx::Context& context, uint8_t unit) {
|
||||
upload(context, unit);
|
||||
context.bindTexture(*texture, unit, gfx::TextureFilterType::Linear, gfx::TextureMipMapType::No,
|
||||
gfx::TextureWrapType::Repeat, gfx::TextureWrapType::Clamp);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gl/object.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
|
||||
@@ -11,9 +10,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace gl {
|
||||
namespace gfx {
|
||||
class Context;
|
||||
} // namespace gl
|
||||
} // namespace gfx
|
||||
|
||||
class LinePatternPos {
|
||||
public:
|
||||
@@ -33,11 +32,11 @@ public:
|
||||
~LineAtlas();
|
||||
|
||||
// Binds the atlas texture to the GPU, and uploads data if it is out of date.
|
||||
void bind(gl::Context&, uint8_t unit);
|
||||
void bind(gfx::Context&, uint8_t unit);
|
||||
|
||||
// Uploads the texture to the GPU to be available when we need it. This is a lazy operation;
|
||||
// the texture is only bound when the data is out of date (=dirty).
|
||||
void upload(gl::Context&, uint8_t unit);
|
||||
void upload(gfx::Context&, uint8_t unit);
|
||||
|
||||
LinePatternPos getDashPosition(const std::vector<float>&, LinePatternCap);
|
||||
LinePatternPos addDash(const std::vector<float>& dasharray, LinePatternCap);
|
||||
@@ -47,7 +46,7 @@ public:
|
||||
private:
|
||||
const AlphaImage image;
|
||||
bool dirty;
|
||||
mbgl::optional<gfx::Texture> texture;
|
||||
optional<gfx::Texture> texture;
|
||||
uint32_t nextRow = 0;
|
||||
std::unordered_map<size_t, LinePatternPos> positions;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/gl/vertex_array.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace gl {
|
||||
namespace gfx {
|
||||
class Context;
|
||||
} // namespace gl
|
||||
} // namespace gfx
|
||||
|
||||
class RenderLayer;
|
||||
class PatternDependency;
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
// As long as this bucket has a Prepare render pass, this function is getting called. Typically,
|
||||
// this only happens once when the bucket is being rendered for the first time.
|
||||
virtual void upload(gl::Context&) = 0;
|
||||
virtual void upload(gfx::Context&) = 0;
|
||||
|
||||
virtual bool hasData() const = 0;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ CircleBucket::CircleBucket(const BucketParameters& parameters, const std::vector
|
||||
|
||||
CircleBucket::~CircleBucket() = default;
|
||||
|
||||
void CircleBucket::upload(gl::Context& context) {
|
||||
void CircleBucket::upload(gfx::Context& context) {
|
||||
vertexBuffer = context.createVertexBuffer(std::move(vertices));
|
||||
indexBuffer = context.createIndexBuffer(std::move(triangles));
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
|
||||
bool hasData() const override;
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
|
||||
float getQueryRadius(const RenderLayer&) const override;
|
||||
bool supportsLayer(const style::Layer::Impl&) const override;
|
||||
|
||||
@@ -16,7 +16,7 @@ DebugBucket::DebugBucket(const OverscaledTileID& id,
|
||||
optional<Timestamp> modified_,
|
||||
optional<Timestamp> expires_,
|
||||
MapDebugOptions debugMode_,
|
||||
gl::Context& context)
|
||||
gfx::Context& context)
|
||||
: renderable(renderable_),
|
||||
complete(complete_),
|
||||
modified(std::move(modified_)),
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
optional<Timestamp> modified,
|
||||
optional<Timestamp> expires,
|
||||
MapDebugOptions,
|
||||
gl::Context&);
|
||||
gfx::Context&);
|
||||
|
||||
const bool renderable;
|
||||
const bool complete;
|
||||
|
||||
@@ -121,7 +121,7 @@ void FillBucket::addFeature(const GeometryTileFeature& feature,
|
||||
}
|
||||
}
|
||||
|
||||
void FillBucket::upload(gl::Context& context) {
|
||||
void FillBucket::upload(gfx::Context& context) {
|
||||
vertexBuffer = context.createVertexBuffer(std::move(vertices));
|
||||
lineIndexBuffer = context.createIndexBuffer(std::move(lines));
|
||||
triangleIndexBuffer = context.createIndexBuffer(std::move(triangles));
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
bool hasData() const override;
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
|
||||
float getQueryRadius(const RenderLayer&) const override;
|
||||
bool supportsLayer(const style::Layer::Impl&) const override;
|
||||
|
||||
@@ -165,7 +165,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
|
||||
}
|
||||
}
|
||||
|
||||
void FillExtrusionBucket::upload(gl::Context& context) {
|
||||
void FillExtrusionBucket::upload(gfx::Context& context) {
|
||||
vertexBuffer = context.createVertexBuffer(std::move(vertices));
|
||||
indexBuffer = context.createIndexBuffer(std::move(triangles));
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
bool supportsLayer(const style::Layer::Impl&) const override;
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
|
||||
float getQueryRadius(const RenderLayer&) const override;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ HeatmapBucket::HeatmapBucket(const BucketParameters& parameters, const std::vect
|
||||
|
||||
HeatmapBucket::~HeatmapBucket() = default;
|
||||
|
||||
void HeatmapBucket::upload(gl::Context& context) {
|
||||
void HeatmapBucket::upload(gfx::Context& context) {
|
||||
vertexBuffer = context.createVertexBuffer(std::move(vertices));
|
||||
indexBuffer = context.createIndexBuffer(std::move(triangles));
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
const PatternLayerMap&) override;
|
||||
bool hasData() const override;
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
|
||||
float getQueryRadius(const RenderLayer&) const override;
|
||||
bool supportsLayer(const style::Layer::Impl&) const override;
|
||||
|
||||
@@ -26,7 +26,7 @@ DEMData& HillshadeBucket::getDEMData() {
|
||||
return demdata;
|
||||
}
|
||||
|
||||
void HillshadeBucket::upload(gl::Context& context) {
|
||||
void HillshadeBucket::upload(gfx::Context& context) {
|
||||
if (!hasData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
HillshadeBucket(DEMData&&);
|
||||
~HillshadeBucket() override;
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
bool hasData() const override;
|
||||
bool supportsLayer(const style::Layer::Impl&) const override;
|
||||
|
||||
|
||||
@@ -508,7 +508,7 @@ void LineBucket::addPieSliceVertex(const GeometryCoordinate& currentVertex,
|
||||
}
|
||||
}
|
||||
|
||||
void LineBucket::upload(gl::Context& context) {
|
||||
void LineBucket::upload(gfx::Context& context) {
|
||||
vertexBuffer = context.createVertexBuffer(std::move(vertices));
|
||||
indexBuffer = context.createIndexBuffer(std::move(triangles));
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
bool hasData() const override;
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
|
||||
float getQueryRadius(const RenderLayer&) const override;
|
||||
bool supportsLayer(const style::Layer::Impl&) const override;
|
||||
|
||||
@@ -17,7 +17,7 @@ RasterBucket::RasterBucket(std::shared_ptr<PremultipliedImage> image_)
|
||||
|
||||
RasterBucket::~RasterBucket() = default;
|
||||
|
||||
void RasterBucket::upload(gl::Context& context) {
|
||||
void RasterBucket::upload(gfx::Context& context) {
|
||||
if (!hasData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
RasterBucket(std::shared_ptr<PremultipliedImage>);
|
||||
~RasterBucket() override;
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
bool hasData() const override;
|
||||
bool supportsLayer(const style::Layer::Impl&) const override;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layo
|
||||
|
||||
SymbolBucket::~SymbolBucket() = default;
|
||||
|
||||
void SymbolBucket::upload(gl::Context& context) {
|
||||
void SymbolBucket::upload(gfx::Context& context) {
|
||||
if (hasTextData()) {
|
||||
if (!staticUploaded) {
|
||||
text.indexBuffer = context.createIndexBuffer(std::move(text.triangles), sortFeaturesByY ? gfx::BufferUsageType::StreamDraw : gfx::BufferUsageType::StaticDraw);
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
const std::vector<SymbolInstance>&&);
|
||||
~SymbolBucket() override;
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
bool hasData() const override;
|
||||
bool supportsLayer(const style::Layer::Impl&) const override;
|
||||
bool hasTextData() const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <mbgl/renderer/image_manager.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/gl/context.hpp>
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -167,7 +167,7 @@ Size ImageManager::getPixelSize() const {
|
||||
};
|
||||
}
|
||||
|
||||
void ImageManager::upload(gl::Context& context, uint8_t unit) {
|
||||
void ImageManager::upload(gfx::Context& context, uint8_t unit) {
|
||||
if (!atlasTexture) {
|
||||
atlasTexture = context.createTexture(atlasImage, unit);
|
||||
} else if (dirty) {
|
||||
@@ -177,7 +177,7 @@ void ImageManager::upload(gl::Context& context, uint8_t unit) {
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
void ImageManager::bind(gl::Context& context, uint8_t unit) {
|
||||
void ImageManager::bind(gfx::Context& context, uint8_t unit) {
|
||||
upload(context, unit);
|
||||
context.bindTexture(*atlasTexture, unit, gfx::TextureFilterType::Linear);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace gl {
|
||||
namespace gfx {
|
||||
class Context;
|
||||
} // namespace gl
|
||||
} // namespace gfx
|
||||
|
||||
class ImageRequestor {
|
||||
public:
|
||||
@@ -65,8 +65,8 @@ private:
|
||||
public:
|
||||
optional<ImagePosition> getPattern(const std::string& name);
|
||||
|
||||
void bind(gl::Context&, uint8_t unit);
|
||||
void upload(gl::Context&, uint8_t unit);
|
||||
void bind(gfx::Context&, uint8_t unit);
|
||||
void upload(gfx::Context&, uint8_t unit);
|
||||
|
||||
Size getPixelSize() const;
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ const optional<ImagePosition> GeometryTile::getPattern(const std::string& patter
|
||||
return {};
|
||||
}
|
||||
|
||||
void GeometryTile::upload(gl::Context& context) {
|
||||
void GeometryTile::upload(gfx::Context& context) {
|
||||
auto uploadFn = [&] (Bucket& bucket) {
|
||||
if (bucket.needsUpload()) {
|
||||
bucket.upload(context);
|
||||
|
||||
@@ -42,12 +42,9 @@ public:
|
||||
void getGlyphs(GlyphDependencies);
|
||||
void getImages(ImageRequestPair);
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
Bucket* getBucket(const style::Layer::Impl&) const override;
|
||||
|
||||
Size bindGlyphAtlas(gl::Context&);
|
||||
Size bindIconAtlas(gl::Context&);
|
||||
|
||||
void queryRenderedFeatures(
|
||||
std::unordered_map<std::string, std::vector<Feature>>& result,
|
||||
const GeometryCoordinates& queryGeometry,
|
||||
|
||||
@@ -69,7 +69,7 @@ void RasterDEMTile::onError(std::exception_ptr err, const uint64_t resultCorrela
|
||||
observer->onTileError(*this, err);
|
||||
}
|
||||
|
||||
void RasterDEMTile::upload(gl::Context& context) {
|
||||
void RasterDEMTile::upload(gfx::Context& context) {
|
||||
if (bucket) {
|
||||
bucket->upload(context);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
|
||||
void setData(std::shared_ptr<const std::string> data);
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
Bucket* getBucket(const style::Layer::Impl&) const override;
|
||||
|
||||
HillshadeBucket* getBucket() const;
|
||||
|
||||
@@ -58,7 +58,7 @@ void RasterTile::onError(std::exception_ptr err, const uint64_t resultCorrelatio
|
||||
observer->onTileError(*this, err);
|
||||
}
|
||||
|
||||
void RasterTile::upload(gl::Context& context) {
|
||||
void RasterTile::upload(gfx::Context& context) {
|
||||
if (bucket) {
|
||||
bucket->upload(context);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
void setMetadata(optional<Timestamp> modified, optional<Timestamp> expires);
|
||||
void setData(std::shared_ptr<const std::string> data);
|
||||
|
||||
void upload(gl::Context&) override;
|
||||
void upload(gfx::Context&) override;
|
||||
Bucket* getBucket(const style::Layer::Impl&) const override;
|
||||
|
||||
void setMask(TileMask&&) override;
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
// Mark this tile as no longer needed and cancel any pending work.
|
||||
virtual void cancel();
|
||||
|
||||
virtual void upload(gl::Context&) = 0;
|
||||
virtual void upload(gfx::Context&) = 0;
|
||||
virtual Bucket* getBucket(const style::Layer::Impl&) const = 0;
|
||||
|
||||
template <class T>
|
||||
|
||||
Reference in New Issue
Block a user