Clean up placefile shared pointer usage with const references

This commit is contained in:
Dan Paulat 2023-08-22 21:52:11 -05:00
parent 232fafc9fa
commit 9955c4ccbe
12 changed files with 33 additions and 31 deletions

View file

@ -54,7 +54,7 @@ struct PlacefileIconInfo
class PlacefileIcons::Impl
{
public:
explicit Impl(std::shared_ptr<GlContext> context) :
explicit Impl(const std::shared_ptr<GlContext>& context) :
context_ {context},
shaderProgram_ {nullptr},
uMVPMatrixLocation_(GL_INVALID_INDEX),
@ -69,6 +69,9 @@ public:
~Impl() {}
void UpdateBuffers();
void Update(bool textureAtlasChanged);
std::shared_ptr<GlContext> context_;
bool dirty_ {false};
@ -98,12 +101,9 @@ public:
std::array<GLuint, 2> vbo_;
GLsizei numVertices_;
void UpdateBuffers();
void Update(bool textureAtlasChanged);
};
PlacefileIcons::PlacefileIcons(std::shared_ptr<GlContext> context) :
PlacefileIcons::PlacefileIcons(const std::shared_ptr<GlContext>& context) :
DrawItem(context->gl()), p(std::make_unique<Impl>(context))
{
}

View file

@ -18,7 +18,7 @@ namespace draw
class PlacefileIcons : public DrawItem
{
public:
explicit PlacefileIcons(std::shared_ptr<GlContext> context);
explicit PlacefileIcons(const std::shared_ptr<GlContext>& context);
~PlacefileIcons();
PlacefileIcons(const PlacefileIcons&) = delete;

View file

@ -28,7 +28,7 @@ static const boost::gil::rgba8_pixel_t kBlack_ {0, 0, 0, 255};
class PlacefileLines::Impl
{
public:
explicit Impl(std::shared_ptr<GlContext> context) :
explicit Impl(const std::shared_ptr<GlContext>& context) :
context_ {context},
shaderProgram_ {nullptr},
uMVPMatrixLocation_(GL_INVALID_INDEX),
@ -49,7 +49,8 @@ public:
const float angle,
const boost::gil::rgba8_pixel_t color,
const GLint threshold);
void UpdateBuffers(std::shared_ptr<const gr::Placefile::LineDrawItem>);
void
UpdateBuffers(const std::shared_ptr<const gr::Placefile::LineDrawItem>& di);
void Update();
std::shared_ptr<GlContext> context_;
@ -79,7 +80,7 @@ public:
GLsizei numVertices_;
};
PlacefileLines::PlacefileLines(std::shared_ptr<GlContext> context) :
PlacefileLines::PlacefileLines(const std::shared_ptr<GlContext>& context) :
DrawItem(context->gl()), p(std::make_unique<Impl>(context))
{
}
@ -255,7 +256,7 @@ void PlacefileLines::FinishLines()
}
void PlacefileLines::Impl::UpdateBuffers(
std::shared_ptr<const gr::Placefile::LineDrawItem> di)
const std::shared_ptr<const gr::Placefile::LineDrawItem>& di)
{
// Threshold value
units::length::nautical_miles<double> threshold = di->threshold_;

View file

@ -16,7 +16,7 @@ namespace draw
class PlacefileLines : public DrawItem
{
public:
explicit PlacefileLines(std::shared_ptr<GlContext> context);
explicit PlacefileLines(const std::shared_ptr<GlContext>& context);
~PlacefileLines();
PlacefileLines(const PlacefileLines&) = delete;

View file

@ -42,7 +42,7 @@ typedef std::array<GLdouble, kTessVertexSize_> TessVertexArray;
class PlacefilePolygons::Impl
{
public:
explicit Impl(std::shared_ptr<GlContext> context) :
explicit Impl(const std::shared_ptr<GlContext>& context) :
context_ {context},
shaderProgram_ {nullptr},
uMVPMatrixLocation_(GL_INVALID_INDEX),
@ -115,7 +115,8 @@ public:
GLint currentThreshold_;
};
PlacefilePolygons::PlacefilePolygons(std::shared_ptr<GlContext> context) :
PlacefilePolygons::PlacefilePolygons(
const std::shared_ptr<GlContext>& context) :
DrawItem(context->gl()), p(std::make_unique<Impl>(context))
{
}

View file

@ -18,7 +18,7 @@ namespace draw
class PlacefilePolygons : public DrawItem
{
public:
explicit PlacefilePolygons(std::shared_ptr<GlContext> context);
explicit PlacefilePolygons(const std::shared_ptr<GlContext>& context);
~PlacefilePolygons();
PlacefilePolygons(const PlacefilePolygons&) = delete;

View file

@ -23,8 +23,8 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class PlacefileText::Impl
{
public:
explicit Impl(std::shared_ptr<GlContext> context,
const std::string& placefileName) :
explicit Impl(const std::shared_ptr<GlContext>& context,
const std::string& placefileName) :
context_ {context}, placefileName_ {placefileName}
{
}
@ -63,8 +63,8 @@ public:
std::vector<std::shared_ptr<const gr::Placefile::TextDrawItem>> newList_ {};
};
PlacefileText::PlacefileText(std::shared_ptr<GlContext> context,
const std::string& placefileName) :
PlacefileText::PlacefileText(const std::shared_ptr<GlContext>& context,
const std::string& placefileName) :
DrawItem(context->gl()), p(std::make_unique<Impl>(context, placefileName))
{
}

View file

@ -16,8 +16,8 @@ namespace draw
class PlacefileText : public DrawItem
{
public:
explicit PlacefileText(std::shared_ptr<GlContext> context,
const std::string& placefileName);
explicit PlacefileText(const std::shared_ptr<GlContext>& context,
const std::string& placefileName);
~PlacefileText();
PlacefileText(const PlacefileText&) = delete;