From cf6549a6fa01d3c0142360aa4802fc74cd06798a Mon Sep 17 00:00:00 2001 From: Maxim Pimenov Date: Mon, 23 Sep 2019 14:09:56 +0300 Subject: [PATCH] Got rid of the old style std/ includes for several files, mostly in software_renderer/. --- 3party/jansson/jansson_handle.hpp | 4 +- 3party/sdf_image/sdf_image.cpp | 51 +++++----- 3party/sdf_image/sdf_image.h | 19 ++-- coding/dd_vector.hpp | 10 +- drape/glyph_manager.cpp | 2 +- drape/visual_scale.hpp | 2 +- partners_api/opentable_api.cpp | 6 +- partners_api/opentable_api.hpp | 4 +- .../partners_api_tests/taxi_engine_tests.cpp | 12 +-- partners_api/uber_api.cpp | 45 +++++---- partners_api/uber_api.hpp | 39 ++++---- software_renderer/area_info.hpp | 11 +-- software_renderer/cpu_drawer.cpp | 12 ++- software_renderer/cpu_drawer.hpp | 67 ++++++------- software_renderer/feature_processor.cpp | 7 +- software_renderer/feature_processor.hpp | 12 +-- software_renderer/feature_styler.cpp | 21 ++-- software_renderer/feature_styler.hpp | 7 +- software_renderer/frame_image.hpp | 8 +- software_renderer/geometry_processors.cpp | 12 +-- software_renderer/geometry_processors.hpp | 23 ++--- software_renderer/glyph_cache.cpp | 15 ++- software_renderer/glyph_cache.hpp | 38 ++++---- software_renderer/glyph_cache_impl.cpp | 96 ++++++++++--------- software_renderer/glyph_cache_impl.hpp | 51 +++++----- software_renderer/icon_info.hpp | 12 +-- software_renderer/path_info.hpp | 12 +-- software_renderer/proto_to_styles.cpp | 18 ++-- software_renderer/proto_to_styles.hpp | 4 +- software_renderer/rect.h | 3 +- software_renderer/text_engine.cpp | 5 +- software_renderer/text_engine.h | 34 +++---- .../storage_3levels_tests.cpp | 4 +- 33 files changed, 326 insertions(+), 340 deletions(-) diff --git a/3party/jansson/jansson_handle.hpp b/3party/jansson/jansson_handle.hpp index 565c5323d3..b6ba745b10 100644 --- a/3party/jansson/jansson_handle.hpp +++ b/3party/jansson/jansson_handle.hpp @@ -1,6 +1,6 @@ #pragma once -#include "std/algorithm.hpp" +#include struct json_struct_t; @@ -36,7 +36,7 @@ public: void swap(JsonHandle & json) { - ::swap(m_pJson, json.m_pJson); + std::swap(m_pJson, json.m_pJson); } json_struct_t * get() const diff --git a/3party/sdf_image/sdf_image.cpp b/3party/sdf_image/sdf_image.cpp index 5def20aa5f..928991fd9b 100644 --- a/3party/sdf_image/sdf_image.cpp +++ b/3party/sdf_image/sdf_image.cpp @@ -17,18 +17,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "sdf_image.h" +#include "3party/sdf_image/sdf_image.h" #include "base/math.hpp" #include "base/scope_guard.hpp" -#include "std/algorithm.hpp" -#include "std/limits.hpp" -#include "std/bind.hpp" +#include +#include + +using namespace std::placeholders; namespace sdf_image { - namespace { float const SQRT2 = 1.4142136f; @@ -44,7 +44,7 @@ namespace } } -#define BIND_GRADIENT(f) bind(&f, _1, _2, _3, _4, _5, _6, _7, _8) +#define BIND_GRADIENT(f) std::bind(&f, _1, _2, _3, _4, _5, _6, _7, _8) #define TRANSFORM(offset, dx, dy) \ if (Transform(i, offset, dx, dy, xDist, yDist, oldDist)) \ { \ @@ -94,10 +94,10 @@ uint32_t SdfImage::GetHeight() const return m_height; } -void SdfImage::GetData(vector & dst) +void SdfImage::GetData(std::vector & dst) { ASSERT(m_data.size() <= dst.size(), ()); - transform(m_data.begin(), m_data.end(), dst.begin(), [](float const & node) + std::transform(m_data.begin(), m_data.end(), dst.begin(), [](float const & node) { return static_cast(node * 255.0f); }); @@ -105,17 +105,17 @@ void SdfImage::GetData(vector & dst) void SdfImage::Scale() { - float maxi = numeric_limits::min(); - float mini = numeric_limits::max(); + float maxi = std::numeric_limits::min(); + float mini = std::numeric_limits::max(); - for_each(m_data.begin(), m_data.end(), [&maxi, &mini](float const & node) + std::for_each(m_data.begin(), m_data.end(), [&maxi, &mini](float const & node) { - maxi = max(maxi, node); - mini = min(mini, node); + maxi = std::max(maxi, node); + mini = std::min(mini, node); }); maxi -= mini; - for_each(m_data.begin(), m_data.end(), [&maxi, &mini](float & node) + std::for_each(m_data.begin(), m_data.end(), [&maxi, &mini](float & node) { node = (node - mini) / maxi; }); @@ -123,7 +123,7 @@ void SdfImage::Scale() void SdfImage::Invert() { - for_each(m_data.begin(), m_data.end(), [](float & node) + std::for_each(m_data.begin(), m_data.end(), [](float & node) { node = 1.0f - node; }); @@ -132,7 +132,7 @@ void SdfImage::Invert() void SdfImage::Minus(SdfImage & im) { ASSERT(m_data.size() == im.m_data.size(), ()); - transform(m_data.begin(), m_data.end(), im.m_data.begin(), m_data.begin(), [](float const & n1, float const & n2) + std::transform(m_data.begin(), m_data.end(), im.m_data.begin(), m_data.begin(), [](float const & n1, float const & n2) { return n1 - n2; }); @@ -140,7 +140,7 @@ void SdfImage::Minus(SdfImage & im) void SdfImage::Distquant() { - for_each(m_data.begin(), m_data.end(), [](float & node) + std::for_each(m_data.begin(), m_data.end(), [](float & node) { node = base::Clamp(0.5f + node * 0.0325f, 0.0f, 1.0f); }); @@ -154,8 +154,8 @@ void SdfImage::GenerateSDF(float sc) SdfImage inside(m_height, m_width); size_t shortCount = m_width * m_height; - vector xDist; - vector yDist; + std::vector xDist; + std::vector yDist; xDist.resize(shortCount, 0); yDist.resize(shortCount, 0); @@ -244,7 +244,7 @@ float SdfImage::ComputeGradient(uint32_t x, uint32_t y, SdfImage::TComputeFn con return 0.0; } -void SdfImage::MexFunction(SdfImage const & img, vector & xDist, vector & yDist, SdfImage & out) +void SdfImage::MexFunction(SdfImage const & img, std::vector & xDist, std::vector & yDist, SdfImage & out) { ASSERT_EQUAL(img.GetWidth(), out.GetWidth(), ()); ASSERT_EQUAL(img.GetHeight(), out.GetHeight(), ()); @@ -252,9 +252,9 @@ void SdfImage::MexFunction(SdfImage const & img, vector & xDist, vector0.5 will have a negative distance. // This is correct, but we don't want values <0 returned here. - for_each(out.m_data.begin(), out.m_data.end(), [](float & n) + std::for_each(out.m_data.begin(), out.m_data.end(), [](float & n) { - n = max(0.0f, n); + n = std::max(0.0f, n); }); } @@ -318,7 +318,7 @@ double SdfImage::EdgeDf(double gx, double gy, double a) const gx = fabs(gx); gy = fabs(gy); if (gx < gy) - swap(gx, gy); + std::swap(gx, gy); double a1 = 0.5 * gy / gx; if (a < a1) @@ -332,7 +332,7 @@ double SdfImage::EdgeDf(double gx, double gy, double a) const return df; } -void SdfImage::EdtaA3(vector & xDist, vector & yDist, SdfImage & dist) const +void SdfImage::EdtaA3(std::vector & xDist, std::vector & yDist, SdfImage & dist) const { ASSERT_EQUAL(dist.GetHeight(), GetHeight(), ()); ASSERT_EQUAL(dist.GetWidth(), GetWidth(), ()); @@ -479,7 +479,7 @@ void SdfImage::EdtaA3(vector & xDist, vector & yDist, SdfImage & d while(changed); } -bool SdfImage::Transform(int baseIndex, int offset, int dx, int dy, vector & xDist, vector & yDist, float & oldDist) const +bool SdfImage::Transform(int baseIndex, int offset, int dx, int dy, std::vector & xDist, std::vector & yDist, float & oldDist) const { double const epsilon = 1e-3; ASSERT_EQUAL(xDist.size(), yDist.size(), ()); @@ -505,5 +505,4 @@ bool SdfImage::Transform(int baseIndex, int offset, int dx, int dy, vector +#include +#include namespace sdf_image { - class SdfImage { public: @@ -63,18 +63,19 @@ private: /// d = down /// dr = down right /// ul u ur l r dl d dr - typedef function TComputeFn; + using TComputeFn = std::function; float ComputeGradient(uint32_t x, uint32_t y, TComputeFn const & fn) const; - void MexFunction(SdfImage const & img, vector & xDist, vector & yDist, SdfImage & out); + void MexFunction(SdfImage const & img, std::vector & xDist, std::vector & yDist, + SdfImage & out); float DistaA3(int c, int xc, int yc, int xi, int yi) const; double EdgeDf(double gx, double gy, double a) const; - void EdtaA3(vector & xDist, vector & yDist, SdfImage & dist) const; - bool Transform(int baseIndex, int offset, int dx, int dy, vector & xDist, vector & yDist, float & oldDist) const; + void EdtaA3(std::vector & xDist, std::vector & yDist, SdfImage & dist) const; + bool Transform(int baseIndex, int offset, int dx, int dy, std::vector & xDist, + std::vector & yDist, float & oldDist) const; private: uint32_t m_height = 0; uint32_t m_width = 0; buffer_vector m_data; }; - -} // namespace sdf_image +} // namespace sdf_image diff --git a/coding/dd_vector.hpp b/coding/dd_vector.hpp index 0f65a5a24c..a196dd82fc 100644 --- a/coding/dd_vector.hpp +++ b/coding/dd_vector.hpp @@ -1,13 +1,14 @@ #pragma once + #include "coding/reader.hpp" #include "base/assert.hpp" #include "base/exception.hpp" -#include "std/iterator_facade.hpp" - #include +#include + // Disk-driven vector. template class DDVector @@ -43,10 +44,10 @@ public: return ReadPrimitiveFromPos(m_reader, static_cast(i) * sizeof(T)); } - class const_iterator : public iterator_facade< + class const_iterator : public boost::iterator_facade< const_iterator, value_type const, - random_access_traversal_tag> + boost::random_access_traversal_tag> { public: const_iterator() : m_pReader(NULL), m_I(0), m_bValueRead(false) @@ -144,7 +145,6 @@ public: #else return const_iterator(&m_reader, m_Size); #endif - } void Read(size_type i, T & result) const diff --git a/drape/glyph_manager.cpp b/drape/glyph_manager.cpp index e016ed91e7..a8774c5f37 100644 --- a/drape/glyph_manager.cpp +++ b/drape/glyph_manager.cpp @@ -258,7 +258,7 @@ public: return result; } - void GetCharcodes(vector & charcodes) + void GetCharcodes(std::vector & charcodes) { FT_UInt gindex; charcodes.push_back(FT_Get_First_Char(m_fontFace, &gindex)); diff --git a/drape/visual_scale.hpp b/drape/visual_scale.hpp index beb8f3e72e..68518196ab 100644 --- a/drape/visual_scale.hpp +++ b/drape/visual_scale.hpp @@ -12,6 +12,6 @@ inline double VisualScale(double exactDensityDPI) // For some old devices (for example iPad 2) the density could be less than 160 DPI. // Returns one in that case to keep readable text on the map. - return max(1.35, exactDensityDPI / kMdpiDensityDPI); + return std::max(1.35, exactDensityDPI / kMdpiDensityDPI); } } // namespace dp diff --git a/partners_api/opentable_api.cpp b/partners_api/opentable_api.cpp index 9454cef63b..d6d1650f12 100644 --- a/partners_api/opentable_api.cpp +++ b/partners_api/opentable_api.cpp @@ -1,6 +1,6 @@ #include "partners_api/opentable_api.hpp" -#include "std/sstream.hpp" +#include #include "private.h" @@ -12,9 +12,9 @@ namespace namespace opentable { // static -string Api::GetBookTableUrl(string const & restaurantId) +std::string Api::GetBookTableUrl(std::string const & restaurantId) { - stringstream ss; + std::stringstream ss; ss << kOpentableBaseUrl << restaurantId << "?ref=" << OPENTABLE_AFFILATE_ID; return ss.str(); } diff --git a/partners_api/opentable_api.hpp b/partners_api/opentable_api.hpp index b298fafdd7..9e75188a1b 100644 --- a/partners_api/opentable_api.hpp +++ b/partners_api/opentable_api.hpp @@ -1,12 +1,12 @@ #pragma once -#include "std/string.hpp" +#include namespace opentable { class Api { public: - static string GetBookTableUrl(string const & restaurantId); + static std::string GetBookTableUrl(std::string const & restaurantId); }; } // namespace opentable diff --git a/partners_api/partners_api_tests/taxi_engine_tests.cpp b/partners_api/partners_api_tests/taxi_engine_tests.cpp index 061b1863f3..d255a78e41 100644 --- a/partners_api/partners_api_tests/taxi_engine_tests.cpp +++ b/partners_api/partners_api_tests/taxi_engine_tests.cpp @@ -114,7 +114,7 @@ std::vector GetUberSynchronous(ms::LatLon const & from, ms::LatLo maker.SetTimes(reqId, times); maker.SetPrices(reqId, prices); maker.MakeProducts( - reqId, [&uberProducts](vector const & products) { uberProducts = products; }, + reqId, [&uberProducts](std::vector const & products) { uberProducts = products; }, [](taxi::ErrorCode const code) { TEST(false, (code)); }); return uberProducts; @@ -230,7 +230,7 @@ bool CompareProviders(taxi::ProvidersContainer const & lhs, taxi::ProvidersConta auto const m = lhs.size(); - vector used(m); + std::vector used(m); // TODO (@y) Change it to algorithm, based on bipartite graphs. for (auto const & rItem : rhs) { @@ -457,25 +457,25 @@ UNIT_CLASS_TEST(AsyncGuiThread, TaxiEngine_Smoke) { { - lock_guard lock(resultsMutex); + std::lock_guard lock(resultsMutex); reqId = engine.GetAvailableProducts(ms::LatLon(55.753960, 37.624513), ms::LatLon(55.765866, 37.661270), standardCallback, errorPossibleCallback); } { - lock_guard lock(resultsMutex); + std::lock_guard lock(resultsMutex); reqId = engine.GetAvailableProducts(ms::LatLon(59.922445, 30.367201), ms::LatLon(59.943675, 30.361123), standardCallback, errorPossibleCallback); } { - lock_guard lock(resultsMutex); + std::lock_guard lock(resultsMutex); reqId = engine.GetAvailableProducts(ms::LatLon(52.509621, 13.450067), ms::LatLon(52.510811, 13.409490), standardCallback, errorPossibleCallback); } { - lock_guard lock(resultsMutex); + std::lock_guard lock(resultsMutex); reqId = engine.GetAvailableProducts(from, to, lastCallback, errorCallback); } } diff --git a/partners_api/uber_api.cpp b/partners_api/uber_api.cpp index b629e67590..57938e9bfc 100644 --- a/partners_api/uber_api.cpp +++ b/partners_api/uber_api.cpp @@ -9,7 +9,6 @@ #include "base/thread.hpp" #include -#include #include #include #include @@ -53,7 +52,7 @@ bool IsIncomplete(taxi::Product const & p) return p.m_name.empty() || p.m_productId.empty() || p.m_time.empty() || p.m_price.empty(); } -void FillProducts(json_t const * time, json_t const * price, vector & products) +void FillProducts(json_t const * time, json_t const * price, std::vector & products) { // Fill data from time. auto const timeSize = json_array_size(time); @@ -72,7 +71,7 @@ void FillProducts(json_t const * time, json_t const * price, vector & products) +void MakeFromJson(char const * times, char const * prices, std::vector & products) { products.clear(); try @@ -122,11 +121,11 @@ namespace taxi { namespace uber { -string const kEstimatesUrl = "https://api.uber.com/v1/estimates"; -string const kProductsUrl = "https://api.uber.com/v1/products"; +std::string const kEstimatesUrl = "https://api.uber.com/v1/estimates"; +std::string const kProductsUrl = "https://api.uber.com/v1/products"; // static -bool RawApi::GetProducts(ms::LatLon const & pos, string & result, +bool RawApi::GetProducts(ms::LatLon const & pos, std::string & result, std::string const & baseUrl /* = kProductsUrl */) { std::ostringstream url; @@ -137,7 +136,7 @@ bool RawApi::GetProducts(ms::LatLon const & pos, string & result, } // static -bool RawApi::GetEstimatedTime(ms::LatLon const & pos, string & result, +bool RawApi::GetEstimatedTime(ms::LatLon const & pos, std::string & result, std::string const & baseUrl /* = kEstimatesUrl */) { std::ostringstream url; @@ -148,7 +147,7 @@ bool RawApi::GetEstimatedTime(ms::LatLon const & pos, string & result, } // static -bool RawApi::GetEstimatedPrice(ms::LatLon const & from, ms::LatLon const & to, string & result, +bool RawApi::GetEstimatedPrice(ms::LatLon const & from, ms::LatLon const & to, std::string & result, std::string const & baseUrl /* = kEstimatesUrl */) { std::ostringstream url; @@ -162,41 +161,41 @@ bool RawApi::GetEstimatedPrice(ms::LatLon const & from, ms::LatLon const & to, s void ProductMaker::Reset(uint64_t const requestId) { - lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); m_requestId = requestId; m_times.reset(); m_prices.reset(); } -void ProductMaker::SetTimes(uint64_t const requestId, string const & times) +void ProductMaker::SetTimes(uint64_t const requestId, std::string const & times) { - lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); if (requestId != m_requestId) return; - m_times = make_unique(times); + m_times = std::make_unique(times); } -void ProductMaker::SetPrices(uint64_t const requestId, string const & prices) +void ProductMaker::SetPrices(uint64_t const requestId, std::string const & prices) { - lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); if (requestId != m_requestId) return; - m_prices = make_unique(prices); + m_prices = std::make_unique(prices); } void ProductMaker::SetError(uint64_t const requestId, taxi::ErrorCode code) { - lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); if (requestId != m_requestId) return; - m_error = make_unique(code); + m_error = std::make_unique(code); } void ProductMaker::MakeProducts(uint64_t const requestId, ProductsCallback const & successFn, @@ -205,10 +204,10 @@ void ProductMaker::MakeProducts(uint64_t const requestId, ProductsCallback const ASSERT(successFn, ()); ASSERT(errorFn, ()); - vector products; - unique_ptr error; + std::vector products; + std::unique_ptr error; { - lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); if (requestId != m_requestId || !m_times || !m_prices) return; @@ -258,7 +257,7 @@ void Api::GetAvailableProducts(ms::LatLon const & from, ms::LatLon const & to, GetPlatform().RunTask(Platform::Thread::Network, [maker, from, reqId, baseUrl, successFn, errorFn]() { - string result; + std::string result; if (!RawApi::GetEstimatedTime(from, result, baseUrl)) maker->SetError(reqId, ErrorCode::RemoteError); @@ -268,7 +267,7 @@ void Api::GetAvailableProducts(ms::LatLon const & from, ms::LatLon const & to, GetPlatform().RunTask(Platform::Thread::Network, [maker, from, to, reqId, baseUrl, successFn, errorFn]() { - string result; + std::string result; if (!RawApi::GetEstimatedPrice(from, to, result, baseUrl)) maker->SetError(reqId, ErrorCode::RemoteError); diff --git a/partners_api/uber_api.hpp b/partners_api/uber_api.hpp index 3a5ef7e11a..c2051f0f3b 100644 --- a/partners_api/uber_api.hpp +++ b/partners_api/uber_api.hpp @@ -2,12 +2,11 @@ #include "partners_api/taxi_base.hpp" -#include "std/function.hpp" -#include "std/mutex.hpp" -#include "std/shared_ptr.hpp" -#include "std/string.hpp" -#include "std/unique_ptr.hpp" -#include "std/vector.hpp" +#include +#include +#include +#include +#include namespace ms { @@ -23,8 +22,8 @@ namespace taxi { namespace uber { -extern string const kEstimatesUrl; -extern string const kProductsUrl; +extern std::string const kEstimatesUrl; +extern std::string const kProductsUrl; /// Uber api wrapper based on synchronous http requests. class RawApi { @@ -33,7 +32,7 @@ public: /// otherwise returns false. The response contains the display name and other details about each /// product, and lists the products in the proper display order. This endpoint does not reflect /// real-time availability of the products. - static bool GetProducts(ms::LatLon const & pos, string & result, + static bool GetProducts(ms::LatLon const & pos, std::string & result, std::string const & url = kProductsUrl); /// Returns true when http request was executed successfully and response copied into @result, /// otherwise returns false. The response contains ETAs for all products currently available @@ -41,13 +40,13 @@ public: /// product returned from GetProducts is not returned from this endpoint for a given /// latitude/longitude pair then there are currently none of that product available to request. /// Call this endpoint every minute to provide the most accurate, up-to-date ETAs. - static bool GetEstimatedTime(ms::LatLon const & pos, string & result, + static bool GetEstimatedTime(ms::LatLon const & pos, std::string & result, std::string const & url = kEstimatesUrl); /// Returns true when http request was executed successfully and response copied into @result, /// otherwise returns false. The response contains an estimated price range for each product /// offered at a given location. The price estimate is provided as a formatted string with the /// full price range and the localized currency symbol. - static bool GetEstimatedPrice(ms::LatLon const & from, ms::LatLon const & to, string & result, + static bool GetEstimatedPrice(ms::LatLon const & from, ms::LatLon const & to, std::string & result, std::string const & url = kEstimatesUrl); }; @@ -56,18 +55,18 @@ class ProductMaker { public: void Reset(uint64_t const requestId); - void SetTimes(uint64_t const requestId, string const & times); - void SetPrices(uint64_t const requestId, string const & prices); + void SetTimes(uint64_t const requestId, std::string const & times); + void SetPrices(uint64_t const requestId, std::string const & prices); void SetError(uint64_t const requestId, taxi::ErrorCode code); void MakeProducts(uint64_t const requestId, ProductsCallback const & successFn, ErrorProviderCallback const & errorFn); private: uint64_t m_requestId = 0; - unique_ptr m_times; - unique_ptr m_prices; - unique_ptr m_error; - mutex m_mutex; + std::unique_ptr m_times; + std::unique_ptr m_prices; + std::unique_ptr m_error; + std::mutex m_mutex; }; class Api : public ApiBase @@ -81,14 +80,14 @@ public: ErrorProviderCallback const & errorFn) override; /// Returns link which allows you to launch the Uber app. - RideRequestLinks GetRideRequestLinks(string const & productId, ms::LatLon const & from, + RideRequestLinks GetRideRequestLinks(std::string const & productId, ms::LatLon const & from, ms::LatLon const & to) const override; private: - shared_ptr m_maker = make_shared(); + std::shared_ptr m_maker = std::make_shared(); uint64_t m_requestId = 0; }; -void SetUberUrlForTesting(string const & url); +void SetUberUrlForTesting(std::string const & url); } // namespace uber } // namespace taxi diff --git a/software_renderer/area_info.hpp b/software_renderer/area_info.hpp index f087980aaf..4310bcb829 100644 --- a/software_renderer/area_info.hpp +++ b/software_renderer/area_info.hpp @@ -2,18 +2,18 @@ #include "geometry/point2d.hpp" -#include "std/vector.hpp" -#include "std/algorithm.hpp" +#include +#include +#include namespace software_renderer { - class AreaInfo { m2::PointD m_center; public: - vector m_path; + std::vector m_path; void reserve(size_t ptsCount) { @@ -36,8 +36,7 @@ public: void SetCenter(m2::PointD const & p) { m_center = p; } m2::PointD GetCenter() const { return m_center; } }; - -} +} // namespace software_renderer inline void swap(software_renderer::AreaInfo & p1, software_renderer::AreaInfo & p2) { diff --git a/software_renderer/cpu_drawer.cpp b/software_renderer/cpu_drawer.cpp index 9ea1c88e42..f553482b01 100644 --- a/software_renderer/cpu_drawer.cpp +++ b/software_renderer/cpu_drawer.cpp @@ -1,6 +1,8 @@ #include "software_renderer/cpu_drawer.hpp" + #include "software_renderer/proto_to_styles.hpp" #include "software_renderer/software_renderer.hpp" + #include "drape_frontend/navigator.hpp" #include "drape_frontend/visual_params.hpp" @@ -14,12 +16,13 @@ #include "base/macros.hpp" #include "base/logging.hpp" -#include "std/algorithm.hpp" -#include "std/bind.hpp" +#include +#include + +using namespace std; namespace { - void CorrectFont(dp::FontDecl & font) { font.m_size = font.m_size * 0.75; @@ -828,5 +831,4 @@ void CPUDrawer::Draw(FeatureData const & data) DrawFeatureEnd(data.m_id); } - -} +} // namespace software_renderer diff --git a/software_renderer/cpu_drawer.hpp b/software_renderer/cpu_drawer.hpp index 7d5886de86..2942915886 100644 --- a/software_renderer/cpu_drawer.hpp +++ b/software_renderer/cpu_drawer.hpp @@ -9,27 +9,28 @@ #include "geometry/screenbase.hpp" -#include "std/function.hpp" -#include "std/list.hpp" -#include "std/unique_ptr.hpp" +#include +#include +#include +#include +#include +#include namespace software_renderer { - class SoftwareRenderer; class CPUDrawer { - public: struct Params { - Params(string const & resourcesPrefix, double visualScale) + Params(std::string const & resourcesPrefix, double visualScale) : m_resourcesPrefix(resourcesPrefix) , m_visualScale(visualScale) {} - string m_resourcesPrefix; + std::string m_resourcesPrefix; double m_visualScale; }; @@ -62,10 +63,11 @@ protected: void DrawPathText(PathInfo const & info, FeatureStyler const & fs, DrawRule const & rule); void DrawPathNumber(PathInfo const & path, FeatureStyler const & fs, DrawRule const & rule); - using TRoadNumberCallbackFn = function; - void GenerateRoadNumbers(PathInfo const & path, dp::FontDecl const & font, FeatureStyler const & fs, - TRoadNumberCallbackFn const & fn); + using TRoadNumberCallbackFn = std::function; + + void GenerateRoadNumbers(PathInfo const & path, dp::FontDecl const & font, + FeatureStyler const & fs, TRoadNumberCallbackFn const & fn); void DrawFeatureStart(FeatureID const & id); void DrawFeatureEnd(FeatureID const & id); @@ -76,13 +78,13 @@ protected: FeatureID const & Insert(PathInfo const & info); FeatureID const & Insert(AreaInfo const & info); FeatureID const & Insert(FeatureStyler const & styler); - FeatureID const & Insert(string const & text); + FeatureID const & Insert(std::string const & text); private: void Render(); private: - unique_ptr m_renderer; + std::unique_ptr m_renderer; int m_generationCounter; enum EShapeType @@ -178,42 +180,43 @@ private: BaseShape const * m_rules[2]; size_t m_ruleCount; - vector m_rects; + std::vector m_rects; m2::RectD m_boundRect; }; OverlayWrapper & AddOverlay(BaseShape const * shape1, BaseShape const * shape2 = nullptr); - using TTextRendererCall = function; + using TTextRendererCall = + std::function; + void CallTextRendererFn(TextShape const * shape, TTextRendererCall const & fn); - using TRoadNumberRendererCall = function; + using TRoadNumberRendererCall = std::function; + void CallTextRendererFn(TextShape const * shape, TRoadNumberRendererCall const & fn); - using TPathTextRendererCall = function; + using TPathTextRendererCall = std::function; void CallTextRendererFn(ComplexShape const * shape, TPathTextRendererCall const & fn); - list m_areaPathShapes; + std::list m_areaPathShapes; // overlay part - list m_pointShapes; - list m_pathTextShapes; - list m_textShapes; - list m_overlayList; + std::list m_pointShapes; + std::list m_pathTextShapes; + std::list m_textShapes; + std::list m_overlayList; - map m_stylers; - map m_areasGeometry; - map m_pathGeometry; - map m_roadNames; + std::map m_stylers; + std::map m_areasGeometry; + std::map m_pathGeometry; + std::map m_roadNames; dp::FontDecl m_roadNumberFont; double m_visualScale; FeatureID m_currentFeatureID; }; - -} +} // namespace software_renderer diff --git a/software_renderer/feature_processor.cpp b/software_renderer/feature_processor.cpp index 7ed22a61e9..1b48a7a573 100644 --- a/software_renderer/feature_processor.cpp +++ b/software_renderer/feature_processor.cpp @@ -1,4 +1,5 @@ #include "software_renderer/feature_processor.hpp" + #include "software_renderer/geometry_processors.hpp" #include "software_renderer/feature_styler.hpp" #include "software_renderer/cpu_drawer.hpp" @@ -8,7 +9,6 @@ namespace software_renderer { - namespace { template void assign_point(FeatureData & data, TSrc & src) @@ -28,7 +28,7 @@ namespace ASSERT(!data.m_areas.empty(), ()); data.m_areas.back().SetCenter(src.GetCenter()); } -} +} // namespace FeatureProcessor::FeatureProcessor(ref_ptr drawer, m2::RectD const & r, @@ -165,5 +165,4 @@ bool FeatureProcessor::operator()(FeatureType const & f) return true; } - -} +} // namespace software_renderer diff --git a/software_renderer/feature_processor.hpp b/software_renderer/feature_processor.hpp index e888f8c516..5a963e03be 100644 --- a/software_renderer/feature_processor.hpp +++ b/software_renderer/feature_processor.hpp @@ -13,7 +13,8 @@ #include "geometry/rect2d.hpp" -#include "std/list.hpp" +#include +#include class ScreenBase; @@ -25,8 +26,8 @@ struct FeatureData FeatureStyler m_styler; FeatureID m_id; - list m_pathes; - list m_areas; + std::list m_pathes; + std::list m_areas; m2::PointD m_point; }; @@ -50,7 +51,6 @@ private: int m_zoom; bool m_hasAnyFeature; - void PreProcessKeys(vector & keys) const; + void PreProcessKeys(std::vector & keys) const; }; - -} +} // namespace software_renderer diff --git a/software_renderer/feature_styler.cpp b/software_renderer/feature_styler.cpp index 623d5621b9..174b1ddde6 100644 --- a/software_renderer/feature_styler.cpp +++ b/software_renderer/feature_styler.cpp @@ -1,4 +1,5 @@ #include "software_renderer/feature_styler.hpp" + #include "software_renderer/proto_to_styles.hpp" #include "software_renderer/glyph_cache.hpp" #include "software_renderer/geometry_processors.hpp" @@ -15,11 +16,13 @@ #include "base/logging.hpp" #include "base/stl_helpers.hpp" -#include "std/iterator_facade.hpp" +#include +#include + +#include namespace { - struct less_depth { bool operator() (software_renderer::DrawRule const & r1, software_renderer::DrawRule const & r2) const @@ -27,8 +30,7 @@ struct less_depth return (r1.m_depth < r2.m_depth); } }; - -} +} // namespace namespace software_renderer { @@ -61,7 +63,7 @@ FeatureStyler::FeatureStyler(FeatureType const & f, m_rect(rect) { drule::KeysT keys; - pair type = feature::GetDrawRule(f, zoom, keys); + std::pair type = feature::GetDrawRule(f, zoom, keys); // don't try to do anything to invisible feature if (keys.empty()) @@ -89,7 +91,7 @@ FeatureStyler::FeatureStyler(FeatureType const & f, // m_primaryText.clear(); //} - string houseNumber; + std::string houseNumber; if (ftypes::IsBuildingChecker::Instance()(f)) { houseNumber = f.GetHouseNumber(); @@ -264,9 +266,9 @@ FeatureStyler::FeatureStyler(FeatureType const & f, sort(m_rules.begin(), m_rules.end(), less_depth()); } -typedef pair RangeT; +typedef std::pair RangeT; template class RangeIterT : - public iterator_facade, RangeT, forward_traversal_tag, RangeT> + public boost::iterator_facade, RangeT, forward_traversal_tag, RangeT> { IterT m_iter; public: @@ -404,5 +406,4 @@ bool FeatureStyler::FilterTextSize(drule::BaseRule const * pRule) const return true; } } - -} +} // namespace software_renderer diff --git a/software_renderer/feature_styler.hpp b/software_renderer/feature_styler.hpp index 0b736c77ab..385afd436a 100644 --- a/software_renderer/feature_styler.hpp +++ b/software_renderer/feature_styler.hpp @@ -4,14 +4,14 @@ #include "geometry/rect2d.hpp" -#include "std/vector.hpp" +#include +#include class FeatureType; class ScreenBase; namespace software_renderer { - const int maxDepth = 20000; const int minDepth = -20000; @@ -78,5 +78,4 @@ private: uint8_t GetTextFontSize(drule::BaseRule const * pRule) const; void LayoutTexts(double pathLength); }; - -} +} // namespace software_renderer diff --git a/software_renderer/frame_image.hpp b/software_renderer/frame_image.hpp index a9ab458080..cd6a197706 100644 --- a/software_renderer/frame_image.hpp +++ b/software_renderer/frame_image.hpp @@ -2,12 +2,11 @@ #include "geometry/point2d.hpp" -#include "std/cstdint.hpp" -#include "std/vector.hpp" +#include +#include namespace software_renderer { - struct FrameSymbols { m2::PointD m_searchResult; @@ -25,5 +24,4 @@ struct FrameImage uint32_t m_height = 0; // pixel height of image uint32_t m_stride = 0; // row stride in bytes }; - -} +} // namespace software_renderer diff --git a/software_renderer/geometry_processors.cpp b/software_renderer/geometry_processors.cpp index 21251a1c3c..895e2edaf3 100644 --- a/software_renderer/geometry_processors.cpp +++ b/software_renderer/geometry_processors.cpp @@ -1,10 +1,9 @@ -#include "geometry_processors.hpp" +#include "software_renderer/geometry_processors.hpp" -#include "std/bind.hpp" +#include namespace software_renderer { - base_screen::base_screen(params const & p) : base(p) { @@ -129,7 +128,7 @@ bool cut_path_intervals::IsExist() { // finally, assign whole length to every cutted path for_each(m_points.begin(), m_points.end(), - bind(&PathInfo::SetFullLength, _1, m_length)); + std::bind(&PathInfo::SetFullLength, std::placeholders::_1, m_length)); return !m_points.empty(); } @@ -243,7 +242,7 @@ bool path_points::IsExist() { // finally, assign whole length to every cutted path for_each(m_points.begin(), m_points.end(), - bind(&PathInfo::SetFullLength, _1, m_length)); + std::bind(&PathInfo::SetFullLength, std::placeholders::_1, m_length)); EndPL(); return base_type::IsExist(); @@ -272,5 +271,4 @@ bool area_tess_points::IsExist() const { return !m_points.empty(); } - -} +} // namespace software_renderer diff --git a/software_renderer/geometry_processors.hpp b/software_renderer/geometry_processors.hpp index 59b657747e..fc17f5b819 100644 --- a/software_renderer/geometry_processors.hpp +++ b/software_renderer/geometry_processors.hpp @@ -1,32 +1,30 @@ #pragma once -#include "area_info.hpp" -#include "path_info.hpp" +#include "software_renderer/area_info.hpp" +#include "software_renderer/path_info.hpp" -#include "indexer/cell_id.hpp" // CoordPointT +#include "indexer/cell_id.hpp" #include "geometry/point2d.hpp" #include "geometry/rect2d.hpp" #include "geometry/rect_intersect.hpp" #include "geometry/screenbase.hpp" -#include "std/list.hpp" -#include "std/limits.hpp" - #include "base/buffer_vector.hpp" +#include +#include + class ScreenBase; namespace software_renderer { - /// @name Base class policies (use by inheritance) for points processing. /// Containt next functions:\n /// - make_point - convert from Feature point to Screen point /// - convert_point - convert point to screen coordinates;\n /// - m_rect - clip rect;\n -//@{ struct base { struct params @@ -91,8 +89,6 @@ struct base_screen : public base } }; -//@} - template struct calc_length : public TBase { @@ -147,7 +143,7 @@ template struct geometry_base : public TBase { public: - list m_points; + std::list m_points; typedef typename TBase::params params; @@ -310,7 +306,7 @@ public: explicit filter_screenpts_adapter(params const & p) : TBase(p), - m_prev(numeric_limits::min(), numeric_limits::min()), m_center(0, 0) + m_prev(std::numeric_limits::min(), std::numeric_limits::min()), m_center(0, 0) { } @@ -339,5 +335,4 @@ public: m2::PointD GetCenter() const { return m_center; } void SetCenter(m2::PointD const & p) { m_center = this->g2p(p); } }; - -} +} // namespace software_renderer diff --git a/software_renderer/glyph_cache.cpp b/software_renderer/glyph_cache.cpp index b8bcc22673..dea432516c 100644 --- a/software_renderer/glyph_cache.cpp +++ b/software_renderer/glyph_cache.cpp @@ -1,9 +1,9 @@ #include "software_renderer/glyph_cache.hpp" + #include "software_renderer/glyph_cache_impl.hpp" namespace software_renderer { - GlyphKey::GlyphKey(strings::UniChar symbolCode, int fontSize, bool isMask, @@ -40,9 +40,9 @@ bool operator!=(GlyphKey const & l, GlyphKey const & r) || !(l.m_color == r.m_color); } -GlyphCache::Params::Params(string const & blocksFile, - string const & whiteListFile, - string const & blackListFile, +GlyphCache::Params::Params(std::string const & blocksFile, + std::string const & whiteListFile, + std::string const & blackListFile, size_t maxSize, double visualScale, bool isDebugging) @@ -61,7 +61,7 @@ GlyphCache::GlyphCache(Params const & params) : m_impl(new GlyphCacheImpl(params { } -void GlyphCache::addFonts(vector const & fontNames) +void GlyphCache::addFonts(std::vector const & fontNames) { m_impl->addFonts(fontNames); } @@ -81,7 +81,7 @@ shared_ptr const GlyphCache::getGlyphBitmap(GlyphKey const & key) return m_impl->getGlyphBitmap(key); } -double GlyphCache::getTextLength(double fontSize, string const & text) +double GlyphCache::getTextLength(double fontSize, std::string const & text) { strings::UniString const s = strings::MakeUniString(text); double len = 0; @@ -93,5 +93,4 @@ double GlyphCache::getTextLength(double fontSize, string const & text) return len; } - -} +} // namespace software_renderer diff --git a/software_renderer/glyph_cache.hpp b/software_renderer/glyph_cache.hpp index 3756569234..d886a2c651 100644 --- a/software_renderer/glyph_cache.hpp +++ b/software_renderer/glyph_cache.hpp @@ -4,14 +4,13 @@ #include "base/string_utils.hpp" -#include "std/shared_ptr.hpp" -#include "std/vector.hpp" -#include "std/string.hpp" -#include "std/utility.hpp" +#include +#include +#include +#include namespace software_renderer { - /// metrics of the single glyph struct GlyphMetrics { @@ -28,7 +27,7 @@ struct GlyphBitmap unsigned m_width; unsigned m_height; unsigned m_pitch; - vector m_data; + std::vector m_data; }; struct GlyphKey @@ -55,22 +54,20 @@ struct GlyphCacheImpl; class GlyphCache { private: - - shared_ptr m_impl; + std::shared_ptr m_impl; public: - struct Params { - string m_blocksFile; - string m_whiteListFile; - string m_blackListFile; + std::string m_blocksFile; + std::string m_whiteListFile; + std::string m_blackListFile; size_t m_maxSize; double m_visualScale; bool m_isDebugging; - Params(string const & blocksFile, - string const & whiteListFile, - string const & blackListFile, + Params(std::string const & blocksFile, + std::string const & whiteListFile, + std::string const & blackListFile, size_t maxSize, double visualScale, bool isDebugging); @@ -80,15 +77,14 @@ public: GlyphCache(Params const & params); void reset(); - void addFonts(vector const & fontNames); + void addFonts(std::vector const & fontNames); - pair getCharIDX(GlyphKey const & key); + std::pair getCharIDX(GlyphKey const & key); - shared_ptr const getGlyphBitmap(GlyphKey const & key); + std::shared_ptr const getGlyphBitmap(GlyphKey const & key); /// return control box(could be slightly larger than the precise bound box). GlyphMetrics const getGlyphMetrics(GlyphKey const & key); - double getTextLength(double fontSize, string const & text); + double getTextLength(double fontSize, std::string const & text); }; - -} +} // namespace software_renderer diff --git a/software_renderer/glyph_cache_impl.cpp b/software_renderer/glyph_cache_impl.cpp index 92e6b44fb0..e08bbfad62 100644 --- a/software_renderer/glyph_cache_impl.cpp +++ b/software_renderer/glyph_cache_impl.cpp @@ -7,8 +7,12 @@ #include "base/assert.hpp" #include "base/logging.hpp" -#include "std/bind.hpp" -#include "std/cstring.hpp" +#include +#include +#include +#include +#include +#include #include @@ -17,8 +21,7 @@ namespace software_renderer { - -UnicodeBlock::UnicodeBlock(string const & name, strings::UniChar start, strings::UniChar end) +UnicodeBlock::UnicodeBlock(std::string const & name, strings::UniChar start, strings::UniChar end) : m_name(name), m_start(start), m_end(end) {} @@ -78,9 +81,9 @@ FT_Error Font::CreateFaceID(FT_Library library, FT_Face * face) //return FT_New_Memory_Face(library, (unsigned char*)m_fontData.data(), m_fontData.size(), 0, face); } -void GlyphCacheImpl::initBlocks(string const & fileName) +void GlyphCacheImpl::initBlocks(std::string const & fileName) { - string buffer; + std::string buffer; try { ReaderPtr(GetPlatform().GetReader(fileName)).ReadAsString(buffer); @@ -91,10 +94,10 @@ void GlyphCacheImpl::initBlocks(string const & fileName) return; } - istringstream fin(buffer); + std::istringstream fin(buffer); while (true) { - string name; + std::string name; strings::UniChar start; strings::UniChar end; fin >> name >> std::hex >> start >> std::hex >> end; @@ -107,15 +110,15 @@ void GlyphCacheImpl::initBlocks(string const & fileName) m_lastUsedBlock = m_unicodeBlocks.end(); } -bool find_ub_by_name(string const & ubName, UnicodeBlock const & ub) +bool find_ub_by_name(std::string const & ubName, UnicodeBlock const & ub) { return ubName == ub.m_name; } -void GlyphCacheImpl::initFonts(string const & whiteListFile, string const & blackListFile) +void GlyphCacheImpl::initFonts(std::string const & whiteListFile, std::string const & blackListFile) { { - string buffer; + std::string buffer; try { ReaderPtr(GetPlatform().GetReader(whiteListFile)).ReadAsString(buffer); @@ -126,11 +129,11 @@ void GlyphCacheImpl::initFonts(string const & whiteListFile, string const & blac return; } - istringstream fin(buffer); + std::istringstream fin(buffer); while (true) { - string ubName; - string fontName; + std::string ubName; + std::string fontName; fin >> ubName >> fontName; if (!fin) break; @@ -142,7 +145,9 @@ void GlyphCacheImpl::initFonts(string const & whiteListFile, string const & blac it->m_whitelist.push_back(fontName); else { - unicode_blocks_t::iterator it = find_if(m_unicodeBlocks.begin(), m_unicodeBlocks.end(), bind(&find_ub_by_name, ubName, _1)); + unicode_blocks_t::iterator it = + std::find_if(m_unicodeBlocks.begin(), m_unicodeBlocks.end(), + std::bind(&find_ub_by_name, ubName, std::placeholders::_1)); if (it != m_unicodeBlocks.end()) it->m_whitelist.push_back(fontName); } @@ -150,7 +155,7 @@ void GlyphCacheImpl::initFonts(string const & whiteListFile, string const & blac } { - string buffer; + std::string buffer; try { ReaderPtr(GetPlatform().GetReader(blackListFile)).ReadAsString(buffer); @@ -161,11 +166,11 @@ void GlyphCacheImpl::initFonts(string const & whiteListFile, string const & blac return; } - istringstream fin(buffer); + std::istringstream fin(buffer); while (true) { - string ubName; - string fontName; + std::string ubName; + std::string fontName; fin >> ubName >> fontName; if (!fin) break; @@ -177,7 +182,9 @@ void GlyphCacheImpl::initFonts(string const & whiteListFile, string const & blac it->m_blacklist.push_back(fontName); else { - unicode_blocks_t::iterator it = find_if(m_unicodeBlocks.begin(), m_unicodeBlocks.end(), bind(&find_ub_by_name, ubName, _1)); + unicode_blocks_t::iterator it = + std::find_if(m_unicodeBlocks.begin(), m_unicodeBlocks.end(), + std::bind(&find_ub_by_name, ubName, std::placeholders::_1)); if (it != m_unicodeBlocks.end()) it->m_blacklist.push_back(fontName); } @@ -185,12 +192,13 @@ void GlyphCacheImpl::initFonts(string const & whiteListFile, string const & blac } } -bool greater_coverage(pair > const & l, pair > const & r) +bool greater_coverage(std::pair> const & l, + std::pair> const & r) { return l.first > r.first; } -void GlyphCacheImpl::addFonts(vector const & fontNames) +void GlyphCacheImpl::addFonts(std::vector const & fontNames) { if (m_isDebugging) return; @@ -213,7 +221,7 @@ void GlyphCacheImpl::addFont(char const * fileName) if (m_isDebugging) return; - shared_ptr pFont(new Font(GetPlatform().GetReader(fileName))); + std::shared_ptr pFont(new Font(GetPlatform().GetReader(fileName))); // Obtaining all glyphs, supported by this font. Call to FTCHECKRETURN functions may return // from routine, so add font to fonts array only in the end. @@ -221,15 +229,15 @@ void GlyphCacheImpl::addFont(char const * fileName) FT_Face face; FREETYPE_CHECK_RETURN(pFont->CreateFaceID(m_lib, &face), fileName); - vector charcodes; + std::vector charcodes; FT_UInt gindex; charcodes.push_back(FT_Get_First_Char(face, &gindex)); while (gindex) charcodes.push_back(FT_Get_Next_Char(face, charcodes.back(), &gindex)); - sort(charcodes.begin(), charcodes.end()); - charcodes.erase(unique(charcodes.begin(), charcodes.end()), charcodes.end()); + std::sort(charcodes.begin(), charcodes.end()); + charcodes.erase(std::unique(charcodes.begin(), charcodes.end()), charcodes.end()); FREETYPE_CHECK_RETURN(FT_Done_Face(face), fileName); @@ -237,7 +245,7 @@ void GlyphCacheImpl::addFont(char const * fileName) // modifying the m_unicodeBlocks unicode_blocks_t::iterator ubIt = m_unicodeBlocks.begin(); - vector::iterator ccIt = charcodes.begin(); + std::vector::iterator ccIt = charcodes.begin(); while (ccIt != charcodes.end()) { @@ -296,13 +304,13 @@ void GlyphCacheImpl::addFont(char const * fileName) size_t const count = ubIt->m_fonts.size(); - vector > > sortData; + std::vector>> sortData; sortData.reserve(count); for (size_t i = 0; i < count; ++i) - sortData.push_back(make_pair(ubIt->m_coverage[i], ubIt->m_fonts[i])); + sortData.push_back(std::make_pair(ubIt->m_coverage[i], ubIt->m_fonts[i])); - sort(sortData.begin(), sortData.end(), &greater_coverage); + std::sort(sortData.begin(), sortData.end(), &greater_coverage); for (size_t i = 0; i < count; ++i) { @@ -328,15 +336,15 @@ struct sym_in_block } }; -vector > & GlyphCacheImpl::getFonts(strings::UniChar sym) +std::vector> & GlyphCacheImpl::getFonts(strings::UniChar sym) { if ((m_lastUsedBlock != m_unicodeBlocks.end()) && m_lastUsedBlock->hasSymbol(sym)) return m_lastUsedBlock->m_fonts; - unicode_blocks_t::iterator it = lower_bound(m_unicodeBlocks.begin(), - m_unicodeBlocks.end(), - sym, - sym_in_block()); + unicode_blocks_t::iterator it = std::lower_bound(m_unicodeBlocks.begin(), + m_unicodeBlocks.end(), + sym, + sym_in_block()); if (it == m_unicodeBlocks.end()) it = m_unicodeBlocks.end()-1; @@ -362,7 +370,6 @@ vector > & GlyphCacheImpl::getFonts(strings::UniChar sym) return m_fonts; } - GlyphCacheImpl::GlyphCacheImpl(GlyphCache::Params const & params) { m_isDebugging = params.m_isDebugging; @@ -420,12 +427,12 @@ int GlyphCacheImpl::getCharIDX(shared_ptr const & font, strings::UniChar s ); } -pair const GlyphCacheImpl::getCharIDX(GlyphKey const & key) +std::pair const GlyphCacheImpl::getCharIDX(GlyphKey const & key) { if (m_isDebugging) - return make_pair((Font*)0, 0); + return std::make_pair((Font*)0, 0); - vector > & fonts = getFonts(key.m_symbolCode); + std::vector > & fonts = getFonts(key.m_symbolCode); Font * font = 0; @@ -436,7 +443,7 @@ pair const GlyphCacheImpl::getCharIDX(GlyphKey const & key) charIDX = getCharIDX(fonts[i], key.m_symbolCode); if (charIDX != 0) - return make_pair(fonts[i].get(), charIDX); + return std::make_pair(fonts[i].get(), charIDX); } #ifdef DEBUG @@ -459,7 +466,7 @@ pair const GlyphCacheImpl::getCharIDX(GlyphKey const & key) if (charIDX == 0) charIDX = getCharIDX(fonts.front(), 32); - return make_pair(font, charIDX); + return std::make_pair(font, charIDX); } GlyphMetrics const GlyphCacheImpl::getGlyphMetrics(GlyphKey const & key) @@ -516,9 +523,9 @@ GlyphMetrics const GlyphCacheImpl::getGlyphMetrics(GlyphKey const & key) return m; } -shared_ptr const GlyphCacheImpl::getGlyphBitmap(GlyphKey const & key) +std::shared_ptr const GlyphCacheImpl::getGlyphBitmap(GlyphKey const & key) { - pair charIDX = getCharIDX(key); + std::pair charIDX = getCharIDX(key); FTC_ScalerRec fontScaler = { @@ -584,5 +591,4 @@ FT_Error GlyphCacheImpl::RequestFace(FTC_FaceID faceID, FT_Library library, FT_P Font * font = reinterpret_cast(faceID); return font->CreateFaceID(library, face); } - -} +} // namespace software_renderer diff --git a/software_renderer/glyph_cache_impl.hpp b/software_renderer/glyph_cache_impl.hpp index e24bc69b6a..818fdfaeb5 100644 --- a/software_renderer/glyph_cache_impl.hpp +++ b/software_renderer/glyph_cache_impl.hpp @@ -2,6 +2,15 @@ #include "software_renderer/glyph_cache.hpp" +#include "coding/reader.hpp" + +#include "base/string_utils.hpp" + +#include +#include +#include +#include + #include #include FT_TYPES_H #include FT_SYSTEM_H @@ -9,17 +18,8 @@ #include FT_STROKER_H #include FT_CACHE_H -#include "base/string_utils.hpp" - -#include "coding/reader.hpp" - -#include "std/string.hpp" -#include "std/vector.hpp" -#include "std/shared_ptr.hpp" - namespace software_renderer { - struct Font { FT_Stream m_fontStream; @@ -37,24 +37,24 @@ struct Font /// Information about single unicode block. struct UnicodeBlock { - string m_name; + std::string m_name; /// @{ font matching tuning /// whitelist has priority over the blacklist in case of duplicates. /// this fonts are promoted to the top of the font list for this block. - vector m_whitelist; + std::vector m_whitelist; /// this fonts are removed from the font list for this block. - vector m_blacklist; + std::vector m_blacklist; /// @} strings::UniChar m_start; strings::UniChar m_end; /// sorted indices in m_fonts, from the best to the worst - vector > m_fonts; + std::vector > m_fonts; /// coverage of each font, in symbols - vector m_coverage; + std::vector m_coverage; - UnicodeBlock(string const & name, strings::UniChar start, strings::UniChar end); + UnicodeBlock(std::string const & name, strings::UniChar start, strings::UniChar end); bool hasSymbol(strings::UniChar sym) const; }; @@ -73,30 +73,29 @@ struct GlyphCacheImpl FTC_CMapCache m_charMapCache; //< cache of glyphID -> glyphIdx mapping - typedef vector unicode_blocks_t; + typedef std::vector unicode_blocks_t; unicode_blocks_t m_unicodeBlocks; unicode_blocks_t::iterator m_lastUsedBlock; bool m_isDebugging; - typedef vector > TFonts; + typedef std::vector > TFonts; TFonts m_fonts; static FT_Error RequestFace(FTC_FaceID faceID, FT_Library library, FT_Pointer requestData, FT_Face * face); - void initBlocks(string const & fileName); - void initFonts(string const & whiteListFile, string const & blackListFile); + void initBlocks(std::string const & fileName); + void initFonts(std::string const & whiteListFile, std::string const & blackListFile); - vector > & getFonts(strings::UniChar sym); + std::vector > & getFonts(strings::UniChar sym); void addFont(char const * fileName); - void addFonts(vector const & fontNames); + void addFonts(std::vector const & fontNames); - int getCharIDX(shared_ptr const & font, strings::UniChar symbolCode); - pair const getCharIDX(GlyphKey const & key); + int getCharIDX(std::shared_ptr const & font, strings::UniChar symbolCode); + std::pair const getCharIDX(GlyphKey const & key); GlyphMetrics const getGlyphMetrics(GlyphKey const & key); - shared_ptr const getGlyphBitmap(GlyphKey const & key); + std::shared_ptr const getGlyphBitmap(GlyphKey const & key); GlyphCacheImpl(GlyphCache::Params const & params); ~GlyphCacheImpl(); }; - -} +} // namespace software_renderer diff --git a/software_renderer/icon_info.hpp b/software_renderer/icon_info.hpp index 23fdc83d4c..9460decca8 100644 --- a/software_renderer/icon_info.hpp +++ b/software_renderer/icon_info.hpp @@ -1,16 +1,14 @@ #pragma once -#include "std/string.hpp" +#include namespace software_renderer { - struct IconInfo { - string m_name; - IconInfo() = default; - explicit IconInfo(string const & name) : m_name(name) {} -}; + explicit IconInfo(std::string const & name) : m_name(name) {} -} + std::string m_name; +}; +} // namespace software_renderer diff --git a/software_renderer/path_info.hpp b/software_renderer/path_info.hpp index 2c558d51ed..200b3446d9 100644 --- a/software_renderer/path_info.hpp +++ b/software_renderer/path_info.hpp @@ -3,19 +3,20 @@ #include "geometry/point2d.hpp" #include "geometry/rect2d.hpp" -#include "std/vector.hpp" -#include "std/algorithm.hpp" +#include "base/assert.hpp" + +#include +#include namespace software_renderer { - class PathInfo { double m_fullL; double m_offset; public: - vector m_path; + std::vector m_path; // -1.0 means "not" initialized explicit PathInfo(double offset = -1.0) : m_fullL(-1.0), m_offset(offset) {} @@ -89,8 +90,7 @@ public: return rect; } }; - -} +} // namespace software_renderer inline void swap(software_renderer::PathInfo & p1, software_renderer::PathInfo & p2) { diff --git a/software_renderer/proto_to_styles.cpp b/software_renderer/proto_to_styles.cpp index e13841d2ba..ec4fa7353f 100644 --- a/software_renderer/proto_to_styles.cpp +++ b/software_renderer/proto_to_styles.cpp @@ -1,23 +1,20 @@ -#include "proto_to_styles.hpp" +#include "software_renderer/proto_to_styles.hpp" #include "indexer/drules_include.hpp" -#include "std/algorithm.hpp" -#include "std/vector.hpp" +#include +#include namespace { - double ConvertWidth(double w, double scale) { - return max(w * scale, 1.0); -} - + return std::max(w * scale, 1.0); } +} // namespace namespace software_renderer { - dp::Color ConvertColor(uint32_t c) { return dp::Extract(c, 255 - (c >> 24)); @@ -26,7 +23,7 @@ dp::Color ConvertColor(uint32_t c) void ConvertStyle(LineDefProto const * pSrc, double scale, PenInfo & dest) { double offset = 0.0; - vector v; + std::vector v; if (pSrc->has_dashdot()) { @@ -129,5 +126,4 @@ uint8_t GetFontSize(CaptionDefProto const * pSrc) { return pSrc->height(); } - -} +} // namespace software_renderer diff --git a/software_renderer/proto_to_styles.hpp b/software_renderer/proto_to_styles.hpp index a4dccb05ac..825847bed5 100644 --- a/software_renderer/proto_to_styles.hpp +++ b/software_renderer/proto_to_styles.hpp @@ -17,7 +17,6 @@ class ShieldRuleProto; namespace software_renderer { - dp::Color ConvertColor(uint32_t c); void ConvertStyle(LineDefProto const * pSrc, double scale, PenInfo & dest); @@ -27,5 +26,4 @@ void ConvertStyle(CaptionDefProto const * pSrc, double scale, dp::FontDecl & des void ConvertStyle(ShieldRuleProto const * pSrc, double scale, dp::FontDecl & dest); uint8_t GetFontSize(CaptionDefProto const * pSrc); - -} +} // namespace software_renderer diff --git a/software_renderer/rect.h b/software_renderer/rect.h index 2a56b38b5c..8e780132a0 100644 --- a/software_renderer/rect.h +++ b/software_renderer/rect.h @@ -1,7 +1,8 @@ #ifndef __IA__RECT__ #define __IA__RECT__ -#include "point.h" +#include "software_renderer/point.h" + #include #include diff --git a/software_renderer/text_engine.cpp b/software_renderer/text_engine.cpp index c6ea397534..d89d4b8efd 100644 --- a/software_renderer/text_engine.cpp +++ b/software_renderer/text_engine.cpp @@ -1,6 +1,7 @@ -#include "text_engine.h" +#include "software_renderer/text_engine.h" #include + #include extern "C" const char default_font_data[741536]; @@ -459,4 +460,4 @@ text_engine::text_engine() load_face("default", default_font_data, sizeof(default_font_data)); // face("default",16); } -} +} // namespace ml diff --git a/software_renderer/text_engine.h b/software_renderer/text_engine.h index 2b8dd59f8b..0cb2211db7 100644 --- a/software_renderer/text_engine.h +++ b/software_renderer/text_engine.h @@ -1,25 +1,26 @@ #pragma once + #ifndef __ML__TEXT_ENGINE_H__ #define __ML__TEXT_ENGINE_H__ -#include -#include + +#include "software_renderer/point.h" +#include "software_renderer/rect.h" + +#include "base/string_utils.hpp" + +#include #include +#include +#include +#include #include -#include #include #include FT_FREETYPE_H #include FT_GLYPH_H #include FT_STROKER_H -#include "point.h" -#include "rect.h" - -#include "base/string_utils.hpp" - -#include "std/utility.hpp" - namespace ml { class text_engine; @@ -47,12 +48,12 @@ public: void flip_y(bool f) { m_flip_y = f; } face(ml::text_engine & e, std::string const & name, size_t size); - inline std::string const & face_name() const { return m_face_name; } - inline size_t face_size() const { return m_face_size; } + std::string const & face_name() const { return m_face_name; } + size_t face_size() const { return m_face_size; } FT_Glyph glyph(unsigned int code, unsigned int prev_code = 0, ml::point_d * kerning = NULL); - inline double ascender() const { return m_ascender; } - inline double descender() const { return m_descender; } - inline double height() const { return m_height; } + double ascender() const { return m_ascender; } + double descender() const { return m_descender; } + double height() const { return m_height; } }; struct text_engine_exception : public std::runtime_error @@ -199,7 +200,7 @@ protected: class text_engine { typedef std::map face_map_type; - typedef std::map, face> face_cache_type; + typedef std::map, face> face_cache_type; FT_Library m_library; face_map_type m_faces; FT_Face m_current_face; @@ -218,7 +219,6 @@ public: text_engine(); // ~text_engine() {} // TODO: destroy all faces before exit }; - } // namespace ml #endif // __ML__TEXT_ENGINE_H__ diff --git a/storage/storage_integration_tests/storage_3levels_tests.cpp b/storage/storage_integration_tests/storage_3levels_tests.cpp index 95bfe53022..47400a6aea 100644 --- a/storage/storage_integration_tests/storage_3levels_tests.cpp +++ b/storage/storage_integration_tests/storage_3levels_tests.cpp @@ -9,6 +9,7 @@ #include "base/file_name_utils.hpp" +#include #include #include "defines.hpp" @@ -26,10 +27,9 @@ int GetLevelCount(Storage & storage, CountryId const & countryId) storage.GetChildren(countryId, children); int level = 0; for (auto const & child : children) - level = max(level, GetLevelCount(storage, child)); + level = std::max(level, GetLevelCount(storage, child)); return 1 + level; } - } // namespace UNIT_TEST(SmallMwms_3levels_Test)