Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2015-08-12 12:40:39 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2015-11-30 16:09:59 +0300
commitdf0cda81cb14de2b94f7e56d171e0b33e1ce4222 (patch)
tree58c8f7f7eb031ea89d1eaba1984322d3da56436f
parentbcc6847396aeff5ca0a9fded861d98acb3bd47b8 (diff)
Review fixes
-rw-r--r--.gitignore1
-rw-r--r--drape/stipple_pen_resource.cpp30
-rw-r--r--drape/texture_manager.cpp54
-rw-r--r--drape/texture_of_colors.cpp33
4 files changed, 47 insertions, 71 deletions
diff --git a/.gitignore b/.gitignore
index 7662a9a905..6134a7c7e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,6 +58,7 @@ iphone/*/build/*
xcode/**/xcuserdata
xcode/**/xcshareddata
tools/emacsmode/build
+**/DerivedData/*
# GeneratedFiles
version/version.hpp
diff --git a/drape/stipple_pen_resource.cpp b/drape/stipple_pen_resource.cpp
index 3c3e0a5071..dec9f11d70 100644
--- a/drape/stipple_pen_resource.cpp
+++ b/drape/stipple_pen_resource.cpp
@@ -12,30 +12,30 @@ namespace dp
{
uint32_t const MAX_STIPPLE_PEN_LENGTH = 512;
-uint32_t const STIPPLE_HEIGHT_DISTANCE = 4;
+uint32_t const STIPPLE_HEIGHT = 1;
StipplePenPacker::StipplePenPacker(m2::PointU const & canvasSize)
: m_canvasSize(canvasSize)
, m_currentRow(0)
{
- ASSERT(canvasSize.x <= MAX_STIPPLE_PEN_LENGTH, ());
+ ASSERT_LESS_OR_EQUAL(canvasSize.x, MAX_STIPPLE_PEN_LENGTH, ());
}
m2::RectU StipplePenPacker::PackResource(uint32_t width)
{
- ASSERT(m_currentRow < m_canvasSize.y, ());
- ASSERT(width <= m_canvasSize.x, ());
+ ASSERT_LESS(m_currentRow, m_canvasSize.y, ());
+ ASSERT_LESS_OR_EQUAL(width, m_canvasSize.x, ());
uint32_t yOffset = m_currentRow;
- m_currentRow += STIPPLE_HEIGHT_DISTANCE;
- return m2::RectU(0, yOffset, width, yOffset + (STIPPLE_HEIGHT_DISTANCE / 2));
+ m_currentRow += STIPPLE_HEIGHT;
+ return m2::RectU(0, yOffset, width, yOffset + STIPPLE_HEIGHT);
}
m2::RectF StipplePenPacker::MapTextureCoords(m2::RectU const & pixelRect) const
{
- return m2::RectF((pixelRect.minX() + 1.0f) / m_canvasSize.x,
- (pixelRect.minY() + 1.0f) / m_canvasSize.y,
- (pixelRect.maxX() - 1.0f) / m_canvasSize.x,
- (pixelRect.maxY() - 1.0f) / m_canvasSize.y);
+ return m2::RectF((pixelRect.minX() + 0.5f) / m_canvasSize.x,
+ (pixelRect.minY() + 0.5f) / m_canvasSize.y,
+ (pixelRect.maxX() - 0.5f) / m_canvasSize.x,
+ (pixelRect.maxY() - 0.5f) / m_canvasSize.y);
}
StipplePenHandle::StipplePenHandle(buffer_vector<uint8_t, 8> const & pattern)
@@ -66,8 +66,8 @@ void StipplePenHandle::Init(buffer_vector<uint8_t, 8> const & pattern)
for (size_t i = 0; i < patternSize; ++i)
{
m_keyValue <<=7;
- ASSERT(pattern[i] > 0, ()); // we have 7 bytes for value. value = 1 encode like 0000000
- ASSERT(pattern[i] < 129, ()); // value = 128 encode like 1111111
+ ASSERT_GREATER(pattern[i], 0, ()); // we have 7 bytes for value. value = 1 encode like 0000000
+ ASSERT_LESS(pattern[i], 129, ()); // value = 128 encode like 1111111
uint32_t value = pattern[i] - 1;
m_keyValue += value;
}
@@ -79,7 +79,7 @@ StipplePenRasterizator::StipplePenRasterizator(StipplePenKey const & key)
: m_key(key)
{
m_patternLength = accumulate(m_key.m_pattern.begin(), m_key.m_pattern.end(), 0);
- ASSERT(m_patternLength < MAX_STIPPLE_PEN_LENGTH, ());
+ ASSERT_LESS(m_patternLength, MAX_STIPPLE_PEN_LENGTH, ());
uint32_t count = floor(MAX_STIPPLE_PEN_LENGTH / m_patternLength);
m_pixelLength = count * m_patternLength;
}
@@ -180,7 +180,7 @@ void StipplePenIndex::UploadResources(ref_ptr<Texture> texture)
}
SharedBufferManager & mng = SharedBufferManager::instance();
- uint32_t const bytesPerNode = MAX_STIPPLE_PEN_LENGTH * STIPPLE_HEIGHT_DISTANCE;
+ uint32_t const bytesPerNode = MAX_STIPPLE_PEN_LENGTH * STIPPLE_HEIGHT;
uint32_t reserveBufferSize = my::NextPowOf2(pendingNodes.size() * bytesPerNode);
SharedBufferManager::shared_buffer_ptr_t ptr = mng.reserveSharedBuffer(reserveBufferSize);
uint8_t * rawBuffer = SharedBufferManager::GetRawPointer(ptr);
@@ -189,7 +189,7 @@ void StipplePenIndex::UploadResources(ref_ptr<Texture> texture)
pendingNodes[i].second.Rasterize(rawBuffer + i * bytesPerNode);
texture->UploadData(0, pendingNodes.front().first.minY(),
- MAX_STIPPLE_PEN_LENGTH, pendingNodes.size() * STIPPLE_HEIGHT_DISTANCE,
+ MAX_STIPPLE_PEN_LENGTH, pendingNodes.size() * STIPPLE_HEIGHT,
dp::ALPHA, make_ref(rawBuffer));
mng.freeSharedBuffer(reserveBufferSize, ptr);
diff --git a/drape/texture_manager.cpp b/drape/texture_manager.cpp
index c72454ae88..16cf7b7648 100644
--- a/drape/texture_manager.cpp
+++ b/drape/texture_manager.cpp
@@ -21,13 +21,12 @@
namespace dp
{
+uint32_t const kMaxTextureSize = 2048;
uint32_t const kStippleTextureWidth = 512;
uint32_t const kMinStippleTextureHeight = 64;
-uint32_t const kMinColorTextureSize = 64;
+uint32_t const kMinColorTextureSize = 32;
size_t const kInvalidGlyphGroup = numeric_limits<size_t>::max();
-size_t const kPixelsPerColor = 2;
-
// number of glyphs (since 0) which will be in each texture
size_t const kDuplicatedGlyphsCount = 128;
@@ -49,21 +48,25 @@ void MultilineTextToUniString(TextureManager::TMultilineText const & text, strin
outString.append(str.begin(), str.end());
}
-template <typename ToDo>
-void ParseColorsList(string const & colorsFile, ToDo toDo)
+string ReadFileToString(string const & filename)
{
- string colorsList;
+ string result;
try
{
- ReaderPtr<Reader>(GetPlatform().GetReader(colorsFile)).ReadAsString(colorsList);
+ ReaderPtr<Reader>(GetPlatform().GetReader(filename)).ReadAsString(result);
}
catch(RootException const & e)
{
- LOG(LWARNING, ("Error reading colors list ", colorsFile, " : ", e.what()));
- return;
+ LOG(LWARNING, ("Error reading file ", filename, " : ", e.what()));
+ return "";
}
+ return result;
+}
- istringstream fin(colorsList);
+template <typename ToDo>
+void ParseColorsList(string const & colorsFile, ToDo toDo)
+{
+ istringstream fin(ReadFileToString(colorsFile));
while (true)
{
uint32_t color;
@@ -78,18 +81,7 @@ void ParseColorsList(string const & colorsFile, ToDo toDo)
template <typename ToDo>
void ParsePatternsList(string const & patternsFile, ToDo toDo)
{
- string patternsList;
- try
- {
- ReaderPtr<Reader>(GetPlatform().GetReader(patternsFile)).ReadAsString(patternsList);
- }
- catch(RootException const & e)
- {
- LOG(LWARNING, ("Error reading patterns list ", patternsFile, " : ", e.what()));
- return;
- }
-
- strings::Tokenize(patternsList, "\n", [&](string const & patternStr)
+ strings::Tokenize(ReadFileToString(patternsFile), "\n", [&](string const & patternStr)
{
if (patternStr.empty())
return;
@@ -98,7 +90,7 @@ void ParsePatternsList(string const & patternsFile, ToDo toDo)
strings::Tokenize(patternStr, " ", [&](string const & token)
{
double d = 0.0;
- strings::to_double(token, d);
+ VERIFY(strings::to_double(token, d), ());
pattern.push_back(d);
});
@@ -107,6 +99,7 @@ void ParsePatternsList(string const & patternsFile, ToDo toDo)
{
if (fabs(pattern[i]) < 1e-5)
{
+ LOG(LWARNING, ("Pattern was skipped", patternStr));
isValid = false;
break;
}
@@ -365,14 +358,14 @@ size_t TextureManager::FindHybridGlyphsGroup(TMultilineText const & text)
void TextureManager::Init(Params const & params)
{
- uint32_t const kMaxTextureSize = 2048;
+ m_maxTextureSize = min(kMaxTextureSize, (uint32_t)GLFunctions::glGetInteger(gl_const::GLMaxTextureSize));
GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1);
m_symbolTexture = make_unique_dp<SymbolsTexture>(params.m_resPostfix);
// initialize patterns
- list<buffer_vector<uint8_t, 8>> patterns;
+ buffer_vector<buffer_vector<uint8_t, 8>, 64> patterns;
double const visualScale = params.m_visualScale;
ParsePatternsList(params.m_patterns, [&patterns, visualScale](buffer_vector<double, 8> const & pattern)
{
@@ -382,8 +375,8 @@ void TextureManager::Init(Params const & params)
patterns.push_back(move(p));
});
- uint32_t stippleTextureHeight = max(4 * my::NextPowOf2(patterns.size() + kReservedPatterns), kMinStippleTextureHeight);
- stippleTextureHeight = min(kMaxTextureSize, stippleTextureHeight);
+ uint32_t stippleTextureHeight = max(my::NextPowOf2(patterns.size() + kReservedPatterns), kMinStippleTextureHeight);
+ stippleTextureHeight = min(m_maxTextureSize, stippleTextureHeight);
m_stipplePenTexture = make_unique_dp<StipplePenTexture>(m2::PointU(kStippleTextureWidth, stippleTextureHeight));
LOG(LDEBUG, ("Patterns texture size = ", m_stipplePenTexture->GetWidth(), m_stipplePenTexture->GetHeight()));
@@ -392,14 +385,14 @@ void TextureManager::Init(Params const & params)
stipplePenTextureTex->ReservePattern(*it);
// initialize colors
- list<dp::Color> colors;
+ buffer_vector<dp::Color, 256> colors;
ParseColorsList(params.m_colors, [&colors](dp::Color const & color)
{
colors.push_back(color);
});
- uint32_t colorTextureSize = max(my::NextPowOf2(floor(sqrt(colors.size() + kReservedColors)) * kPixelsPerColor), kMinColorTextureSize);
- colorTextureSize = min(kMaxTextureSize, colorTextureSize);
+ uint32_t colorTextureSize = max(my::NextPowOf2(floor(sqrt(colors.size() + kReservedColors))), kMinColorTextureSize);
+ colorTextureSize = min(m_maxTextureSize, colorTextureSize);
m_colorTexture = make_unique_dp<ColorTexture>(m2::PointU(colorTextureSize, colorTextureSize));
LOG(LDEBUG, ("Colors texture size = ", m_colorTexture->GetWidth(), m_colorTexture->GetHeight()));
@@ -409,7 +402,6 @@ void TextureManager::Init(Params const & params)
// initialize glyphs
m_glyphManager = make_unique_dp<GlyphManager>(params.m_glyphMngParams);
- m_maxTextureSize = min(kMaxTextureSize, (uint32_t)GLFunctions::glGetInteger(gl_const::GLMaxTextureSize));
uint32_t const textureSquare = m_maxTextureSize * m_maxTextureSize;
uint32_t const baseGlyphHeight = params.m_glyphMngParams.m_baseGlyphHeight;
diff --git a/drape/texture_of_colors.cpp b/drape/texture_of_colors.cpp
index 41995bc6d0..1274394d10 100644
--- a/drape/texture_of_colors.cpp
+++ b/drape/texture_of_colors.cpp
@@ -11,7 +11,7 @@ namespace dp
namespace
{
- int const RESOURCE_SIZE = 2;
+ int const RESOURCE_SIZE = 1;
int const BYTES_PER_PIXEL = 4;
}
@@ -119,7 +119,6 @@ void ColorPalette::UploadResources(ref_ptr<Texture> texture)
uploadRect = m2::RectU(0, startRect.minY(), m_textureSize.x, endRect.maxY());
}
- size_t pixelStride = uploadRect.SizeX();
size_t byteCount = BYTES_PER_PIXEL * uploadRect.SizeX() * uploadRect.SizeY();
size_t bufferSize = my::NextPowOf2(byteCount);
@@ -127,33 +126,17 @@ void ColorPalette::UploadResources(ref_ptr<Texture> texture)
uint8_t * pointer = SharedBufferManager::GetRawPointer(buffer);
if (m_isDebug)
memset(pointer, 0, bufferSize);
- uint32_t currentY = startRect.minY();
+
for (size_t j = startRange; j < endRange; ++j)
{
ASSERT(pointer < SharedBufferManager::GetRawPointer(buffer) + byteCount, ());
PendingColor const & c = pendingNodes[j];
- if (c.m_rect.minY() > currentY)
- {
- pointer += BYTES_PER_PIXEL * pixelStride;
- currentY = c.m_rect.minY();
- }
-
- uint32_t byteStride = pixelStride * BYTES_PER_PIXEL;
- uint8_t red = c.m_color.GetRed();
- uint8_t green = c.m_color.GetGreen();
- uint8_t blue = c.m_color.GetBlue();
- uint8_t alfa = c.m_color.GetAlfa();
-
- pointer[0] = pointer[4] = red;
- pointer[1] = pointer[5] = green;
- pointer[2] = pointer[6] = blue;
- pointer[3] = pointer[7] = alfa;
- pointer[byteStride + 0] = pointer[byteStride + 4] = red;
- pointer[byteStride + 1] = pointer[byteStride + 5] = green;
- pointer[byteStride + 2] = pointer[byteStride + 6] = blue;
- pointer[byteStride + 3] = pointer[byteStride + 7] = alfa;
-
- pointer += 2 * BYTES_PER_PIXEL;
+ pointer[0] = c.m_color.GetRed();
+ pointer[1] = c.m_color.GetGreen();
+ pointer[2] = c.m_color.GetBlue();
+ pointer[3] = c.m_color.GetAlfa();
+
+ pointer += BYTES_PER_PIXEL;
ASSERT(pointer <= SharedBufferManager::GetRawPointer(buffer) + byteCount, ());
}