From 9955c4ccbe27d19b5d212f7c96841991343a1060 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 22 Aug 2023 21:52:11 -0500 Subject: [PATCH] Clean up placefile shared pointer usage with const references --- scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp | 10 +++++----- scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp | 2 +- scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp | 9 +++++---- scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp | 2 +- scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp | 5 +++-- scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp | 2 +- scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp | 8 ++++---- scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp | 4 ++-- scwx-qt/source/scwx/qt/map/draw_layer.cpp | 4 ++-- scwx-qt/source/scwx/qt/map/draw_layer.hpp | 4 ++-- scwx-qt/source/scwx/qt/map/placefile_layer.cpp | 10 +++++----- scwx-qt/source/scwx/qt/map/placefile_layer.hpp | 4 ++-- 12 files changed, 33 insertions(+), 31 deletions(-) diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp index 722d5fb9..e03cc887 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp @@ -54,7 +54,7 @@ struct PlacefileIconInfo class PlacefileIcons::Impl { public: - explicit Impl(std::shared_ptr context) : + explicit Impl(const std::shared_ptr& context) : context_ {context}, shaderProgram_ {nullptr}, uMVPMatrixLocation_(GL_INVALID_INDEX), @@ -69,6 +69,9 @@ public: ~Impl() {} + void UpdateBuffers(); + void Update(bool textureAtlasChanged); + std::shared_ptr context_; bool dirty_ {false}; @@ -98,12 +101,9 @@ public: std::array vbo_; GLsizei numVertices_; - - void UpdateBuffers(); - void Update(bool textureAtlasChanged); }; -PlacefileIcons::PlacefileIcons(std::shared_ptr context) : +PlacefileIcons::PlacefileIcons(const std::shared_ptr& context) : DrawItem(context->gl()), p(std::make_unique(context)) { } diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp index 08069ac5..418d774d 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_icons.hpp @@ -18,7 +18,7 @@ namespace draw class PlacefileIcons : public DrawItem { public: - explicit PlacefileIcons(std::shared_ptr context); + explicit PlacefileIcons(const std::shared_ptr& context); ~PlacefileIcons(); PlacefileIcons(const PlacefileIcons&) = delete; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp index aa2a7da2..6112d078 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.cpp @@ -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 context) : + explicit Impl(const std::shared_ptr& 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); + void + UpdateBuffers(const std::shared_ptr& di); void Update(); std::shared_ptr context_; @@ -79,7 +80,7 @@ public: GLsizei numVertices_; }; -PlacefileLines::PlacefileLines(std::shared_ptr context) : +PlacefileLines::PlacefileLines(const std::shared_ptr& context) : DrawItem(context->gl()), p(std::make_unique(context)) { } @@ -255,7 +256,7 @@ void PlacefileLines::FinishLines() } void PlacefileLines::Impl::UpdateBuffers( - std::shared_ptr di) + const std::shared_ptr& di) { // Threshold value units::length::nautical_miles threshold = di->threshold_; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp index 17461d49..4dbf518d 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_lines.hpp @@ -16,7 +16,7 @@ namespace draw class PlacefileLines : public DrawItem { public: - explicit PlacefileLines(std::shared_ptr context); + explicit PlacefileLines(const std::shared_ptr& context); ~PlacefileLines(); PlacefileLines(const PlacefileLines&) = delete; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp index 87077690..db1851ac 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.cpp @@ -42,7 +42,7 @@ typedef std::array TessVertexArray; class PlacefilePolygons::Impl { public: - explicit Impl(std::shared_ptr context) : + explicit Impl(const std::shared_ptr& context) : context_ {context}, shaderProgram_ {nullptr}, uMVPMatrixLocation_(GL_INVALID_INDEX), @@ -115,7 +115,8 @@ public: GLint currentThreshold_; }; -PlacefilePolygons::PlacefilePolygons(std::shared_ptr context) : +PlacefilePolygons::PlacefilePolygons( + const std::shared_ptr& context) : DrawItem(context->gl()), p(std::make_unique(context)) { } diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp index 451e007f..75c21793 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_polygons.hpp @@ -18,7 +18,7 @@ namespace draw class PlacefilePolygons : public DrawItem { public: - explicit PlacefilePolygons(std::shared_ptr context); + explicit PlacefilePolygons(const std::shared_ptr& context); ~PlacefilePolygons(); PlacefilePolygons(const PlacefilePolygons&) = delete; diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp index d2bfa0f1..082ee88e 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_text.cpp @@ -23,8 +23,8 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class PlacefileText::Impl { public: - explicit Impl(std::shared_ptr context, - const std::string& placefileName) : + explicit Impl(const std::shared_ptr& context, + const std::string& placefileName) : context_ {context}, placefileName_ {placefileName} { } @@ -63,8 +63,8 @@ public: std::vector> newList_ {}; }; -PlacefileText::PlacefileText(std::shared_ptr context, - const std::string& placefileName) : +PlacefileText::PlacefileText(const std::shared_ptr& context, + const std::string& placefileName) : DrawItem(context->gl()), p(std::make_unique(context, placefileName)) { } diff --git a/scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp b/scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp index 363164c7..58e22929 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/placefile_text.hpp @@ -16,8 +16,8 @@ namespace draw class PlacefileText : public DrawItem { public: - explicit PlacefileText(std::shared_ptr context, - const std::string& placefileName); + explicit PlacefileText(const std::shared_ptr& context, + const std::string& placefileName); ~PlacefileText(); PlacefileText(const PlacefileText&) = delete; diff --git a/scwx-qt/source/scwx/qt/map/draw_layer.cpp b/scwx-qt/source/scwx/qt/map/draw_layer.cpp index 097f7a40..d6bafa4d 100644 --- a/scwx-qt/source/scwx/qt/map/draw_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/draw_layer.cpp @@ -28,7 +28,7 @@ public: std::uint64_t textureAtlasBuildCount_ {}; }; -DrawLayer::DrawLayer(std::shared_ptr context) : +DrawLayer::DrawLayer(const std::shared_ptr& context) : GenericLayer(context), p(std::make_unique(context)) { } @@ -76,7 +76,7 @@ void DrawLayer::Deinitialize() } } -void DrawLayer::AddDrawItem(std::shared_ptr drawItem) +void DrawLayer::AddDrawItem(const std::shared_ptr& drawItem) { p->drawList_.push_back(drawItem); } diff --git a/scwx-qt/source/scwx/qt/map/draw_layer.hpp b/scwx-qt/source/scwx/qt/map/draw_layer.hpp index e2835f02..0ac3e03f 100644 --- a/scwx-qt/source/scwx/qt/map/draw_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/draw_layer.hpp @@ -15,7 +15,7 @@ class DrawLayerImpl; class DrawLayer : public GenericLayer { public: - explicit DrawLayer(std::shared_ptr context); + explicit DrawLayer(const std::shared_ptr& context); virtual ~DrawLayer(); virtual void Initialize(); @@ -23,7 +23,7 @@ public: virtual void Deinitialize(); protected: - void AddDrawItem(std::shared_ptr drawItem); + void AddDrawItem(const std::shared_ptr& drawItem); private: std::unique_ptr p; diff --git a/scwx-qt/source/scwx/qt/map/placefile_layer.cpp b/scwx-qt/source/scwx/qt/map/placefile_layer.cpp index b6ec78d4..2c1b66ab 100644 --- a/scwx-qt/source/scwx/qt/map/placefile_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/placefile_layer.cpp @@ -22,9 +22,9 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class PlacefileLayer::Impl { public: - explicit Impl(PlacefileLayer* self, - std::shared_ptr context, - const std::string& placefileName) : + explicit Impl(PlacefileLayer* self, + const std::shared_ptr& context, + const std::string& placefileName) : self_ {self}, placefileName_ {placefileName}, placefileIcons_ {std::make_shared(context)}, @@ -53,8 +53,8 @@ public: std::shared_ptr placefileText_; }; -PlacefileLayer::PlacefileLayer(std::shared_ptr context, - const std::string& placefileName) : +PlacefileLayer::PlacefileLayer(const std::shared_ptr& context, + const std::string& placefileName) : DrawLayer(context), p(std::make_unique(this, context, placefileName)) { diff --git a/scwx-qt/source/scwx/qt/map/placefile_layer.hpp b/scwx-qt/source/scwx/qt/map/placefile_layer.hpp index 9c08db10..ec351510 100644 --- a/scwx-qt/source/scwx/qt/map/placefile_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/placefile_layer.hpp @@ -16,8 +16,8 @@ class PlacefileLayer : public DrawLayer Q_OBJECT public: - explicit PlacefileLayer(std::shared_ptr context, - const std::string& placefileName); + explicit PlacefileLayer(const std::shared_ptr& context, + const std::string& placefileName); ~PlacefileLayer(); std::string placefile_name() const;