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:
authorrachytski <siarhei.rachytski@gmail.com>2012-11-12 14:51:18 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:46:47 +0300
commit599cbc140f200b530d619f2074c928d9c7fd7829 (patch)
treeb753800f170b3bf819fc2bf719a77a84690a7120
parentca0ee60ed3313935743eb3fd92401cc26061d75b (diff)
added ImageRenderer and tests for it.
-rw-r--r--coding/lodepng_io.hpp3
-rw-r--r--data/test.pngbin0 -> 213771 bytes
-rw-r--r--graphics/area_renderer.cpp214
-rw-r--r--graphics/area_renderer.hpp53
-rw-r--r--graphics/graphics.pro8
-rw-r--r--graphics/graphics_tests/screengl_test.cpp26
-rw-r--r--graphics/graphics_tests/shape_renderer_test.cpp2
-rw-r--r--graphics/image_info.cpp53
-rw-r--r--graphics/image_info.hpp31
-rw-r--r--graphics/image_renderer.cpp67
-rw-r--r--graphics/image_renderer.hpp21
-rw-r--r--graphics/path_renderer.cpp493
-rw-r--r--graphics/path_renderer.hpp43
-rw-r--r--graphics/pen_info.hpp4
-rw-r--r--graphics/resource_style.cpp44
-rw-r--r--graphics/resource_style.hpp46
-rw-r--r--graphics/shape_renderer.cpp328
-rw-r--r--graphics/shape_renderer.hpp107
-rw-r--r--graphics/skin.cpp17
-rw-r--r--graphics/skin.hpp5
-rw-r--r--graphics/skin_page.cpp44
-rw-r--r--graphics/skin_page.hpp9
-rw-r--r--graphics/text_renderer.hpp6
-rw-r--r--graphics/texture.hpp7
-rw-r--r--qt_tstfrm/macros.hpp3
-rw-r--r--qt_tstfrm/tstwidgets.cpp2
26 files changed, 976 insertions, 660 deletions
diff --git a/coding/lodepng_io.hpp b/coding/lodepng_io.hpp
index f0eb1b0230..f6254e4c62 100644
--- a/coding/lodepng_io.hpp
+++ b/coding/lodepng_io.hpp
@@ -129,7 +129,8 @@ inline void lodepng_read_and_convert_view(ReaderPtr<Reader> & reader,const View&
/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
template <typename View,typename CC>
inline void lodepng_read_and_convert_view(ReaderPtr<Reader> & reader,const View& view,CC cc) {
- lodepng_read_and_convert_view(reader,view,cc);
+ detail::lodepng_reader_color_convert<CC> m(reader, cc);
+ m.apply(view);
}
/// \ingroup LODEPNG_IO
diff --git a/data/test.png b/data/test.png
new file mode 100644
index 0000000000..f8518c6127
--- /dev/null
+++ b/data/test.png
Binary files differ
diff --git a/graphics/area_renderer.cpp b/graphics/area_renderer.cpp
index f2835609e6..d9b3af5e48 100644
--- a/graphics/area_renderer.cpp
+++ b/graphics/area_renderer.cpp
@@ -8,155 +8,151 @@
namespace graphics
{
- namespace gl
+ AreaRenderer::Params::Params()
+ : m_drawAreas(true)
{
- AreaRenderer::Params::Params()
- : m_drawAreas(true)
- {
- }
+ }
- AreaRenderer::AreaRenderer(Params const & params)
- : base_t(params),
+ AreaRenderer::AreaRenderer(Params const & params)
+ : base_t(params),
m_drawAreas(params.m_drawAreas)
- {}
+ {}
- void AreaRenderer::beginFrame()
- {
- base_t::beginFrame();
- m_areasCount = 0;
- m_trianglesCount = 0;
- }
+ void AreaRenderer::beginFrame()
+ {
+ base_t::beginFrame();
+ m_areasCount = 0;
+ m_trianglesCount = 0;
+ }
- void AreaRenderer::endFrame()
+ void AreaRenderer::endFrame()
+ {
+ if (isDebugging())
{
- if (isDebugging())
- {
- LOG(LINFO, ("drawing ", m_areasCount, " areas, ", m_trianglesCount, " triangles total"));
- }
- base_t::endFrame();
+ LOG(LINFO, ("drawing ", m_areasCount, " areas, ", m_trianglesCount, " triangles total"));
}
+ base_t::endFrame();
+ }
- void AreaRenderer::drawTrianglesFan(m2::PointF const * points,
- size_t pointsCount,
- uint32_t styleID,
- double depth)
- {
- ++m_areasCount;
- m_trianglesCount += (pointsCount - 2);
+ void AreaRenderer::drawTrianglesFan(m2::PointF const * points,
+ size_t pointsCount,
+ uint32_t styleID,
+ double depth)
+ {
+ ++m_areasCount;
+ m_trianglesCount += (pointsCount - 2);
- if (!m_drawAreas)
- return;
+ if (!m_drawAreas)
+ return;
- ResourceStyle const * style = skin()->fromID(styleID);
+ ResourceStyle const * style = skin()->fromID(styleID);
- if (style == 0)
- {
- LOG(LINFO, ("drawTrianglesFan: styleID=", styleID, " wasn't found on current skin."));
- return;
- }
+ if (style == 0)
+ {
+ LOG(LINFO, ("drawTrianglesFan: styleID=", styleID, " wasn't found on current skin."));
+ return;
+ }
- ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
+ ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
- float texX = style->m_texRect.minX() + 1.0f;
- float texY = style->m_texRect.minY() + 1.0f;
+ float texX = style->m_texRect.minX() + 1.0f;
+ float texY = style->m_texRect.minY() + 1.0f;
- shared_ptr<BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
+ shared_ptr<gl::BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
- if (!texture)
- {
- LOG(LDEBUG, ("returning as no texture is reserved"));
- return;
- }
+ if (!texture)
+ {
+ LOG(LDEBUG, ("returning as no texture is reserved"));
+ return;
+ }
- texture->mapPixel(texX, texY);
+ texture->mapPixel(texX, texY);
- m2::PointF texCoord(texX, texY);
- m2::PointF normal(0, 0);
+ m2::PointF texCoord(texX, texY);
+ m2::PointF normal(0, 0);
- addTexturedFanStrided(points, sizeof(m2::PointF),
- &normal, 0,
- &texCoord, 0,
- pointsCount,
- depth,
- style->m_pipelineID);
- }
+ addTexturedFanStrided(points, sizeof(m2::PointF),
+ &normal, 0,
+ &texCoord, 0,
+ pointsCount,
+ depth,
+ style->m_pipelineID);
+ }
- void AreaRenderer::drawTrianglesList(m2::PointD const * points, size_t pointsCount, uint32_t styleID, double depth)
- {
- ++m_areasCount;
- m_trianglesCount += pointsCount / 3;
+ void AreaRenderer::drawTrianglesList(m2::PointD const * points, size_t pointsCount, uint32_t styleID, double depth)
+ {
+ ++m_areasCount;
+ m_trianglesCount += pointsCount / 3;
- if (!m_drawAreas)
- return;
+ if (!m_drawAreas)
+ return;
- ResourceStyle const * style = skin()->fromID(styleID);
+ ResourceStyle const * style = skin()->fromID(styleID);
- if (style == 0)
- {
- LOG(LINFO, ("drawArea: styleID=", styleID, " wasn't found on current skin."));
- return;
- }
+ if (style == 0)
+ {
+ LOG(LINFO, ("drawArea: styleID=", styleID, " wasn't found on current skin."));
+ return;
+ }
- if (!hasRoom(pointsCount, pointsCount, style->m_pipelineID))
- flush(style->m_pipelineID);
+ if (!hasRoom(pointsCount, pointsCount, style->m_pipelineID))
+ flush(style->m_pipelineID);
- ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
+ ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
- float texX = style->m_texRect.minX() + 1.0f;
- float texY = style->m_texRect.minY() + 1.0f;
+ float texX = style->m_texRect.minX() + 1.0f;
+ float texY = style->m_texRect.minY() + 1.0f;
- shared_ptr<BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
+ shared_ptr<gl::BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
- if (!texture)
- {
- LOG(LDEBUG, ("returning as no texture is reserved"));
- return;
- }
+ if (!texture)
+ {
+ LOG(LDEBUG, ("returning as no texture is reserved"));
+ return;
+ }
- texture->mapPixel(texX, texY);
+ texture->mapPixel(texX, texY);
- size_t pointsLeft = pointsCount;
- size_t batchOffset = 0;
+ size_t pointsLeft = pointsCount;
+ size_t batchOffset = 0;
- while (true)
- {
- size_t batchSize = pointsLeft;
+ while (true)
+ {
+ size_t batchSize = pointsLeft;
- int vLeft = verticesLeft(style->m_pipelineID);
- int iLeft = indicesLeft(style->m_pipelineID);
+ int vLeft = verticesLeft(style->m_pipelineID);
+ int iLeft = indicesLeft(style->m_pipelineID);
- if ((vLeft == -1) || (iLeft == -1))
- return;
+ if ((vLeft == -1) || (iLeft == -1))
+ return;
- if (batchSize > vLeft)
- /// Rounding to the boundary of 3 vertices
- batchSize = vLeft / 3 * 3;
+ if (batchSize > vLeft)
+ /// Rounding to the boundary of 3 vertices
+ batchSize = vLeft / 3 * 3;
- if (batchSize > iLeft)
- batchSize = iLeft / 3 * 3;
+ if (batchSize > iLeft)
+ batchSize = iLeft / 3 * 3;
- bool needToFlush = (batchSize < pointsLeft);
+ bool needToFlush = (batchSize < pointsLeft);
- m2::PointF texCoord(texX, texY);
- m2::PointF normal(0, 0);
+ m2::PointF texCoord(texX, texY);
+ m2::PointF normal(0, 0);
- addTexturedListStrided(&points[batchOffset], sizeof(m2::PointD),
- &normal, 0,
- &texCoord, 0,
- batchSize,
- depth,
- style->m_pipelineID);
+ addTexturedListStrided(&points[batchOffset], sizeof(m2::PointD),
+ &normal, 0,
+ &texCoord, 0,
+ batchSize,
+ depth,
+ style->m_pipelineID);
- batchOffset += batchSize;
- pointsLeft -= batchSize;
+ batchOffset += batchSize;
+ pointsLeft -= batchSize;
- if (needToFlush)
- flush(style->m_pipelineID);
+ if (needToFlush)
+ flush(style->m_pipelineID);
- if (pointsLeft == 0)
- break;
- }
+ if (pointsLeft == 0)
+ break;
}
-
}
}
diff --git a/graphics/area_renderer.hpp b/graphics/area_renderer.hpp
index 856582ed8a..31aec8eec8 100644
--- a/graphics/area_renderer.hpp
+++ b/graphics/area_renderer.hpp
@@ -4,41 +4,38 @@
namespace graphics
{
- namespace gl
+ class AreaRenderer : public gl::GeometryBatcher
{
- class AreaRenderer : public GeometryBatcher
- {
- private:
+ private:
- unsigned m_trianglesCount;
- unsigned m_areasCount;
- bool m_drawAreas;
+ unsigned m_trianglesCount;
+ unsigned m_areasCount;
+ bool m_drawAreas;
- public:
+ public:
- typedef GeometryBatcher base_t;
+ typedef gl::GeometryBatcher base_t;
- struct Params : base_t::Params
- {
- bool m_drawAreas;
- Params();
- };
+ struct Params : base_t::Params
+ {
+ bool m_drawAreas;
+ Params();
+ };
- AreaRenderer(Params const & params);
+ AreaRenderer(Params const & params);
- /// drawing triangles list. assuming that each 3 points compose a triangle
- void drawTrianglesList(m2::PointD const * points,
- size_t pointsCount,
- uint32_t styleID,
- double depth);
+ /// drawing triangles list. assuming that each 3 points compose a triangle
+ void drawTrianglesList(m2::PointD const * points,
+ size_t pointsCount,
+ uint32_t styleID,
+ double depth);
- void drawTrianglesFan(m2::PointF const * points,
- size_t pointsCount,
- uint32_t styleID,
- double depth);
+ void drawTrianglesFan(m2::PointF const * points,
+ size_t pointsCount,
+ uint32_t styleID,
+ double depth);
- void beginFrame();
- void endFrame();
- };
- }
+ void beginFrame();
+ void endFrame();
+ };
}
diff --git a/graphics/graphics.pro b/graphics/graphics.pro
index 2b391e915a..21f32c20f4 100644
--- a/graphics/graphics.pro
+++ b/graphics/graphics.pro
@@ -60,7 +60,9 @@ SOURCES += \
circle_element.cpp \
packets_queue.cpp \
display_list.cpp \
- data_formats.cpp
+ data_formats.cpp \
+ image_info.cpp \
+ image_renderer.cpp
HEADERS += \
internal/opengl.hpp \
@@ -114,7 +116,9 @@ HEADERS += \
circle_element.hpp \
packets_queue.hpp \
display_list.hpp \
- data_traits.hpp
+ data_traits.hpp \
+ image_renderer.hpp \
+ image_info.hpp
win32* {
SOURCES += internal/opengl_win32.cpp
diff --git a/graphics/graphics_tests/screengl_test.cpp b/graphics/graphics_tests/screengl_test.cpp
index 8f02659a61..40a6e16de6 100644
--- a/graphics/graphics_tests/screengl_test.cpp
+++ b/graphics/graphics_tests/screengl_test.cpp
@@ -1,6 +1,8 @@
#include "../../base/SRC_FIRST.hpp"
#include "../../3party/sgitess/interface.h"
+#include "../../geometry/transformations.hpp"
+
#include "../../graphics/screen.hpp"
#include "../../graphics/utils.hpp"
#include "../../graphics/internal/opengl.hpp"
@@ -1333,7 +1335,26 @@ namespace
}
};
- UNIT_TEST_GL(TestDrawPolyOverflow);
+ struct TestDrawImage
+ {
+ void DoDraw(shared_ptr<graphics::gl::Screen> const & p)
+ {
+ graphics::ImageInfo ii("test.png");
+
+ math::Matrix<double, 3, 3> m =
+ math::Shift(
+ math::Rotate(
+ math::Identity<double, 3>(),
+ math::pi / 4),
+ 100, 100);
+
+ p->drawImage(m,
+ p->skin()->mapImageInfo(ii),
+ graphics::maxDepth);
+ }
+ };
+
+/* UNIT_TEST_GL(TestDrawPolyOverflow);
UNIT_TEST_GL(TestDrawText);
UNIT_TEST_GL(TestDrawSingleSymbol);
UNIT_TEST_GL(TestDrawEmptySymbol);
@@ -1373,5 +1394,6 @@ namespace
UNIT_TEST_GL(TestDrawUtilsRect);
UNIT_TEST_GL(TestDrawUtilsRectFilledTexture);
UNIT_TEST_GL(TestDrawSymbolFiltering);
- UNIT_TEST_GL(TestDrawCircle);
+ UNIT_TEST_GL(TestDrawCircle);*/
+ UNIT_TEST_GL(TestDrawImage);
}
diff --git a/graphics/graphics_tests/shape_renderer_test.cpp b/graphics/graphics_tests/shape_renderer_test.cpp
index 878882487c..a5a68d97ab 100644
--- a/graphics/graphics_tests/shape_renderer_test.cpp
+++ b/graphics/graphics_tests/shape_renderer_test.cpp
@@ -2,7 +2,7 @@
#include "../shape_renderer.hpp"
#include "../../base/math.hpp"
-using namespace graphics::gl;
+using namespace graphics;
namespace
{
diff --git a/graphics/image_info.cpp b/graphics/image_info.cpp
new file mode 100644
index 0000000000..3449b40552
--- /dev/null
+++ b/graphics/image_info.cpp
@@ -0,0 +1,53 @@
+#include "image_info.hpp"
+#include "data_traits.hpp"
+
+#include "../platform/platform.hpp"
+
+#include "../coding/lodepng_io.hpp"
+
+namespace gil = boost::gil;
+
+namespace graphics
+{
+ m2::PointU const GetDimensions(string const & resourceName)
+ {
+ ReaderPtr<Reader> reader = GetPlatform().GetReader(resourceName);
+ gil::point2<ptrdiff_t> size = gil::lodepng_read_dimensions(reader);
+ return m2::PointU(size.x, size.y);
+ }
+
+ ImageInfo::ImageInfo(char const * resourceName)
+ {
+ m_size = GetDimensions(resourceName);
+ m_data.resize(m_size.x * m_size.y * sizeof(DATA_TRAITS::pixel_t));
+
+ DATA_TRAITS::view_t v = gil::interleaved_view(
+ m_size.x, m_size.y,
+ (DATA_TRAITS::pixel_t*)&m_data[0],
+ m_size.x * sizeof(DATA_TRAITS::pixel_t));
+
+ ReaderPtr<Reader> reader = GetPlatform().GetReader(resourceName);
+
+ gil::lodepng_read_and_convert_view(reader, v, DATA_TRAITS::color_converter());
+ }
+
+ unsigned ImageInfo::width() const
+ {
+ return m_size.x;
+ }
+
+ unsigned ImageInfo::height() const
+ {
+ return m_size.y;
+ }
+
+ unsigned char const * ImageInfo::data() const
+ {
+ return &m_data[0];
+ }
+
+ bool operator<(ImageInfo const & l, ImageInfo const & r)
+ {
+ return l.m_resourceName < r.m_resourceName;
+ }
+}
diff --git a/graphics/image_info.hpp b/graphics/image_info.hpp
new file mode 100644
index 0000000000..eba2440964
--- /dev/null
+++ b/graphics/image_info.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "../std/string.hpp"
+
+#include "../geometry/point2d.hpp"
+
+namespace graphics
+{
+ /// get dimensions of PNG image specified by it's resourceName.
+ m2::PointU const GetDimensions(string const & resourceName);
+
+ class ImageInfo
+ {
+ private:
+ vector<unsigned char> m_data;
+ m2::PointU m_size;
+ string m_resourceName;
+ public:
+ /// create ImageInfo from PNG resource
+ ImageInfo(char const * resourceName);
+
+ unsigned width() const;
+ unsigned height() const;
+
+ unsigned char const * data() const;
+
+ friend bool operator < (ImageInfo const & l, ImageInfo const & r);
+ };
+
+ bool operator < (ImageInfo const & l, ImageInfo const & r);
+}
diff --git a/graphics/image_renderer.cpp b/graphics/image_renderer.cpp
new file mode 100644
index 0000000000..b928b4ba0e
--- /dev/null
+++ b/graphics/image_renderer.cpp
@@ -0,0 +1,67 @@
+#include "image_renderer.hpp"
+
+#include "base_texture.hpp"
+#include "resource_style.hpp"
+#include "skin.hpp"
+
+#include "../base/assert.hpp"
+#include "../base/macros.hpp"
+
+namespace graphics
+{
+ ImageRenderer::ImageRenderer(base_t::Params const & p)
+ : base_t(p)
+ {}
+
+ void ImageRenderer::drawImage(math::Matrix<double, 3, 3> const & m,
+ uint32_t styleID,
+ double depth)
+ {
+ ResourceStyle const * style(skin()->fromID(styleID));
+
+ if (style == 0)
+ {
+ LOG(LINFO, ("drawImage: styleID=", styleID, "wasn't found on current skin"));
+ return;
+ }
+
+ ASSERT(style->m_cat == ResourceStyle::EImageStyle, ());
+
+ m2::RectI texRect(style->m_texRect);
+ texRect.Inflate(-1, -1);
+
+ m2::PointF pts[6] =
+ {
+ m2::PointF(m2::PointD(-1, -1) * m),
+ m2::PointF(m2::PointD(texRect.SizeX() - 1, -1) * m),
+ m2::PointF(m2::PointD(texRect.SizeX() - 1, texRect.SizeY() - 1) * m),
+ m2::PointF(m2::PointD(texRect.SizeX() - 1, texRect.SizeY() - 1) * m),
+ m2::PointF(m2::PointD(-1, texRect.SizeY() - 1) * m),
+ m2::PointF(m2::PointD(-1, -1) * m)
+ };
+
+ shared_ptr<gl::BaseTexture> const & texture = skin()->page(style->m_pipelineID)->texture();
+
+ m2::PointF texPts[6] =
+ {
+ m2::PointF(texRect.minX(), texRect.minY()),
+ m2::PointF(texRect.maxX(), texRect.minY()),
+ m2::PointF(texRect.maxX(), texRect.maxY()),
+ m2::PointF(texRect.maxX(), texRect.maxY()),
+ m2::PointF(texRect.minX(), texRect.maxY()),
+ m2::PointF(texRect.minX(), texRect.minY())
+ };
+
+ for (unsigned i = 0; i < ARRAY_SIZE(texPts); ++i)
+ texture->mapPixel(texPts[i].x, texPts[i].y);
+
+ m2::PointF normal(0, 0);
+
+ addTexturedListStrided(pts, sizeof(m2::PointF),
+ &normal, 0,
+ texPts, sizeof(m2::PointF),
+ 6,
+ depth,
+ style->m_pipelineID);
+ }
+}
diff --git a/graphics/image_renderer.hpp b/graphics/image_renderer.hpp
new file mode 100644
index 0000000000..8956deeac7
--- /dev/null
+++ b/graphics/image_renderer.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "shape_renderer.hpp"
+#include "defines.hpp"
+
+namespace graphics
+{
+ class ImageRenderer : public ShapeRenderer
+ {
+ private:
+ public:
+
+ typedef ShapeRenderer base_t;
+
+ ImageRenderer(base_t::Params const & p);
+
+ void drawImage(math::Matrix<double, 3, 3> const & m,
+ uint32_t styleID,
+ double depth);
+ };
+}
diff --git a/graphics/path_renderer.cpp b/graphics/path_renderer.cpp
index 2e6c78988e..46b75f2434 100644
--- a/graphics/path_renderer.cpp
+++ b/graphics/path_renderer.cpp
@@ -8,320 +8,317 @@
namespace graphics
{
- namespace gl
+ PathRenderer::Params::Params()
+ : m_drawPathes(true),
+ m_fastSolidPath(true)
+ {}
+
+ PathRenderer::PathRenderer(Params const & params)
+ : base_t(params),
+ m_drawPathes(params.m_drawPathes),
+ m_fastSolidPath(params.m_fastSolidPath)
+ {}
+
+ void PathRenderer::drawPath(m2::PointD const * points, size_t pointsCount, double offset, uint32_t styleID, double depth)
{
- PathRenderer::Params::Params()
- : m_drawPathes(true),
- m_fastSolidPath(true)
- {}
-
- PathRenderer::PathRenderer(Params const & params)
- : base_t(params),
- m_drawPathes(params.m_drawPathes),
- m_fastSolidPath(params.m_fastSolidPath)
- {}
-
- void PathRenderer::drawPath(m2::PointD const * points, size_t pointsCount, double offset, uint32_t styleID, double depth)
- {
- ++m_pathCount;
- m_pointsCount += pointsCount;
+ ++m_pathCount;
+ m_pointsCount += pointsCount;
- if (!m_drawPathes)
- return;
+ if (!m_drawPathes)
+ return;
- ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
- ASSERT_NOT_EQUAL(styleID, uint32_t(-1), ());
+ ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
+ ASSERT_NOT_EQUAL(styleID, uint32_t(-1), ());
- ResourceStyle const * style(skin()->fromID(styleID));
- if (style == 0)
- {
- LOG(LINFO, ("drawPath: styleID=", styleID, " wasn't found on current skin"));
- return;
- }
+ ResourceStyle const * style(skin()->fromID(styleID));
+ if (style == 0)
+ {
+ LOG(LINFO, ("drawPath: styleID=", styleID, " wasn't found on current skin"));
+ return;
+ }
- ASSERT(style->m_cat == ResourceStyle::ELineStyle, ());
+ ASSERT(style->m_cat == ResourceStyle::ELineStyle, ());
- LineStyle const * lineStyle = static_cast<LineStyle const *>(style);
- if (m_fastSolidPath && lineStyle->m_isSolid)
- {
- drawFastSolidPath(points, pointsCount, styleID, depth);
- return;
- }
+ LineStyle const * lineStyle = static_cast<LineStyle const *>(style);
+ if (m_fastSolidPath && lineStyle->m_isSolid)
+ {
+ drawFastSolidPath(points, pointsCount, styleID, depth);
+ return;
+ }
- float rawTileStartLen = 0;
+ float rawTileStartLen = 0;
- float rawTileLen = (float)lineStyle->rawTileLen();
+ float rawTileLen = (float)lineStyle->rawTileLen();
- if ((offset < 0) && (!lineStyle->m_isWrapped))
- offset = offset - rawTileLen * ceil(offset / rawTileLen);
+ if ((offset < 0) && (!lineStyle->m_isWrapped))
+ offset = offset - rawTileLen * ceil(offset / rawTileLen);
- bool skipToOffset = true;
+ bool skipToOffset = true;
- for (size_t i = 0; i < pointsCount - 1; ++i)
- {
- m2::PointD dir = points[i + 1] - points[i];
- dir *= 1.0 / dir.Length(m2::PointD(0, 0));
- m2::PointD norm(-dir.y, dir.x);
+ for (size_t i = 0; i < pointsCount - 1; ++i)
+ {
+ m2::PointD dir = points[i + 1] - points[i];
+ dir *= 1.0 / dir.Length(m2::PointD(0, 0));
+ m2::PointD norm(-dir.y, dir.x);
- /// The length of the current segment.
- float segLen = points[i + 1].Length(points[i]);
- /// The remaining length of the segment
- float segLenRemain = segLen;
+ /// The length of the current segment.
+ float segLen = points[i + 1].Length(points[i]);
+ /// The remaining length of the segment
+ float segLenRemain = segLen;
- if (skipToOffset)
+ if (skipToOffset)
+ {
+ offset -= segLen;
+ if (offset >= 0)
+ continue;
+ else
{
- offset -= segLen;
- if (offset >= 0)
- continue;
- else
- {
- skipToOffset = false;
- segLenRemain = -offset;
- }
+ skipToOffset = false;
+ segLenRemain = -offset;
}
+ }
- /// Geometry width. It's 1px wider than the pattern width.
- int geomWidth = static_cast<int>(lineStyle->m_penInfo.m_w) + 4 - 2 * aaShift();
- float geomHalfWidth = geomWidth / 2.0;
+ /// Geometry width. It's 1px wider than the pattern width.
+ int geomWidth = static_cast<int>(lineStyle->m_penInfo.m_w) + 4 - 2 * aaShift();
+ float geomHalfWidth = geomWidth / 2.0;
- /// Starting point of the tiles on this segment
- m2::PointF rawTileStartPt = points[i] + dir * (segLen - segLenRemain);
+ /// Starting point of the tiles on this segment
+ m2::PointF rawTileStartPt = points[i] + dir * (segLen - segLenRemain);
- /// Tiling procedes as following :
- /// The leftmost tile goes antialiased at left and non-antialiased at right.
- /// The inner tiles goes non-antialiased at both sides.
- /// The rightmost tile goes non-antialised at left and antialiased at right side.
+ /// Tiling procedes as following :
+ /// The leftmost tile goes antialiased at left and non-antialiased at right.
+ /// The inner tiles goes non-antialiased at both sides.
+ /// The rightmost tile goes non-antialised at left and antialiased at right side.
- /// Length of the actual pattern data being tiling(without antialiasing zones).
- rawTileLen = 0;
+ /// Length of the actual pattern data being tiling(without antialiasing zones).
+ rawTileLen = 0;
- shared_ptr<BaseTexture> texture = skin()->page(lineStyle->m_pipelineID)->texture();
+ shared_ptr<gl::BaseTexture> texture = skin()->page(lineStyle->m_pipelineID)->texture();
- if (!texture)
- {
- LOG(LDEBUG, ("returning as no texture is reserved"));
- return;
- }
+ if (!texture)
+ {
+ LOG(LDEBUG, ("returning as no texture is reserved"));
+ return;
+ }
- float texMaxY = lineStyle->m_texRect.maxY() - aaShift();
- float texMinY = lineStyle->m_texRect.minY() + aaShift();
+ float texMaxY = lineStyle->m_texRect.maxY() - aaShift();
+ float texMinY = lineStyle->m_texRect.minY() + aaShift();
- m2::PointF const fNorm = norm * geomHalfWidth; // enough to calc it once
+ m2::PointF const fNorm = norm * geomHalfWidth; // enough to calc it once
- while (segLenRemain > 0)
- {
- rawTileLen = lineStyle->m_isWrapped
- ? segLen
- : std::min(((float)lineStyle->rawTileLen() - rawTileStartLen), segLenRemain);
+ while (segLenRemain > 0)
+ {
+ rawTileLen = lineStyle->m_isWrapped
+ ? segLen
+ : std::min(((float)lineStyle->rawTileLen() - rawTileStartLen), segLenRemain);
- float texMinX = lineStyle->m_isWrapped ? 0 : lineStyle->m_texRect.minX() + 2 + rawTileStartLen;
- float texMaxX = texMinX + rawTileLen;
+ float texMinX = lineStyle->m_isWrapped ? 0 : lineStyle->m_texRect.minX() + 2 + rawTileStartLen;
+ float texMaxX = texMinX + rawTileLen;
- rawTileStartLen += rawTileLen;
- if (rawTileStartLen >= lineStyle->rawTileLen())
- rawTileStartLen -= lineStyle->rawTileLen();
- ASSERT(rawTileStartLen < lineStyle->rawTileLen(), ());
+ rawTileStartLen += rawTileLen;
+ if (rawTileStartLen >= lineStyle->rawTileLen())
+ rawTileStartLen -= lineStyle->rawTileLen();
+ ASSERT(rawTileStartLen < lineStyle->rawTileLen(), ());
- m2::PointF rawTileEndPt(rawTileStartPt.x + dir.x * rawTileLen, rawTileStartPt.y + dir.y * rawTileLen);
+ m2::PointF rawTileEndPt(rawTileStartPt.x + dir.x * rawTileLen, rawTileStartPt.y + dir.y * rawTileLen);
- m2::PointF coords[4] =
- {
- // vng: i think this "rawTileStartPt + fNorm" reading better, isn't it?
- m2::PointF(rawTileStartPt.x + fNorm.x, rawTileStartPt.y + fNorm.y),
- m2::PointF(rawTileStartPt.x - fNorm.x, rawTileStartPt.y - fNorm.y),
- m2::PointF(rawTileEndPt.x - fNorm.x, rawTileEndPt.y - fNorm.y),
- m2::PointF(rawTileEndPt.x + fNorm.x, rawTileEndPt.y + fNorm.y)
- };
+ m2::PointF coords[4] =
+ {
+ // vng: i think this "rawTileStartPt + fNorm" reading better, isn't it?
+ m2::PointF(rawTileStartPt.x + fNorm.x, rawTileStartPt.y + fNorm.y),
+ m2::PointF(rawTileStartPt.x - fNorm.x, rawTileStartPt.y - fNorm.y),
+ m2::PointF(rawTileEndPt.x - fNorm.x, rawTileEndPt.y - fNorm.y),
+ m2::PointF(rawTileEndPt.x + fNorm.x, rawTileEndPt.y + fNorm.y)
+ };
- m2::PointF texCoords[4] =
- {
- texture->mapPixel(m2::PointF(texMinX, texMinY)),
- texture->mapPixel(m2::PointF(texMinX, texMaxY)),
- texture->mapPixel(m2::PointF(texMaxX, texMaxY)),
- texture->mapPixel(m2::PointF(texMaxX, texMinY))
- };
+ m2::PointF texCoords[4] =
+ {
+ texture->mapPixel(m2::PointF(texMinX, texMinY)),
+ texture->mapPixel(m2::PointF(texMinX, texMaxY)),
+ texture->mapPixel(m2::PointF(texMaxX, texMaxY)),
+ texture->mapPixel(m2::PointF(texMaxX, texMinY))
+ };
- m2::PointF normals[4] =
- {
- m2::PointF(0, 0),
- m2::PointF(0, 0),
- m2::PointF(0, 0),
- m2::PointF(0, 0)
- };
+ m2::PointF normals[4] =
+ {
+ m2::PointF(0, 0),
+ m2::PointF(0, 0),
+ m2::PointF(0, 0),
+ m2::PointF(0, 0)
+ };
- addTexturedFan(coords, normals, texCoords, 4, depth, lineStyle->m_pipelineID);
+ addTexturedFan(coords, normals, texCoords, 4, depth, lineStyle->m_pipelineID);
- segLenRemain -= rawTileLen;
+ segLenRemain -= rawTileLen;
- rawTileStartPt = rawTileEndPt;
- }
+ rawTileStartPt = rawTileEndPt;
+ }
+
+ bool isColorJoin = lineStyle->m_isSolid ? true : lineStyle->m_penInfo.atDashOffset(rawTileLen);
+
+ /// Adding geometry for a line join between previous and current segment.
+ if ((i != pointsCount - 2) && (isColorJoin))
+ {
+ m2::PointD nextDir = points[i + 2] - points[i + 1];
+ nextDir *= 1.0 / nextDir.Length(m2::PointD(0, 0));
+ m2::PointD nextNorm(-nextDir.y, nextDir.x);
+
+ /// Computing the sin of angle between directions.
+ double alphaSin = dir.x * nextDir.y - dir.y * nextDir.x;
+ double alphaCos = dir.x * nextDir.x + dir.y * nextDir.y;
+ double alpha = atan2(alphaSin, alphaCos);
+ int angleSegCount = int(ceil(fabs(alpha) / (math::pi / 6)));
+ double angleStep = alpha / angleSegCount;
- bool isColorJoin = lineStyle->m_isSolid ? true : lineStyle->m_penInfo.atDashOffset(rawTileLen);
+ m2::PointD startVec;
- /// Adding geometry for a line join between previous and current segment.
- if ((i != pointsCount - 2) && (isColorJoin))
+ if (alpha > 0)
+ {
+ /// The outer site is on the prevNorm direction.
+ startVec = -norm;
+ }
+ else
{
- m2::PointD nextDir = points[i + 2] - points[i + 1];
- nextDir *= 1.0 / nextDir.Length(m2::PointD(0, 0));
- m2::PointD nextNorm(-nextDir.y, nextDir.x);
+ /// The outer site is on the -prevNorm direction
+ startVec = norm;
+ }
- /// Computing the sin of angle between directions.
- double alphaSin = dir.x * nextDir.y - dir.y * nextDir.x;
- double alphaCos = dir.x * nextDir.x + dir.y * nextDir.y;
- double alpha = atan2(alphaSin, alphaCos);
- int angleSegCount = int(ceil(fabs(alpha) / (math::pi / 6)));
- double angleStep = alpha / angleSegCount;
+ shared_ptr<gl::BaseTexture> texture = skin()->page(lineStyle->m_pipelineID)->texture();
- m2::PointD startVec;
+ if (!texture)
+ {
+ LOG(LDEBUG, ("returning as no texture is reserved"));
+ return;
+ }
- if (alpha > 0)
- {
- /// The outer site is on the prevNorm direction.
- startVec = -norm;
- }
- else
- {
- /// The outer site is on the -prevNorm direction
- startVec = norm;
- }
+ m2::PointF joinSegTex[3] =
+ {
+ texture->mapPixel(lineStyle->m_centerColorPixel),
+ texture->mapPixel(lineStyle->m_borderColorPixel),
+ texture->mapPixel(lineStyle->m_borderColorPixel)
+ };
- shared_ptr<BaseTexture> texture = skin()->page(lineStyle->m_pipelineID)->texture();
+ m2::PointD prevStartVec = startVec;
+ for (int j = 0; j < angleSegCount; ++j)
+ {
+ /// Rotate start vector to find another point on a join.
+ startVec.Rotate(angleStep);
- if (!texture)
+ /// Computing three points of a join segment.
+ m2::PointF joinSeg[3] =
{
- LOG(LDEBUG, ("returning as no texture is reserved"));
- return;
- }
+ m2::PointF(points[i + 1]),
+ m2::PointF(points[i + 1] + startVec * geomHalfWidth),
+ m2::PointF(points[i + 1] + prevStartVec * geomHalfWidth)
+ };
- m2::PointF joinSegTex[3] =
+ m2::PointF joinSegNormals[3] =
{
- texture->mapPixel(lineStyle->m_centerColorPixel),
- texture->mapPixel(lineStyle->m_borderColorPixel),
- texture->mapPixel(lineStyle->m_borderColorPixel)
+ m2::PointF(0, 0),
+ m2::PointF(0, 0),
+ m2::PointF(0, 0)
};
- m2::PointD prevStartVec = startVec;
- for (int j = 0; j < angleSegCount; ++j)
- {
- /// Rotate start vector to find another point on a join.
- startVec.Rotate(angleStep);
-
- /// Computing three points of a join segment.
- m2::PointF joinSeg[3] =
- {
- m2::PointF(points[i + 1]),
- m2::PointF(points[i + 1] + startVec * geomHalfWidth),
- m2::PointF(points[i + 1] + prevStartVec * geomHalfWidth)
- };
-
- m2::PointF joinSegNormals[3] =
- {
- m2::PointF(0, 0),
- m2::PointF(0, 0),
- m2::PointF(0, 0)
- };
-
- addTexturedFan(joinSeg, joinSegNormals, joinSegTex, 3, depth, lineStyle->m_pipelineID);
-
- prevStartVec = startVec;
- }
+ addTexturedFan(joinSeg, joinSegNormals, joinSegTex, 3, depth, lineStyle->m_pipelineID);
+
+ prevStartVec = startVec;
}
}
}
+ }
- void PathRenderer::drawFastSolidPath(m2::PointD const * points, size_t pointsCount, uint32_t styleID, double depth)
- {
- ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
- ResourceStyle const * style(skin()->fromID(styleID));
-
- ASSERT(style->m_cat == ResourceStyle::ELineStyle, ());
- LineStyle const * lineStyle = static_cast<LineStyle const *>(style);
-
- ASSERT(lineStyle->m_isSolid, ());
-
- for (size_t i = 0; i < pointsCount - 1; ++i)
- {
- m2::PointD dir = points[i + 1] - points[i];
- double len = dir.Length(m2::PointD(0, 0));
- dir *= 1.0 / len;
- m2::PointD norm(-dir.y, dir.x);
- m2::PointD const & nextPt = points[i + 1];
-
- float geomHalfWidth = (lineStyle->m_penInfo.m_w + 4 - aaShift() * 2) / 2.0;
-
- float texMinX = lineStyle->m_texRect.minX() + 1;
- float texMaxX = lineStyle->m_texRect.maxX() - 1;
+ void PathRenderer::drawFastSolidPath(m2::PointD const * points, size_t pointsCount, uint32_t styleID, double depth)
+ {
+ ASSERT_GREATER_OR_EQUAL(pointsCount, 2, ());
+ ResourceStyle const * style(skin()->fromID(styleID));
- float texMinY = lineStyle->m_texRect.maxY() - aaShift();
- float texMaxY = lineStyle->m_texRect.minY() + aaShift();
+ ASSERT(style->m_cat == ResourceStyle::ELineStyle, ());
+ LineStyle const * lineStyle = static_cast<LineStyle const *>(style);
- float texCenterX = (texMinX + texMaxX) / 2;
+ ASSERT(lineStyle->m_isSolid, ());
- m2::PointF const fNorm = norm * geomHalfWidth; // enough to calc it once
- m2::PointF const fDir(fNorm.y, -fNorm.x);
+ for (size_t i = 0; i < pointsCount - 1; ++i)
+ {
+ m2::PointD dir = points[i + 1] - points[i];
+ double len = dir.Length(m2::PointD(0, 0));
+ dir *= 1.0 / len;
+ m2::PointD norm(-dir.y, dir.x);
+ m2::PointD const & nextPt = points[i + 1];
- m2::PointF coords[8] =
- {
- /// left round cap
- points[i] - fDir + fNorm,
- points[i] - fDir - fNorm,
- points[i] + fNorm,
- /// inner part
- points[i] - fNorm,
- nextPt + fNorm,
- nextPt - fNorm,
- /// right round cap
- nextPt + fDir + fNorm,
- nextPt + fDir - fNorm
- };
+ float geomHalfWidth = (lineStyle->m_penInfo.m_w + 4 - aaShift() * 2) / 2.0;
- shared_ptr<BaseTexture> texture = skin()->page(lineStyle->m_pipelineID)->texture();
+ float texMinX = lineStyle->m_texRect.minX() + 1;
+ float texMaxX = lineStyle->m_texRect.maxX() - 1;
- if (!texture)
- {
- LOG(LDEBUG, ("returning as no texture is reserved"));
- return;
- }
+ float texMinY = lineStyle->m_texRect.maxY() - aaShift();
+ float texMaxY = lineStyle->m_texRect.minY() + aaShift();
- m2::PointF texCoords[8] =
- {
- texture->mapPixel(m2::PointF(texMinX, texMinY)),
- texture->mapPixel(m2::PointF(texMinX, texMaxY)),
- texture->mapPixel(m2::PointF(texCenterX, texMinY)),
- texture->mapPixel(m2::PointF(texCenterX, texMaxY)),
- texture->mapPixel(m2::PointF(texCenterX, texMinY)),
- texture->mapPixel(m2::PointF(texCenterX, texMaxY)),
- texture->mapPixel(m2::PointF(texMaxX, texMinY)),
- texture->mapPixel(m2::PointF(texMaxX, texMaxY))
- };
+ float texCenterX = (texMinX + texMaxX) / 2;
- m2::PointF normal(0, 0);
+ m2::PointF const fNorm = norm * geomHalfWidth; // enough to calc it once
+ m2::PointF const fDir(fNorm.y, -fNorm.x);
- addTexturedStripStrided(coords, sizeof(m2::PointF),
- &normal, 0,
- texCoords, sizeof(m2::PointF),
- 8,
- depth,
- lineStyle->m_pipelineID);
+ m2::PointF coords[8] =
+ {
+ /// left round cap
+ points[i] - fDir + fNorm,
+ points[i] - fDir - fNorm,
+ points[i] + fNorm,
+ /// inner part
+ points[i] - fNorm,
+ nextPt + fNorm,
+ nextPt - fNorm,
+ /// right round cap
+ nextPt + fDir + fNorm,
+ nextPt + fDir - fNorm
+ };
+
+ shared_ptr<gl::BaseTexture> texture = skin()->page(lineStyle->m_pipelineID)->texture();
+
+ if (!texture)
+ {
+ LOG(LDEBUG, ("returning as no texture is reserved"));
+ return;
}
- }
- void PathRenderer::beginFrame()
- {
- base_t::beginFrame();
- m_pathCount = 0;
- m_pointsCount = 0;
+ m2::PointF texCoords[8] =
+ {
+ texture->mapPixel(m2::PointF(texMinX, texMinY)),
+ texture->mapPixel(m2::PointF(texMinX, texMaxY)),
+ texture->mapPixel(m2::PointF(texCenterX, texMinY)),
+ texture->mapPixel(m2::PointF(texCenterX, texMaxY)),
+ texture->mapPixel(m2::PointF(texCenterX, texMinY)),
+ texture->mapPixel(m2::PointF(texCenterX, texMaxY)),
+ texture->mapPixel(m2::PointF(texMaxX, texMinY)),
+ texture->mapPixel(m2::PointF(texMaxX, texMaxY))
+ };
+
+ m2::PointF normal(0, 0);
+
+ addTexturedStripStrided(coords, sizeof(m2::PointF),
+ &normal, 0,
+ texCoords, sizeof(m2::PointF),
+ 8,
+ depth,
+ lineStyle->m_pipelineID);
}
+ }
- void PathRenderer::endFrame()
+ void PathRenderer::beginFrame()
+ {
+ base_t::beginFrame();
+ m_pathCount = 0;
+ m_pointsCount = 0;
+ }
+
+ void PathRenderer::endFrame()
+ {
+ if (isDebugging())
{
- if (isDebugging())
- {
- LOG(LINFO, ("drawing ", m_pathCount, " pathes, ", m_pointsCount, " points total"));
- }
- base_t::endFrame();
+ LOG(LINFO, ("drawing ", m_pathCount, " pathes, ", m_pointsCount, " points total"));
}
+ base_t::endFrame();
}
}
diff --git a/graphics/path_renderer.hpp b/graphics/path_renderer.hpp
index 648865ecf7..6f2c43be13 100644
--- a/graphics/path_renderer.hpp
+++ b/graphics/path_renderer.hpp
@@ -5,36 +5,33 @@
namespace graphics
{
- namespace gl
+ class PathRenderer : public AreaRenderer
{
- class PathRenderer : public AreaRenderer
- {
- private:
+ private:
- unsigned m_pathCount;
- unsigned m_pointsCount;
- bool m_drawPathes;
- bool m_fastSolidPath;
+ unsigned m_pathCount;
+ unsigned m_pointsCount;
+ bool m_drawPathes;
+ bool m_fastSolidPath;
- void drawFastSolidPath(m2::PointD const * points, size_t pointsCount, uint32_t styleID, double depth);
+ void drawFastSolidPath(m2::PointD const * points, size_t pointsCount, uint32_t styleID, double depth);
- public:
+ public:
- typedef AreaRenderer base_t;
+ typedef AreaRenderer base_t;
- struct Params : base_t::Params
- {
- bool m_drawPathes;
- bool m_fastSolidPath;
- Params();
- };
+ struct Params : base_t::Params
+ {
+ bool m_drawPathes;
+ bool m_fastSolidPath;
+ Params();
+ };
- PathRenderer(Params const & params);
+ PathRenderer(Params const & params);
- void drawPath(m2::PointD const * points, size_t pointsCount, double offset, uint32_t styleID, double depth);
+ void drawPath(m2::PointD const * points, size_t pointsCount, double offset, uint32_t styleID, double depth);
- void beginFrame();
- void endFrame();
- };
- }
+ void beginFrame();
+ void endFrame();
+ };
}
diff --git a/graphics/pen_info.hpp b/graphics/pen_info.hpp
index b1645b668d..0911011dcc 100644
--- a/graphics/pen_info.hpp
+++ b/graphics/pen_info.hpp
@@ -8,11 +8,11 @@
namespace graphics
{
- /// definition of the line style pattern used as a texture-cache-key
+ /// definition of the line style pattern
+ /// used as a texture-cache-key
struct PenInfo
{
typedef buffer_vector<double, 16> TPattern;
-// typedef vector<double> TPattern;
Color m_color;
double m_w;
TPattern m_pat;
diff --git a/graphics/resource_style.cpp b/graphics/resource_style.cpp
index 5b243da76a..78ac1f883c 100644
--- a/graphics/resource_style.cpp
+++ b/graphics/resource_style.cpp
@@ -60,4 +60,48 @@ namespace graphics
for (size_t x = 0; x < r.SizeX(); ++x)
v(x, y) = px;
}
+
+ ImageStyle::ImageStyle(m2::RectU const & texRect,
+ int pipelineID,
+ ImageInfo const & ii)
+ : ResourceStyle(EImageStyle, texRect, pipelineID),
+ m_ii(ii)
+ {}
+
+ void ImageStyle::render(void * dst)
+ {
+ m2::RectU const & r = m_texRect;
+
+ DATA_TRAITS::view_t dstV = gil::interleaved_view(
+ r.SizeX(), r.SizeY(),
+ (DATA_TRAITS::pixel_t*)dst,
+ sizeof(DATA_TRAITS::pixel_t) * r.SizeX()
+ );
+
+ DATA_TRAITS::view_t srcV = gil::interleaved_view(
+ r.SizeX() - 4, r.SizeY() - 4,
+ (DATA_TRAITS::pixel_t*)m_ii.data(),
+ sizeof(DATA_TRAITS::pixel_t) * (r.SizeX() - 4)
+ );
+
+ DATA_TRAITS::pixel_t borderPixel = DATA_TRAITS::createPixel(Color(255, 0, 0, 255));
+
+ for (unsigned y = 0; y < 2; ++y)
+ {
+ dstV(0, y) = borderPixel;
+ dstV(1, y) = borderPixel;
+ dstV(r.SizeX() - 2, y) = borderPixel;
+ dstV(r.SizeX() - 1, y) = borderPixel;
+ }
+
+ for (unsigned y = r.SizeY() - 2; y < r.SizeY(); ++y)
+ {
+ dstV(0, y) = borderPixel;
+ dstV(1, y) = borderPixel;
+ dstV(r.SizeX() - 2, y) = borderPixel;
+ dstV(r.SizeX() - 1, y) = borderPixel;
+ }
+
+ gil::copy_pixels(srcV, gil::subimage_view(dstV, 2, 2, r.SizeX() - 4, r.SizeY() - 4));
+ }
}
diff --git a/graphics/resource_style.hpp b/graphics/resource_style.hpp
index ed17b5f79b..75e4bade8e 100644
--- a/graphics/resource_style.hpp
+++ b/graphics/resource_style.hpp
@@ -2,6 +2,7 @@
#include "pen_info.hpp"
#include "circle_info.hpp"
+#include "image_info.hpp"
#include "../geometry/rect2d.hpp"
@@ -20,6 +21,7 @@ namespace graphics
EGlyphStyle,
EPointStyle,
ECircleStyle,
+ EImageStyle,
EUnknownStyle
};
@@ -28,23 +30,29 @@ namespace graphics
int m_pipelineID;
ResourceStyle();
- ResourceStyle(m2::RectU const & texRect, int pipelineID);
+ ResourceStyle(m2::RectU const & texRect,
+ int pipelineID);
virtual ~ResourceStyle();
virtual void render(void * dst) = 0;
protected:
- ResourceStyle(Category cat, m2::RectU const & texRect, int pipelineID);
+ ResourceStyle(Category cat,
+ m2::RectU const & texRect,
+ int pipelineID);
};
struct LineStyle : public ResourceStyle
{
bool m_isWrapped;
bool m_isSolid;
- graphics::PenInfo m_penInfo;
+ PenInfo m_penInfo;
m2::PointU m_centerColorPixel;
m2::PointU m_borderColorPixel;
- LineStyle(bool isWrapped, m2::RectU const & texRect, int pipelineID, graphics::PenInfo const & penInfo);
+ LineStyle(bool isWrapped,
+ m2::RectU const & texRect,
+ int pipelineID,
+ PenInfo const & penInfo);
/// with antialiasing zones
double geometryTileLen() const;
@@ -60,7 +68,9 @@ namespace graphics
struct GlyphStyle : public ResourceStyle
{
shared_ptr<GlyphInfo> m_gi;
- GlyphStyle(m2::RectU const & texRect, int pipelineID, shared_ptr<GlyphInfo> const & gi);
+ GlyphStyle(m2::RectU const & texRect,
+ int pipelineID,
+ shared_ptr<GlyphInfo> const & gi);
void render(void * dst);
};
@@ -68,23 +78,39 @@ namespace graphics
struct PointStyle : public ResourceStyle
{
string m_styleName;
- PointStyle(m2::RectU const & texRect, int pipelineID, string const & styleName);
+ PointStyle(m2::RectU const & texRect,
+ int pipelineID,
+ string const & styleName);
void render(void * dst);
};
struct CircleStyle : public ResourceStyle
{
- graphics::CircleInfo m_ci;
- CircleStyle(m2::RectU const & texRect, int pipelineID, graphics::CircleInfo const & ci);
+ CircleInfo m_ci;
+ CircleStyle(m2::RectU const & texRect,
+ int pipelineID,
+ CircleInfo const & ci);
void render(void * dst);
};
struct ColorStyle : public ResourceStyle
{
- graphics::Color m_c;
- ColorStyle(m2::RectU const & texRect, int pipelineID, graphics::Color const & c);
+ Color m_c;
+ ColorStyle(m2::RectU const & texRect,
+ int pipelineID,
+ Color const & c);
+
+ void render(void * dst);
+ };
+
+ struct ImageStyle : public ResourceStyle
+ {
+ ImageInfo m_ii;
+ ImageStyle(m2::RectU const & texRect,
+ int pipelineID,
+ ImageInfo const & ii);
void render(void * dst);
};
diff --git a/graphics/shape_renderer.cpp b/graphics/shape_renderer.cpp
index fbeec593d1..860dddaf89 100644
--- a/graphics/shape_renderer.cpp
+++ b/graphics/shape_renderer.cpp
@@ -11,159 +11,157 @@
namespace graphics
{
- namespace gl
+ ShapeRenderer::ShapeRenderer(base_t::Params const & params) : base_t(params)
{
- ShapeRenderer::ShapeRenderer(base_t::Params const & params) : base_t(params)
- {
- }
-
- void ShapeRenderer::drawConvexPolygon(m2::PointF const * pts, size_t ptsCount, graphics::Color const & color, double depth)
- {
- uint32_t styleID = skin()->mapColor(color);
+ }
- if (styleID == skin()->invalidHandle())
- {
- LOG(LINFO, ("cannot map color"));
- return;
- }
+ void ShapeRenderer::drawConvexPolygon(m2::PointF const * pts, size_t ptsCount, graphics::Color const & color, double depth)
+ {
+ uint32_t styleID = skin()->mapColor(color);
- drawTrianglesFan(pts, ptsCount, styleID, depth);
+ if (styleID == skin()->invalidHandle())
+ {
+ LOG(LINFO, ("cannot map color"));
+ return;
}
- void ShapeRenderer::drawArc(m2::PointD const & center, double startA, double endA, double r, graphics::Color const & c, double depth)
- {
- vector<m2::PointD> pts;
- approximateArc(center, startA, endA, r, pts);
+ drawTrianglesFan(pts, ptsCount, styleID, depth);
+ }
- if (pts.size() < 2)
- return;
+ void ShapeRenderer::drawArc(m2::PointD const & center, double startA, double endA, double r, graphics::Color const & c, double depth)
+ {
+ vector<m2::PointD> pts;
+ approximateArc(center, startA, endA, r, pts);
- drawPath(&pts[0], pts.size(), 0, skin()->mapPenInfo(graphics::PenInfo(c, 3, 0, 0, 0)), depth);
- }
+ if (pts.size() < 2)
+ return;
- void ShapeRenderer::approximateArc(m2::PointD const & center, double startA, double endA, double r, vector<m2::PointD> & pts)
- {
- double sectorA = math::pi / 30.0;
- size_t const sectorsCount = static_cast<size_t>(floor(fabs(endA - startA) / sectorA));
- sectorA = (endA - startA) / sectorsCount;
+ drawPath(&pts[0], pts.size(), 0, skin()->mapPenInfo(graphics::PenInfo(c, 3, 0, 0, 0)), depth);
+ }
- for (size_t i = 0; i <= sectorsCount; ++i)
- pts.push_back(m2::Shift(m2::Rotate(m2::PointD(r, 0), startA + i * sectorA), center));
- }
+ void ShapeRenderer::approximateArc(m2::PointD const & center, double startA, double endA, double r, vector<m2::PointD> & pts)
+ {
+ double sectorA = math::pi / 30.0;
+ size_t const sectorsCount = static_cast<size_t>(floor(fabs(endA - startA) / sectorA));
+ sectorA = (endA - startA) / sectorsCount;
- void ShapeRenderer::drawSector(m2::PointD const & center, double startA, double endA, double r, graphics::Color const & c, double depth)
- {
- vector<m2::PointD> pts;
+ for (size_t i = 0; i <= sectorsCount; ++i)
+ pts.push_back(m2::Shift(m2::Rotate(m2::PointD(r, 0), startA + i * sectorA), center));
+ }
- pts.push_back(center);
- approximateArc(center, startA, endA, r, pts);
- pts.push_back(center);
+ void ShapeRenderer::drawSector(m2::PointD const & center, double startA, double endA, double r, graphics::Color const & c, double depth)
+ {
+ vector<m2::PointD> pts;
- if (pts.size() < 3)
- return;
+ pts.push_back(center);
+ approximateArc(center, startA, endA, r, pts);
+ pts.push_back(center);
- drawPath(&pts[0], pts.size(), 0, skin()->mapPenInfo(graphics::PenInfo(c, 2, 0, 0, 0)), depth);
- }
+ if (pts.size() < 3)
+ return;
- void ShapeRenderer::fillSector(m2::PointD const & center, double startA, double endA, double r, graphics::Color const & c, double depth)
- {
- vector<m2::PointD> arcPts;
+ drawPath(&pts[0], pts.size(), 0, skin()->mapPenInfo(graphics::PenInfo(c, 2, 0, 0, 0)), depth);
+ }
- arcPts.push_back(center);
- approximateArc(center, startA, endA, r, arcPts);
+ void ShapeRenderer::fillSector(m2::PointD const & center, double startA, double endA, double r, graphics::Color const & c, double depth)
+ {
+ vector<m2::PointD> arcPts;
- if (arcPts.size() < 3)
- return;
+ arcPts.push_back(center);
+ approximateArc(center, startA, endA, r, arcPts);
- m2::PointD pt0 = arcPts[0];
- m2::PointD pt1 = arcPts[1];
+ if (arcPts.size() < 3)
+ return;
- vector<m2::PointD> sectorPts;
+ m2::PointD pt0 = arcPts[0];
+ m2::PointD pt1 = arcPts[1];
- for (size_t i = 2; i < arcPts.size(); ++i)
- {
- sectorPts.push_back(pt0);
- sectorPts.push_back(pt1);
- sectorPts.push_back(arcPts[i]);
- pt1 = arcPts[i];
- }
+ vector<m2::PointD> sectorPts;
- drawTrianglesList(&sectorPts[0], sectorPts.size(), skin()->mapColor(c), depth);
+ for (size_t i = 2; i < arcPts.size(); ++i)
+ {
+ sectorPts.push_back(pt0);
+ sectorPts.push_back(pt1);
+ sectorPts.push_back(arcPts[i]);
+ pt1 = arcPts[i];
}
- void ShapeRenderer::drawRectangle(m2::AnyRectD const & r, graphics::Color const & c, double depth)
+ drawTrianglesList(&sectorPts[0], sectorPts.size(), skin()->mapColor(c), depth);
+ }
+
+ void ShapeRenderer::drawRectangle(m2::AnyRectD const & r, graphics::Color const & c, double depth)
+ {
+ ResourceStyle const * style = skin()->fromID(skin()->mapColor(c));
+
+ if (style == 0)
{
- ResourceStyle const * style = skin()->fromID(skin()->mapColor(c));
+ LOG(LINFO, ("cannot map color"));
+ return;
+ }
- if (style == 0)
- {
- LOG(LINFO, ("cannot map color"));
- return;
- }
+ m2::PointD rectPts[4];
- m2::PointD rectPts[4];
+ r.GetGlobalPoints(rectPts);
+ swap(rectPts[2], rectPts[3]);
- r.GetGlobalPoints(rectPts);
- swap(rectPts[2], rectPts[3]);
+ m2::PointF rectPtsF[4];
+ for (int i = 0; i < 4; ++i)
+ rectPtsF[i] = m2::PointF(rectPts[i].x, rectPts[i].y);
- m2::PointF rectPtsF[4];
- for (int i = 0; i < 4; ++i)
- rectPtsF[i] = m2::PointF(rectPts[i].x, rectPts[i].y);
+ shared_ptr<gl::BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
- shared_ptr<BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
+ if (!texture)
+ {
+ LOG(LDEBUG, ("returning as no texture is reserved"));
+ return;
+ }
- if (!texture)
- {
- LOG(LDEBUG, ("returning as no texture is reserved"));
- return;
- }
+ m2::PointF texPt = texture->mapPixel(m2::RectF(style->m_texRect).Center());
- m2::PointF texPt = texture->mapPixel(m2::RectF(style->m_texRect).Center());
+ m2::PointF normal(0, 0);
- m2::PointF normal(0, 0);
+ addTexturedStripStrided(
+ rectPtsF,
+ sizeof(m2::PointF),
+ &normal,
+ 0,
+ &texPt,
+ 0,
+ 4,
+ depth,
+ style->m_pipelineID);
+ }
- addTexturedStripStrided(
- rectPtsF,
- sizeof(m2::PointF),
- &normal,
- 0,
- &texPt,
- 0,
- 4,
- depth,
- style->m_pipelineID);
- }
+ void ShapeRenderer::drawRectangle(m2::RectD const & r, graphics::Color const & c, double depth)
+ {
+ ResourceStyle const * style = skin()->fromID(skin()->mapColor(c));
- void ShapeRenderer::drawRectangle(m2::RectD const & r, graphics::Color const & c, double depth)
+ if (style == 0)
{
- ResourceStyle const * style = skin()->fromID(skin()->mapColor(c));
-
- if (style == 0)
- {
- LOG(LINFO, ("cannot map color"));
- return;
- }
+ LOG(LINFO, ("cannot map color"));
+ return;
+ }
- m2::PointF rectPts[4] = {
- m2::PointF(r.minX(), r.minY()),
- m2::PointF(r.maxX(), r.minY()),
- m2::PointF(r.minX(), r.maxY()),
- m2::PointF(r.maxX(), r.maxY())
- };
+ m2::PointF rectPts[4] = {
+ m2::PointF(r.minX(), r.minY()),
+ m2::PointF(r.maxX(), r.minY()),
+ m2::PointF(r.minX(), r.maxY()),
+ m2::PointF(r.maxX(), r.maxY())
+ };
- shared_ptr<BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
+ shared_ptr<gl::BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
- if (!texture)
- {
- LOG(LDEBUG, ("returning as no texture is reserved"));
- return;
- }
+ if (!texture)
+ {
+ LOG(LDEBUG, ("returning as no texture is reserved"));
+ return;
+ }
- m2::PointF texPt = texture->mapPixel(m2::RectF(style->m_texRect).Center());
+ m2::PointF texPt = texture->mapPixel(m2::RectF(style->m_texRect).Center());
- m2::PointF normal(0, 0);
+ m2::PointF normal(0, 0);
- addTexturedStripStrided(
+ addTexturedStripStrided(
rectPts,
sizeof(m2::PointF),
&normal,
@@ -174,74 +172,74 @@ namespace graphics
depth,
style->m_pipelineID
);
- }
+ }
- void ShapeRenderer::drawRoundedRectangle(m2::RectD const & r, double rad, graphics::Color const & c, double depth)
- {
- ResourceStyle const * style = skin()->fromID(skin()->mapColor(c));
+ void ShapeRenderer::drawRoundedRectangle(m2::RectD const & r, double rad, graphics::Color const & c, double depth)
+ {
+ ResourceStyle const * style = skin()->fromID(skin()->mapColor(c));
- if (style == 0)
- {
- LOG(LINFO, ("cannot map color"));
- return;
- }
+ if (style == 0)
+ {
+ LOG(LINFO, ("cannot map color"));
+ return;
+ }
- shared_ptr<BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
+ shared_ptr<gl::BaseTexture> texture = skin()->page(style->m_pipelineID)->texture();
- if (!texture)
- {
- LOG(LDEBUG, ("returning as no texture is reserved"));
- return;
- }
+ if (!texture)
+ {
+ LOG(LDEBUG, ("returning as no texture is reserved"));
+ return;
+ }
- m2::PointF texPt = texture->mapPixel(m2::RectF(style->m_texRect).Center());
+ m2::PointF texPt = texture->mapPixel(m2::RectF(style->m_texRect).Center());
- vector<m2::PointD> seg00;
- vector<m2::PointD> seg10;
- vector<m2::PointD> seg11;
- vector<m2::PointD> seg01;
+ vector<m2::PointD> seg00;
+ vector<m2::PointD> seg10;
+ vector<m2::PointD> seg11;
+ vector<m2::PointD> seg01;
- approximateArc(m2::PointD(r.minX() + rad, r.minY() + rad),
- math::pi,
- 3 * math::pi / 2,
- rad,
- seg00);
+ approximateArc(m2::PointD(r.minX() + rad, r.minY() + rad),
+ math::pi,
+ 3 * math::pi / 2,
+ rad,
+ seg00);
- approximateArc(m2::PointD(r.minX() + rad, r.maxY() - rad),
- math::pi / 2,
- math::pi,
- rad,
- seg01);
+ approximateArc(m2::PointD(r.minX() + rad, r.maxY() - rad),
+ math::pi / 2,
+ math::pi,
+ rad,
+ seg01);
- approximateArc(m2::PointD(r.maxX() - rad, r.maxY() - rad),
- 0,
- math::pi / 2,
- rad,
- seg11);
+ approximateArc(m2::PointD(r.maxX() - rad, r.maxY() - rad),
+ 0,
+ math::pi / 2,
+ rad,
+ seg11);
- approximateArc(m2::PointD(r.maxX() - rad, r.minY() + rad),
- 3 * math::pi / 2,
- math::pi * 2,
- rad,
- seg10);
+ approximateArc(m2::PointD(r.maxX() - rad, r.minY() + rad),
+ 3 * math::pi / 2,
+ math::pi * 2,
+ rad,
+ seg10);
- vector<m2::PointF> pts;
+ vector<m2::PointF> pts;
- for (unsigned i = 0; i < seg11.size(); ++i)
- pts.push_back(m2::PointF(seg11[i]));
+ for (unsigned i = 0; i < seg11.size(); ++i)
+ pts.push_back(m2::PointF(seg11[i]));
- for (unsigned i = 0; i < seg01.size(); ++i)
- pts.push_back(m2::PointF(seg01[i]));
+ for (unsigned i = 0; i < seg01.size(); ++i)
+ pts.push_back(m2::PointF(seg01[i]));
- for (unsigned i = 0; i < seg00.size(); ++i)
- pts.push_back(m2::PointF(seg00[i]));
+ for (unsigned i = 0; i < seg00.size(); ++i)
+ pts.push_back(m2::PointF(seg00[i]));
- for (unsigned i = 0; i < seg10.size(); ++i)
- pts.push_back(m2::PointF(seg10[i]));
+ for (unsigned i = 0; i < seg10.size(); ++i)
+ pts.push_back(m2::PointF(seg10[i]));
- m2::PointF normal(0, 0);
+ m2::PointF normal(0, 0);
- addTexturedFanStrided(
+ addTexturedFanStrided(
&pts[0],
sizeof(m2::PointF),
&normal,
@@ -252,7 +250,5 @@ namespace graphics
depth,
style->m_pipelineID
);
- }
-
}
}
diff --git a/graphics/shape_renderer.hpp b/graphics/shape_renderer.hpp
index cea20fab0d..e9e685e166 100644
--- a/graphics/shape_renderer.hpp
+++ b/graphics/shape_renderer.hpp
@@ -6,60 +6,57 @@
namespace graphics
{
- namespace gl
+ class ShapeRenderer : public PathRenderer
{
- class ShapeRenderer : public PathRenderer
- {
- private:
- typedef PathRenderer base_t;
- public:
-
- ShapeRenderer(base_t::Params const & params);
-
- void drawConvexPolygon(m2::PointF const * points,
- size_t pointsCount,
- graphics::Color const & color,
- double depth);
-
- static void approximateArc(m2::PointD const & center,
- double startA,
- double endA,
- double r,
- vector<m2::PointD> & pts);
-
- void drawArc(m2::PointD const & center,
- double startA,
- double endA,
- double r,
- graphics::Color const & c,
- double depth);
-
- void drawSector(m2::PointD const & center,
- double startA,
- double endA,
- double r,
- graphics::Color const & c,
- double depth);
-
- void fillSector(m2::PointD const & center,
- double startA,
- double endA,
- double r,
- graphics::Color const & c,
- double depth);
-
- void drawRectangle(m2::AnyRectD const & r,
- graphics::Color const & c,
- double depth);
-
- void drawRectangle(m2::RectD const & r,
- graphics::Color const & c,
- double depth);
-
- void drawRoundedRectangle(m2::RectD const & r,
- double rad,
- graphics::Color const & c,
- double depth);
- };
- }
+ private:
+ typedef PathRenderer base_t;
+ public:
+
+ ShapeRenderer(base_t::Params const & params);
+
+ void drawConvexPolygon(m2::PointF const * points,
+ size_t pointsCount,
+ Color const & color,
+ double depth);
+
+ static void approximateArc(m2::PointD const & center,
+ double startA,
+ double endA,
+ double r,
+ vector<m2::PointD> & pts);
+
+ void drawArc(m2::PointD const & center,
+ double startA,
+ double endA,
+ double r,
+ Color const & c,
+ double depth);
+
+ void drawSector(m2::PointD const & center,
+ double startA,
+ double endA,
+ double r,
+ Color const & c,
+ double depth);
+
+ void fillSector(m2::PointD const & center,
+ double startA,
+ double endA,
+ double r,
+ Color const & c,
+ double depth);
+
+ void drawRectangle(m2::AnyRectD const & r,
+ Color const & c,
+ double depth);
+
+ void drawRectangle(m2::RectD const & r,
+ Color const & c,
+ double depth);
+
+ void drawRoundedRectangle(m2::RectD const & r,
+ double rad,
+ Color const & c,
+ double depth);
+ };
}
diff --git a/graphics/skin.cpp b/graphics/skin.cpp
index caef41da1f..bc6ae971b5 100644
--- a/graphics/skin.cpp
+++ b/graphics/skin.cpp
@@ -149,6 +149,23 @@ namespace graphics
return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapCircleInfo(circleInfo));
}
+ uint32_t Skin::mapImageInfo(ImageInfo const & imageInfo)
+ {
+ uint32_t res = invalidPageHandle();
+
+ for (uint8_t i = 0; i < m_pages.size(); ++i)
+ {
+ res = m_pages[i]->findImageInfo(imageInfo);
+ if (res != invalidPageHandle())
+ return packID(i, res);
+ }
+
+ if (!m_pages[m_dynamicPage]->hasRoom(imageInfo))
+ flushDynamicPage();
+
+ return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapImageInfo(imageInfo));
+ }
+
bool Skin::mapPenInfo(PenInfo const * penInfos, uint32_t * styleIDS, size_t count)
{
int startDynamicPage = m_dynamicPage;
diff --git a/graphics/skin.hpp b/graphics/skin.hpp
index e9bd4277ee..4b609d62e1 100644
--- a/graphics/skin.hpp
+++ b/graphics/skin.hpp
@@ -28,6 +28,7 @@ namespace graphics
struct ResourceStyle;
struct PenInfo;
struct CircleInfo;
+ struct ImageInfo;
struct Color;
struct GlyphKey;
class GlyphCache;
@@ -125,6 +126,10 @@ namespace graphics
/// if found - return id
/// if not - pack and return id
uint32_t mapCircleInfo(CircleInfo const & circleInfo);
+ /// find imageInfo on texture
+ /// if found - return id
+ /// if not - pack and return id
+ uint32_t mapImageInfo(ImageInfo const & imageInfo);
/// adding function which will be called, when some SkinPage
/// is getting cleared.
diff --git a/graphics/skin_page.cpp b/graphics/skin_page.cpp
index 98cf268d31..bb85d81a30 100644
--- a/graphics/skin_page.cpp
+++ b/graphics/skin_page.cpp
@@ -49,6 +49,7 @@ namespace graphics
clearColorHandles();
clearFontHandles();
clearCircleInfoHandles();
+ clearImageInfoHandles();
m_packer.reset();
}
@@ -96,6 +97,49 @@ namespace graphics
m_glyphMap.clear();
}
+ void SkinPage::clearImageInfoHandles()
+ {
+ for (TImageInfoMap::const_iterator it = m_imageInfoMap.begin();
+ it != m_imageInfoMap.end();
+ ++it)
+ m_styles.erase(it->second);
+
+ m_imageInfoMap.clear();
+ }
+
+ uint32_t SkinPage::findImageInfo(ImageInfo const & ii) const
+ {
+ TImageInfoMap::const_iterator it = m_imageInfoMap.find(ii);
+ if (it == m_imageInfoMap.end())
+ return m_packer.invalidHandle();
+ else
+ return it->second;
+ }
+
+ uint32_t SkinPage::mapImageInfo(ImageInfo const & ii)
+ {
+ uint32_t foundHandle = findImageInfo(ii);
+ if (foundHandle != m_packer.invalidHandle())
+ return foundHandle;
+
+ m2::Packer::handle_t h = m_packer.pack(ii.width() + 4, ii.height() + 4);
+
+ m_imageInfoMap[ii] = h;
+
+ m2::RectU texRect = m_packer.find(h).second;
+ shared_ptr<ResourceStyle> imageStyle(new ImageStyle(texRect, m_pipelineID, ii));
+
+ m_styles[h] = imageStyle;
+ m_uploadQueue.push_back(imageStyle);
+
+ return h;
+ }
+
+ bool SkinPage::hasRoom(ImageInfo const & ii) const
+ {
+ return m_packer.hasRoom(ii.width() + 4, ii.height() + 4);
+ }
+
uint32_t SkinPage::findColor(graphics::Color const & c) const
{
TColorMap::const_iterator it = m_colorMap.find(c);
diff --git a/graphics/skin_page.hpp b/graphics/skin_page.hpp
index 90e693ae4a..3a370a21b8 100644
--- a/graphics/skin_page.hpp
+++ b/graphics/skin_page.hpp
@@ -9,6 +9,7 @@
#include "circle_info.hpp"
#include "color.hpp"
#include "glyph_cache.hpp"
+#include "image_info.hpp"
#include "packets_queue.hpp"
namespace graphics
@@ -59,6 +60,9 @@ namespace graphics
typedef map<GlyphKey, uint32_t> TGlyphMap;
TGlyphMap m_glyphMap;
+ typedef map<ImageInfo, uint32_t> TImageInfoMap;
+ TImageInfoMap m_imageInfoMap;
+
/// made mutable to implement lazy reservation of texture
/// @{
mutable shared_ptr<gl::BaseTexture> m_texture;
@@ -84,6 +88,7 @@ namespace graphics
void clearPenInfoHandles();
void clearFontHandles();
void clearCircleInfoHandles();
+ void clearImageInfoHandles();
void clearHandles();
@@ -113,6 +118,10 @@ namespace graphics
void resetTexture();
void createPacker();
+ uint32_t findImageInfo(ImageInfo const & ii) const;
+ uint32_t mapImageInfo(ImageInfo const & ii);
+ bool hasRoom(ImageInfo const & ii) const;
+
uint32_t findColor(Color const & c) const;
uint32_t mapColor(Color const & c);
bool hasRoom(Color const & c) const;
diff --git a/graphics/text_renderer.hpp b/graphics/text_renderer.hpp
index 5f8e45af22..334353818d 100644
--- a/graphics/text_renderer.hpp
+++ b/graphics/text_renderer.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "shape_renderer.hpp"
+#include "image_renderer.hpp"
#include "defines.hpp"
#include "font_desc.hpp"
#include "text_element.hpp"
@@ -14,7 +14,7 @@ namespace graphics
{
namespace gl
{
- class TextRenderer : public ShapeRenderer
+ class TextRenderer : public ImageRenderer
{
private:
@@ -23,7 +23,7 @@ namespace graphics
public:
- typedef ShapeRenderer base_t;
+ typedef ImageRenderer base_t;
struct Params : base_t::Params
{
diff --git a/graphics/texture.hpp b/graphics/texture.hpp
index 6bfa592153..49861e9f9d 100644
--- a/graphics/texture.hpp
+++ b/graphics/texture.hpp
@@ -2,6 +2,7 @@
#include "managed_texture.hpp"
#include "data_traits.hpp"
+#include "image_info.hpp"
#include "../platform/platform.hpp"
@@ -18,12 +19,6 @@ namespace graphics
template <typename Traits, bool IsBacked>
class Texture{};
- inline m2::PointU const GetDimensions(string const & fileName)
- {
- ReaderPtr<Reader> reader = GetPlatform().GetReader(fileName);
- gil::point2<ptrdiff_t> size = gil::lodepng_read_dimensions(reader);
- return m2::PointU(size.x, size.y);
- }
template <typename Traits>
class Texture<Traits, false> : public BaseTexture
diff --git a/qt_tstfrm/macros.hpp b/qt_tstfrm/macros.hpp
index ac85415562..fc249faf64 100644
--- a/qt_tstfrm/macros.hpp
+++ b/qt_tstfrm/macros.hpp
@@ -111,10 +111,7 @@ public:
virtual void DoDraw(shared_ptr<graphics::gl::Screen> p)
{
- p->beginFrame();
- p->clear(graphics::gl::Screen::s_bgColor);
test.DoDraw(p);
- p->endFrame();
}
virtual void DoResize(int, int)
{
diff --git a/qt_tstfrm/tstwidgets.cpp b/qt_tstfrm/tstwidgets.cpp
index c7f69d3156..7d6ab3a293 100644
--- a/qt_tstfrm/tstwidgets.cpp
+++ b/qt_tstfrm/tstwidgets.cpp
@@ -96,7 +96,7 @@ void GLDrawWidget::initializeGL()
false);
rmp.m_primaryTexturesParams = graphics::ResourceManager::TexturePoolParams(512,
- 256,
+ 512,
10,
rmp.m_texFormat,
true,