[core] move Texture to the gfx namespace

This commit is contained in:
Konstantin Käfer
2019-03-06 18:26:32 +01:00
parent 2a25270298
commit a7f151ab48
21 changed files with 182 additions and 137 deletions

View File

@@ -508,6 +508,7 @@
"mbgl/gfx/index_vector.hpp": "src/mbgl/gfx/index_vector.hpp",
"mbgl/gfx/primitives.hpp": "src/mbgl/gfx/primitives.hpp",
"mbgl/gfx/stencil_mode.hpp": "src/mbgl/gfx/stencil_mode.hpp",
"mbgl/gfx/texture.hpp": "src/mbgl/gfx/texture.hpp",
"mbgl/gfx/types.hpp": "src/mbgl/gfx/types.hpp",
"mbgl/gfx/uniform.hpp": "src/mbgl/gfx/uniform.hpp",
"mbgl/gfx/vertex_buffer.hpp": "src/mbgl/gfx/vertex_buffer.hpp",
@@ -527,7 +528,7 @@
"mbgl/gl/program_binary_extension.hpp": "src/mbgl/gl/program_binary_extension.hpp",
"mbgl/gl/renderbuffer.hpp": "src/mbgl/gl/renderbuffer.hpp",
"mbgl/gl/state.hpp": "src/mbgl/gl/state.hpp",
"mbgl/gl/texture.hpp": "src/mbgl/gl/texture.hpp",
"mbgl/gl/texture_resource.hpp": "src/mbgl/gl/texture_resource.hpp",
"mbgl/gl/types.hpp": "src/mbgl/gl/types.hpp",
"mbgl/gl/uniform.hpp": "src/mbgl/gl/uniform.hpp",
"mbgl/gl/value.hpp": "src/mbgl/gl/value.hpp",

View File

@@ -126,7 +126,7 @@ Size LineAtlas::getSize() const {
return image.size;
}
void LineAtlas::upload(gl::Context& context, gl::TextureUnit unit) {
void LineAtlas::upload(gl::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, gl::TextureUnit unit) {
dirty = false;
}
void LineAtlas::bind(gl::Context& context, gl::TextureUnit unit) {
void LineAtlas::bind(gl::Context& context, uint8_t unit) {
upload(context, unit);
context.bindTexture(*texture, unit, gfx::TextureFilterType::Linear, gfx::TextureMipMapType::No,
gfx::TextureWrapType::Repeat, gfx::TextureWrapType::Clamp);

View File

@@ -1,6 +1,6 @@
#pragma once
#include <mbgl/gl/texture.hpp>
#include <mbgl/gfx/texture.hpp>
#include <mbgl/gl/object.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/optional.hpp>
@@ -33,11 +33,11 @@ public:
~LineAtlas();
// Binds the atlas texture to the GPU, and uploads data if it is out of date.
void bind(gl::Context&, gl::TextureUnit unit);
void bind(gl::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&, gl::TextureUnit unit);
void upload(gl::Context&, uint8_t unit);
LinePatternPos getDashPosition(const std::vector<float>&, LinePatternCap);
LinePatternPos addDash(const std::vector<float>& dasharray, LinePatternCap);
@@ -47,7 +47,7 @@ public:
private:
const AlphaImage image;
bool dirty;
mbgl::optional<gl::Texture> texture;
mbgl::optional<gfx::Texture> texture;
uint32_t nextRow = 0;
std::unordered_map<size_t, LinePatternPos> positions;
};

View File

@@ -4,6 +4,7 @@
#include <mbgl/gfx/vertex_buffer.hpp>
#include <mbgl/gfx/index_vector.hpp>
#include <mbgl/gfx/index_buffer.hpp>
#include <mbgl/gfx/texture.hpp>
#include <mbgl/gfx/types.hpp>
namespace mbgl {
@@ -56,6 +57,48 @@ protected:
createIndexBufferResource(const void* data, std::size_t size, const BufferUsageType) = 0;
virtual void
updateIndexBufferResource(const IndexBufferResource&, const void* data, std::size_t size) = 0;
public:
// Create a texture from an image with data.
template <typename Image>
Texture createTexture(const Image& image,
uint8_t unit = 0,
TextureChannelDataType type = TextureChannelDataType::UnsignedByte) {
auto format = image.channels == 4 ? TexturePixelType::RGBA : TexturePixelType::Alpha;
return { image.size,
createTextureResource(image.size, image.data.get(), format, unit, type) };
}
// Creates an empty texture with the specified dimensions.
Texture createTexture(const Size size,
TexturePixelType format = TexturePixelType::RGBA,
uint8_t unit = 0,
TextureChannelDataType type = TextureChannelDataType::UnsignedByte) {
return { size, createTextureResource(size, nullptr, format, unit, type) };
}
template <typename Image>
void updateTexture(Texture& texture,
const Image& image,
uint8_t unit = 0,
TextureChannelDataType type = TextureChannelDataType::UnsignedByte) {
auto format = image.channels == 4 ? TexturePixelType::RGBA : TexturePixelType::Alpha;
updateTextureResource(*texture.resource, image.size, image.data.get(), format, unit, type);
texture.size = image.size;
}
virtual void bindTexture(Texture&,
uint8_t unit = 0,
TextureFilterType = TextureFilterType::Nearest,
TextureMipMapType = TextureMipMapType::No,
TextureWrapType wrapX = TextureWrapType::Clamp,
TextureWrapType wrapY = TextureWrapType::Clamp) = 0;
protected:
virtual std::unique_ptr<const TextureResource> createTextureResource(
Size, const void* data, TexturePixelType, uint8_t unit, TextureChannelDataType) = 0;
virtual void updateTextureResource(const TextureResource&, Size, const void* data,
TexturePixelType, uint8_t unit, TextureChannelDataType) = 0;
};
} // namespace gfx

33
src/mbgl/gfx/texture.hpp Normal file
View File

@@ -0,0 +1,33 @@
#pragma once
#include <mbgl/gfx/types.hpp>
#include <mbgl/util/size.hpp>
#include <memory>
namespace mbgl {
namespace gfx {
class TextureResource {
protected:
TextureResource() = default;
public:
virtual ~TextureResource() = default;
};
class Texture {
public:
Texture(Size size_, std::unique_ptr<const TextureResource>&& resource_)
: size(std::move(size_)), resource(std::move(resource_)) {
}
Size size;
TextureFilterType filter = TextureFilterType::Nearest;
TextureMipMapType mipmap = TextureMipMapType::No;
TextureWrapType wrapX = TextureWrapType::Clamp;
TextureWrapType wrapY = TextureWrapType::Clamp;
std::unique_ptr<const TextureResource> resource;
};
} // namespace gfx
} // namespace mbgl

View File

@@ -2,6 +2,7 @@
#include <mbgl/gl/enum.hpp>
#include <mbgl/gl/vertex_buffer_resource.hpp>
#include <mbgl/gl/index_buffer_resource.hpp>
#include <mbgl/gl/texture_resource.hpp>
#include <mbgl/gl/debugging_extension.hpp>
#include <mbgl/gl/vertex_array_extension.hpp>
#include <mbgl/gl/program_binary_extension.hpp>
@@ -266,7 +267,7 @@ void Context::updateIndexBufferResource(const gfx::IndexBufferResource& resource
}
UniqueTexture Context::createTexture() {
UniqueTexture Context::createUniqueTexture() {
if (pooledTextures.empty()) {
pooledTextures.resize(TextureMax);
MBGL_CHECK_ERROR(glGenTextures(TextureMax, pooledTextures.data()));
@@ -468,83 +469,91 @@ Framebuffer Context::createFramebuffer(const Renderbuffer<RenderbufferType::RGBA
}
Framebuffer
Context::createFramebuffer(const Texture& color,
Context::createFramebuffer(const gfx::Texture& color,
const Renderbuffer<RenderbufferType::DepthStencil>& depthStencil) {
if (color.size != depthStencil.size) {
throw std::runtime_error("Renderbuffer size mismatch");
}
auto fbo = createFramebuffer();
bindFramebuffer = fbo;
MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
color.texture, 0));
MBGL_CHECK_ERROR(glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
reinterpret_cast<const gl::TextureResource&>(*color.resource).texture, 0));
bindDepthStencilRenderbuffer(depthStencil);
checkFramebuffer();
return { color.size, std::move(fbo) };
}
Framebuffer Context::createFramebuffer(const Texture& color) {
Framebuffer Context::createFramebuffer(const gfx::Texture& color) {
auto fbo = createFramebuffer();
bindFramebuffer = fbo;
MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
color.texture, 0));
MBGL_CHECK_ERROR(glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
reinterpret_cast<const gl::TextureResource&>(*color.resource).texture, 0));
checkFramebuffer();
return { color.size, std::move(fbo) };
}
Framebuffer
Context::createFramebuffer(const Texture& color,
Context::createFramebuffer(const gfx::Texture& color,
const Renderbuffer<RenderbufferType::DepthComponent>& depthTarget) {
if (color.size != depthTarget.size) {
throw std::runtime_error("Renderbuffer size mismatch");
}
auto fbo = createFramebuffer();
bindFramebuffer = fbo;
MBGL_CHECK_ERROR(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color.texture, 0));
MBGL_CHECK_ERROR(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthTarget.renderbuffer));
MBGL_CHECK_ERROR(glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
reinterpret_cast<const gl::TextureResource&>(*color.resource).texture, 0));
MBGL_CHECK_ERROR(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
depthTarget.renderbuffer));
checkFramebuffer();
return { depthTarget.size, std::move(fbo) };
}
UniqueTexture Context::createTexture(const Size size,
const void* data,
gfx::TexturePixelType format,
TextureUnit unit,
gfx::TextureChannelDataType type) {
auto obj = createTexture();
std::unique_ptr<const gfx::TextureResource>
Context::createTextureResource(const Size size,
const void* data,
gfx::TexturePixelType format,
uint8_t unit,
gfx::TextureChannelDataType type) {
auto obj = createUniqueTexture();
std::unique_ptr<const gfx::TextureResource> resource = std::make_unique<gl::TextureResource>(std::move(obj));
pixelStoreUnpack = { 1 };
updateTexture(obj, size, data, format, unit, type);
updateTextureResource(*resource, size, data, format, unit, type);
// We are using clamp to edge here since OpenGL ES doesn't allow GL_REPEAT on NPOT textures.
// We use those when the pixelRatio isn't a power of two, e.g. on iPhone 6 Plus.
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
return obj;
return resource;
}
void Context::updateTexture(TextureID id,
const Size size,
const void* data,
gfx::TexturePixelType format,
TextureUnit unit,
gfx::TextureChannelDataType type) {
void Context::updateTextureResource(const gfx::TextureResource& resource,
const Size size,
const void* data,
gfx::TexturePixelType format,
uint8_t unit,
gfx::TextureChannelDataType type) {
activeTextureUnit = unit;
texture[unit] = id;
texture[unit] = reinterpret_cast<const gl::TextureResource&>(resource).texture;
MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, Enum<gfx::TexturePixelType>::to(format),
size.width, size.height, 0,
Enum<gfx::TexturePixelType>::to(format),
Enum<gfx::TextureChannelDataType>::to(type), data));
}
void Context::bindTexture(Texture& obj,
TextureUnit unit,
void Context::bindTexture(gfx::Texture& obj,
uint8_t unit,
gfx::TextureFilterType filter,
gfx::TextureMipMapType mipmap,
gfx::TextureWrapType wrapX,
gfx::TextureWrapType wrapY) {
TextureID id = reinterpret_cast<const gl::TextureResource&>(*obj.resource).texture;
if (filter != obj.filter || mipmap != obj.mipmap || wrapX != obj.wrapX || wrapY != obj.wrapY) {
activeTextureUnit = unit;
texture[unit] = obj.texture;
texture[unit] = id;
if (filter != obj.filter || mipmap != obj.mipmap) {
MBGL_CHECK_ERROR(glTexParameteri(
@@ -571,11 +580,11 @@ void Context::bindTexture(Texture& obj,
wrapY == gfx::TextureWrapType::Clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT));
obj.wrapY = wrapY;
}
} else if (texture[unit] != obj.texture) {
} else if (texture[unit] != id) {
// We are checking first to avoid setting the active texture without a subsequent
// texture bind.
activeTextureUnit = unit;
texture[unit] = obj.texture;
texture[unit] = id;
}
}

View File

@@ -5,7 +5,6 @@
#include <mbgl/gl/object.hpp>
#include <mbgl/gl/state.hpp>
#include <mbgl/gl/value.hpp>
#include <mbgl/gl/texture.hpp>
#include <mbgl/gl/renderbuffer.hpp>
#include <mbgl/gl/framebuffer.hpp>
#include <mbgl/gl/vertex_array.hpp>
@@ -52,7 +51,7 @@ public:
UniqueProgram createProgram(BinaryProgramFormat binaryFormat, const std::string& binaryProgram);
void verifyProgramLinkage(ProgramID);
void linkProgram(ProgramID);
UniqueTexture createTexture();
UniqueTexture createUniqueTexture();
VertexArray createVertexArray();
#if MBGL_HAS_BINARY_PROGRAMS
@@ -74,10 +73,10 @@ public:
Framebuffer createFramebuffer(const Renderbuffer<RenderbufferType::RGBA>&,
const Renderbuffer<RenderbufferType::DepthStencil>&);
Framebuffer createFramebuffer(const Renderbuffer<RenderbufferType::RGBA>&);
Framebuffer createFramebuffer(const Texture&,
Framebuffer createFramebuffer(const gfx::Texture&,
const Renderbuffer<RenderbufferType::DepthStencil>&);
Framebuffer createFramebuffer(const Texture&);
Framebuffer createFramebuffer(const Texture&,
Framebuffer createFramebuffer(const gfx::Texture&);
Framebuffer createFramebuffer(const gfx::Texture&,
const Renderbuffer<RenderbufferType::DepthComponent>&);
template <typename Image,
@@ -89,6 +88,13 @@ public:
return { size, readFramebuffer(size, format, flip) };
}
void bindTexture(gfx::Texture&,
uint8_t unit = 0,
gfx::TextureFilterType = gfx::TextureFilterType::Nearest,
gfx::TextureMipMapType = gfx::TextureMipMapType::No,
gfx::TextureWrapType wrapX = gfx::TextureWrapType::Clamp,
gfx::TextureWrapType wrapY = gfx::TextureWrapType::Clamp) override;
#if not MBGL_USE_GLES2
template <typename Image>
void drawPixels(const Image& image) {
@@ -97,40 +103,6 @@ public:
}
#endif // MBGL_USE_GLES2
// Create a texture from an image with data.
template <typename Image>
Texture createTexture(const Image& image,
TextureUnit unit = 0,
gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte) {
auto format = image.channels == 4 ? gfx::TexturePixelType::RGBA : gfx::TexturePixelType::Alpha;
return { image.size, createTexture(image.size, image.data.get(), format, unit, type) };
}
template <typename Image>
void updateTexture(Texture& obj,
const Image& image,
TextureUnit unit = 0,
gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte) {
auto format = image.channels == 4 ? gfx::TexturePixelType::RGBA : gfx::TexturePixelType::Alpha;
updateTexture(obj.texture.get(), image.size, image.data.get(), format, unit, type);
obj.size = image.size;
}
// Creates an empty texture with the specified dimensions.
Texture createTexture(const Size size,
gfx::TexturePixelType format = gfx::TexturePixelType::RGBA,
TextureUnit unit = 0,
gfx::TextureChannelDataType type = gfx::TextureChannelDataType::UnsignedByte) {
return { size, createTexture(size, nullptr, format, unit, type) };
}
void bindTexture(Texture&,
TextureUnit = 0,
gfx::TextureFilterType = gfx::TextureFilterType::Nearest,
gfx::TextureMipMapType = gfx::TextureMipMapType::No,
gfx::TextureWrapType wrapX = gfx::TextureWrapType::Clamp,
gfx::TextureWrapType wrapY = gfx::TextureWrapType::Clamp);
void clear(optional<mbgl::Color> color,
optional<float> depth,
optional<int32_t> stencil);
@@ -248,8 +220,9 @@ private:
std::unique_ptr<const gfx::IndexBufferResource> createIndexBufferResource(const void* data, std::size_t size, const gfx::BufferUsageType) override;
void updateIndexBufferResource(const gfx::IndexBufferResource&, const void* data, std::size_t size) override;
UniqueTexture createTexture(Size size, const void* data, gfx::TexturePixelType, TextureUnit, gfx::TextureChannelDataType);
void updateTexture(TextureID, Size size, const void* data, gfx::TexturePixelType, TextureUnit, gfx::TextureChannelDataType);
std::unique_ptr<const gfx::TextureResource> createTextureResource(Size, const void* data, gfx::TexturePixelType, uint8_t, gfx::TextureChannelDataType) override;
void updateTextureResource(const gfx::TextureResource&, Size, const void* data, gfx::TexturePixelType, uint8_t, gfx::TextureChannelDataType) override;
UniqueFramebuffer createFramebuffer();
UniqueRenderbuffer createRenderbuffer(RenderbufferType, Size size);
std::unique_ptr<uint8_t[]> readFramebuffer(Size, gfx::TexturePixelType, bool flip);

View File

@@ -1,33 +0,0 @@
#pragma once
#include <mbgl/gfx/types.hpp>
#include <mbgl/gl/object.hpp>
#include <mbgl/util/size.hpp>
namespace mbgl {
namespace gl {
class Texture {
public:
Texture(Size size_, UniqueTexture texture_,
gfx::TextureFilterType filter_ = gfx::TextureFilterType::Nearest,
gfx::TextureMipMapType mipmap_ = gfx::TextureMipMapType::No,
gfx::TextureWrapType wrapX_ = gfx::TextureWrapType::Clamp,
gfx::TextureWrapType wrapY_ = gfx::TextureWrapType::Clamp)
: size(std::move(size_)),
texture(std::move(texture_)),
filter(filter_),
mipmap(mipmap_),
wrapX(wrapX_),
wrapY(wrapY_) {}
Size size;
UniqueTexture texture;
gfx::TextureFilterType filter;
gfx::TextureMipMapType mipmap;
gfx::TextureWrapType wrapX;
gfx::TextureWrapType wrapY;
};
} // namespace gl
} // namespace mbgl

View File

@@ -0,0 +1,18 @@
#pragma once
#include <mbgl/gfx/texture.hpp>
#include <mbgl/gl/object.hpp>
namespace mbgl {
namespace gl {
class TextureResource : public gfx::TextureResource {
public:
TextureResource(UniqueTexture&& texture_) : texture(std::move(texture_)) {
}
UniqueTexture texture;
};
} // namespace gl
} // namespace mbgl

View File

@@ -25,8 +25,6 @@ using AttributeLocation = uint32_t;
// "silently ignored".
using UniformLocation = int32_t;
using TextureUnit = uint8_t;
enum class ShaderType : uint32_t {
Vertex = 0x8B31,
Fragment = 0x8B30

View File

@@ -168,7 +168,7 @@ struct LineWidth {
};
struct ActiveTextureUnit {
using Type = TextureUnit;
using Type = uint8_t;
static const constexpr Type Default = 0;
static void Set(const Type&);
static Type Get();

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/gfx/index_buffer.hpp>
#include <mbgl/gl/texture.hpp>
#include <mbgl/gfx/texture.hpp>
#include <mbgl/gfx/vertex_buffer.hpp>
#include <mbgl/programs/hillshade_program.hpp>
#include <mbgl/programs/hillshade_prepare_program.hpp>
@@ -29,8 +29,8 @@ public:
void clear();
void setMask(TileMask&&);
optional<gl::Texture> dem;
optional<gl::Texture> texture;
optional<gfx::Texture> dem;
optional<gfx::Texture> texture;
TileMask mask{ { 0, 0, 0 } };

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/gfx/index_buffer.hpp>
#include <mbgl/gl/texture.hpp>
#include <mbgl/gfx/texture.hpp>
#include <mbgl/gfx/vertex_buffer.hpp>
#include <mbgl/programs/raster_program.hpp>
#include <mbgl/renderer/bucket.hpp>
@@ -27,7 +27,7 @@ public:
void setMask(TileMask&&);
std::shared_ptr<PremultipliedImage> image;
optional<gl::Texture> texture;
optional<gfx::Texture> texture;
TileMask mask{ { 0, 0, 0 } };
// Bucket specific vertices are used for Image Sources only

View File

@@ -167,7 +167,7 @@ Size ImageManager::getPixelSize() const {
};
}
void ImageManager::upload(gl::Context& context, gl::TextureUnit unit) {
void ImageManager::upload(gl::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, gl::TextureUnit unit) {
dirty = false;
}
void ImageManager::bind(gl::Context& context, gl::TextureUnit unit) {
void ImageManager::bind(gl::Context& context, uint8_t unit) {
upload(context, unit);
context.bindTexture(*atlasTexture, unit, gfx::TextureFilterType::Linear);
}

View File

@@ -5,7 +5,7 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/immutable.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/gl/texture.hpp>
#include <mbgl/gfx/texture.hpp>
#include <mapbox/shelf-pack.hpp>
@@ -65,8 +65,8 @@ private:
public:
optional<ImagePosition> getPattern(const std::string& name);
void bind(gl::Context&, gl::TextureUnit unit);
void upload(gl::Context&, gl::TextureUnit unit);
void bind(gl::Context&, uint8_t unit);
void upload(gl::Context&, uint8_t unit);
Size getPixelSize() const;
@@ -84,7 +84,7 @@ private:
mapbox::ShelfPack shelfPack;
std::unordered_map<std::string, Pattern> patterns;
PremultipliedImage atlasImage;
mbgl::optional<gl::Texture> atlasTexture;
mbgl::optional<gfx::Texture> atlasTexture;
bool dirty = true;
};

View File

@@ -3,7 +3,7 @@
#include <mbgl/renderer/render_layer.hpp>
#include <mbgl/style/layers/heatmap_layer_impl.hpp>
#include <mbgl/style/layers/heatmap_layer_properties.hpp>
#include <mbgl/gl/texture.hpp>
#include <mbgl/gfx/texture.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/util/offscreen_texture.hpp>
@@ -37,7 +37,7 @@ public:
PremultipliedImage colorRamp;
optional<OffscreenTexture> renderTexture;
optional<gl::Texture> colorRampTexture;
optional<gfx::Texture> colorRampTexture;
private:
void updateColorRamp();

View File

@@ -6,7 +6,7 @@
#include <mbgl/programs/uniforms.hpp>
#include <mbgl/style/image_impl.hpp>
#include <mbgl/layout/pattern_layout.hpp>
#include <mbgl/gl/texture.hpp>
#include <mbgl/gfx/texture.hpp>
namespace mbgl {
@@ -53,7 +53,7 @@ private:
void updateColorRamp();
CrossfadeParameters crossfade;
PremultipliedImage colorRamp;
optional<gl::Texture> colorRampTexture;
optional<gfx::Texture> colorRampTexture;
};
inline const RenderLineLayer* toRenderLineLayer(const RenderLayer* layer) {

View File

@@ -132,8 +132,8 @@ private:
FadeState fadeState = FadeState::Loaded;
public:
optional<gl::Texture> glyphAtlasTexture;
optional<gl::Texture> iconAtlasTexture;
optional<gfx::Texture> glyphAtlasTexture;
optional<gfx::Texture> iconAtlasTexture;
};
} // namespace mbgl

View File

@@ -44,7 +44,7 @@ public:
return context.readFramebuffer<PremultipliedImage>(size);
}
gl::Texture& getTexture() {
gfx::Texture& getTexture() {
assert(texture);
return *texture;
}
@@ -57,7 +57,7 @@ private:
gl::Context& context;
const Size size;
optional<gl::Framebuffer> framebuffer;
optional<gl::Texture> texture;
optional<gfx::Texture> texture;
gl::Renderbuffer<gl::RenderbufferType::DepthComponent>* depth = nullptr;
const gfx::TextureChannelDataType type;
};
@@ -87,7 +87,7 @@ PremultipliedImage OffscreenTexture::readStillImage() {
return impl->readStillImage();
}
gl::Texture& OffscreenTexture::getTexture() {
gfx::Texture& OffscreenTexture::getTexture() {
return impl->getTexture();
}

View File

@@ -8,9 +8,12 @@ namespace mbgl {
namespace gl {
class Context;
class Texture;
} // namespace gl
namespace gfx {
class Texture;
} // namespace gfx
class OffscreenTexture {
public:
OffscreenTexture(gl::Context&,
@@ -28,7 +31,7 @@ public:
PremultipliedImage readStillImage();
gl::Texture& getTexture();
gfx::Texture& getTexture();
const Size& getSize() const;

View File

@@ -51,7 +51,7 @@ TEST(GLObject, Store) {
gl::Context context;
EXPECT_TRUE(context.empty());
gl::UniqueTexture texture = context.createTexture();
gl::UniqueTexture texture = context.createUniqueTexture();
EXPECT_NE(texture.get(), 0u);
texture.reset();
EXPECT_FALSE(context.empty());