Eliminate some unnecessary pointer indirection

Buckets had a pointer to the associated layout type, when they can just
have a direct member.
This commit is contained in:
John Firebaugh
2015-03-31 14:34:31 -07:00
parent 1cf4799ea1
commit 3d9b441c8b
10 changed files with 76 additions and 107 deletions

View File

@@ -28,12 +28,10 @@ void FillBucket::free(void *, void *ptr) {
::free(ptr);
}
FillBucket::FillBucket(std::unique_ptr<const StyleLayoutFill> styleLayout_,
FillVertexBuffer &vertexBuffer_,
FillBucket::FillBucket(FillVertexBuffer &vertexBuffer_,
TriangleElementsBuffer &triangleElementsBuffer_,
LineElementsBuffer &lineElementsBuffer_)
: styleLayout(std::move(styleLayout_)),
allocator(new TESSalloc{
: allocator(new TESSalloc{
&alloc,
&realloc,
&free,
@@ -53,7 +51,6 @@ FillBucket::FillBucket(std::unique_ptr<const StyleLayoutFill> styleLayout_,
triangle_elements_start(triangleElementsBuffer_.index()),
line_elements_start(lineElementsBuffer.index()) {
assert(tesselator);
assert(styleLayout);
}
FillBucket::~FillBucket() {

View File

@@ -6,6 +6,7 @@
#include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/geometry/fill_buffer.hpp>
#include <mbgl/style/style_bucket.hpp>
#include <mbgl/style/style_layout.hpp>
#include <clipper/clipper.hpp>
#include <libtess2/tesselator.h>
@@ -39,8 +40,7 @@ class FillBucket : public Bucket {
typedef ElementGroup<1> line_group_type;
public:
FillBucket(std::unique_ptr<const StyleLayoutFill> styleLayout,
FillVertexBuffer &vertexBuffer,
FillBucket(FillVertexBuffer &vertexBuffer,
TriangleElementsBuffer &triangleElementsBuffer,
LineElementsBuffer &lineElementsBuffer);
~FillBucket() override;
@@ -57,7 +57,7 @@ public:
void drawVertices(OutlineShader& shader);
public:
const std::unique_ptr<const StyleLayoutFill> styleLayout;
StyleLayoutFill layout;
private:
TESSalloc *allocator;

View File

@@ -14,18 +14,15 @@
using namespace mbgl;
LineBucket::LineBucket(std::unique_ptr<const StyleLayoutLine> styleLayout_,
LineVertexBuffer &vertexBuffer_,
LineBucket::LineBucket(LineVertexBuffer &vertexBuffer_,
TriangleElementsBuffer &triangleElementsBuffer_,
PointElementsBuffer &pointElementsBuffer_)
: styleLayout(std::move(styleLayout_)),
vertexBuffer(vertexBuffer_),
: vertexBuffer(vertexBuffer_),
triangleElementsBuffer(triangleElementsBuffer_),
pointElementsBuffer(pointElementsBuffer_),
vertex_start(vertexBuffer_.index()),
triangle_elements_start(triangleElementsBuffer_.index()),
point_elements_start(pointElementsBuffer_.index()) {
assert(styleLayout);
}
LineBucket::~LineBucket() {
@@ -46,7 +43,6 @@ void LineBucket::addGeometry(const GeometryCollection& geometryCollection) {
}
void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
auto &layout = *styleLayout;
// TODO: use roundLimit
// const float roundLimit = geometry.round_limit;

View File

@@ -7,6 +7,7 @@
#include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/geometry/line_buffer.hpp>
#include <mbgl/style/style_bucket.hpp>
#include <mbgl/style/style_layout.hpp>
#include <mbgl/util/vec.hpp>
#include <vector>
@@ -14,7 +15,6 @@
namespace mbgl {
class Style;
class StyleLayoutLine;
class LineVertexBuffer;
class TriangleElementsBuffer;
class LineShader;
@@ -27,8 +27,7 @@ class LineBucket : public Bucket {
typedef ElementGroup<1> point_group_type;
public:
LineBucket(std::unique_ptr<const StyleLayoutLine> styleLayout,
LineVertexBuffer &vertexBuffer,
LineBucket(LineVertexBuffer &vertexBuffer,
TriangleElementsBuffer &triangleElementsBuffer,
PointElementsBuffer &pointElementsBuffer);
~LineBucket() override;
@@ -48,7 +47,7 @@ public:
void drawPoints(LinejoinShader& shader);
public:
const std::unique_ptr<const StyleLayoutLine> styleLayout;
StyleLayoutLine layout;
private:
LineVertexBuffer& vertexBuffer;

View File

@@ -18,7 +18,7 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const
depthMask(false);
const auto &properties = layer_desc.getProperties<LineProperties>();
const auto &layout = *bucket.styleLayout;
const auto &layout = bucket.layout;
// the distance over which the line edge fades out.
// Retina devices need a smaller distance to avoid aliasing.

View File

@@ -119,7 +119,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, const StyleLayer &layer_desc, c
}
const auto &properties = layer_desc.getProperties<SymbolProperties>();
const auto &layout = *bucket.styleLayout;
const auto &layout = bucket.layout;
MBGL_CHECK_ERROR(glDisable(GL_STENCIL_TEST));
depthMask(false);

View File

@@ -22,9 +22,8 @@
namespace mbgl {
SymbolBucket::SymbolBucket(std::unique_ptr<const StyleLayoutSymbol> styleLayout_, Collision &collision_)
: styleLayout(std::move(styleLayout_)), collision(collision_) {
assert(styleLayout);
SymbolBucket::SymbolBucket(Collision &collision_)
: collision(collision_) {
}
SymbolBucket::~SymbolBucket() {
@@ -46,7 +45,6 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const GeometryTileLayer
const FilterExpression& filter,
GlyphStore &glyphStore,
const Sprite &sprite) {
auto &layout = *styleLayout;
const bool has_text = layout.text.field.size();
const bool has_icon = layout.icon.image.size();
@@ -129,7 +127,6 @@ void SymbolBucket::addFeatures(const GeometryTileLayer& layer,
Sprite& sprite,
GlyphAtlas& glyphAtlas,
GlyphStore& glyphStore) {
auto &layout = *styleLayout;
const std::vector<SymbolFeature> features = processFeatures(layer, filter, glyphStore, sprite);
float horizontalAlign = 0.5;
@@ -228,7 +225,6 @@ const PlacementRange fullRange{{2 * M_PI, 0}};
void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping &shaping,
const GlyphPositions &face, const Rect<uint16_t> &image) {
assert(line.size());
auto &layout = *styleLayout;
const float minScale = 0.5f;
const float glyphSize = 24.0f;

View File

@@ -10,7 +10,7 @@
#include <mbgl/text/types.hpp>
#include <mbgl/text/glyph.hpp>
#include <mbgl/style/style_bucket.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/style/style_layout.hpp>
#include <memory>
#include <map>
@@ -56,7 +56,7 @@ class SymbolBucket : public Bucket {
typedef ElementGroup<2> IconElementGroup;
public:
SymbolBucket(std::unique_ptr<const StyleLayoutSymbol> styleLayout, Collision &collision);
SymbolBucket(Collision &collision);
~SymbolBucket() override;
void render(Painter &painter, const StyleLayer &layer_desc, const Tile::ID &id,
@@ -90,7 +90,7 @@ private:
void addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float scale, PlacementRange placementRange);
public:
const std::unique_ptr<const StyleLayoutSymbol> styleLayout;
StyleLayoutSymbol layout;
bool sdfIcons = false;
private: