From c34b0b50e13e286abafe8351475670b47937c3dc Mon Sep 17 00:00:00 2001 From: rachytski Date: Thu, 15 Nov 2012 22:58:45 +0300 Subject: [PATCH] separated OpenGL-dependent classes into separate namespace for better modularity and easier porting. --- .../com/mapswithme/core/render_context.hpp | 2 +- android/jni/com/mapswithme/maps/Framework.cpp | 4 +- android/jni/com/mapswithme/maps/Lifecycle.cpp | 2 +- graphics/agg_traits.hpp | 2 +- graphics/area_renderer.cpp | 3 +- graphics/area_renderer.hpp | 4 +- graphics/blitter.cpp | 541 +++---- graphics/blitter.hpp | 209 ++- graphics/circle_element.cpp | 2 +- graphics/circle_element.hpp | 2 +- graphics/circle_style.cpp | 4 +- graphics/composite_overlay_element.cpp | 2 +- graphics/composite_overlay_element.hpp | 2 +- graphics/defines.hpp | 13 + graphics/display_list.cpp | 180 +-- graphics/display_list.hpp | 70 +- graphics/display_list_renderer.cpp | 160 ++ graphics/display_list_renderer.hpp | 65 + graphics/geometry_batcher.cpp | 1427 +++++++++-------- graphics/geometry_batcher.hpp | 300 ++-- graphics/glyph_cache.cpp | 5 +- graphics/glyph_style.cpp | 4 +- graphics/graphics.pro | 82 +- graphics/graphics_tests/screengl_test.cpp | 79 +- .../graphics_tests/screenglglobal_test.cpp | 2 +- graphics/graphics_tests/texture_test.cpp | 2 +- graphics/graphics_tests/thread_render.cpp | 16 +- graphics/image_info.cpp | 3 +- graphics/image_renderer.cpp | 4 +- graphics/line_style.cpp | 4 +- graphics/{ => opengl}/base_texture.cpp | 18 +- graphics/{ => opengl}/base_texture.hpp | 13 +- graphics/{ => opengl}/buffer_object.cpp | 12 +- graphics/{ => opengl}/buffer_object.hpp | 4 +- graphics/{ => opengl}/clipper.cpp | 8 +- graphics/{ => opengl}/clipper.hpp | 2 +- graphics/{ => opengl}/data_traits.hpp | 4 +- graphics/{ => opengl}/framebuffer.cpp | 6 +- graphics/{ => opengl}/framebuffer.hpp | 5 +- graphics/{ => opengl}/geometry_renderer.cpp | 243 +-- graphics/{ => opengl}/geometry_renderer.hpp | 69 +- .../{internal => opengl}/gl_procedures.inl | 0 graphics/{ => opengl}/managed_texture.cpp | 5 +- graphics/{ => opengl}/managed_texture.hpp | 10 +- graphics/{internal => opengl}/opengl.cpp | 0 graphics/{internal => opengl}/opengl.hpp | 1 + graphics/{internal => opengl}/opengl_es.cpp | 0 graphics/{internal => opengl}/opengl_ext.cpp | 0 .../{internal => opengl}/opengl_glsl_es2.cpp | 0 .../{internal => opengl}/opengl_glsl_ext.cpp | 0 .../{internal => opengl}/opengl_glsl_impl.cpp | 0 .../{internal => opengl}/opengl_glsl_impl.hpp | 0 .../{internal => opengl}/opengl_win32.cpp | 0 graphics/{ => opengl}/renderbuffer.cpp | 2 +- graphics/{ => opengl}/renderbuffer.hpp | 4 +- graphics/{ => opengl}/rendercontext.cpp | 2 +- graphics/{ => opengl}/rendercontext.hpp | 2 +- graphics/{ => opengl}/renderer.cpp | 8 +- graphics/{ => opengl}/renderer.hpp | 18 +- graphics/{ => opengl}/storage.cpp | 4 +- graphics/{ => opengl}/storage.hpp | 2 +- graphics/{ => opengl}/texture.hpp | 7 +- graphics/{ => opengl}/utils.cpp | 2 +- graphics/{ => opengl}/utils.hpp | 2 +- graphics/{ => opengl}/vertex.cpp | 2 +- graphics/{ => opengl}/vertex.hpp | 4 +- graphics/overlay.cpp | 4 +- graphics/overlay.hpp | 2 +- graphics/overlay_element.hpp | 7 +- graphics/overlay_renderer.cpp | 287 ++-- graphics/overlay_renderer.hpp | 95 +- graphics/packets_queue.cpp | 211 ++- graphics/packets_queue.hpp | 197 ++- graphics/path_renderer.cpp | 3 +- graphics/path_text_element.cpp | 2 +- graphics/path_text_element.hpp | 2 +- graphics/render_target.hpp | 23 +- graphics/resource_manager.cpp | 15 +- graphics/resource_manager.hpp | 2 +- graphics/resource_style.cpp | 2 +- graphics/screen.hpp | 17 +- graphics/shape_renderer.cpp | 3 +- graphics/skin.cpp | 3 - graphics/skin_page.cpp | 6 +- graphics/straight_text_element.cpp | 2 +- graphics/straight_text_element.hpp | 2 +- graphics/symbol_element.cpp | 2 +- graphics/symbol_element.hpp | 2 +- graphics/text_element.cpp | 2 +- graphics/text_element.hpp | 8 +- graphics/text_renderer.cpp | 110 +- graphics/text_renderer.hpp | 63 +- gui/button.cpp | 2 +- gui/button.hpp | 2 +- gui/controller.cpp | 6 +- gui/controller.hpp | 18 +- gui/element.cpp | 2 +- gui/element.hpp | 2 +- gui/text_view.cpp | 2 +- gui/text_view.hpp | 2 +- iphone/Maps/Classes/EAGLView.mm | 6 +- iphone/Maps/Classes/RenderBuffer.hpp | 2 +- iphone/Maps/Classes/RenderBuffer.mm | 4 +- iphone/Maps/Classes/RenderContext.hpp | 2 +- map/compass_arrow.cpp | 4 +- map/compass_arrow.hpp | 4 +- map/country_status_display.cpp | 2 +- map/country_status_display.hpp | 2 +- map/coverage_generator.cpp | 8 +- map/coverage_generator.hpp | 4 +- map/drawer.cpp | 4 +- map/drawer.hpp | 7 +- map/framework.cpp | 4 +- map/location_state.cpp | 16 +- map/location_state.hpp | 16 +- map/qgl_render_context.hpp | 3 +- map/queued_renderer.cpp | 39 +- map/queued_renderer.hpp | 16 +- map/render_policy.cpp | 8 +- map/render_policy.hpp | 4 +- map/ruler.cpp | 2 +- map/ruler.hpp | 2 +- map/screen_coverage.cpp | 10 +- map/screen_coverage.hpp | 10 +- map/simple_render_policy.cpp | 3 +- map/test_render_policy.cpp | 14 +- map/test_render_policy.hpp | 4 +- map/tile.cpp | 4 +- map/tile_renderer.cpp | 15 +- map/tile_renderer.hpp | 7 +- map/tiling_render_policy_mt.cpp | 1 - map/tiling_render_policy_st.cpp | 4 +- qt/draw_widget.cpp | 2 +- qt_tstfrm/macros.hpp | 2 +- qt_tstfrm/tstwidgets.cpp | 15 +- qt_tstfrm/tstwidgets.hpp | 12 +- 136 files changed, 2587 insertions(+), 2437 deletions(-) create mode 100644 graphics/display_list_renderer.cpp create mode 100644 graphics/display_list_renderer.hpp rename graphics/{ => opengl}/base_texture.cpp (89%) rename graphics/{ => opengl}/base_texture.hpp (81%) rename graphics/{ => opengl}/buffer_object.cpp (94%) rename graphics/{ => opengl}/buffer_object.hpp (90%) rename graphics/{ => opengl}/clipper.cpp (95%) rename graphics/{ => opengl}/clipper.hpp (96%) rename graphics/{ => opengl}/data_traits.hpp (98%) rename graphics/{ => opengl}/framebuffer.cpp (97%) rename graphics/{ => opengl}/framebuffer.hpp (94%) rename graphics/{ => opengl}/geometry_renderer.cpp (65%) rename graphics/{ => opengl}/geometry_renderer.hpp (60%) rename graphics/{internal => opengl}/gl_procedures.inl (100%) rename graphics/{ => opengl}/managed_texture.cpp (92%) rename graphics/{ => opengl}/managed_texture.hpp (86%) rename graphics/{internal => opengl}/opengl.cpp (100%) rename graphics/{internal => opengl}/opengl.hpp (99%) rename graphics/{internal => opengl}/opengl_es.cpp (100%) rename graphics/{internal => opengl}/opengl_ext.cpp (100%) rename graphics/{internal => opengl}/opengl_glsl_es2.cpp (100%) rename graphics/{internal => opengl}/opengl_glsl_ext.cpp (100%) rename graphics/{internal => opengl}/opengl_glsl_impl.cpp (100%) rename graphics/{internal => opengl}/opengl_glsl_impl.hpp (100%) rename graphics/{internal => opengl}/opengl_win32.cpp (100%) rename graphics/{ => opengl}/renderbuffer.cpp (98%) rename graphics/{ => opengl}/renderbuffer.hpp (90%) rename graphics/{ => opengl}/rendercontext.cpp (92%) rename graphics/{ => opengl}/rendercontext.hpp (94%) rename graphics/{ => opengl}/renderer.cpp (98%) rename graphics/{ => opengl}/renderer.hpp (93%) rename graphics/{ => opengl}/storage.cpp (83%) rename graphics/{ => opengl}/storage.hpp (88%) rename graphics/{ => opengl}/texture.hpp (98%) rename graphics/{ => opengl}/utils.cpp (95%) rename graphics/{ => opengl}/utils.hpp (84%) rename graphics/{ => opengl}/vertex.cpp (97%) rename graphics/{ => opengl}/vertex.hpp (92%) diff --git a/android/jni/com/mapswithme/core/render_context.hpp b/android/jni/com/mapswithme/core/render_context.hpp index 56374cc531..f878cd7be1 100644 --- a/android/jni/com/mapswithme/core/render_context.hpp +++ b/android/jni/com/mapswithme/core/render_context.hpp @@ -7,7 +7,7 @@ #pragma once -#include "../../../../../graphics/rendercontext.hpp" +#include "../../../../../graphics/opengl/rendercontext.hpp" #include "../../../../../std/shared_ptr.hpp" diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index ce04bd6114..8b8c5a579e 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -12,8 +12,8 @@ #include "../../../../../coding/file_container.hpp" -#include "../../../../../graphics/framebuffer.hpp" -#include "../../../../../graphics/internal/opengl.hpp" +#include "../../../../../graphics/opengl/framebuffer.hpp" +#include "../../../../../graphics/opengl/opengl.hpp" #include "../../../../../platform/platform.hpp" #include "../../../../../platform/location.hpp" diff --git a/android/jni/com/mapswithme/maps/Lifecycle.cpp b/android/jni/com/mapswithme/maps/Lifecycle.cpp index 8c51782bd7..8ae89f0b30 100644 --- a/android/jni/com/mapswithme/maps/Lifecycle.cpp +++ b/android/jni/com/mapswithme/maps/Lifecycle.cpp @@ -18,7 +18,7 @@ #include "../../../nv_event/nv_event.hpp" #include "../../../nv_thread/nv_thread.hpp" #include "../../../../../base/logging.hpp" -#include "../../../../../graphics/internal/opengl.hpp" +#include "../../../../../graphics/opengl/opengl.hpp" #include "Framework.hpp" #include "../platform/Platform.hpp" diff --git a/graphics/agg_traits.hpp b/graphics/agg_traits.hpp index da61009316..4233d28e41 100644 --- a/graphics/agg_traits.hpp +++ b/graphics/agg_traits.hpp @@ -7,7 +7,7 @@ #include #include -#include "data_traits.hpp" +#include "opengl/data_traits.hpp" template struct AggTraits diff --git a/graphics/area_renderer.cpp b/graphics/area_renderer.cpp index d9b3af5e48..f7aba20de8 100644 --- a/graphics/area_renderer.cpp +++ b/graphics/area_renderer.cpp @@ -2,7 +2,8 @@ #include "resource_style.hpp" #include "skin.hpp" #include "skin_page.hpp" -#include "base_texture.hpp" + +#include "opengl/base_texture.hpp" #include "../base/logging.hpp" diff --git a/graphics/area_renderer.hpp b/graphics/area_renderer.hpp index 31aec8eec8..615cd65dc1 100644 --- a/graphics/area_renderer.hpp +++ b/graphics/area_renderer.hpp @@ -4,7 +4,7 @@ namespace graphics { - class AreaRenderer : public gl::GeometryBatcher + class AreaRenderer : public GeometryBatcher { private: @@ -14,7 +14,7 @@ namespace graphics public: - typedef gl::GeometryBatcher base_t; + typedef GeometryBatcher base_t; struct Params : base_t::Params { diff --git a/graphics/blitter.cpp b/graphics/blitter.cpp index c1878e9df3..25524db925 100644 --- a/graphics/blitter.cpp +++ b/graphics/blitter.cpp @@ -1,356 +1,255 @@ -#include "../base/SRC_FIRST.hpp" +#include "opengl/base_texture.hpp" +#include "opengl/buffer_object.hpp" +#include "opengl/utils.hpp" +#include "opengl/storage.hpp" +#include "opengl/vertex.hpp" +#include "opengl/texture.hpp" #include "blitter.hpp" -#include "framebuffer.hpp" -#include "base_texture.hpp" #include "resource_manager.hpp" -#include "buffer_object.hpp" -#include "utils.hpp" -#include "storage.hpp" -#include "vertex.hpp" #include "defines.hpp" -#include "texture.hpp" #include "../geometry/screenbase.hpp" #include "../base/logging.hpp" namespace graphics { - namespace gl + Blitter::Blitter(base_t::Params const & params) : base_t(params) { - Blitter::IMMDrawTexturedRect::IMMDrawTexturedRect( - m2::RectF const & rect, - m2::RectF const & texRect, - shared_ptr const & texture, - shared_ptr const & rm) + } + + Blitter::~Blitter() + { + } + + void Blitter::beginFrame() + { + base_t::beginFrame(); + } + + void Blitter::endFrame() + { + base_t::endFrame(); + } + + void Blitter::blit(shared_ptr const & srcSurface, + ScreenBase const & from, + ScreenBase const & to, + bool isSubPixel, + graphics::Color const & color, + m2::RectI const & srcRect, + m2::RectU const & texRect) + { + blit(srcSurface, + from.PtoGMatrix() * to.GtoPMatrix(), + isSubPixel, + color, + srcRect, + texRect); + } + + void Blitter::blit(BlitInfo const * blitInfo, + size_t s, + bool isSubPixel) + { + vector geomPts(4 * s); + vector texPts(4 * s); + vector idxData(4 * s); + + for (size_t i = 0; i < s; ++i) { - m2::PointF rectPoints[4] = - { - m2::PointF(rect.minX(), rect.minY()), - m2::PointF(rect.maxX(), rect.minY()), - m2::PointF(rect.maxX(), rect.maxY()), - m2::PointF(rect.minX(), rect.maxY()) - }; + calcPoints(blitInfo[i].m_srcRect, + blitInfo[i].m_texRect, + blitInfo[i].m_srcSurface, + blitInfo[i].m_matrix, + isSubPixel, + &geomPts[i * 4], + &texPts[i * 4]); - m2::PointF texRectPoints[4] = - { - m2::PointF(texRect.minX(), texRect.minY()), - m2::PointF(texRect.maxX(), texRect.minY()), - m2::PointF(texRect.maxX(), texRect.maxY()), - m2::PointF(texRect.minX(), texRect.maxY()), - }; - - m_pts.resize(4); - m_texPts.resize(4); - - copy(rectPoints, rectPoints + 4, &m_pts[0]); - copy(texRectPoints, texRectPoints + 4, &m_texPts[0]); - m_ptsCount = 4; - m_texture = texture; - m_hasTexture = true; - m_hasColor = false; - m_color = graphics::Color(255, 255, 255, 255); - m_resourceManager = rm; + idxData[i * 4 ] = i * 4; + idxData[i * 4 + 1] = i * 4 + 1; + idxData[i * 4 + 2] = i * 4 + 2; + idxData[i * 4 + 3] = i * 4 + 3; } - Blitter::Blitter(base_t::Params const & params) : base_t(params) + graphics::gl::Storage storage = resourceManager()->multiBlitStorages()->Reserve(); + + if (resourceManager()->multiBlitStorages()->IsCancelled()) { + LOG(LINFO, ("skipping multiBlit on cancelled multiBlitStorages pool")); + return; } - Blitter::~Blitter() + /// TODO : Bad lock/unlock checking pattern. Should refactor + if (!storage.m_vertices->isLocked()) + storage.m_vertices->lock(); + if (!storage.m_indices->isLocked()) + storage.m_indices->lock(); + + gl::Vertex * pointsData = (gl::Vertex*)storage.m_vertices->data(); + + for (size_t i = 0; i < s * 4; ++i) { + pointsData[i].pt.x = geomPts[i].x; + pointsData[i].pt.y = geomPts[i].y; + pointsData[i].depth = graphics::maxDepth; + pointsData[i].tex.x = texPts[i].x; + pointsData[i].tex.y = texPts[i].y; + pointsData[i].normal.x = 0; + pointsData[i].normal.y = 0; + // pointsData[i].color = graphics::Color(255, 255, 255, 255); } - void Blitter::beginFrame() + memcpy(storage.m_indices->data(), &idxData[0], idxData.size() * sizeof(unsigned short)); + + base_t::unlockStorage(storage); + base_t::applyBlitStates(); + + for (unsigned i = 0; i < s; ++i) + base_t::drawGeometry(blitInfo[i].m_srcSurface, + storage, + 4, + sizeof(unsigned short) * i * 4, + ETrianglesFan); + + base_t::applyStates(); + base_t::discardStorage(storage); + + base_t::freeStorage(storage, resourceManager()->multiBlitStorages()); + } + + void Blitter::blit(shared_ptr const & srcSurface, + math::Matrix const & m, + bool isSubPixel) + { + blit(srcSurface, + m, + isSubPixel, + graphics::Color(), + m2::RectI(0, 0, srcSurface->width(), srcSurface->height()), + m2::RectU(0, 0, srcSurface->width(), srcSurface->height())); + } + + void Blitter::calcPoints(m2::RectI const & srcRect, + m2::RectU const & texRect, + shared_ptr const & srcSurface, + math::Matrix const & m, + bool isSubPixel, + m2::PointF * geomPts, + m2::PointF * texPts) + { + m2::PointF pt = m2::PointF(m2::PointD(srcRect.minX(), srcRect.minY()) * m); + + if (!isSubPixel) { - base_t::beginFrame(); + pt.x = pt.x - my::rounds(pt.x); + pt.y = pt.y - my::rounds(pt.y); } + else + pt = m2::PointF(0, 0); - void Blitter::endFrame() + geomPts[0] = m2::PointF(m2::PointD(srcRect.minX(), srcRect.minY()) * m) + pt; + geomPts[1] = m2::PointF(m2::PointD(srcRect.maxX(), srcRect.minY()) * m) + pt; + geomPts[2] = m2::PointF(m2::PointD(srcRect.maxX(), srcRect.maxY()) * m) + pt; + geomPts[3] = m2::PointF(m2::PointD(srcRect.minX(), srcRect.maxY()) * m) + pt; + + texPts[0] = srcSurface->mapPixel(m2::PointF(texRect.minX(), texRect.minY())); + texPts[1] = srcSurface->mapPixel(m2::PointF(texRect.maxX(), texRect.minY())); + texPts[2] = srcSurface->mapPixel(m2::PointF(texRect.maxX(), texRect.maxY())); + texPts[3] = srcSurface->mapPixel(m2::PointF(texRect.minX(), texRect.maxY())); + } + + void Blitter::blit(shared_ptr const & srcSurface, + math::Matrix const & m, + bool isSubPixel, + graphics::Color const & color, + m2::RectI const & srcRect, + m2::RectU const & texRect) + { + m2::PointF pts[4]; + m2::PointF texPts[4]; + + calcPoints(srcRect, texRect, srcSurface, m, isSubPixel, pts, texPts); + + immDrawTexturedPrimitives(pts, texPts, 4, srcSurface, true, color, false); + } + + void Blitter::blit(shared_ptr const & srcSurface, + ScreenBase const & from, + ScreenBase const & to, + bool isSubPixel) + { + blit(srcSurface, + from, + to, + isSubPixel, + graphics::Color(), + m2::RectI(0, 0, srcSurface->width(), srcSurface->height()), + m2::RectU(0, 0, srcSurface->width(), srcSurface->height())); + } + + void Blitter::immDrawSolidRect(m2::RectF const & rect, + graphics::Color const & color) + { + immDrawRect(rect, m2::RectF(), shared_ptr(), false, color, true); + } + + void Blitter::immDrawRect(m2::RectF const & rect, + m2::RectF const & texRect, + shared_ptr texture, + bool hasTexture, + graphics::Color const & color, + bool hasColor) + { + m2::PointF rectPoints[4] = { - base_t::endFrame(); - } + m2::PointF(rect.minX(), rect.minY()), + m2::PointF(rect.maxX(), rect.minY()), + m2::PointF(rect.maxX(), rect.maxY()), + m2::PointF(rect.minX(), rect.maxY()) + }; - void Blitter::blit(shared_ptr const & srcSurface, - ScreenBase const & from, - ScreenBase const & to, - bool isSubPixel, - graphics::Color const & color, - m2::RectI const & srcRect, - m2::RectU const & texRect) + m2::PointF texRectPoints[4] = { - blit(srcSurface, - from.PtoGMatrix() * to.GtoPMatrix(), - isSubPixel, - color, - srcRect, - texRect); - } + m2::PointF(texRect.minX(), texRect.minY()), + m2::PointF(texRect.maxX(), texRect.minY()), + m2::PointF(texRect.maxX(), texRect.maxY()), + m2::PointF(texRect.minX(), texRect.maxY()), + }; - void Blitter::blit(BlitInfo const * blitInfo, - size_t s, - bool isSubPixel) - { - vector geomPts(4 * s); - vector texPts(4 * s); - vector idxData(4 * s); + immDrawTexturedPrimitives(rectPoints, texRectPoints, 4, texture, hasTexture, color, hasColor); + } - for (size_t i = 0; i < s; ++i) - { - calcPoints(blitInfo[i].m_srcRect, - blitInfo[i].m_texRect, - blitInfo[i].m_srcSurface, - blitInfo[i].m_matrix, - isSubPixel, - &geomPts[i * 4], - &texPts[i * 4]); + void Blitter::immDrawTexturedRect(m2::RectF const & rect, + m2::RectF const & texRect, + shared_ptr const & texture) + { + shared_ptr command(new IMMDrawTexturedRect(rect, texRect, texture, resourceManager())); + processCommand(command); + } - idxData[i * 4 ] = i * 4; - idxData[i * 4 + 1] = i * 4 + 1; - idxData[i * 4 + 2] = i * 4 + 2; - idxData[i * 4 + 3] = i * 4 + 3; - } + void Blitter::immDrawTexturedPrimitives(m2::PointF const * pts, + m2::PointF const * texPts, + size_t size, + shared_ptr const & texture, + bool hasTexture, + graphics::Color const & color, + bool hasColor) + { + shared_ptr command(new IMMDrawTexturedPrimitives()); - graphics::gl::Storage storage = resourceManager()->multiBlitStorages()->Reserve(); + command->m_ptsCount = size; + command->m_pts.resize(size); + command->m_texPts.resize(size); + copy(pts, pts + size, command->m_pts.begin()); + copy(texPts, texPts + size, command->m_texPts.begin()); + command->m_texture = texture; + command->m_hasTexture = hasTexture; + command->m_color = color; + command->m_hasColor = hasColor; + command->m_resourceManager = resourceManager(); - if (resourceManager()->multiBlitStorages()->IsCancelled()) - { - LOG(LINFO, ("skipping multiBlit on cancelled multiBlitStorages pool")); - return; - } - - /// TODO : Bad lock/unlock checking pattern. Should refactor - if (!storage.m_vertices->isLocked()) - storage.m_vertices->lock(); - if (!storage.m_indices->isLocked()) - storage.m_indices->lock(); - - Vertex * pointsData = (Vertex*)storage.m_vertices->data(); - - for (size_t i = 0; i < s * 4; ++i) - { - pointsData[i].pt.x = geomPts[i].x; - pointsData[i].pt.y = geomPts[i].y; - pointsData[i].depth = graphics::maxDepth; - pointsData[i].tex.x = texPts[i].x; - pointsData[i].tex.y = texPts[i].y; - pointsData[i].normal.x = 0; - pointsData[i].normal.y = 0; -// pointsData[i].color = graphics::Color(255, 255, 255, 255); - } - - memcpy(storage.m_indices->data(), &idxData[0], idxData.size() * sizeof(unsigned short)); - - base_t::unlockStorage(storage); - base_t::applyBlitStates(); - - for (unsigned i = 0; i < s; ++i) - base_t::drawGeometry(blitInfo[i].m_srcSurface, - storage, - 4, - sizeof(unsigned short) * i * 4, - GL_TRIANGLE_FAN); - - base_t::applyStates(); - base_t::discardStorage(storage); - - base_t::freeStorage(storage, resourceManager()->multiBlitStorages()); - } - - void Blitter::blit(shared_ptr const & srcSurface, - math::Matrix const & m, - bool isSubPixel) - { - blit(srcSurface, - m, - isSubPixel, - graphics::Color(), - m2::RectI(0, 0, srcSurface->width(), srcSurface->height()), - m2::RectU(0, 0, srcSurface->width(), srcSurface->height())); - } - - void Blitter::calcPoints(m2::RectI const & srcRect, - m2::RectU const & texRect, - shared_ptr const & srcSurface, - math::Matrix const & m, - bool isSubPixel, - m2::PointF * geomPts, - m2::PointF * texPts) - { - m2::PointF pt = m2::PointF(m2::PointD(srcRect.minX(), srcRect.minY()) * m); - - if (!isSubPixel) - { - pt.x = pt.x - my::rounds(pt.x); - pt.y = pt.y - my::rounds(pt.y); - } - else - pt = m2::PointF(0, 0); - - geomPts[0] = m2::PointF(m2::PointD(srcRect.minX(), srcRect.minY()) * m) + pt; - geomPts[1] = m2::PointF(m2::PointD(srcRect.maxX(), srcRect.minY()) * m) + pt; - geomPts[2] = m2::PointF(m2::PointD(srcRect.maxX(), srcRect.maxY()) * m) + pt; - geomPts[3] = m2::PointF(m2::PointD(srcRect.minX(), srcRect.maxY()) * m) + pt; - - texPts[0] = srcSurface->mapPixel(m2::PointF(texRect.minX(), texRect.minY())); - texPts[1] = srcSurface->mapPixel(m2::PointF(texRect.maxX(), texRect.minY())); - texPts[2] = srcSurface->mapPixel(m2::PointF(texRect.maxX(), texRect.maxY())); - texPts[3] = srcSurface->mapPixel(m2::PointF(texRect.minX(), texRect.maxY())); - } - - void Blitter::blit(shared_ptr const & srcSurface, - math::Matrix const & m, - bool isSubPixel, - graphics::Color const & color, - m2::RectI const & srcRect, - m2::RectU const & texRect) - { - m2::PointF pts[4]; - m2::PointF texPts[4]; - - calcPoints(srcRect, texRect, srcSurface, m, isSubPixel, pts, texPts); - - immDrawTexturedPrimitives(pts, texPts, 4, srcSurface, true, color, false); - } - - void Blitter::blit(shared_ptr const & srcSurface, - ScreenBase const & from, - ScreenBase const & to, - bool isSubPixel) - { - blit(srcSurface, - from, - to, - isSubPixel, - graphics::Color(), - m2::RectI(0, 0, srcSurface->width(), srcSurface->height()), - m2::RectU(0, 0, srcSurface->width(), srcSurface->height())); - } - - void Blitter::immDrawSolidRect(m2::RectF const & rect, - graphics::Color const & color) - { - immDrawRect(rect, m2::RectF(), shared_ptr(), false, color, true); - } - - void Blitter::immDrawRect(m2::RectF const & rect, - m2::RectF const & texRect, - shared_ptr texture, - bool hasTexture, - graphics::Color const & color, - bool hasColor) - { - m2::PointF rectPoints[4] = - { - m2::PointF(rect.minX(), rect.minY()), - m2::PointF(rect.maxX(), rect.minY()), - m2::PointF(rect.maxX(), rect.maxY()), - m2::PointF(rect.minX(), rect.maxY()) - }; - - m2::PointF texRectPoints[4] = - { - m2::PointF(texRect.minX(), texRect.minY()), - m2::PointF(texRect.maxX(), texRect.minY()), - m2::PointF(texRect.maxX(), texRect.maxY()), - m2::PointF(texRect.minX(), texRect.maxY()), - }; - - immDrawTexturedPrimitives(rectPoints, texRectPoints, 4, texture, hasTexture, color, hasColor); - } - - void Blitter::immDrawTexturedRect(m2::RectF const & rect, - m2::RectF const & texRect, - shared_ptr const & texture) - { - shared_ptr command(new IMMDrawTexturedRect(rect, texRect, texture, resourceManager())); - processCommand(command); - } - - void Blitter::immDrawTexturedPrimitives(m2::PointF const * pts, - m2::PointF const * texPts, - size_t size, - shared_ptr const & texture, - bool hasTexture, - graphics::Color const & color, - bool hasColor) - { - shared_ptr command(new IMMDrawTexturedPrimitives()); - - command->m_ptsCount = size; - command->m_pts.resize(size); - command->m_texPts.resize(size); - copy(pts, pts + size, command->m_pts.begin()); - copy(texPts, texPts + size, command->m_texPts.begin()); - command->m_texture = texture; - command->m_hasTexture = hasTexture; - command->m_color = color; - command->m_hasColor = hasColor; - command->m_resourceManager = resourceManager(); - - processCommand(command); - } - - void Blitter::IMMDrawTexturedPrimitives::perform() - { - if (isDebugging()) - LOG(LINFO, ("performing IMMDrawTexturedPrimitives command")); - - graphics::gl::Storage blitStorage = m_resourceManager->blitStorages()->Reserve(); - - if (m_resourceManager->blitStorages()->IsCancelled()) - { - LOG(LDEBUG, ("skipping IMMDrawTexturedPrimitives on cancelled multiBlitStorages pool")); - return; - } - - if (!blitStorage.m_vertices->isLocked()) - blitStorage.m_vertices->lock(); - - if (!blitStorage.m_indices->isLocked()) - blitStorage.m_indices->lock(); - - Vertex * pointsData = (Vertex*)blitStorage.m_vertices->data(); - - for (size_t i = 0; i < m_ptsCount; ++i) - { - pointsData[i].pt.x = m_pts[i].x; - pointsData[i].pt.y = m_pts[i].y; - pointsData[i].depth = graphics::maxDepth; - pointsData[i].tex.x = m_texPts[i].x; - pointsData[i].tex.y = m_texPts[i].y; - pointsData[i].normal.x = 0; - pointsData[i].normal.y = 0; - } - - blitStorage.m_vertices->unlock(); - blitStorage.m_vertices->makeCurrent(); - - Vertex::setupLayout(blitStorage.m_vertices->glPtr()); - - if (m_texture) - m_texture->makeCurrent(); - - unsigned short idxData[4] = {0, 1, 2, 3}; - memcpy(blitStorage.m_indices->data(), idxData, sizeof(idxData)); - blitStorage.m_indices->unlock(); - blitStorage.m_indices->makeCurrent(); - - OGLCHECK(glDisableFn(GL_ALPHA_TEST_MWM)); - OGLCHECK(glDisableFn(GL_BLEND)); - OGLCHECK(glDisableFn(GL_DEPTH_TEST)); - OGLCHECK(glDepthMask(GL_FALSE)); - OGLCHECK(glDrawElementsFn(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, blitStorage.m_indices->glPtr())); - OGLCHECK(glDepthMask(GL_TRUE)); - OGLCHECK(glEnableFn(GL_DEPTH_TEST)); - OGLCHECK(glEnableFn(GL_BLEND)); - OGLCHECK(glEnableFn(GL_ALPHA_TEST_MWM)); - - blitStorage.m_vertices->discard(); - blitStorage.m_indices->discard(); - - m_resourceManager->blitStorages()->Free(blitStorage); - } + processCommand(command); } } diff --git a/graphics/blitter.hpp b/graphics/blitter.hpp index 115acceb9e..0a967e9ab6 100644 --- a/graphics/blitter.hpp +++ b/graphics/blitter.hpp @@ -1,7 +1,8 @@ #pragma once -#include "geometry_renderer.hpp" -#include "storage.hpp" +#include "opengl/storage.hpp" + +#include "display_list_renderer.hpp" #include "../geometry/point2d.hpp" #include "../geometry/rect2d.hpp" @@ -19,119 +20,95 @@ namespace graphics namespace gl { class BaseTexture; - - struct BlitInfo - { - shared_ptr m_srcSurface; - math::Matrix m_matrix; - m2::RectI m_srcRect; - m2::RectU m_texRect; - }; - - class Blitter : public GeometryRenderer - { - private: - - graphics::gl::Storage m_blitStorage; - - protected: - - typedef GeometryRenderer base_t; - - void calcPoints(m2::RectI const & srcRect, - m2::RectU const & texRect, - shared_ptr const & texture, - math::Matrix const & m, - bool isSubPixel, - m2::PointF * geomPts, - m2::PointF * texPts); - - public: - - struct IMMDrawTexturedPrimitives : Command - { - buffer_vector m_pts; - buffer_vector m_texPts; - unsigned m_ptsCount; - shared_ptr m_texture; - bool m_hasTexture; - graphics::Color m_color; - bool m_hasColor; - - shared_ptr m_resourceManager; - - void perform(); - }; - - struct IMMDrawTexturedRect : IMMDrawTexturedPrimitives - { - IMMDrawTexturedRect(m2::RectF const & rect, - m2::RectF const & texRect, - shared_ptr const & texture, - shared_ptr const & rm); - }; - - Blitter(base_t::Params const & params); - ~Blitter(); - - void beginFrame(); - void endFrame(); - - /// Immediate mode rendering functions. - /// they doesn't buffer any data as other functions do, but immediately renders it - /// @{ - - void blit(shared_ptr const & srcSurface, - ScreenBase const & from, - ScreenBase const & to, - bool isSubPixel, - graphics::Color const & color, - m2::RectI const & srcRect, - m2::RectU const & texRect); - - void blit(shared_ptr const & srcSurface, - ScreenBase const & from, - ScreenBase const & to, - bool isSubPixel = false); - - void blit(shared_ptr const & srcSurface, - math::Matrix const & m, - bool isSubPixel = false); - - void blit(shared_ptr const & srcSurface, - math::Matrix const & m, - bool isSubPixel, - graphics::Color const & color, - m2::RectI const & srcRect, - m2::RectU const & texRect); - - void blit(BlitInfo const * blitInfo, - size_t s, - bool isSubPixel); - - void immDrawSolidRect(m2::RectF const & rect, - graphics::Color const & color); - - void immDrawRect(m2::RectF const & rect, - m2::RectF const & texRect, - shared_ptr texture, - bool hasTexture, - graphics::Color const & color, - bool hasColor); - - void immDrawTexturedPrimitives(m2::PointF const * pts, - m2::PointF const * texPts, - size_t size, - shared_ptr const & texture, - bool hasTexture, - graphics::Color const & color, - bool hasColor); - - void immDrawTexturedRect(m2::RectF const & rect, - m2::RectF const & texRect, - shared_ptr const & texture); - - /// @} - }; } + + struct BlitInfo + { + shared_ptr m_srcSurface; + math::Matrix m_matrix; + m2::RectI m_srcRect; + m2::RectU m_texRect; + }; + + class Blitter : public DisplayListRenderer + { + private: + + gl::Storage m_blitStorage; + + protected: + + typedef DisplayListRenderer base_t; + + void calcPoints(m2::RectI const & srcRect, + m2::RectU const & texRect, + shared_ptr const & texture, + math::Matrix const & m, + bool isSubPixel, + m2::PointF * geomPts, + m2::PointF * texPts); + public: + + Blitter(base_t::Params const & params); + ~Blitter(); + + void beginFrame(); + void endFrame(); + + /// Immediate mode rendering functions. + /// they doesn't buffer any data as other functions do, but immediately renders it + /// @{ + + void blit(shared_ptr const & srcSurface, + ScreenBase const & from, + ScreenBase const & to, + bool isSubPixel, + graphics::Color const & color, + m2::RectI const & srcRect, + m2::RectU const & texRect); + + void blit(shared_ptr const & srcSurface, + ScreenBase const & from, + ScreenBase const & to, + bool isSubPixel = false); + + void blit(shared_ptr const & srcSurface, + math::Matrix const & m, + bool isSubPixel = false); + + void blit(shared_ptr const & srcSurface, + math::Matrix const & m, + bool isSubPixel, + graphics::Color const & color, + m2::RectI const & srcRect, + m2::RectU const & texRect); + + void blit(BlitInfo const * blitInfo, + size_t s, + bool isSubPixel); + + void immDrawSolidRect(m2::RectF const & rect, + Color const & color); + + void immDrawRect(m2::RectF const & rect, + m2::RectF const & texRect, + shared_ptr texture, + bool hasTexture, + Color const & color, + bool hasColor); + + void immDrawTexturedPrimitives(m2::PointF const * pts, + m2::PointF const * texPts, + size_t size, + shared_ptr const & texture, + bool hasTexture, + Color const & color, + bool hasColor); + + void immDrawTexturedRect(m2::RectF const & rect, + m2::RectF const & texRect, + shared_ptr const & texture); + + /// @} + }; } diff --git a/graphics/circle_element.cpp b/graphics/circle_element.cpp index 6a7723d610..a0fd5a0b58 100644 --- a/graphics/circle_element.cpp +++ b/graphics/circle_element.cpp @@ -41,7 +41,7 @@ namespace graphics return m2::AnyRectD(m2::RectD(posPt, posPt + m2::PointD(texRect.SizeX(), texRect.SizeY()))); } - void CircleElement::draw(gl::OverlayRenderer * r, math::Matrix const & m) const + void CircleElement::draw(OverlayRenderer * r, math::Matrix const & m) const { if (!isNeedRedraw()) return; diff --git a/graphics/circle_element.hpp b/graphics/circle_element.hpp index 6f99c87a05..49fbde0e0e 100644 --- a/graphics/circle_element.hpp +++ b/graphics/circle_element.hpp @@ -29,7 +29,7 @@ namespace graphics vector const & boundRects() const; - void draw(gl::OverlayRenderer * s, math::Matrix const & m) const; + void draw(OverlayRenderer * s, math::Matrix const & m) const; int visualRank() const; diff --git a/graphics/circle_style.cpp b/graphics/circle_style.cpp index 6a379da0fe..f9d059a855 100644 --- a/graphics/circle_style.cpp +++ b/graphics/circle_style.cpp @@ -1,7 +1,7 @@ #include "resource_style.hpp" - #include "agg_traits.hpp" -#include "data_traits.hpp" + +#include "opengl/data_traits.hpp" namespace graphics { diff --git a/graphics/composite_overlay_element.cpp b/graphics/composite_overlay_element.cpp index e0dbbf3293..c49f946995 100644 --- a/graphics/composite_overlay_element.cpp +++ b/graphics/composite_overlay_element.cpp @@ -41,7 +41,7 @@ namespace graphics return m_boundRects; } - void CompositeOverlayElement::draw(gl::OverlayRenderer * r, math::Matrix const & m) const + void CompositeOverlayElement::draw(OverlayRenderer * r, math::Matrix const & m) const { r->drawRectangle(roughBoundRect(), graphics::Color(255, 255, 0, 64), depth() - 3); for (unsigned i = 0; i < m_elements.size(); ++i) diff --git a/graphics/composite_overlay_element.hpp b/graphics/composite_overlay_element.hpp index 97ba118547..96604f1489 100644 --- a/graphics/composite_overlay_element.hpp +++ b/graphics/composite_overlay_element.hpp @@ -24,7 +24,7 @@ namespace graphics vector const & boundRects() const; - void draw(gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(OverlayRenderer * r, math::Matrix const & m) const; int visualRank() const; diff --git a/graphics/defines.hpp b/graphics/defines.hpp index 046759874f..2935f7676b 100644 --- a/graphics/defines.hpp +++ b/graphics/defines.hpp @@ -4,6 +4,19 @@ namespace graphics { static const int maxDepth = 20000; + enum EPrimitives + { + ETriangles, + ETrianglesFan, + ETrianglesStrip + }; + + enum EMatrix + { + EModelView, + EProjection + }; + enum EPosition { EPosCenter = 0x00, diff --git a/graphics/display_list.cpp b/graphics/display_list.cpp index 2af5151843..bcced2c0b6 100644 --- a/graphics/display_list.cpp +++ b/graphics/display_list.cpp @@ -1,124 +1,118 @@ #include "display_list.hpp" -#include "internal/opengl.hpp" namespace graphics { - namespace gl + DisplayList::DisplayList(DisplayListRenderer * parent) + : m_parent(parent), + m_isDebugging(false) + {} + + DisplayList::~DisplayList() { - DisplayList::DisplayList(GeometryRenderer * parent) - : m_parent(parent), - m_isDebugging(false) - {} + for (list >::const_iterator it = m_discardStorageCmd.begin(); + it != m_discardStorageCmd.end(); + ++it) + m_parent->processCommand(*it); - DisplayList::~DisplayList() - { - for (list >::const_iterator it = m_discardStorageCmd.begin(); - it != m_discardStorageCmd.end(); - ++it) - m_parent->processCommand(*it); + m_discardStorageCmd.clear(); - m_discardStorageCmd.clear(); + for (list >::const_iterator it = m_freeStorageCmd.begin(); + it != m_freeStorageCmd.end(); + ++it) + m_parent->processCommand(*it); - for (list >::const_iterator it = m_freeStorageCmd.begin(); - it != m_freeStorageCmd.end(); - ++it) - m_parent->processCommand(*it); + m_freeStorageCmd.clear(); - m_freeStorageCmd.clear(); + for (list >::const_iterator it = m_freeTextureCmd.begin(); + it != m_freeTextureCmd.end(); + ++it) + m_parent->processCommand(*it); - for (list >::const_iterator it = m_freeTextureCmd.begin(); - it != m_freeTextureCmd.end(); - ++it) - m_parent->processCommand(*it); + m_freeTextureCmd.clear(); - m_freeTextureCmd.clear(); + m_commands.clear(); + } - m_commands.clear(); - } + void DisplayList::applyBlitStates(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_commands.push_back(cmd); + } - void DisplayList::applyBlitStates(shared_ptr const & cmd) - { - cmd->setIsDebugging(m_isDebugging); - m_commands.push_back(cmd); - } + void DisplayList::applyStates(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_commands.push_back(cmd); + } - void DisplayList::applyStates(shared_ptr const & cmd) - { - cmd->setIsDebugging(m_isDebugging); - m_commands.push_back(cmd); - } + void DisplayList::drawGeometry(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_commands.push_back(cmd); + } - void DisplayList::drawGeometry(shared_ptr const & cmd) - { - cmd->setIsDebugging(m_isDebugging); - m_commands.push_back(cmd); - } + void DisplayList::unlockStorage(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_parent->processCommand(cmd); + } - void DisplayList::unlockStorage(shared_ptr const & cmd) - { - cmd->setIsDebugging(m_isDebugging); - m_parent->processCommand(cmd); - } + void DisplayList::freeStorage(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_freeStorageCmd.push_back(cmd); + } - void DisplayList::freeStorage(shared_ptr const & cmd) - { - cmd->setIsDebugging(m_isDebugging); - m_freeStorageCmd.push_back(cmd); - } + void DisplayList::freeTexture(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_freeTextureCmd.push_back(cmd); + } - void DisplayList::freeTexture(shared_ptr const & cmd) - { - cmd->setIsDebugging(m_isDebugging); - m_freeTextureCmd.push_back(cmd); - } + void DisplayList::discardStorage(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_discardStorageCmd.push_back(cmd); + } - void DisplayList::discardStorage(shared_ptr const & cmd) - { - cmd->setIsDebugging(m_isDebugging); - m_discardStorageCmd.push_back(cmd); - } + void DisplayList::uploadStyles(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_parent->processCommand(cmd); + } - void DisplayList::uploadData(shared_ptr const & cmd) - { - cmd->setIsDebugging(m_isDebugging); - m_parent->processCommand(cmd); - } + void DisplayList::addCheckPoint() + { + static_cast(m_parent)->addCheckPoint(); + } - void DisplayList::addCheckPoint() - { - m_parent->addCheckPoint(); - } + void DisplayList::draw(DisplayListRenderer * r, + math::Matrix const & m) + { + math::Matrix mv; - void DisplayList::draw(math::Matrix const & m) - { - math::Matrix mv; + /// preparing ModelView matrix - /// preparing ModelView matrix + mv(0, 0) = m(0, 0); mv(0, 1) = m(1, 0); mv(0, 2) = 0; mv(0, 3) = m(2, 0); + mv(1, 0) = m(0, 1); mv(1, 1) = m(1, 1); mv(1, 2) = 0; mv(1, 3) = m(2, 1); + mv(2, 0) = 0; mv(2, 1) = 0; mv(2, 2) = 1; mv(2, 3) = 0; + mv(3, 0) = m(0, 2); mv(3, 1) = m(1, 2); mv(3, 2) = 0; mv(3, 3) = m(2, 2); - mv(0, 0) = m(0, 0); mv(0, 1) = m(1, 0); mv(0, 2) = 0; mv(0, 3) = m(2, 0); - mv(1, 0) = m(0, 1); mv(1, 1) = m(1, 1); mv(1, 2) = 0; mv(1, 3) = m(2, 1); - mv(2, 0) = 0; mv(2, 1) = 0; mv(2, 2) = 1; mv(2, 3) = 0; - mv(3, 0) = m(0, 2); mv(3, 1) = m(1, 2); mv(3, 2) = 0; mv(3, 3) = m(2, 2); + r->loadMatrix(EModelView, mv); - OGLCHECK(glMatrixModeFn(GL_MODELVIEW_MWM)); - OGLCHECK(glLoadIdentityFn()); - OGLCHECK(glLoadMatrixfFn(&mv(0, 0))); + /// drawing collected geometry - /// drawing collected geometry + if (m_isDebugging) + LOG(LINFO, ("started DisplayList::draw")); - if (m_isDebugging) - LOG(LINFO, ("started DisplayList::draw")); + for (list >::const_iterator it = m_commands.begin(); + it != m_commands.end(); + ++it) + (*it)->perform(); - for (list >::const_iterator it = m_commands.begin(); - it != m_commands.end(); - ++it) - (*it)->perform(); + if (m_isDebugging) + LOG(LINFO, ("finished DisplayList::draw")); - if (m_isDebugging) - LOG(LINFO, ("finished DisplayList::draw")); - - OGLCHECK(glMatrixModeFn(GL_MODELVIEW_MWM)); - OGLCHECK(glLoadIdentityFn()); - } + r->loadMatrix(EModelView, math::Identity()); } } diff --git a/graphics/display_list.hpp b/graphics/display_list.hpp index cfaa5c6b44..68d24af86f 100644 --- a/graphics/display_list.hpp +++ b/graphics/display_list.hpp @@ -1,51 +1,51 @@ #pragma once -#include "geometry_renderer.hpp" +#include "defines.hpp" +#include "display_list_renderer.hpp" namespace graphics { - namespace gl + class DisplayList { - class DisplayList - { - private: + private: - typedef GeometryRenderer::DrawGeometry DrawGeometryCmd; - typedef GeometryRenderer::DiscardStorage DiscardStorageCmd; - typedef GeometryRenderer::FreeTexture FreeTextureCmd; - typedef GeometryRenderer::UnlockStorage UnlockStorageCmd; - typedef GeometryRenderer::FreeStorage FreeStorageCmd; - typedef GeometryRenderer::ApplyBlitStates ApplyBlitStatesCmd; - typedef GeometryRenderer::ApplyStates ApplyStatesCmd; - typedef GeometryRenderer::UploadData UploadDataCmd; + typedef gl::GeometryRenderer::DrawGeometry DrawGeometryCmd; + typedef gl::GeometryRenderer::DiscardStorage DiscardStorageCmd; + typedef gl::GeometryRenderer::FreeTexture FreeTextureCmd; + typedef gl::GeometryRenderer::UnlockStorage UnlockStorageCmd; + typedef gl::GeometryRenderer::FreeStorage FreeStorageCmd; + typedef gl::GeometryRenderer::ApplyBlitStates ApplyBlitStatesCmd; + typedef gl::GeometryRenderer::ApplyStates ApplyStatesCmd; + typedef gl::GeometryRenderer::UploadData UploadDataCmd; - list > m_commands; + list > m_commands; - list > m_discardStorageCmd; - list > m_freeTextureCmd; - list > m_freeStorageCmd; + list > m_discardStorageCmd; + list > m_freeTextureCmd; + list > m_freeStorageCmd; - GeometryRenderer * m_parent; - bool m_isDebugging; + DisplayListRenderer * m_parent; + bool m_isDebugging; - friend class GeometryRenderer; - DisplayList(GeometryRenderer * parent); + DisplayList(DisplayListRenderer * parent); - public: + friend class DisplayListRenderer; - ~DisplayList(); + public: - void applyStates(shared_ptr const & cmd); - void applyBlitStates(shared_ptr const & cmd); - void drawGeometry(shared_ptr const & cmd); - void unlockStorage(shared_ptr const & cmd); - void discardStorage(shared_ptr const & cmd); - void freeTexture(shared_ptr const & cmd); - void freeStorage(shared_ptr const & cmd); - void uploadData(shared_ptr const & cmd); - void addCheckPoint(); + ~DisplayList(); - void draw(math::Matrix const & m); - }; - } + void applyStates(shared_ptr const & cmd); + void applyBlitStates(shared_ptr const & cmd); + void drawGeometry(shared_ptr const & cmd); + void unlockStorage(shared_ptr const & cmd); + void discardStorage(shared_ptr const & cmd); + void freeTexture(shared_ptr const & cmd); + void freeStorage(shared_ptr const & cmd); + void uploadStyles(shared_ptr const & cmd); + void addCheckPoint(); + + void draw(DisplayListRenderer * r, + math::Matrix const & m); + }; } diff --git a/graphics/display_list_renderer.cpp b/graphics/display_list_renderer.cpp new file mode 100644 index 0000000000..3c00bc84bc --- /dev/null +++ b/graphics/display_list_renderer.cpp @@ -0,0 +1,160 @@ +#include "display_list_renderer.hpp" +#include "display_list.hpp" + +namespace graphics +{ + DisplayListRenderer::DisplayListRenderer(Params const & p) + : base_t(p), + m_displayList(0) + { + } + + DisplayList * DisplayListRenderer::createDisplayList() + { + return new DisplayList(this); + } + + void DisplayListRenderer::setDisplayList(DisplayList * dl) + { + m_displayList = dl; + } + + DisplayList * DisplayListRenderer::displayList() const + { + return m_displayList; + } + + void DisplayListRenderer::drawDisplayList(DisplayList * dl, + math::Matrix const & m) + { + dl->draw(this, m); + } + + void DisplayListRenderer::drawGeometry(shared_ptr const & texture, + gl::Storage const & storage, + size_t indicesCount, + size_t indicesOffs, + EPrimitives primType) + { + if (isCancelled()) + return; + + if (m_displayList) + { + shared_ptr command(new DrawGeometry()); + + command->m_texture = texture; + command->m_storage = storage; + command->m_indicesCount = indicesCount; + command->m_indicesOffs = indicesOffs; + command->m_primitiveType = primType; + + m_displayList->drawGeometry(command); + } + else + base_t::drawGeometry(texture, + storage, + indicesCount, + indicesOffs, + primType); + + } + + void DisplayListRenderer::uploadStyles(shared_ptr const * styles, + size_t count, + shared_ptr const & texture) + { + if (isCancelled()) + return; + + if (m_displayList) + m_displayList->uploadStyles(make_shared_ptr(new UploadData(styles, count, texture))); + else + base_t::uploadStyles(styles, count, texture); + } + + void DisplayListRenderer::freeTexture(shared_ptr const & texture, + TTexturePool * texturePool) + { + if (m_displayList) + { + shared_ptr command(new FreeTexture()); + + command->m_texture = texture; + command->m_texturePool = texturePool; + + m_displayList->freeTexture(command); + } + else + base_t::freeTexture(texture, texturePool); + } + + void DisplayListRenderer::freeStorage(gl::Storage const & storage, + TStoragePool * storagePool) + { + if (m_displayList) + { + shared_ptr command(new FreeStorage()); + + command->m_storage = storage; + command->m_storagePool = storagePool; + + m_displayList->freeStorage(command); + } + else + base_t::freeStorage(storage, storagePool); + } + + void DisplayListRenderer::unlockStorage(gl::Storage const & storage) + { + if (m_displayList) + { + shared_ptr cmd(new UnlockStorage()); + + cmd->m_storage = storage; + + m_displayList->unlockStorage(cmd); + } + else + base_t::unlockStorage(storage); + } + + void DisplayListRenderer::discardStorage(gl::Storage const & storage) + { + if (m_displayList) + { + shared_ptr cmd(new DiscardStorage()); + + cmd->m_storage = storage; + + m_displayList->discardStorage(cmd); + } + else + base_t::discardStorage(storage); + } + + void DisplayListRenderer::applyBlitStates() + { + if (m_displayList) + m_displayList->applyBlitStates(make_shared_ptr(new ApplyBlitStates())); + else + base_t::applyBlitStates(); + } + + void DisplayListRenderer::applyStates() + { + if (m_displayList) + m_displayList->applyStates(make_shared_ptr(new ApplyStates())); + else + base_t::applyStates(); + } + + void DisplayListRenderer::addCheckPoint() + { + if (m_displayList) + m_displayList->addCheckPoint(); + else + base_t::addCheckPoint(); + } + +} diff --git a/graphics/display_list_renderer.hpp b/graphics/display_list_renderer.hpp new file mode 100644 index 0000000000..f065442616 --- /dev/null +++ b/graphics/display_list_renderer.hpp @@ -0,0 +1,65 @@ +#pragma once + +#include "opengl/storage.hpp" +#include "opengl/base_texture.hpp" +#include "opengl/geometry_renderer.hpp" + +namespace graphics +{ + class DisplayList; + + class DisplayListRenderer : public gl::GeometryRenderer + { + private: + + DisplayList * m_displayList; + + public: + + typedef gl::GeometryRenderer base_t; + typedef base_t::Params Params; + + DisplayListRenderer(Params const & p); + + /// create display list + DisplayList * createDisplayList(); + /// set current display list + void setDisplayList(DisplayList * displayList); + /// get current display list + DisplayList * displayList() const; + /// draw display list + void drawDisplayList(DisplayList * dl, math::Matrix const & m); + + /// Interceptable commands + /// @{ + + /// draw geometry + void drawGeometry(shared_ptr const & texture, + gl::Storage const & storage, + size_t indicesCount, + size_t indicesOffs, + EPrimitives primType); + /// upload ResourceStyle's on texture + void uploadStyles(shared_ptr const * styles, + size_t count, + shared_ptr const & texture); + /// free texture + void freeTexture(shared_ptr const & texture, + TTexturePool * texturePool); + /// free storage + void freeStorage(gl::Storage const & storage, + TStoragePool * storagePool); + /// unlock storage + void unlockStorage(gl::Storage const & storage); + /// discard storage + void discardStorage(gl::Storage const & storage); + /// add checkpoint + void addCheckPoint(); + /// apply blit states + void applyBlitStates(); + /// apply geometry rendering states + void applyStates(); + + /// @} + }; +} diff --git a/graphics/geometry_batcher.cpp b/graphics/geometry_batcher.cpp index fed5b06fdb..0fbaae07be 100644 --- a/graphics/geometry_batcher.cpp +++ b/graphics/geometry_batcher.cpp @@ -1,12 +1,13 @@ #include "geometry_batcher.hpp" #include "skin.hpp" #include "color.hpp" -#include "utils.hpp" #include "resource_manager.hpp" #include "skin_page.hpp" -#include "base_texture.hpp" +#include "resource_style.hpp" -#include "internal/opengl.hpp" +#include "opengl/base_texture.hpp" +#include "opengl/utils.hpp" +#include "opengl/opengl.hpp" #include "../geometry/rect2d.hpp" @@ -20,792 +21,824 @@ namespace graphics { - namespace gl + GeometryBatcher::Params::Params() + : m_useGuiResources(false) + {} + + GeometryBatcher::GeometryBatcher(Params const & params) + : base_t(params), + m_isAntiAliased(true), + m_useGuiResources(params.m_useGuiResources) { - GeometryBatcher::Params::Params() - : m_useGuiResources(false) - {} + reset(-1); + base_t::applyStates(); - GeometryBatcher::GeometryBatcher(Params const & params) - : base_t(params), - m_isAntiAliased(true), - m_useGuiResources(params.m_useGuiResources) + /// 1 to turn antialiasing on + /// 2 to switch it off + m_aaShift = m_isAntiAliased ? 1 : 2; + } + + GeometryBatcher::~GeometryBatcher() + { + for (size_t i = 0; i < m_pipelines.size(); ++i) { - reset(-1); - base_t::applyStates(); + discardPipeline(i); + freePipeline(i); + if (m_skin->page(i)->type() != SkinPage::EStatic) + freeTexture(i); + } + } - /// 1 to turn antialiasing on - /// 2 to switch it off - m_aaShift = m_isAntiAliased ? 1 : 2; + void GeometryBatcher::reset(int pipelineID) + { + for (size_t i = 0; i < m_pipelines.size(); ++i) + { + if ((pipelineID == -1) || ((size_t)pipelineID == i)) + { + m_pipelines[i].m_currentVertex = 0; + m_pipelines[i].m_currentIndex = 0; + } + } + } + + void GeometryBatcher::GeometryPipeline::checkStorage(shared_ptr const & resourceManager) const + { + if (!m_hasStorage) + { + if (m_useGuiResources) + m_storage = resourceManager->guiThreadStorages()->Reserve(); + else + { + switch (m_type) + { + case SkinPage::EPrimary: + m_storage = resourceManager->primaryStorages()->Reserve(); + break; + case SkinPage::EFonts: + m_storage = resourceManager->smallStorages()->Reserve(); + break; + case SkinPage::EStatic: + m_storage = resourceManager->smallStorages()->Reserve(); + break; + default: + LOG(LERROR, ("invalid storage type in checkStorage")); + } + } + + if (m_storage.m_vertices && m_storage.m_indices) + { + m_maxVertices = m_storage.m_vertices->size() / sizeof(gl::Vertex); + m_maxIndices = m_storage.m_indices->size() / sizeof(unsigned short); + + if (!m_storage.m_vertices->isLocked()) + m_storage.m_vertices->lock(); + if (!m_storage.m_indices->isLocked()) + m_storage.m_indices->lock(); + + m_vertices = (gl::Vertex*)m_storage.m_vertices->data(); + m_indices = (unsigned short *)m_storage.m_indices->data(); + + m_hasStorage = true; + } + else + { + m_maxVertices = 0; + m_maxIndices = 0; + + m_vertices = 0; + m_indices = 0; + + m_hasStorage = false; + } + } + } + + void GeometryBatcher::freePipeline(int pipelineID) + { + GeometryPipeline & pipeline = m_pipelines[pipelineID]; + + if (pipeline.m_hasStorage) + { + TStoragePool * storagePool = 0; + if (pipeline.m_useGuiResources) + storagePool = resourceManager()->guiThreadStorages(); + else + switch (pipeline.m_type) + { + case SkinPage::EPrimary: + storagePool = resourceManager()->primaryStorages(); + break; + case SkinPage::EFonts: + storagePool = resourceManager()->smallStorages(); + break; + case SkinPage::EStatic: + storagePool = resourceManager()->smallStorages(); + break; + default: + LOG(LERROR, ("invalid pipeline type in freePipeline")); + break; + } + + base_t::freeStorage(pipeline.m_storage, storagePool); + + pipeline.m_hasStorage = false; + pipeline.m_storage = gl::Storage(); + } + } + + void GeometryBatcher::setSkin(shared_ptr skin) + { + m_skin = skin; + if (m_skin != 0) + { + /// settings proper skin page type according to useGuiResources flag + if (m_useGuiResources) + for (size_t i = 0; i < m_skin->pagesCount(); ++i) + if (m_skin->page(i)->type() != SkinPage::EStatic) + m_skin->page(i)->setType(SkinPage::ELightWeight); + + m_pipelines.resize(m_skin->pagesCount()); + + m_skin->addClearPageFn(bind(&GeometryBatcher::flush, this, _1), 100); + m_skin->addClearPageFn(bind(&GeometryBatcher::freeTexture, this, _1), 99); + + for (size_t i = 0; i < m_pipelines.size(); ++i) + { + m_pipelines[i].m_useGuiResources = m_useGuiResources; + m_pipelines[i].m_currentVertex = 0; + m_pipelines[i].m_currentIndex = 0; + + m_pipelines[i].m_hasStorage = false; + m_pipelines[i].m_type = skin->page(i)->type(); + + m_pipelines[i].m_maxVertices = 0; + m_pipelines[i].m_maxIndices = 0; + + m_pipelines[i].m_vertices = 0; + m_pipelines[i].m_indices = 0; + } + } + } + + shared_ptr const & GeometryBatcher::skin() const + { + return m_skin; + } + + void GeometryBatcher::beginFrame() + { + base_t::beginFrame(); + reset(-1); + for (size_t i = 0; i < m_pipelines.size(); ++i) + { + m_pipelines[i].m_verticesDrawn = 0; + m_pipelines[i].m_indicesDrawn = 0; + } + } + + void GeometryBatcher::clear(graphics::Color const & c, bool clearRT, float depth, bool clearDepth) + { + flush(-1); + base_t::clear(c, clearRT, depth, clearDepth); + } + + void GeometryBatcher::setRenderTarget(shared_ptr const & rt) + { + flush(-1); + base_t::setRenderTarget(rt); + } + + void GeometryBatcher::endFrame() + { + flush(-1); + /// Syncronization point. + enableClipRect(false); + + if (isDebugging()) + { + for (size_t i = 0; i < m_pipelines.size(); ++i) + if ((m_pipelines[i].m_verticesDrawn != 0) || (m_pipelines[i].m_indicesDrawn != 0)) + { + LOG(LINFO, ("pipeline #", i, " vertices=", m_pipelines[i].m_verticesDrawn, ", triangles=", m_pipelines[i].m_indicesDrawn / 3)); + } } - GeometryBatcher::~GeometryBatcher() - { - for (size_t i = 0; i < m_pipelines.size(); ++i) - { - discardPipeline(i); - freePipeline(i); - if (m_skin->page(i)->type() != SkinPage::EStatic) - freeTexture(i); - } - } + /// is the rendering was cancelled, there possibly could + /// be "ghost" render styles which are present in internal + /// skin structures, but aren't rendered onto skin texture. + /// so we are clearing the whole skin, to ensure that they + /// are gone(slightly heavy, but very simple solution). + if (isCancelled()) + m_skin->clearHandles(); - void GeometryBatcher::reset(int pipelineID) - { - for (size_t i = 0; i < m_pipelines.size(); ++i) - { - if ((pipelineID == -1) || ((size_t)pipelineID == i)) - { - m_pipelines[i].m_currentVertex = 0; - m_pipelines[i].m_currentIndex = 0; - } - } - } + base_t::endFrame(); + } - void GeometryBatcher::GeometryPipeline::checkStorage(shared_ptr const & resourceManager) const - { - if (!m_hasStorage) - { - if (m_useGuiResources) - m_storage = resourceManager->guiThreadStorages()->Reserve(); - else - { - switch (m_type) - { - case SkinPage::EPrimary: - m_storage = resourceManager->primaryStorages()->Reserve(); - break; - case SkinPage::EFonts: - m_storage = resourceManager->smallStorages()->Reserve(); - break; - case SkinPage::EStatic: - m_storage = resourceManager->smallStorages()->Reserve(); - break; - default: - LOG(LERROR, ("invalid storage type in checkStorage")); - } - } + bool GeometryBatcher::hasRoom(size_t verticesCount, size_t indicesCount, int pipelineID) const + { + GeometryPipeline const & pipeline = m_pipelines[pipelineID]; - if (m_storage.m_vertices && m_storage.m_indices) - { - m_maxVertices = m_storage.m_vertices->size() / sizeof(Vertex); - m_maxIndices = m_storage.m_indices->size() / sizeof(unsigned short); + pipeline.checkStorage(resourceManager()); + if (!pipeline.m_hasStorage) + return false; - if (!m_storage.m_vertices->isLocked()) - m_storage.m_vertices->lock(); - if (!m_storage.m_indices->isLocked()) - m_storage.m_indices->lock(); + return ((pipeline.m_currentVertex + verticesCount <= pipeline.m_maxVertices) + && (pipeline.m_currentIndex + indicesCount <= pipeline.m_maxIndices)); + } - m_vertices = (Vertex*)m_storage.m_vertices->data(); - m_indices = (unsigned short *)m_storage.m_indices->data(); + int GeometryBatcher::verticesLeft(int pipelineID) const + { + GeometryPipeline const & pipeline = m_pipelines[pipelineID]; - m_hasStorage = true; - } - else - { - m_maxVertices = 0; - m_maxIndices = 0; + pipeline.checkStorage(resourceManager()); + if (!pipeline.m_hasStorage) + return -1; - m_vertices = 0; - m_indices = 0; + return pipeline.m_maxVertices - pipeline.m_currentVertex; + } - m_hasStorage = false; - } - } - } + int GeometryBatcher::indicesLeft(int pipelineID) const + { + GeometryPipeline const & pipeline = m_pipelines[pipelineID]; - void GeometryBatcher::freePipeline(int pipelineID) - { - GeometryPipeline & pipeline = m_pipelines[pipelineID]; + pipeline.checkStorage(resourceManager()); + if (!pipeline.m_hasStorage) + return -1; - if (pipeline.m_hasStorage) - { - TStoragePool * storagePool = 0; - if (pipeline.m_useGuiResources) - storagePool = resourceManager()->guiThreadStorages(); - else - switch (pipeline.m_type) - { - case SkinPage::EPrimary: - storagePool = resourceManager()->primaryStorages(); - break; - case SkinPage::EFonts: - storagePool = resourceManager()->smallStorages(); - break; - case SkinPage::EStatic: - storagePool = resourceManager()->smallStorages(); - break; - default: - LOG(LERROR, ("invalid pipeline type in freePipeline")); - break; - } + return pipeline.m_maxIndices - pipeline.m_currentIndex; + } - base_t::freeStorage(pipeline.m_storage, storagePool); + void GeometryBatcher::flush(int pipelineID) + { + if (m_skin) + { + for (size_t i = m_pipelines.size(); i > 0; --i) + { + size_t id = i - 1; - pipeline.m_hasStorage = false; - pipeline.m_storage = Storage(); - } - } + if ((pipelineID == -1) || (id == (size_t)pipelineID)) + { + if (flushPipeline(m_skin->page(id), id)) + { + int nextPage = m_skin->nextPage(id); - void GeometryBatcher::setSkin(shared_ptr skin) - { - m_skin = skin; - if (m_skin != 0) - { - /// settings proper skin page type according to useGuiResources flag - if (m_useGuiResources) - for (size_t i = 0; i < m_skin->pagesCount(); ++i) - if (m_skin->page(i)->type() != SkinPage::EStatic) - m_skin->page(i)->setType(SkinPage::ELightWeight); + if (nextPage != id) + { + // reserving texture in advance, before we'll + // potentially return current texture into the pool. + m_skin->page(nextPage)->checkTexture(); + } - m_pipelines.resize(m_skin->pagesCount()); + m_skin->changePage(id); + } - m_skin->addClearPageFn(bind(&GeometryBatcher::flush, this, _1), 100); - m_skin->addClearPageFn(bind(&GeometryBatcher::freeTexture, this, _1), 99); + /// resetting geometry storage associated + /// with the specified pipeline. + reset(id); + } + } + } + } - for (size_t i = 0; i < m_pipelines.size(); ++i) - { - m_pipelines[i].m_useGuiResources = m_useGuiResources; - m_pipelines[i].m_currentVertex = 0; - m_pipelines[i].m_currentIndex = 0; + void GeometryBatcher::freeTexture(int pipelineID) + { + if (!m_skin->page(pipelineID)->hasTexture()) + return; - m_pipelines[i].m_hasStorage = false; - m_pipelines[i].m_type = skin->page(i)->type(); + shared_ptr texture = m_skin->page(pipelineID)->texture(); + TTexturePool * texturePool = 0; - m_pipelines[i].m_maxVertices = 0; - m_pipelines[i].m_maxIndices = 0; + switch (m_skin->page(pipelineID)->type()) + { + case SkinPage::EPrimary: + texturePool = resourceManager()->primaryTextures(); + break; + case SkinPage::EFonts: + texturePool = resourceManager()->fontTextures(); + break; + case SkinPage::ELightWeight: + texturePool = resourceManager()->guiThreadTextures(); + break; + case SkinPage::EStatic: + LOG(LWARNING, ("texture with EStatic can't be freed.")); + return; + } - m_pipelines[i].m_vertices = 0; - m_pipelines[i].m_indices = 0; - } - } - } + base_t::freeTexture(texture, texturePool); - shared_ptr const & GeometryBatcher::skin() const - { - return m_skin; - } + m_skin->page(pipelineID)->resetTexture(); + } - void GeometryBatcher::beginFrame() - { - base_t::beginFrame(); - reset(-1); - for (size_t i = 0; i < m_pipelines.size(); ++i) - { - m_pipelines[i].m_verticesDrawn = 0; - m_pipelines[i].m_indicesDrawn = 0; - } - } + void GeometryBatcher::unlockPipeline(int pipelineID) + { + GeometryPipeline & pipeline = m_pipelines[pipelineID]; + base_t::unlockStorage(pipeline.m_storage); + } - void GeometryBatcher::clear(graphics::Color const & c, bool clearRT, float depth, bool clearDepth) - { - flush(-1); - base_t::clear(c, clearRT, depth, clearDepth); - } + void GeometryBatcher::discardPipeline(int pipelineID) + { + GeometryPipeline & pipeline = m_pipelines[pipelineID]; - void GeometryBatcher::setRenderTarget(shared_ptr const & rt) - { - flush(-1); - base_t::setRenderTarget(rt); - } + if (pipeline.m_hasStorage) + base_t::discardStorage(pipeline.m_storage); + } - void GeometryBatcher::endFrame() - { - flush(-1); - /// Syncronization point. - enableClipRect(false); + bool GeometryBatcher::flushPipeline(shared_ptr const & skinPage, + int pipelineID) + { + GeometryPipeline & pipeline = m_pipelines[pipelineID]; + if (pipeline.m_currentIndex) + { + if (skinPage->hasData()) + { + uploadStyles(&skinPage->uploadQueue()[0], skinPage->uploadQueue().size(), skinPage->texture()); + skinPage->clearUploadQueue(); + } - if (isDebugging()) - { - for (size_t i = 0; i < m_pipelines.size(); ++i) - if ((m_pipelines[i].m_verticesDrawn != 0) || (m_pipelines[i].m_indicesDrawn != 0)) - { - LOG(LINFO, ("pipeline #", i, " vertices=", m_pipelines[i].m_verticesDrawn, ", triangles=", m_pipelines[i].m_indicesDrawn / 3)); - } - } + unlockPipeline(pipelineID); - /// is the rendering was cancelled, there possibly could - /// be "ghost" render styles which are present in internal - /// skin structures, but aren't rendered onto skin texture. - /// so we are clearing the whole skin, to ensure that they - /// are gone(slightly heavy, but very simple solution). - if (isCancelled()) - m_skin->clearHandles(); + drawGeometry(skinPage->texture(), + pipeline.m_storage, + pipeline.m_currentIndex, + 0, + ETriangles); - base_t::endFrame(); - } + discardPipeline(pipelineID); - bool GeometryBatcher::hasRoom(size_t verticesCount, size_t indicesCount, int pipelineID) const - { - GeometryPipeline const & pipeline = m_pipelines[pipelineID]; - pipeline.checkStorage(resourceManager()); - if (!pipeline.m_hasStorage) - return false; + if (isDebugging()) + { + pipeline.m_verticesDrawn += pipeline.m_currentVertex; + pipeline.m_indicesDrawn += pipeline.m_currentIndex; + // LOG(LINFO, ("Pipeline #", i - 1, "draws ", pipeline.m_currentIndex / 3, "/", pipeline.m_maxIndices / 3," triangles")); + } - return ((pipeline.m_currentVertex + verticesCount <= pipeline.m_maxVertices) - && (pipeline.m_currentIndex + indicesCount <= pipeline.m_maxIndices)); - } + freePipeline(pipelineID); - int GeometryBatcher::verticesLeft(int pipelineID) const - { - GeometryPipeline const & pipeline = m_pipelines[pipelineID]; + pipeline.m_maxIndices = 0; + pipeline.m_maxVertices = 0; + pipeline.m_vertices = 0; + pipeline.m_indices = 0; + pipeline.m_currentIndex = 0; + pipeline.m_currentVertex = 0; - pipeline.checkStorage(resourceManager()); - if (!pipeline.m_hasStorage) - return -1; + return true; + } - return pipeline.m_maxVertices - pipeline.m_currentVertex; - } + return false; + } - int GeometryBatcher::indicesLeft(int pipelineID) const - { - GeometryPipeline const & pipeline = m_pipelines[pipelineID]; + void GeometryBatcher::drawTexturedPolygon( + m2::PointD const & ptShift, + ang::AngleD const & angle, + float tx0, float ty0, float tx1, float ty1, + float x0, float y0, float x1, float y1, + double depth, + int pipelineID) + { + if (!hasRoom(4, 6, pipelineID)) + flush(pipelineID); - pipeline.checkStorage(resourceManager()); - if (!pipeline.m_hasStorage) - return -1; + m_pipelines[pipelineID].checkStorage(resourceManager()); + if (!m_pipelines[pipelineID].m_hasStorage) + return; - return pipeline.m_maxIndices - pipeline.m_currentIndex; - } + float texMinX = tx0; + float texMaxX = tx1; + float texMinY = ty0; + float texMaxY = ty1; - void GeometryBatcher::flush(int pipelineID) - { - if (m_skin) - { - for (size_t i = m_pipelines.size(); i > 0; --i) - { - size_t id = i - 1; + shared_ptr const & texture = m_skin->page(pipelineID)->texture(); - if ((pipelineID == -1) || (id == (size_t)pipelineID)) - { - if (flushPipeline(m_skin->page(id), id)) - { - int nextPage = m_skin->nextPage(id); + if (!texture) + { + LOG(LDEBUG, ("returning as no texture is reserved")); + return; + } - if (nextPage != id) - { - // reserving texture in advance, before we'll - // potentially return current texture into the pool. - m_skin->page(nextPage)->checkTexture(); - } + texture->mapPixel(texMinX, texMinY); + texture->mapPixel(texMaxX, texMaxY); - m_skin->changePage(id); - } + /// rotated and translated four points (x0, y0), (x0, y1), (x1, y1), (x1, y0) - /// resetting geometry storage associated - /// with the specified pipeline. - reset(id); - } - } - } - } + m2::PointF coords[4] = + { + m2::PointF(x0 * angle.cos() - y0 * angle.sin() + ptShift.x, x0 * angle.sin() + y0 * angle.cos() + ptShift.y), + m2::PointF(x0 * angle.cos() - y1 * angle.sin() + ptShift.x, x0 * angle.sin() + y1 * angle.cos() + ptShift.y), + m2::PointF(x1 * angle.cos() - y1 * angle.sin() + ptShift.x, x1 * angle.sin() + y1 * angle.cos() + ptShift.y), + m2::PointF(x1 * angle.cos() - y0 * angle.sin() + ptShift.x, x1 * angle.sin() + y0 * angle.cos() + ptShift.y) + }; - void GeometryBatcher::freeTexture(int pipelineID) - { - if (!m_skin->page(pipelineID)->hasTexture()) - return; + /// Special case. Making straight fonts sharp. + if (angle.val() == 0) + { + float deltaX = coords[0].x - ceil(coords[0].x); + float deltaY = coords[0].y - ceil(coords[0].y); - shared_ptr texture = m_skin->page(pipelineID)->texture(); - TTexturePool * texturePool = 0; + for (size_t i = 0; i < 4; ++i) + { + coords[i].x -= deltaX; + coords[i].y -= deltaY; + } + } - switch (m_skin->page(pipelineID)->type()) - { - case SkinPage::EPrimary: - texturePool = resourceManager()->primaryTextures(); - break; - case SkinPage::EFonts: - texturePool = resourceManager()->fontTextures(); - break; - case SkinPage::ELightWeight: - texturePool = resourceManager()->guiThreadTextures(); - break; - case SkinPage::EStatic: - LOG(LWARNING, ("texture with EStatic can't be freed.")); - return; - } + m2::PointF texCoords[4] = + { + m2::PointF(texMinX, texMinY), + m2::PointF(texMinX, texMaxY), + m2::PointF(texMaxX, texMaxY), + m2::PointF(texMaxX, texMinY) + }; - base_t::freeTexture(texture, texturePool); + m2::PointF normal(0, 0); - m_skin->page(pipelineID)->resetTexture(); - } + addTexturedFanStrided(coords, sizeof(m2::PointF), + &normal, 0, + texCoords, sizeof(m2::PointF), + 4, + depth, + pipelineID); + } - void GeometryBatcher::unlockPipeline(int pipelineID) - { - GeometryPipeline & pipeline = m_pipelines[pipelineID]; - base_t::unlockStorage(pipeline.m_storage); - } + void GeometryBatcher::drawStraightTexturedPolygon( + m2::PointD const & ptPivot, + float tx0, float ty0, float tx1, float ty1, + float x0, float y0, float x1, float y1, + double depth, + int pipelineID) + { + if (!hasRoom(4, 6, pipelineID)) + flush(pipelineID); - void GeometryBatcher::discardPipeline(int pipelineID) - { - GeometryPipeline & pipeline = m_pipelines[pipelineID]; + m_pipelines[pipelineID].checkStorage(resourceManager()); + if (!m_pipelines[pipelineID].m_hasStorage) + return; - if (pipeline.m_hasStorage) - base_t::discardStorage(pipeline.m_storage); - } + float texMinX = tx0; + float texMaxX = tx1; + float texMinY = ty0; + float texMaxY = ty1; - bool GeometryBatcher::flushPipeline(shared_ptr const & skinPage, + shared_ptr const & texture = m_skin->page(pipelineID)->texture(); + + if (!texture) + { + LOG(LDEBUG, ("returning as no texture is reserved")); + return; + } + + texture->mapPixel(texMinX, texMinY); + texture->mapPixel(texMaxX, texMaxY); + + /// rotated and translated four points (x0, y0), (x0, y1), (x1, y1), (x1, y0) + + m2::PointF offsets[4] = + { + m2::PointF(x0, y0), + m2::PointF(x0, y1), + m2::PointF(x1, y1), + m2::PointF(x1, y0) + }; + + m2::PointF texCoords[4] = + { + m2::PointF(texMinX, texMinY), + m2::PointF(texMinX, texMaxY), + m2::PointF(texMaxX, texMaxY), + m2::PointF(texMaxX, texMinY) + }; + + m2::PointF pv(ptPivot.x, ptPivot.y); + + addTexturedFanStrided(&pv, 0, + offsets, sizeof(m2::PointF), + texCoords, sizeof(m2::PointF), + 4, + depth, + pipelineID); + } + + + void GeometryBatcher::addTexturedFan(m2::PointF const * coords, + m2::PointF const * normals, + m2::PointF const * texCoords, + unsigned size, + double depth, int pipelineID) - { - GeometryPipeline & pipeline = m_pipelines[pipelineID]; - if (pipeline.m_currentIndex) - { - if (skinPage->hasData()) - { - uploadTexture(skinPage->uploadQueue(), skinPage->texture()); - skinPage->clearUploadQueue(); - } + { + addTexturedFanStrided(coords, sizeof(m2::PointF), + normals, sizeof(m2::PointF), + texCoords, sizeof(m2::PointF), + size, + depth, + pipelineID); + } - unlockPipeline(pipelineID); + void GeometryBatcher::addTexturedFanStrided(m2::PointF const * coords, + size_t coordsStride, + m2::PointF const * normals, + size_t normalsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pipelineID) + { + if (!hasRoom(size, (size - 2) * 3, pipelineID)) + flush(pipelineID); - drawGeometry(skinPage->texture(), - pipeline.m_storage, - pipeline.m_currentIndex, - 0, - GL_TRIANGLES); + GeometryPipeline & pipeline = m_pipelines[pipelineID]; - discardPipeline(pipelineID); + pipeline.checkStorage(resourceManager()); + if (!pipeline.m_hasStorage) + return; + + ASSERT(size > 2, ()); + + size_t vOffset = pipeline.m_currentVertex; + size_t iOffset = pipeline.m_currentIndex; + + for (unsigned i = 0; i < size; ++i) + { + pipeline.m_vertices[vOffset + i].pt = *coords; + pipeline.m_vertices[vOffset + i].normal = *normals; + pipeline.m_vertices[vOffset + i].tex = *texCoords; + pipeline.m_vertices[vOffset + i].depth = depth; + coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); + normals = reinterpret_cast(reinterpret_cast(normals) + normalsStride); + texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); + } + + pipeline.m_currentVertex += size; + + for (size_t j = 0; j < size - 2; ++j) + { + pipeline.m_indices[iOffset + j * 3] = vOffset; + pipeline.m_indices[iOffset + j * 3 + 1] = vOffset + j + 1; + pipeline.m_indices[iOffset + j * 3 + 2] = vOffset + j + 2; + } + + pipeline.m_currentIndex += (size - 2) * 3; + } + + void GeometryBatcher::addTexturedStrip( + m2::PointF const * coords, + m2::PointF const * normals, + m2::PointF const * texCoords, + unsigned size, + double depth, + int pipelineID + ) + { + addTexturedStripStrided(coords, sizeof(m2::PointF), + normals, sizeof(m2::PointF), + texCoords, sizeof(m2::PointF), + size, + depth, + pipelineID); + } + + void GeometryBatcher::addTexturedStripStrided( + m2::PointF const * coords, + size_t coordsStride, + m2::PointF const * normals, + size_t normalsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pipelineID) + { + if (!hasRoom(size, (size - 2) * 3, pipelineID)) + flush(pipelineID); + + GeometryPipeline & pipeline = m_pipelines[pipelineID]; + + pipeline.checkStorage(resourceManager()); + if (!pipeline.m_hasStorage) + return; + + ASSERT(size > 2, ()); + + size_t vOffset = pipeline.m_currentVertex; + size_t iOffset = pipeline.m_currentIndex; + + for (unsigned i = 0; i < size; ++i) + { + pipeline.m_vertices[vOffset + i].pt = *coords; + pipeline.m_vertices[vOffset + i].normal = *normals; + pipeline.m_vertices[vOffset + i].tex = *texCoords; + pipeline.m_vertices[vOffset + i].depth = depth; + coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); + normals = reinterpret_cast(reinterpret_cast(normals) + normalsStride); + texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); + } + + pipeline.m_currentVertex += size; + + size_t oldIdx1 = vOffset; + size_t oldIdx2 = vOffset + 1; + + for (size_t j = 0; j < size - 2; ++j) + { + pipeline.m_indices[iOffset + j * 3] = oldIdx1; + pipeline.m_indices[iOffset + j * 3 + 1] = oldIdx2; + pipeline.m_indices[iOffset + j * 3 + 2] = vOffset + j + 2; + + oldIdx1 = oldIdx2; + oldIdx2 = vOffset + j + 2; + } + + pipeline.m_currentIndex += (size - 2) * 3; + } + + void GeometryBatcher::addTexturedListStrided( + m2::PointD const * coords, + size_t coordsStride, + m2::PointF const * normals, + size_t normalsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pipelineID) + { + if (!hasRoom(size, size, pipelineID)) + flush(pipelineID); + + GeometryPipeline & pipeline = m_pipelines[pipelineID]; + + pipeline.checkStorage(resourceManager()); + if (!pipeline.m_hasStorage) + return; + + ASSERT(size > 2, ()); + + size_t vOffset = pipeline.m_currentVertex; + size_t iOffset = pipeline.m_currentIndex; + + for (size_t i = 0; i < size; ++i) + { + pipeline.m_vertices[vOffset + i].pt = m2::PointF(coords->x, coords->y); + pipeline.m_vertices[vOffset + i].normal = *normals; + pipeline.m_vertices[vOffset + i].tex = *texCoords; + pipeline.m_vertices[vOffset + i].depth = depth; + coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); + normals = reinterpret_cast(reinterpret_cast(normals) + normalsStride); + texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); + } + + pipeline.m_currentVertex += size; + + for (size_t i = 0; i < size; ++i) + pipeline.m_indices[iOffset + i] = vOffset + i; + + pipeline.m_currentIndex += size; + } - if (isDebugging()) - { - pipeline.m_verticesDrawn += pipeline.m_currentVertex; - pipeline.m_indicesDrawn += pipeline.m_currentIndex; -// LOG(LINFO, ("Pipeline #", i - 1, "draws ", pipeline.m_currentIndex / 3, "/", pipeline.m_maxIndices / 3," triangles")); - } + void GeometryBatcher::addTexturedListStrided( + m2::PointF const * coords, + size_t coordsStride, + m2::PointF const * normals, + size_t normalsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pipelineID) + { + if (!hasRoom(size, size, pipelineID)) + flush(pipelineID); - freePipeline(pipelineID); + GeometryPipeline & pipeline = m_pipelines[pipelineID]; - pipeline.m_maxIndices = 0; - pipeline.m_maxVertices = 0; - pipeline.m_vertices = 0; - pipeline.m_indices = 0; - pipeline.m_currentIndex = 0; - pipeline.m_currentVertex = 0; + pipeline.checkStorage(resourceManager()); + if (!pipeline.m_hasStorage) + return; - return true; - } + ASSERT(size > 2, ()); - return false; - } + size_t vOffset = pipeline.m_currentVertex; + size_t iOffset = pipeline.m_currentIndex; - void GeometryBatcher::drawTexturedPolygon( - m2::PointD const & ptShift, - ang::AngleD const & angle, - float tx0, float ty0, float tx1, float ty1, - float x0, float y0, float x1, float y1, - double depth, - int pipelineID) - { - if (!hasRoom(4, 6, pipelineID)) - flush(pipelineID); + for (size_t i = 0; i < size; ++i) + { + pipeline.m_vertices[vOffset + i].pt = *coords; + pipeline.m_vertices[vOffset + i].normal = *normals; + pipeline.m_vertices[vOffset + i].tex = *texCoords; + pipeline.m_vertices[vOffset + i].depth = depth; + coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); + normals = reinterpret_cast(reinterpret_cast(normals) + normalsStride); + texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); + } - m_pipelines[pipelineID].checkStorage(resourceManager()); - if (!m_pipelines[pipelineID].m_hasStorage) - return; + pipeline.m_currentVertex += size; - float texMinX = tx0; - float texMaxX = tx1; - float texMinY = ty0; - float texMaxY = ty1; + for (size_t i = 0; i < size; ++i) + pipeline.m_indices[iOffset + i] = vOffset + i; - shared_ptr const & texture = m_skin->page(pipelineID)->texture(); + pipeline.m_currentIndex += size; + } - if (!texture) - { - LOG(LDEBUG, ("returning as no texture is reserved")); - return; - } - - texture->mapPixel(texMinX, texMinY); - texture->mapPixel(texMaxX, texMaxY); - - /// rotated and translated four points (x0, y0), (x0, y1), (x1, y1), (x1, y0) - - m2::PointF coords[4] = - { - m2::PointF(x0 * angle.cos() - y0 * angle.sin() + ptShift.x, x0 * angle.sin() + y0 * angle.cos() + ptShift.y), - m2::PointF(x0 * angle.cos() - y1 * angle.sin() + ptShift.x, x0 * angle.sin() + y1 * angle.cos() + ptShift.y), - m2::PointF(x1 * angle.cos() - y1 * angle.sin() + ptShift.x, x1 * angle.sin() + y1 * angle.cos() + ptShift.y), - m2::PointF(x1 * angle.cos() - y0 * angle.sin() + ptShift.x, x1 * angle.sin() + y0 * angle.cos() + ptShift.y) - }; - - /// Special case. Making straight fonts sharp. - if (angle.val() == 0) - { - float deltaX = coords[0].x - ceil(coords[0].x); - float deltaY = coords[0].y - ceil(coords[0].y); - - for (size_t i = 0; i < 4; ++i) - { - coords[i].x -= deltaX; - coords[i].y -= deltaY; - } - } - - m2::PointF texCoords[4] = - { - m2::PointF(texMinX, texMinY), - m2::PointF(texMinX, texMaxY), - m2::PointF(texMaxX, texMaxY), - m2::PointF(texMaxX, texMinY) - }; - - m2::PointF normal(0, 0); - - addTexturedFanStrided(coords, sizeof(m2::PointF), - &normal, 0, - texCoords, sizeof(m2::PointF), - 4, - depth, - pipelineID); - } - - void GeometryBatcher::drawStraightTexturedPolygon( - m2::PointD const & ptPivot, - float tx0, float ty0, float tx1, float ty1, - float x0, float y0, float x1, float y1, - double depth, - int pipelineID) - { - if (!hasRoom(4, 6, pipelineID)) - flush(pipelineID); - - m_pipelines[pipelineID].checkStorage(resourceManager()); - if (!m_pipelines[pipelineID].m_hasStorage) - return; - - float texMinX = tx0; - float texMaxX = tx1; - float texMinY = ty0; - float texMaxY = ty1; - - shared_ptr const & texture = m_skin->page(pipelineID)->texture(); - - if (!texture) - { - LOG(LDEBUG, ("returning as no texture is reserved")); - return; - } - - texture->mapPixel(texMinX, texMinY); - texture->mapPixel(texMaxX, texMaxY); - - /// rotated and translated four points (x0, y0), (x0, y1), (x1, y1), (x1, y0) - - m2::PointF offsets[4] = - { - m2::PointF(x0, y0), - m2::PointF(x0, y1), - m2::PointF(x1, y1), - m2::PointF(x1, y0) - }; - - m2::PointF texCoords[4] = - { - m2::PointF(texMinX, texMinY), - m2::PointF(texMinX, texMaxY), - m2::PointF(texMaxX, texMaxY), - m2::PointF(texMaxX, texMinY) - }; - - m2::PointF pv(ptPivot.x, ptPivot.y); - - addTexturedFanStrided(&pv, 0, - offsets, sizeof(m2::PointF), - texCoords, sizeof(m2::PointF), - 4, - depth, - pipelineID); - } - - - void GeometryBatcher::addTexturedFan(m2::PointF const * coords, + void GeometryBatcher::addTexturedList(m2::PointF const * coords, m2::PointF const * normals, m2::PointF const * texCoords, unsigned size, double depth, int pipelineID) - { - addTexturedFanStrided(coords, sizeof(m2::PointF), + { + addTexturedListStrided(coords, sizeof(m2::PointF), normals, sizeof(m2::PointF), texCoords, sizeof(m2::PointF), - size, - depth, - pipelineID); - } + size, depth, pipelineID); + } - void GeometryBatcher::addTexturedFanStrided(m2::PointF const * coords, - size_t coordsStride, - m2::PointF const * normals, - size_t normalsStride, - m2::PointF const * texCoords, - size_t texCoordsStride, - unsigned size, - double depth, - int pipelineID) - { - if (!hasRoom(size, (size - 2) * 3, pipelineID)) - flush(pipelineID); + void GeometryBatcher::enableClipRect(bool flag) + { + flush(-1); + base_t::enableClipRect(flag); + } - GeometryPipeline & pipeline = m_pipelines[pipelineID]; + void GeometryBatcher::setClipRect(m2::RectI const & rect) + { + flush(-1); + base_t::setClipRect(rect); + } - pipeline.checkStorage(resourceManager()); - if (!pipeline.m_hasStorage) - return; + int GeometryBatcher::aaShift() const + { + return m_aaShift; + } - ASSERT(size > 2, ()); + void GeometryBatcher::memoryWarning() + { + if (m_skin) + m_skin->memoryWarning(); + } - size_t vOffset = pipeline.m_currentVertex; - size_t iOffset = pipeline.m_currentIndex; + void GeometryBatcher::enterBackground() + { + if (m_skin) + m_skin->enterBackground(); + } - for (unsigned i = 0; i < size; ++i) - { - pipeline.m_vertices[vOffset + i].pt = *coords; - pipeline.m_vertices[vOffset + i].normal = *normals; - pipeline.m_vertices[vOffset + i].tex = *texCoords; - pipeline.m_vertices[vOffset + i].depth = depth; - coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); - normals = reinterpret_cast(reinterpret_cast(normals) + normalsStride); - texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); - } + void GeometryBatcher::enterForeground() + { + if (m_skin) + m_skin->enterForeground(); + } - pipeline.m_currentVertex += size; + void GeometryBatcher::setDisplayList(DisplayList * dl) + { + flush(-1); + base_t::setDisplayList(dl); + } - for (size_t j = 0; j < size - 2; ++j) - { - pipeline.m_indices[iOffset + j * 3] = vOffset; - pipeline.m_indices[iOffset + j * 3 + 1] = vOffset + j + 1; - pipeline.m_indices[iOffset + j * 3 + 2] = vOffset + j + 2; - } + void GeometryBatcher::drawDisplayList(DisplayList * dl, math::Matrix const & m) + { + flush(-1); + base_t::drawDisplayList(dl, m); + } - pipeline.m_currentIndex += (size - 2) * 3; - } + void GeometryBatcher::setPixelPrecision(bool flag) + { + flush(-1); + base_t::setPixelPrecision(flag); + } - void GeometryBatcher::addTexturedStrip( - m2::PointF const * coords, - m2::PointF const * normals, - m2::PointF const * texCoords, - unsigned size, - double depth, - int pipelineID - ) - { - addTexturedStripStrided(coords, sizeof(m2::PointF), - normals, sizeof(m2::PointF), - texCoords, sizeof(m2::PointF), - size, - depth, - pipelineID); - } + void GeometryBatcher::uploadStyles(shared_ptr const * styles, + size_t count, + shared_ptr const & texture) + { + /// splitting the whole queue of commands into the chunks no more + /// than 64KB of uploadable data each - void GeometryBatcher::addTexturedStripStrided( - m2::PointF const * coords, - size_t coordsStride, - m2::PointF const * normals, - size_t normalsStride, - m2::PointF const * texCoords, - size_t texCoordsStride, - unsigned size, - double depth, - int pipelineID) - { - if (!hasRoom(size, (size - 2) * 3, pipelineID)) - flush(pipelineID); + size_t bytesUploaded = 0; + size_t bytesPerPixel = graphics::formatSize(resourceManager()->params().m_texFormat); + size_t prev = 0; - GeometryPipeline & pipeline = m_pipelines[pipelineID]; + for (size_t i = 0; i < count; ++i) + { + shared_ptr const & style = styles[i]; - pipeline.checkStorage(resourceManager()); - if (!pipeline.m_hasStorage) - return; + bytesUploaded += style->m_texRect.SizeX() * style->m_texRect.SizeY() * bytesPerPixel; - ASSERT(size > 2, ()); + if (bytesUploaded > 64 * 1024) + { + base_t::uploadStyles(styles + prev, i + 1 - prev, texture); + if (i + 1 < count) + addCheckPoint(); - size_t vOffset = pipeline.m_currentVertex; - size_t iOffset = pipeline.m_currentIndex; + prev = i + 1; + bytesUploaded = 0; + } + } - for (unsigned i = 0; i < size; ++i) - { - pipeline.m_vertices[vOffset + i].pt = *coords; - pipeline.m_vertices[vOffset + i].normal = *normals; - pipeline.m_vertices[vOffset + i].tex = *texCoords; - pipeline.m_vertices[vOffset + i].depth = depth; - coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); - normals = reinterpret_cast(reinterpret_cast(normals) + normalsStride); - texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); - } - - pipeline.m_currentVertex += size; - - size_t oldIdx1 = vOffset; - size_t oldIdx2 = vOffset + 1; - - for (size_t j = 0; j < size - 2; ++j) - { - pipeline.m_indices[iOffset + j * 3] = oldIdx1; - pipeline.m_indices[iOffset + j * 3 + 1] = oldIdx2; - pipeline.m_indices[iOffset + j * 3 + 2] = vOffset + j + 2; - - oldIdx1 = oldIdx2; - oldIdx2 = vOffset + j + 2; - } - - pipeline.m_currentIndex += (size - 2) * 3; - } - - void GeometryBatcher::addTexturedListStrided( - m2::PointD const * coords, - size_t coordsStride, - m2::PointF const * normals, - size_t normalsStride, - m2::PointF const * texCoords, - size_t texCoordsStride, - unsigned size, - double depth, - int pipelineID) - { - if (!hasRoom(size, size, pipelineID)) - flush(pipelineID); - - GeometryPipeline & pipeline = m_pipelines[pipelineID]; - - pipeline.checkStorage(resourceManager()); - if (!pipeline.m_hasStorage) - return; - - ASSERT(size > 2, ()); - - size_t vOffset = pipeline.m_currentVertex; - size_t iOffset = pipeline.m_currentIndex; - - for (size_t i = 0; i < size; ++i) - { - pipeline.m_vertices[vOffset + i].pt = m2::PointF(coords->x, coords->y); - pipeline.m_vertices[vOffset + i].normal = *normals; - pipeline.m_vertices[vOffset + i].tex = *texCoords; - pipeline.m_vertices[vOffset + i].depth = depth; - coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); - normals = reinterpret_cast(reinterpret_cast(normals) + normalsStride); - texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); - } - - pipeline.m_currentVertex += size; - - for (size_t i = 0; i < size; ++i) - pipeline.m_indices[iOffset + i] = vOffset + i; - - pipeline.m_currentIndex += size; - } - - - void GeometryBatcher::addTexturedListStrided( - m2::PointF const * coords, - size_t coordsStride, - m2::PointF const * normals, - size_t normalsStride, - m2::PointF const * texCoords, - size_t texCoordsStride, - unsigned size, - double depth, - int pipelineID) - { - if (!hasRoom(size, size, pipelineID)) - flush(pipelineID); - - GeometryPipeline & pipeline = m_pipelines[pipelineID]; - - pipeline.checkStorage(resourceManager()); - if (!pipeline.m_hasStorage) - return; - - ASSERT(size > 2, ()); - - size_t vOffset = pipeline.m_currentVertex; - size_t iOffset = pipeline.m_currentIndex; - - for (size_t i = 0; i < size; ++i) - { - pipeline.m_vertices[vOffset + i].pt = *coords; - pipeline.m_vertices[vOffset + i].normal = *normals; - pipeline.m_vertices[vOffset + i].tex = *texCoords; - pipeline.m_vertices[vOffset + i].depth = depth; - coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); - normals = reinterpret_cast(reinterpret_cast(normals) + normalsStride); - texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); - } - - pipeline.m_currentVertex += size; - - for (size_t i = 0; i < size; ++i) - pipeline.m_indices[iOffset + i] = vOffset + i; - - pipeline.m_currentIndex += size; - } - - void GeometryBatcher::addTexturedList(m2::PointF const * coords, - m2::PointF const * normals, - m2::PointF const * texCoords, - unsigned size, - double depth, - int pipelineID) - { - addTexturedListStrided(coords, sizeof(m2::PointF), - normals, sizeof(m2::PointF), - texCoords, sizeof(m2::PointF), - size, depth, pipelineID); - } - - void GeometryBatcher::enableClipRect(bool flag) - { - flush(-1); - base_t::enableClipRect(flag); - } - - void GeometryBatcher::setClipRect(m2::RectI const & rect) - { - flush(-1); - base_t::setClipRect(rect); - } - - int GeometryBatcher::aaShift() const - { - return m_aaShift; - } - - void GeometryBatcher::memoryWarning() - { - if (m_skin) - m_skin->memoryWarning(); - } - - void GeometryBatcher::enterBackground() - { - if (m_skin) - m_skin->enterBackground(); - } - - void GeometryBatcher::enterForeground() - { - if (m_skin) - m_skin->enterForeground(); - } - - void GeometryBatcher::setDisplayList(DisplayList * dl) - { - flush(-1); - base_t::setDisplayList(dl); - } - - void GeometryBatcher::drawDisplayList(DisplayList * dl, math::Matrix const & m) - { - flush(-1); - base_t::drawDisplayList(dl, m); - } - - void GeometryBatcher::setPixelPrecision(bool flag) - { - flush(-1); - base_t::setPixelPrecision(flag); - } - } // namespace gl + if (count != 0) + { + base_t::uploadStyles(styles, count, texture); + bytesUploaded = 0; + } + } } // namespace graphics diff --git a/graphics/geometry_batcher.hpp b/graphics/geometry_batcher.hpp index 3dac1dea87..bc969340a5 100644 --- a/graphics/geometry_batcher.hpp +++ b/graphics/geometry_batcher.hpp @@ -1,11 +1,12 @@ #pragma once -#include "vertex.hpp" -#include "buffer_object.hpp" -#include "renderbuffer.hpp" -#include "framebuffer.hpp" +#include "opengl/vertex.hpp" +#include "opengl/buffer_object.hpp" +#include "opengl/renderbuffer.hpp" +#include "opengl/framebuffer.hpp" +#include "opengl/storage.hpp" + #include "blitter.hpp" -#include "storage.hpp" #include "skin_page.hpp" #include "resource_manager.hpp" @@ -27,113 +28,128 @@ namespace graphics { class Skin; - namespace gl + class GeometryBatcher : public Blitter { - class GeometryBatcher : public Blitter + public: + + typedef function onFlushFinishedFn; + + private: + + typedef Blitter base_t; + + shared_ptr m_skin; + + struct GeometryPipeline { - public: + size_t m_verticesDrawn; + size_t m_indicesDrawn; - typedef function onFlushFinishedFn; + size_t m_currentVertex; + size_t m_currentIndex; - private: + /// made mutable to implement lazy reservation of m_storage + /// @{ + mutable size_t m_maxVertices; + mutable size_t m_maxIndices; - typedef Blitter base_t; + mutable bool m_hasStorage; + mutable gl::Storage m_storage; - shared_ptr m_skin; + mutable gl::Vertex * m_vertices; + mutable unsigned short * m_indices; + /// @} - struct GeometryPipeline - { - size_t m_verticesDrawn; - size_t m_indicesDrawn; - - size_t m_currentVertex; - size_t m_currentIndex; - - /// made mutable to implement lazy reservation of m_storage - /// @{ - mutable size_t m_maxVertices; - mutable size_t m_maxIndices; - - mutable bool m_hasStorage; - mutable Storage m_storage; - - mutable Vertex * m_vertices; - mutable unsigned short * m_indices; - /// @} - - bool m_useGuiResources; - graphics::SkinPage::EType m_type; - - int verticesLeft(); - int indicesLeft(); - - void checkStorage(shared_ptr const & resourceManager) const; - }; - - vector m_pipelines; - - void reset(int pipelineID); - - void freePipeline(int pipelineID); - void freeTexture(int pipelineID); - - bool m_isAntiAliased; - bool m_isSynchronized; bool m_useGuiResources; + SkinPage::EType m_type; - int m_aaShift; + int verticesLeft(); + int indicesLeft(); - public: + void checkStorage(shared_ptr const & resourceManager) const; + }; - /// INTERNAL API! USE WITH CAUTION - /// @{ - void flush(int pipelineID); - /// @} + vector m_pipelines; - bool hasRoom(size_t verticesCount, size_t indicesCount, int pipelineID) const; - int verticesLeft(int pipelineID) const; - int indicesLeft(int pipelineID) const; + void reset(int pipelineID); - struct Params : public base_t::Params - { - bool m_useGuiResources; - Params(); - }; + void freePipeline(int pipelineID); + void freeTexture(int pipelineID); - GeometryBatcher(Params const & params); - ~GeometryBatcher(); + bool m_isAntiAliased; + bool m_isSynchronized; + bool m_useGuiResources; - void setSkin(shared_ptr skin); - shared_ptr const & skin() const; + int m_aaShift; - void beginFrame(); - void endFrame(); + public: - bool flushPipeline(shared_ptr const & skinPage, int pipelineID); - void unlockPipeline(int pipelineID); - void discardPipeline(int pipelineID); + /// INTERNAL API! USE WITH CAUTION + /// @{ + void flush(int pipelineID); + /// @} - public: + bool hasRoom(size_t verticesCount, size_t indicesCount, int pipelineID) const; + int verticesLeft(int pipelineID) const; + int indicesLeft(int pipelineID) const; - /// This functions hide the base_t functions with the same name and signature - /// to flush(-1) upon calling them - /// @{ - void enableClipRect(bool flag); - void setClipRect(m2::RectI const & rect); + struct Params : public base_t::Params + { + bool m_useGuiResources; + Params(); + }; - void clear(graphics::Color const & c, bool clearRT = true, float depth = 1.0, bool clearDepth = true); - /// @} + GeometryBatcher(Params const & params); + ~GeometryBatcher(); - void setRenderTarget(shared_ptr const & rt); + void setSkin(shared_ptr skin); + shared_ptr const & skin() const; - void addTexturedFan(m2::PointF const * coords, + void beginFrame(); + void endFrame(); + + bool flushPipeline(shared_ptr const & skinPage, int pipelineID); + void unlockPipeline(int pipelineID); + void discardPipeline(int pipelineID); + + public: + + /// This functions hide the base_t functions with the same name and signature + /// to flush(-1) upon calling them + /// @{ + void enableClipRect(bool flag); + void setClipRect(m2::RectI const & rect); + + void clear(Color const & c, bool clearRT = true, float depth = 1.0, bool clearDepth = true); + /// @} + + void setRenderTarget(shared_ptr const & rt); + + void addTexturedFan(m2::PointF const * coords, + m2::PointF const * normals, + m2::PointF const * texCoords, + unsigned size, + double depth, + int pipelineID); + + void addTexturedFanStrided(m2::PointF const * coords, + size_t coordsStride, + m2::PointF const * normals, + size_t normalsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pipelineID); + + void addTexturedStrip(m2::PointF const * coords, m2::PointF const * normals, m2::PointF const * texCoords, unsigned size, double depth, int pipelineID); - void addTexturedFanStrided(m2::PointF const * coords, + void addTexturedStripStrided(m2::PointF const * coords, size_t coordsStride, m2::PointF const * normals, size_t normalsStride, @@ -143,77 +159,63 @@ namespace graphics double depth, int pipelineID); - void addTexturedStrip(m2::PointF const * coords, - m2::PointF const * normals, - m2::PointF const * texCoords, - unsigned size, - double depth, - int pipelineID); + void addTexturedList(m2::PointF const * coords, + m2::PointF const * texCoords, + m2::PointF const * normalCoords, + unsigned size, + double depth, + int pipelineID); - void addTexturedStripStrided(m2::PointF const * coords, - size_t coordsStride, - m2::PointF const * normals, - size_t normalsStride, - m2::PointF const * texCoords, - size_t texCoordsStride, - unsigned size, - double depth, - int pipelineID); + void addTexturedListStrided(m2::PointD const * coords, + size_t coordsStride, + m2::PointF const * normals, + size_t normalsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pipelineID); - void addTexturedList(m2::PointF const * coords, - m2::PointF const * texCoords, - m2::PointF const * normalCoords, - unsigned size, - double depth, - int pipelineID); + void addTexturedListStrided(m2::PointF const * coords, + size_t coordsStride, + m2::PointF const * normals, + size_t normalsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pipelineID); - void addTexturedListStrided(m2::PointD const * coords, - size_t coordsStride, - m2::PointF const * normals, - size_t normalsStride, - m2::PointF const * texCoords, - size_t texCoordsStride, - unsigned size, - double depth, - int pipelineID); + int aaShift() const; - void addTexturedListStrided(m2::PointF const * coords, - size_t coordsStride, - m2::PointF const * normals, - size_t normalsStride, - m2::PointF const * texCoords, - size_t texCoordsStride, - unsigned size, - double depth, - int pipelineID); + void drawStraightTexturedPolygon( + m2::PointD const & ptPivot, + float tx0, float ty0, float tx1, float ty1, + float x0, float y0, float x1, float y1, + double depth, + int pipelineID); - int aaShift() const; + /// drawing textured polygon with antialiasing + /// we assume that the (tx0, ty0, tx1, ty1) area on texture is surrounded by (0, 0, 0, 0) pixels, + /// and the 1px interior area is also (0, 0, 0, 0). + void drawTexturedPolygon( + m2::PointD const & ptWhere, + ang::AngleD const & angle, + float tx0, float ty0, float tx1, float ty1, + float x0, float y0, float x1, float y1, + double depth, + int pipelineID); - void drawStraightTexturedPolygon( - m2::PointD const & ptPivot, - float tx0, float ty0, float tx1, float ty1, - float x0, float y0, float x1, float y1, - double depth, - int pipelineID); + void memoryWarning(); + void enterBackground(); + void enterForeground(); - /// drawing textured polygon with antialiasing - /// we assume that the (tx0, ty0, tx1, ty1) area on texture is surrounded by (0, 0, 0, 0) pixels, - /// and the 1px interior area is also (0, 0, 0, 0). - void drawTexturedPolygon( - m2::PointD const & ptWhere, - ang::AngleD const & angle, - float tx0, float ty0, float tx1, float ty1, - float x0, float y0, float x1, float y1, - double depth, - int pipelineID); + void setDisplayList(DisplayList * dl); + void drawDisplayList(DisplayList * dl, math::Matrix const & m); + void setPixelPrecision(bool flag); - void memoryWarning(); - void enterBackground(); - void enterForeground(); - - void setDisplayList(DisplayList * dl); - void drawDisplayList(DisplayList * dl, math::Matrix const & m); - void setPixelPrecision(bool flag); - }; - } + void uploadStyles(shared_ptr const * styles, + size_t count, + shared_ptr const & texture); + }; } diff --git a/graphics/glyph_cache.cpp b/graphics/glyph_cache.cpp index 7ad84d8a8e..aa7df2aa4d 100644 --- a/graphics/glyph_cache.cpp +++ b/graphics/glyph_cache.cpp @@ -1,9 +1,10 @@ #include "glyph_cache.hpp" #include "glyph_cache_impl.hpp" -#include "data_traits.hpp" -#include "internal/opengl.hpp" #include "ft2_debug.hpp" +#include "opengl/data_traits.hpp" +#include "opengl/opengl.hpp" + #include "../3party/fribidi/lib/fribidi-deprecated.h" #include "../3party/fribidi/lib/fribidi.h" diff --git a/graphics/glyph_style.cpp b/graphics/glyph_style.cpp index 3ef9d78baa..fa3d7b9001 100644 --- a/graphics/glyph_style.cpp +++ b/graphics/glyph_style.cpp @@ -1,8 +1,8 @@ #include "resource_style.hpp" - #include "glyph_cache.hpp" #include "agg_traits.hpp" -#include "data_traits.hpp" + +#include "opengl/data_traits.hpp" namespace graphics { diff --git a/graphics/graphics.pro b/graphics/graphics.pro index 21f32c20f4..9aa46d03a6 100644 --- a/graphics/graphics.pro +++ b/graphics/graphics.pro @@ -13,26 +13,27 @@ INCLUDEPATH += $$ROOT_DIR/3party/freetype/include $$ROOT_DIR/3party/agg include($$ROOT_DIR/common.pri) SOURCES += \ - internal/opengl.cpp \ - vertex.cpp \ + opengl/framebuffer.cpp \ + opengl/opengl.cpp \ + opengl/buffer_object.cpp \ + opengl/renderbuffer.cpp \ + opengl/base_texture.cpp \ + opengl/managed_texture.cpp \ + opengl/renderer.cpp \ + opengl/rendercontext.cpp \ + opengl/vertex.cpp \ + opengl/clipper.cpp \ + opengl/geometry_renderer.cpp \ + opengl/storage.cpp \ + opengl/utils.cpp \ + blitter.cpp \ resource_manager.cpp \ skin.cpp \ pen_info.cpp \ resource_style.cpp \ color.cpp \ skin_loader.cpp \ - framebuffer.cpp \ - buffer_object.cpp \ - utils.cpp \ - renderbuffer.cpp \ - base_texture.cpp \ - managed_texture.cpp \ - blitter.cpp \ - clipper.cpp \ - renderer.cpp \ - geometry_renderer.cpp \ skin_page.cpp \ - storage.cpp \ glyph_cache.cpp \ glyph_cache_impl.cpp \ ft2_debug.cpp \ @@ -53,7 +54,6 @@ SOURCES += \ composite_overlay_element.cpp \ path_text_element.cpp \ straight_text_element.cpp \ - rendercontext.cpp \ line_style.cpp \ circle_style.cpp \ glyph_style.cpp \ @@ -62,32 +62,34 @@ SOURCES += \ display_list.cpp \ data_formats.cpp \ image_info.cpp \ - image_renderer.cpp + image_renderer.cpp \ + display_list_renderer.cpp HEADERS += \ - internal/opengl.hpp \ - internal/gl_procedures.inl \ - vertex.hpp \ + opengl/opengl.hpp \ + opengl/gl_procedures.inl \ + opengl/vertex.hpp \ + opengl/texture.hpp \ + opengl/framebuffer.hpp \ + opengl/buffer_object.hpp \ + opengl/renderbuffer.hpp \ + opengl/base_texture.hpp \ + opengl/managed_texture.hpp \ + opengl/rendercontext.hpp \ + opengl/clipper.hpp \ + opengl/renderer.hpp \ + opengl/geometry_renderer.hpp \ + opengl/data_traits.hpp \ + opengl/storage.hpp \ + opengl/utils.hpp \ + blitter.hpp \ resource_manager.hpp \ - texture.hpp \ skin.hpp \ skin_loader.hpp \ pen_info.hpp \ resource_style.hpp \ color.hpp \ - framebuffer.hpp \ - buffer_object.hpp \ - utils.hpp \ - renderbuffer.hpp \ - base_texture.hpp \ - managed_texture.hpp \ - rendercontext.hpp \ - blitter.hpp \ - clipper.hpp \ - renderer.hpp \ - geometry_renderer.hpp \ skin_page.hpp \ - storage.hpp \ render_target.hpp \ glyph_cache.hpp \ data_formats.hpp \ @@ -116,18 +118,18 @@ HEADERS += \ circle_element.hpp \ packets_queue.hpp \ display_list.hpp \ - data_traits.hpp \ image_renderer.hpp \ - image_info.hpp + image_info.hpp \ + display_list_renderer.hpp win32* { - SOURCES += internal/opengl_win32.cpp + SOURCES += opengl/opengl_win32.cpp } else: android*|iphone* { - HEADERS += internal/opengl_glsl_impl.hpp - SOURCES += internal/opengl_glsl_es2.cpp \ - internal/opengl_glsl_impl.cpp + HEADERS += opengl/opengl_glsl_impl.hpp + SOURCES += opengl/opengl_glsl_es2.cpp \ + opengl/opengl_glsl_impl.cpp } else { - HEADERS += internal/opengl_glsl_impl.hpp - SOURCES += internal/opengl_glsl_ext.cpp \ - internal/opengl_glsl_impl.cpp + HEADERS += opengl/opengl_glsl_impl.hpp + SOURCES += opengl/opengl_glsl_ext.cpp \ + opengl/opengl_glsl_impl.cpp } diff --git a/graphics/graphics_tests/screengl_test.cpp b/graphics/graphics_tests/screengl_test.cpp index 40a6e16de6..58943f73f7 100644 --- a/graphics/graphics_tests/screengl_test.cpp +++ b/graphics/graphics_tests/screengl_test.cpp @@ -4,8 +4,6 @@ #include "../../geometry/transformations.hpp" #include "../../graphics/screen.hpp" -#include "../../graphics/utils.hpp" -#include "../../graphics/internal/opengl.hpp" #include "../../graphics/skin.hpp" #include "../../graphics/pen_info.hpp" #include "../../graphics/circle_info.hpp" @@ -13,6 +11,9 @@ #include "../../graphics/straight_text_element.hpp" #include "../../graphics/path_text_element.hpp" +#include "../../graphics/opengl/utils.hpp" +#include "../../graphics/opengl/opengl.hpp" + #include "../../qt_tstfrm/macros.hpp" #include "../../testing/testing.hpp" @@ -26,7 +27,7 @@ namespace { struct TestDrawPoint { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->drawSymbol(m2::PointD(40, 40), 0, graphics::EPosCenter, 0); p->drawSymbol(m2::PointD(40.5, 60), 0, graphics::EPosCenter, 0); @@ -36,7 +37,7 @@ namespace struct TestDrawSolidRect { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->immDrawSolidRect(m2::RectF(0, 0, 100, 100), graphics::Color(255, 0, 0, 255)); } @@ -44,7 +45,7 @@ namespace struct TestDrawLine { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { m2::PointD pts[3] = { @@ -100,7 +101,7 @@ namespace return m_pathes[i]; } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { for (size_t i = 0; i < m_pathes.size(); ++i) { @@ -375,7 +376,7 @@ namespace AddTest(testPoints, testPattern, graphics::Color(255, 0, 0, 255), 40, 0.5); } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->enableClipRect(true); p->setClipRect(m2::RectI(50, 70, 150, 150)); @@ -385,7 +386,7 @@ namespace p->beginFrame(); p->setClipRect(r); p->enableClipRect(true); - p->clear(graphics::gl::Screen::s_bgColor); + p->clear(graphics::Screen::s_bgColor); } }; @@ -558,7 +559,7 @@ namespace struct TestDrawPoly { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { // m2::PointD ptsStrip[5] = {m2::PointD(10, 10), m2::PointD(40, 10), m2::PointD(70, 10), m2::PointD(90, 60), m2::PointD(130, 30)}; // p->drawTriangles(ptsStrip, 5, graphics::TriangleStrip, p->skin()->mapColor(graphics::Color(255, 0, 0, 255))); @@ -574,7 +575,7 @@ namespace /// Trying to draw polygon with more vertices that fits into internal buffer. struct TestDrawPolyOverflow { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { size_t verticesCount = 30000; vector vertices; @@ -609,7 +610,7 @@ namespace struct TestDrawText { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { m2::PointD path[2] = {m2::PointD(100, 200), m2::PointD(1000, 200)}; double pat[2] = {2, 2}; @@ -628,7 +629,7 @@ namespace struct TestDrawSingleSymbol { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { graphics::FontDesc fontDesc(20, graphics::Color(0, 0, 0, 0), true, graphics::Color(255, 255, 255, 255)); p->drawText(fontDesc, m2::PointD(40, 50), graphics::EPosAboveRight, "X", 1, true); @@ -637,7 +638,7 @@ namespace struct TestDrawEmptySymbol { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { graphics::FontDesc fontDesc(20, graphics::Color(0, 0, 0, 0), true, graphics::Color(255, 255, 255, 255)); p->drawText(fontDesc, m2::PointD(40, 50), graphics::EPosAboveRight, " ", 1, true); @@ -646,7 +647,7 @@ namespace struct TestDrawStringOnString { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { size_t const maxTimes = 10; size_t const yStep = 30; @@ -661,7 +662,7 @@ namespace struct TestDrawSingleSymbolAndSolidPath { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { vector path; path.push_back(m2::PointD(40, 50)); @@ -681,7 +682,7 @@ namespace struct TestDrawMultiLineStringWithPosition { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { graphics::FontDesc fontDesc(14, graphics::Color(0, 0, 0, 0), true, graphics::Color(255, 255, 255, 255)); @@ -734,7 +735,7 @@ namespace struct TestDrawString { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { graphics::FontDesc fontDesc(20, graphics::Color(0, 0, 0, 0), true, graphics::Color(255, 255, 255, 255)); p->drawText(fontDesc, m2::PointD(40, 150), graphics::EPosAboveRight, "Simplicity is the ultimate sophistication", 0, true); @@ -743,7 +744,7 @@ namespace struct TestDrawStringWithColor { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { graphics::FontDesc fontDesc(25, graphics::Color(0, 0, 255, 255), true, graphics::Color(255, 255, 255, 255)); p->drawText(fontDesc, m2::PointD(40, 50), graphics::EPosAboveRight, "Simplicity is the ultimate sophistication", 0, true); @@ -753,7 +754,7 @@ namespace struct TestDrawUnicodeSymbols { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { graphics::FontDesc fontDesc(12); p->drawText(fontDesc, m2::PointD(40, 50), graphics::EPosAboveRight, "Latin Symbol : A", 0, true); @@ -764,7 +765,7 @@ namespace struct TestDrawTextRect : TestDrawString { typedef TestDrawString base_t; - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { m2::PointD startPt(40, 50); @@ -812,7 +813,7 @@ namespace m_penInfo = graphics::PenInfo(graphics::Color(0xFF, 0xFF, 0xFF, 0xFF), 2, &pat[0], ARRAY_SIZE(pat), 0); } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->drawPath(&m_path[0], m_path.size(), 0, p->skin()->mapPenInfo(m_penInfo), 1); graphics::FontDesc fontDesc(30); @@ -859,7 +860,7 @@ namespace } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->drawPath(&m_testPoints[0], m_testPoints.size(), 0, p->skin()->mapPenInfo(graphics::PenInfo(graphics::Color(255, 255, 255, 255), 2, 0, 0, 0)), 0); graphics::FontDesc fontDesc(20, graphics::Color(0, 0, 0, 255), false); @@ -888,7 +889,7 @@ namespace m_penInfo = graphics::PenInfo(graphics::Color(0, 0, 0, 0xFF), 2, &pat[0], ARRAY_SIZE(pat), 0); } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->drawPath(&m_path[0], m_path.size(), 0, p->skin()->mapPenInfo(m_penInfo), 0); graphics::FontDesc fontDesc(20); @@ -908,7 +909,7 @@ namespace m_penInfo = graphics::PenInfo(graphics::Color(0, 0, 0, 0xFF), 2, &pat[0], ARRAY_SIZE(pat), 0); } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { graphics::StraightTextElement::Params params; params.m_fontDesc = graphics::FontDesc(20); @@ -947,7 +948,7 @@ namespace m_penInfo = graphics::PenInfo(graphics::Color(0, 0, 0, 0xFF), 2, &pat[0], ARRAY_SIZE(pat), 0); } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { graphics::PathTextElement::Params params; params.m_pts = &m_path[0]; @@ -992,7 +993,7 @@ namespace m_penInfo = graphics::PenInfo(graphics::Color(0, 0, 0, 0xFF), 2, &pat[0], ARRAY_SIZE(pat), 0); } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->drawPath(&m_path[0], m_path.size(), 0, p->skin()->mapPenInfo(m_penInfo), 0); // graphics::FontDesc fontDesc(false, 10); @@ -1017,7 +1018,7 @@ namespace m_pathAbove[i].y += 50; } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { TestDrawTextOnPath::DoDraw(p); @@ -1034,7 +1035,7 @@ namespace struct TestDrawTextOverflow { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { int const startSize = 20; size_t const sizesCount = 20; @@ -1051,7 +1052,7 @@ namespace struct TestDrawTextFiltering { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { int const startSize = 20; size_t const sizesCount = 20; @@ -1069,7 +1070,7 @@ namespace struct TestDrawRandomTextFiltering { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { char const * texts [] = {"Simplicity is the ultimate sophistication", "Leonardo Da Vinci"}; @@ -1096,7 +1097,7 @@ namespace struct TestDrawUtilsRect { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { shared_ptr texture(new graphics::gl::RGBA8Texture(512, 512)); texture->randomize(); @@ -1113,7 +1114,7 @@ namespace struct TestDrawUtilsRectFilledTexture { - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { shared_ptr texture(new graphics::gl::RGBA8Texture(512, 512)); texture->fill(graphics::Color(0, 255, 0, 255)); @@ -1131,7 +1132,7 @@ namespace struct TestDrawOverlappedSymbolWithText { public: - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->setOverlay(make_shared_ptr(new graphics::Overlay())); p->overlay()->setCouldOverlap(false); @@ -1153,7 +1154,7 @@ namespace struct TestDrawAnyRect { public: - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { m2::AnyRectD r[3] = { @@ -1173,7 +1174,7 @@ namespace struct TestDrawSector { public: - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { p->drawArc(m2::PointD(100, 100), 0, math::pi * 2, 30, graphics::Color(0, 0, 255, 128), 12000); p->fillSector(m2::PointD(100, 100), 0, math::pi * 2, 30, graphics::Color(0, 0, 255, 64), 12000); @@ -1208,7 +1209,7 @@ namespace t.endPolygon(); } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { double inputDataPat[] = {10, 0}; graphics::PenInfo inputDataRule(graphics::Color::fromARGB(0xFF000000), 6, inputDataPat, 2, 0); @@ -1316,7 +1317,7 @@ namespace struct TestDrawSymbolFiltering { - void DoDraw(shared_ptr const & p) + void DoDraw(shared_ptr const & p) { for (int i = 0; i < 40; ++i) p->drawSymbol(m2::PointD(100 + i, 100), "hospital", graphics::EPosCenter, 0); @@ -1325,7 +1326,7 @@ namespace struct TestDrawCircle { - void DoDraw(shared_ptr const & p) + void DoDraw(shared_ptr const & p) { graphics::CircleInfo ci0(10, graphics::Color(255, 0, 0, 255)); p->drawCircle(m2::PointD(200, 200), ci0, graphics::EPosCenter, 100); @@ -1337,7 +1338,7 @@ namespace struct TestDrawImage { - void DoDraw(shared_ptr const & p) + void DoDraw(shared_ptr const & p) { graphics::ImageInfo ii("test.png"); diff --git a/graphics/graphics_tests/screenglglobal_test.cpp b/graphics/graphics_tests/screenglglobal_test.cpp index 015d1fd4b1..1f0506f9d2 100644 --- a/graphics/graphics_tests/screenglglobal_test.cpp +++ b/graphics/graphics_tests/screenglglobal_test.cpp @@ -33,7 +33,7 @@ namespace TestBase::Init(); } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { std::vector pts; diff --git a/graphics/graphics_tests/texture_test.cpp b/graphics/graphics_tests/texture_test.cpp index f1f2ef4197..cd00777e16 100644 --- a/graphics/graphics_tests/texture_test.cpp +++ b/graphics/graphics_tests/texture_test.cpp @@ -2,7 +2,7 @@ #include "../../qt_tstfrm/macros.hpp" #include "../../testing/testing.hpp" -#include "../texture.hpp" +#include "../opengl/texture.hpp" UNIT_TEST(TextureTest_Main) { diff --git a/graphics/graphics_tests/thread_render.cpp b/graphics/graphics_tests/thread_render.cpp index a8deac8860..8f698101f7 100644 --- a/graphics/graphics_tests/thread_render.cpp +++ b/graphics/graphics_tests/thread_render.cpp @@ -1,7 +1,9 @@ #include "../../base/SRC_FIRST.hpp" + +#include "../../graphics/opengl/utils.hpp" +#include "../../graphics/opengl/texture.hpp" + #include "../../graphics/screen.hpp" -#include "../../graphics/utils.hpp" -#include "../../graphics/texture.hpp" #include "../../std/shared_ptr.hpp" #include "../../qt_tstfrm/macros.hpp" #include "../../base/thread.hpp" @@ -10,11 +12,11 @@ namespace { struct RenderRoutine : public threads::IRoutine { - shared_ptr m_pScreen; + shared_ptr m_pScreen; shared_ptr m_renderContext; int & m_globalCounter; - RenderRoutine(shared_ptr pScreen, + RenderRoutine(shared_ptr pScreen, shared_ptr renderContext, int & globalCounter) : m_pScreen(pScreen), @@ -28,7 +30,7 @@ namespace for (size_t i = 0; i < 30; ++i) { m_pScreen->beginFrame(); - m_pScreen->clear(graphics::gl::Screen::s_bgColor); + m_pScreen->clear(graphics::Screen::s_bgColor); m_pScreen->immDrawRect( m2::RectF(i * 15 + 20, 10, i * 15 + 30, 20), m2::RectF(), @@ -51,7 +53,7 @@ namespace globalCounter = 0; } - void DoDraw(shared_ptr p) + void DoDraw(shared_ptr p) { globalCounter = 0; threads::Thread thread; @@ -59,7 +61,7 @@ namespace for (size_t i = 0; i < 30; ++i) { p->beginFrame(); - p->clear(graphics::gl::Screen::s_bgColor); + p->clear(graphics::Screen::s_bgColor); p->immDrawSolidRect( m2::RectF(i * 15 + 20, 30, i * 15 + 30, 40), graphics::Color(0, 0, 255, (globalCounter++) * (255 / 60) )); diff --git a/graphics/image_info.cpp b/graphics/image_info.cpp index 3449b40552..a972e54d50 100644 --- a/graphics/image_info.cpp +++ b/graphics/image_info.cpp @@ -1,5 +1,6 @@ #include "image_info.hpp" -#include "data_traits.hpp" + +#include "opengl/data_traits.hpp" #include "../platform/platform.hpp" diff --git a/graphics/image_renderer.cpp b/graphics/image_renderer.cpp index b928b4ba0e..c93aa6e20d 100644 --- a/graphics/image_renderer.cpp +++ b/graphics/image_renderer.cpp @@ -1,9 +1,9 @@ #include "image_renderer.hpp" - -#include "base_texture.hpp" #include "resource_style.hpp" #include "skin.hpp" +#include "opengl/base_texture.hpp" + #include "../base/assert.hpp" #include "../base/macros.hpp" diff --git a/graphics/line_style.cpp b/graphics/line_style.cpp index a0248b18c1..eb22bca483 100644 --- a/graphics/line_style.cpp +++ b/graphics/line_style.cpp @@ -1,7 +1,7 @@ #include "resource_style.hpp" - #include "agg_traits.hpp" -#include "data_traits.hpp" + +#include "opengl/data_traits.hpp" namespace graphics { diff --git a/graphics/base_texture.cpp b/graphics/opengl/base_texture.cpp similarity index 89% rename from graphics/base_texture.cpp rename to graphics/opengl/base_texture.cpp index 191cf3a358..c5a8229411 100644 --- a/graphics/base_texture.cpp +++ b/graphics/opengl/base_texture.cpp @@ -1,10 +1,11 @@ -#include "../base/SRC_FIRST.hpp" +#include "../../base/SRC_FIRST.hpp" -#include "internal/opengl.hpp" +#include "../../base/logging.hpp" +#include "../../std/bind.hpp" + +#include "opengl.hpp" #include "base_texture.hpp" #include "utils.hpp" -#include "../base/logging.hpp" -#include "../std/bind.hpp" namespace graphics { @@ -76,18 +77,15 @@ namespace graphics return id; } - void BaseTexture::makeCurrent(graphics::gl::PacketsQueue * queue) const + void BaseTexture::makeCurrent(graphics::PacketsQueue * queue) const { if (queue) { - queue->processFn(bind(&BaseTexture::makeCurrent, this, (graphics::gl::PacketsQueue*)0)); + queue->processFn(bind(&BaseTexture::makeCurrent, this, (graphics::PacketsQueue*)0)); return; } -/*#ifndef OMIM_OS_ANDROID - if (current() != m_id) -#endif*/ - OGLCHECK(glBindTexture(GL_TEXTURE_2D, m_id)); + OGLCHECK(glBindTexture(GL_TEXTURE_2D, m_id)); } unsigned BaseTexture::id() const diff --git a/graphics/base_texture.hpp b/graphics/opengl/base_texture.hpp similarity index 81% rename from graphics/base_texture.hpp rename to graphics/opengl/base_texture.hpp index 39c37ffba5..4be978a5b5 100644 --- a/graphics/base_texture.hpp +++ b/graphics/opengl/base_texture.hpp @@ -1,13 +1,16 @@ #pragma once -#include "../geometry/rect2d.hpp" -#include "../geometry/point2d.hpp" -#include "render_target.hpp" -#include "packets_queue.hpp" +#include "../../geometry/rect2d.hpp" +#include "../../geometry/point2d.hpp" + +#include "../render_target.hpp" +#include "../packets_queue.hpp" namespace graphics { struct Color; + class PacketsQueue; + namespace gl { class BaseTexture : public RenderTarget @@ -34,7 +37,7 @@ namespace graphics unsigned height() const; unsigned id() const; - void makeCurrent(graphics::gl::PacketsQueue * queue = 0) const; + void makeCurrent(graphics::PacketsQueue * queue = 0) const; void attachToFrameBuffer(); void detachFromFrameBuffer(); diff --git a/graphics/buffer_object.cpp b/graphics/opengl/buffer_object.cpp similarity index 94% rename from graphics/buffer_object.cpp rename to graphics/opengl/buffer_object.cpp index 1c316d2429..937e2a639a 100644 --- a/graphics/buffer_object.cpp +++ b/graphics/opengl/buffer_object.cpp @@ -1,12 +1,12 @@ -#include "../base/SRC_FIRST.hpp" -#include "../base/logging.hpp" -#include "../base/assert.hpp" -#include "../base/shared_buffer_manager.hpp" +#include "../../base/SRC_FIRST.hpp" +#include "../../base/logging.hpp" +#include "../../base/assert.hpp" +#include "../../base/shared_buffer_manager.hpp" -#include "internal/opengl.hpp" +#include "../../std/list.hpp" +#include "opengl.hpp" #include "buffer_object.hpp" -#include "../std/list.hpp" namespace graphics { diff --git a/graphics/buffer_object.hpp b/graphics/opengl/buffer_object.hpp similarity index 90% rename from graphics/buffer_object.hpp rename to graphics/opengl/buffer_object.hpp index bdd000db7e..f04190821a 100644 --- a/graphics/buffer_object.hpp +++ b/graphics/opengl/buffer_object.hpp @@ -1,7 +1,7 @@ #pragma once -#include "../std/vector.hpp" -#include "../std/shared_ptr.hpp" +#include "../../std/vector.hpp" +#include "../../std/shared_ptr.hpp" namespace graphics { diff --git a/graphics/clipper.cpp b/graphics/opengl/clipper.cpp similarity index 95% rename from graphics/clipper.cpp rename to graphics/opengl/clipper.cpp index 9fb94e6d88..2c61e18dba 100644 --- a/graphics/clipper.cpp +++ b/graphics/opengl/clipper.cpp @@ -1,8 +1,8 @@ -#include "../base/SRC_FIRST.hpp" +#include "../../std/bind.hpp" +#include "../../base/logging.hpp" + #include "clipper.hpp" -#include "internal/opengl.hpp" -#include "../std/bind.hpp" -#include "../base/logging.hpp" +#include "opengl.hpp" namespace graphics { diff --git a/graphics/clipper.hpp b/graphics/opengl/clipper.hpp similarity index 96% rename from graphics/clipper.hpp rename to graphics/opengl/clipper.hpp index 50f4b9ea42..c9b981d05f 100644 --- a/graphics/clipper.hpp +++ b/graphics/opengl/clipper.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../geometry/rect2d.hpp" +#include "../../geometry/rect2d.hpp" #include "renderer.hpp" namespace graphics diff --git a/graphics/data_traits.hpp b/graphics/opengl/data_traits.hpp similarity index 98% rename from graphics/data_traits.hpp rename to graphics/opengl/data_traits.hpp index bfe3a7d41e..92790406a5 100644 --- a/graphics/data_traits.hpp +++ b/graphics/opengl/data_traits.hpp @@ -1,7 +1,7 @@ #pragma once -#include "internal/opengl.hpp" -#include "color.hpp" +#include "opengl.hpp" +#include "../color.hpp" #include #include diff --git a/graphics/framebuffer.cpp b/graphics/opengl/framebuffer.cpp similarity index 97% rename from graphics/framebuffer.cpp rename to graphics/opengl/framebuffer.cpp index 31a9ec6120..8c34de7aea 100644 --- a/graphics/framebuffer.cpp +++ b/graphics/opengl/framebuffer.cpp @@ -3,11 +3,11 @@ #include "framebuffer.hpp" #include "render_target.hpp" #include "renderbuffer.hpp" -#include "internal/opengl.hpp" +#include "opengl.hpp" #include "utils.hpp" -#include "../base/logging.hpp" -#include "../std/list.hpp" +#include "../../base/logging.hpp" +#include "../../std/list.hpp" namespace graphics { diff --git a/graphics/framebuffer.hpp b/graphics/opengl/framebuffer.hpp similarity index 94% rename from graphics/framebuffer.hpp rename to graphics/opengl/framebuffer.hpp index cb0973c918..d03cae35c5 100644 --- a/graphics/framebuffer.hpp +++ b/graphics/opengl/framebuffer.hpp @@ -1,14 +1,15 @@ #pragma once -#include "../std/shared_ptr.hpp" +#include "../../std/shared_ptr.hpp" namespace graphics { + class RenderTarget; + namespace gl { class BaseTexture; class RenderBuffer; - class RenderTarget; class FrameBuffer { diff --git a/graphics/geometry_renderer.cpp b/graphics/opengl/geometry_renderer.cpp similarity index 65% rename from graphics/geometry_renderer.cpp rename to graphics/opengl/geometry_renderer.cpp index 943e074ff8..bb59cd9675 100644 --- a/graphics/geometry_renderer.cpp +++ b/graphics/opengl/geometry_renderer.cpp @@ -5,9 +5,8 @@ #include "texture.hpp" #include "buffer_object.hpp" #include "managed_texture.hpp" -#include "display_list.hpp" #include "vertex.hpp" -#include "internal/opengl.hpp" +#include "opengl/opengl.hpp" #include "../std/bind.hpp" #include "../base/logging.hpp" @@ -19,14 +18,17 @@ namespace graphics typedef Texture TDynamicTexture; GeometryRenderer::GeometryRenderer(base_t::Params const & params) - : base_t(params), - m_displayList(0) + : base_t(params) {} - GeometryRenderer::UploadData::UploadData(SkinPage::TUploadQueue const & uploadQueue, + GeometryRenderer::UploadData::UploadData(shared_ptr const * styles, + size_t count, shared_ptr const & texture) - : m_uploadQueue(uploadQueue), m_texture(texture) - {} + : m_texture(texture) + { + m_uploadQueue.reserve(count); + copy(styles, styles + count, back_inserter(m_uploadQueue)); + } GeometryRenderer::UploadData::UploadData() {} @@ -84,65 +86,107 @@ namespace graphics } - void GeometryRenderer::uploadTextureImpl(SkinPage::TUploadQueue const & uploadQueue, - size_t start, size_t end, - shared_ptr const & texture, - bool shouldAddCheckPoint) + void GeometryRenderer::uploadStyles(shared_ptr const * styles, + size_t count, + shared_ptr const & texture) { - if (isCancelled()) - return; - - vector > v; - v.reserve(end - start); - copy(&uploadQueue[0] + start, &uploadQueue[0] + end, back_inserter(v)); - - shared_ptr command(new UploadData(v, texture)); - - if (m_displayList) - m_displayList->uploadData(command); - else - processCommand(command); - - if (shouldAddCheckPoint) - { - if (m_displayList) - m_displayList->addCheckPoint(); - else - addCheckPoint(); - } + processCommand(make_shared_ptr(new UploadData(styles, count, texture))); } - void GeometryRenderer::uploadTexture(SkinPage::TUploadQueue const & uploadQueue, - shared_ptr const & texture) + GeometryRenderer::IMMDrawTexturedRect::IMMDrawTexturedRect( + m2::RectF const & rect, + m2::RectF const & texRect, + shared_ptr const & texture, + shared_ptr const & rm) { - /// splitting the whole queue of commands into the chunks no more - /// than 100kb of uploadable data each - - /// tracking the number of bytes downloaded onto the texture - /// in a single shot. - size_t bytesUploaded = 0; - size_t bytesPerPixel = graphics::formatSize(resourceManager()->params().m_texFormat); - size_t prev = 0; - - for (size_t i = 0; i < uploadQueue.size(); ++i) + m2::PointF rectPoints[4] = { - shared_ptr const & style = uploadQueue[i]; + m2::PointF(rect.minX(), rect.minY()), + m2::PointF(rect.maxX(), rect.minY()), + m2::PointF(rect.maxX(), rect.maxY()), + m2::PointF(rect.minX(), rect.maxY()) + }; - bytesUploaded += style->m_texRect.SizeX() * style->m_texRect.SizeY() * bytesPerPixel; + m2::PointF texRectPoints[4] = + { + m2::PointF(texRect.minX(), texRect.minY()), + m2::PointF(texRect.maxX(), texRect.minY()), + m2::PointF(texRect.maxX(), texRect.maxY()), + m2::PointF(texRect.minX(), texRect.maxY()), + }; - if (bytesUploaded > 64 * 1024) - { - uploadTextureImpl(uploadQueue, prev, i + 1, texture, true); - prev = i + 1; - bytesUploaded = 0; - } + m_pts.resize(4); + m_texPts.resize(4); + + copy(rectPoints, rectPoints + 4, &m_pts[0]); + copy(texRectPoints, texRectPoints + 4, &m_texPts[0]); + m_ptsCount = 4; + m_texture = texture; + m_hasTexture = true; + m_hasColor = false; + m_color = graphics::Color(255, 255, 255, 255); + m_resourceManager = rm; + } + + void GeometryRenderer::IMMDrawTexturedPrimitives::perform() + { + if (isDebugging()) + LOG(LINFO, ("performing IMMDrawTexturedPrimitives command")); + + graphics::gl::Storage blitStorage = m_resourceManager->blitStorages()->Reserve(); + + if (m_resourceManager->blitStorages()->IsCancelled()) + { + LOG(LDEBUG, ("skipping IMMDrawTexturedPrimitives on cancelled multiBlitStorages pool")); + return; } - if (!uploadQueue.empty()) + if (!blitStorage.m_vertices->isLocked()) + blitStorage.m_vertices->lock(); + + if (!blitStorage.m_indices->isLocked()) + blitStorage.m_indices->lock(); + + Vertex * pointsData = (Vertex*)blitStorage.m_vertices->data(); + + for (size_t i = 0; i < m_ptsCount; ++i) { - uploadTextureImpl(uploadQueue, prev, uploadQueue.size(), texture, false); - bytesUploaded = 0; + pointsData[i].pt.x = m_pts[i].x; + pointsData[i].pt.y = m_pts[i].y; + pointsData[i].depth = graphics::maxDepth; + pointsData[i].tex.x = m_texPts[i].x; + pointsData[i].tex.y = m_texPts[i].y; + pointsData[i].normal.x = 0; + pointsData[i].normal.y = 0; } + + blitStorage.m_vertices->unlock(); + blitStorage.m_vertices->makeCurrent(); + + Vertex::setupLayout(blitStorage.m_vertices->glPtr()); + + if (m_texture) + m_texture->makeCurrent(); + + unsigned short idxData[4] = {0, 1, 2, 3}; + memcpy(blitStorage.m_indices->data(), idxData, sizeof(idxData)); + blitStorage.m_indices->unlock(); + blitStorage.m_indices->makeCurrent(); + + OGLCHECK(glDisableFn(GL_ALPHA_TEST_MWM)); + OGLCHECK(glDisableFn(GL_BLEND)); + OGLCHECK(glDisableFn(GL_DEPTH_TEST)); + OGLCHECK(glDepthMask(GL_FALSE)); + OGLCHECK(glDrawElementsFn(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, blitStorage.m_indices->glPtr())); + OGLCHECK(glDepthMask(GL_TRUE)); + OGLCHECK(glEnableFn(GL_DEPTH_TEST)); + OGLCHECK(glEnableFn(GL_BLEND)); + OGLCHECK(glEnableFn(GL_ALPHA_TEST_MWM)); + + blitStorage.m_vertices->discard(); + blitStorage.m_indices->discard(); + + m_resourceManager->blitStorages()->Free(blitStorage); } void GeometryRenderer::DrawGeometry::perform() @@ -168,8 +212,23 @@ namespace graphics // OGLCHECK(glPolygonMode( GL_FRONT_AND_BACK, GL_LINE )); + unsigned glPrimType; + + switch (m_primitiveType) + { + case ETrianglesFan: + glPrimType = GL_TRIANGLE_FAN; + break; + case ETriangles: + glPrimType = GL_TRIANGLES; + break; + case ETrianglesStrip: + glPrimType = GL_TRIANGLE_STRIP; + break; + }; + OGLCHECK(glDrawElementsFn( - m_primitiveType, + glPrimType, m_indicesCount, GL_UNSIGNED_SHORT, ((unsigned char*)m_storage.m_indices->glPtr()) + m_indicesOffs)); @@ -186,11 +245,8 @@ namespace graphics Storage const & storage, size_t indicesCount, size_t indicesOffs, - unsigned primType) + EPrimitives primType) { - if (isCancelled()) - return; - shared_ptr command(new DrawGeometry()); command->m_texture = texture; @@ -199,10 +255,7 @@ namespace graphics command->m_indicesOffs = indicesOffs; command->m_primitiveType = primType; - if (m_displayList) - m_displayList->drawGeometry(command); - else - processCommand(command); + processCommand(command); } void GeometryRenderer::FreeStorage::perform() @@ -228,10 +281,7 @@ namespace graphics command->m_storage = storage; command->m_storagePool = storagePool; - if (m_displayList) - m_displayList->freeStorage(command); - else - processCommand(command); + processCommand(command); } void GeometryRenderer::FreeTexture::perform() @@ -265,10 +315,7 @@ namespace graphics command->m_texture = texture; command->m_texturePool = texturePool; - if (m_displayList) - m_displayList->freeTexture(command); - else - processCommand(command); + processCommand(command); } void GeometryRenderer::UnlockStorage::perform() @@ -302,10 +349,7 @@ namespace graphics command->m_storage = storage; - if (m_displayList) - m_displayList->unlockStorage(command); - else - processCommand(command); + processCommand(command); } void GeometryRenderer::DiscardStorage::perform() @@ -333,31 +377,7 @@ namespace graphics command->m_storage = storage; - if (m_displayList) - m_displayList->discardStorage(command); - else - processCommand(command); - } - - DisplayList * GeometryRenderer::createDisplayList() - { - return new DisplayList(this); - } - - void GeometryRenderer::setDisplayList(DisplayList * dl) - { - m_displayList = dl; - } - - void GeometryRenderer::drawDisplayList(DisplayList * dl, - math::Matrix const & m) - { - dl->draw(m); - } - - DisplayList * GeometryRenderer::displayList() const - { - return m_displayList; + processCommand(command); } void GeometryRenderer::ApplyStates::perform() @@ -400,13 +420,7 @@ namespace graphics void GeometryRenderer::applyStates() { - - shared_ptr command(new ApplyStates()); - - if (m_displayList) - m_displayList->applyStates(command); - else - processCommand(command); + processCommand(make_shared_ptr(new ApplyStates())); } void GeometryRenderer::ApplyBlitStates::perform() @@ -427,12 +441,15 @@ namespace graphics void GeometryRenderer::applyBlitStates() { - shared_ptr command(new ApplyBlitStates()); + processCommand(make_shared_ptr(new ApplyBlitStates())); + } - if (m_displayList) - m_displayList->applyBlitStates(command); - else - processCommand(command); + void GeometryRenderer::loadMatrix(EMatrix mt, + math::Matrix const & m) + { + OGLCHECK(glMatrixModeFn(GL_MODELVIEW_MWM)); + OGLCHECK(glLoadIdentityFn()); + OGLCHECK(glLoadMatrixfFn(&m(0, 0))); } } } diff --git a/graphics/geometry_renderer.hpp b/graphics/opengl/geometry_renderer.hpp similarity index 60% rename from graphics/geometry_renderer.hpp rename to graphics/opengl/geometry_renderer.hpp index c90f469b19..bdb691e179 100644 --- a/graphics/geometry_renderer.hpp +++ b/graphics/opengl/geometry_renderer.hpp @@ -1,12 +1,14 @@ #pragma once +#include "../defines.hpp" +#include "../skin_page.hpp" + #include "clipper.hpp" -#include "skin_page.hpp" -#include "../base/threaded_list.hpp" +#include "../../base/threaded_list.hpp" -#include "../std/shared_ptr.hpp" -#include "../std/function.hpp" +#include "../../std/shared_ptr.hpp" +#include "../../std/function.hpp" namespace graphics { @@ -15,31 +17,21 @@ namespace graphics namespace gl { class BaseTexture; - class DisplayList; class GeometryRenderer : public Clipper { - private: - - DisplayList * m_displayList; - - void uploadTextureImpl(SkinPage::TUploadQueue const & uploadQueue, - size_t start, - size_t end, - shared_ptr const & texture, - bool shouldAddCheckPoint); - public: typedef Clipper base_t; struct UploadData : public Command { - SkinPage::TUploadQueue m_uploadQueue; + vector > m_uploadQueue; shared_ptr m_texture; UploadData(); - UploadData(SkinPage::TUploadQueue const & uploadQueue, + UploadData(shared_ptr const * styles, + size_t count, shared_ptr const & texture); void perform(); @@ -47,13 +39,36 @@ namespace graphics void dump(); }; + struct IMMDrawTexturedPrimitives : Command + { + buffer_vector m_pts; + buffer_vector m_texPts; + unsigned m_ptsCount; + shared_ptr m_texture; + bool m_hasTexture; + graphics::Color m_color; + bool m_hasColor; + + shared_ptr m_resourceManager; + + void perform(); + }; + + struct IMMDrawTexturedRect : IMMDrawTexturedPrimitives + { + IMMDrawTexturedRect(m2::RectF const & rect, + m2::RectF const & texRect, + shared_ptr const & texture, + shared_ptr const & rm); + }; + struct DrawGeometry : Command { shared_ptr m_texture; Storage m_storage; size_t m_indicesCount; size_t m_indicesOffs; - unsigned m_primitiveType; + EPrimitives m_primitiveType; void perform(); void dump(); @@ -115,22 +130,20 @@ namespace graphics Storage const & storage, size_t indicesCount, size_t indicesOffs, - unsigned primType); + EPrimitives primType); + + void uploadStyles(shared_ptr const * styles, + size_t count, + shared_ptr const & texture); - void uploadTexture(SkinPage::TUploadQueue const & uploadQueue, shared_ptr const & texture); void freeTexture(shared_ptr const & texture, TTexturePool * texturePool); void freeStorage(Storage const & storage, TStoragePool * storagePool); void unlockStorage(Storage const & storage); void discardStorage(Storage const & storage); - /// create display list - DisplayList * createDisplayList(); - /// set current display list - void setDisplayList(DisplayList * displayList); - /// get current display list - DisplayList * displayList() const; - /// draw display list - void drawDisplayList(DisplayList * dl, math::Matrix const & m); + /// setup rendering matrix + void loadMatrix(EMatrix mt, + math::Matrix const & m); }; } } diff --git a/graphics/internal/gl_procedures.inl b/graphics/opengl/gl_procedures.inl similarity index 100% rename from graphics/internal/gl_procedures.inl rename to graphics/opengl/gl_procedures.inl diff --git a/graphics/managed_texture.cpp b/graphics/opengl/managed_texture.cpp similarity index 92% rename from graphics/managed_texture.cpp rename to graphics/opengl/managed_texture.cpp index 5365cddff5..2ffcca0de3 100644 --- a/graphics/managed_texture.cpp +++ b/graphics/opengl/managed_texture.cpp @@ -1,8 +1,9 @@ #include "../base/SRC_FIRST.hpp" -#include "internal/opengl.hpp" +#include "../../base/shared_buffer_manager.hpp" + +#include "opengl.hpp" #include "managed_texture.hpp" -#include "../base/shared_buffer_manager.hpp" namespace graphics { diff --git a/graphics/managed_texture.hpp b/graphics/opengl/managed_texture.hpp similarity index 86% rename from graphics/managed_texture.hpp rename to graphics/opengl/managed_texture.hpp index c4785c56da..e30b7b938e 100644 --- a/graphics/managed_texture.hpp +++ b/graphics/opengl/managed_texture.hpp @@ -1,10 +1,12 @@ #pragma once -#include "../geometry/rect2d.hpp" -#include "../geometry/point2d.hpp" +#include "../../geometry/rect2d.hpp" +#include "../../geometry/point2d.hpp" + +#include "../../std/vector.hpp" +#include "../../std/shared_ptr.hpp" + #include "base_texture.hpp" -#include "../std/vector.hpp" -#include "../std/shared_ptr.hpp" namespace graphics { diff --git a/graphics/internal/opengl.cpp b/graphics/opengl/opengl.cpp similarity index 100% rename from graphics/internal/opengl.cpp rename to graphics/opengl/opengl.cpp diff --git a/graphics/internal/opengl.hpp b/graphics/opengl/opengl.hpp similarity index 99% rename from graphics/internal/opengl.hpp rename to graphics/opengl/opengl.hpp index 8293066917..58c99aeda9 100644 --- a/graphics/internal/opengl.hpp +++ b/graphics/opengl/opengl.hpp @@ -1,4 +1,5 @@ #pragma once + #include "../../std/target_os.hpp" #include "../../base/logging.hpp" diff --git a/graphics/internal/opengl_es.cpp b/graphics/opengl/opengl_es.cpp similarity index 100% rename from graphics/internal/opengl_es.cpp rename to graphics/opengl/opengl_es.cpp diff --git a/graphics/internal/opengl_ext.cpp b/graphics/opengl/opengl_ext.cpp similarity index 100% rename from graphics/internal/opengl_ext.cpp rename to graphics/opengl/opengl_ext.cpp diff --git a/graphics/internal/opengl_glsl_es2.cpp b/graphics/opengl/opengl_glsl_es2.cpp similarity index 100% rename from graphics/internal/opengl_glsl_es2.cpp rename to graphics/opengl/opengl_glsl_es2.cpp diff --git a/graphics/internal/opengl_glsl_ext.cpp b/graphics/opengl/opengl_glsl_ext.cpp similarity index 100% rename from graphics/internal/opengl_glsl_ext.cpp rename to graphics/opengl/opengl_glsl_ext.cpp diff --git a/graphics/internal/opengl_glsl_impl.cpp b/graphics/opengl/opengl_glsl_impl.cpp similarity index 100% rename from graphics/internal/opengl_glsl_impl.cpp rename to graphics/opengl/opengl_glsl_impl.cpp diff --git a/graphics/internal/opengl_glsl_impl.hpp b/graphics/opengl/opengl_glsl_impl.hpp similarity index 100% rename from graphics/internal/opengl_glsl_impl.hpp rename to graphics/opengl/opengl_glsl_impl.hpp diff --git a/graphics/internal/opengl_win32.cpp b/graphics/opengl/opengl_win32.cpp similarity index 100% rename from graphics/internal/opengl_win32.cpp rename to graphics/opengl/opengl_win32.cpp diff --git a/graphics/renderbuffer.cpp b/graphics/opengl/renderbuffer.cpp similarity index 98% rename from graphics/renderbuffer.cpp rename to graphics/opengl/renderbuffer.cpp index fa468f6be3..d4c3a712e3 100644 --- a/graphics/renderbuffer.cpp +++ b/graphics/opengl/renderbuffer.cpp @@ -1,6 +1,6 @@ #include "../base/SRC_FIRST.hpp" -#include "internal/opengl.hpp" +#include "opengl.hpp" #include "renderbuffer.hpp" #include "utils.hpp" diff --git a/graphics/renderbuffer.hpp b/graphics/opengl/renderbuffer.hpp similarity index 90% rename from graphics/renderbuffer.hpp rename to graphics/opengl/renderbuffer.hpp index fcbf6a38a1..7bfd5383f5 100644 --- a/graphics/renderbuffer.hpp +++ b/graphics/opengl/renderbuffer.hpp @@ -1,7 +1,7 @@ #pragma once -#include "../std/shared_ptr.hpp" -#include "render_target.hpp" +#include "../../std/shared_ptr.hpp" +#include "../render_target.hpp" namespace graphics { diff --git a/graphics/rendercontext.cpp b/graphics/opengl/rendercontext.cpp similarity index 92% rename from graphics/rendercontext.cpp rename to graphics/opengl/rendercontext.cpp index f1e072cc78..eca9c14636 100644 --- a/graphics/rendercontext.cpp +++ b/graphics/opengl/rendercontext.cpp @@ -1,6 +1,6 @@ #include "../base/SRC_FIRST.hpp" #include "rendercontext.hpp" -#include "internal/opengl.hpp" +#include "opengl.hpp" namespace graphics { diff --git a/graphics/rendercontext.hpp b/graphics/opengl/rendercontext.hpp similarity index 94% rename from graphics/rendercontext.hpp rename to graphics/opengl/rendercontext.hpp index f0cb992cce..6ce645f78d 100644 --- a/graphics/rendercontext.hpp +++ b/graphics/opengl/rendercontext.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../std/shared_ptr.hpp" +#include "../../std/shared_ptr.hpp" namespace graphics { diff --git a/graphics/renderer.cpp b/graphics/opengl/renderer.cpp similarity index 98% rename from graphics/renderer.cpp rename to graphics/opengl/renderer.cpp index 7df85142f1..c976164ba1 100644 --- a/graphics/renderer.cpp +++ b/graphics/opengl/renderer.cpp @@ -1,12 +1,12 @@ -#include "../base/SRC_FIRST.hpp" +#include "../base/logging.hpp" + #include "renderer.hpp" #include "data_traits.hpp" #include "utils.hpp" #include "framebuffer.hpp" #include "renderbuffer.hpp" #include "resource_manager.hpp" -#include "internal/opengl.hpp" -#include "../base/logging.hpp" +#include "opengl.hpp" namespace graphics { @@ -289,7 +289,7 @@ namespace graphics void Renderer::processCommand(shared_ptr const & command, Packet::EType type, bool doForce) { if (command) - command->m_isDebugging = renderQueue() && !doForce; + command->setIsDebugging(renderQueue() && !doForce); if (renderQueue() && !doForce) renderQueue()->processPacket(Packet(command, type)); diff --git a/graphics/renderer.hpp b/graphics/opengl/renderer.hpp similarity index 93% rename from graphics/renderer.hpp rename to graphics/opengl/renderer.hpp index ab7c631a55..5be49975c7 100644 --- a/graphics/renderer.hpp +++ b/graphics/opengl/renderer.hpp @@ -1,25 +1,25 @@ #pragma once -#include "color.hpp" -#include "packets_queue.hpp" -#include "resource_manager.hpp" +#include "../color.hpp" +#include "../packets_queue.hpp" +#include "../resource_manager.hpp" -#include "../base/threaded_list.hpp" -#include "../base/commands_queue.hpp" -#include "../std/function.hpp" -#include "../std/shared_ptr.hpp" -#include "../geometry/rect2d.hpp" +#include "../../base/threaded_list.hpp" +#include "../../base/commands_queue.hpp" +#include "../../std/function.hpp" +#include "../../std/shared_ptr.hpp" +#include "../../geometry/rect2d.hpp" namespace graphics { class ResourceManager; + class RenderTarget; namespace gl { class FrameBuffer; class RenderBuffer; class BaseTexture; - class RenderTarget; class Renderer { diff --git a/graphics/storage.cpp b/graphics/opengl/storage.cpp similarity index 83% rename from graphics/storage.cpp rename to graphics/opengl/storage.cpp index d565dc73d4..8412fd2a7b 100644 --- a/graphics/storage.cpp +++ b/graphics/opengl/storage.cpp @@ -1,7 +1,7 @@ -#include "../base/SRC_FIRST.hpp" #include "storage.hpp" #include "buffer_object.hpp" -#include "internal/opengl.hpp" + +#include "opengl/opengl.hpp" namespace graphics { diff --git a/graphics/storage.hpp b/graphics/opengl/storage.hpp similarity index 88% rename from graphics/storage.hpp rename to graphics/opengl/storage.hpp index f77459b1ac..82e49e1366 100644 --- a/graphics/storage.hpp +++ b/graphics/opengl/storage.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../std/shared_ptr.hpp" +#include "../../std/shared_ptr.hpp" namespace graphics { diff --git a/graphics/texture.hpp b/graphics/opengl/texture.hpp similarity index 98% rename from graphics/texture.hpp rename to graphics/opengl/texture.hpp index 49861e9f9d..5d04069cbc 100644 --- a/graphics/texture.hpp +++ b/graphics/opengl/texture.hpp @@ -2,11 +2,12 @@ #include "managed_texture.hpp" #include "data_traits.hpp" -#include "image_info.hpp" -#include "../platform/platform.hpp" +#include "../image_info.hpp" -#include "../coding/lodepng_io.hpp" +#include "../../platform/platform.hpp" + +#include "../../coding/lodepng_io.hpp" namespace gil = boost::gil; namespace mpl = boost::mpl; diff --git a/graphics/utils.cpp b/graphics/opengl/utils.cpp similarity index 95% rename from graphics/utils.cpp rename to graphics/opengl/utils.cpp index 73139c6edf..187d5f8bce 100644 --- a/graphics/utils.cpp +++ b/graphics/opengl/utils.cpp @@ -1,7 +1,7 @@ #include "defines.hpp" #include "utils.hpp" -#include "internal/opengl.hpp" +#include "opengl/opengl.hpp" #include "../std/target_os.hpp" diff --git a/graphics/utils.hpp b/graphics/opengl/utils.hpp similarity index 84% rename from graphics/utils.hpp rename to graphics/opengl/utils.hpp index 7441750c64..4cc8d41f04 100644 --- a/graphics/utils.hpp +++ b/graphics/opengl/utils.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../std/stdint.hpp" +#include "../../std/stdint.hpp" namespace graphics { diff --git a/graphics/vertex.cpp b/graphics/opengl/vertex.cpp similarity index 97% rename from graphics/vertex.cpp rename to graphics/opengl/vertex.cpp index 060f3ea1d9..f260265f4d 100644 --- a/graphics/vertex.cpp +++ b/graphics/opengl/vertex.cpp @@ -1,6 +1,6 @@ #include "vertex.hpp" -#include "internal/opengl.hpp" +#include "opengl.hpp" namespace graphics { diff --git a/graphics/vertex.hpp b/graphics/opengl/vertex.hpp similarity index 92% rename from graphics/vertex.hpp rename to graphics/opengl/vertex.hpp index c58f877840..ec14b8d303 100644 --- a/graphics/vertex.hpp +++ b/graphics/opengl/vertex.hpp @@ -1,8 +1,8 @@ #pragma once -#include "color.hpp" +#include "../color.hpp" -#include "../geometry/point2d.hpp" +#include "../../geometry/point2d.hpp" namespace graphics { diff --git a/graphics/overlay.cpp b/graphics/overlay.cpp index 221a559267..58a0cb6c2f 100644 --- a/graphics/overlay.cpp +++ b/graphics/overlay.cpp @@ -29,7 +29,7 @@ namespace graphics return elem->roughBoundRect(); } - void DrawIfNotCancelled(gl::OverlayRenderer * r, + void DrawIfNotCancelled(OverlayRenderer * r, shared_ptr const & e, math::Matrix const & m) { @@ -37,7 +37,7 @@ namespace graphics e->draw(r, m); } - void Overlay::draw(gl::OverlayRenderer * r, math::Matrix const & m) + void Overlay::draw(OverlayRenderer * r, math::Matrix const & m) { m_tree.ForEach(bind(&DrawIfNotCancelled, r, _1, cref(m))); } diff --git a/graphics/overlay.hpp b/graphics/overlay.hpp index 2945f4f251..c096deebd5 100644 --- a/graphics/overlay.hpp +++ b/graphics/overlay.hpp @@ -35,7 +35,7 @@ namespace graphics Overlay(); Overlay(Overlay const & src); - void draw(gl::OverlayRenderer * r, math::Matrix const & m); + void draw(OverlayRenderer * r, math::Matrix const & m); void selectOverlayElements(m2::PointD const & pt, list > & res); void selectOverlayElements(m2::RectD const & rect, list > & res); diff --git a/graphics/overlay_element.hpp b/graphics/overlay_element.hpp index 27e69b333e..dd565d7764 100644 --- a/graphics/overlay_element.hpp +++ b/graphics/overlay_element.hpp @@ -8,10 +8,7 @@ namespace graphics { - namespace gl - { - class OverlayRenderer; - } + class OverlayRenderer; class OverlayElement { @@ -63,7 +60,7 @@ namespace graphics /// PLEASE, REMEMBER THE REFERENCE!!! virtual vector const & boundRects() const = 0; - virtual void draw(gl::OverlayRenderer * r, math::Matrix const & m) const = 0; + virtual void draw(OverlayRenderer * r, math::Matrix const & m) const = 0; virtual int visualRank() const = 0; m2::PointD const & pivot() const; diff --git a/graphics/overlay_renderer.cpp b/graphics/overlay_renderer.cpp index 55d89f4b6a..fa86e4406f 100644 --- a/graphics/overlay_renderer.cpp +++ b/graphics/overlay_renderer.cpp @@ -12,186 +12,183 @@ namespace graphics { - namespace gl + OverlayRenderer::Params::Params() + : m_drawTexts(true), + m_drawSymbols(true) { - OverlayRenderer::Params::Params() - : m_drawTexts(true), - m_drawSymbols(true) - { - } + } - OverlayRenderer::OverlayRenderer(Params const & p) - : TextRenderer(p), - m_drawTexts(p.m_drawTexts), - m_drawSymbols(p.m_drawSymbols), - m_overlay(p.m_overlay) - { - } + OverlayRenderer::OverlayRenderer(Params const & p) + : TextRenderer(p), + m_drawTexts(p.m_drawTexts), + m_drawSymbols(p.m_drawSymbols), + m_overlay(p.m_overlay) + { + } - void OverlayRenderer::drawSymbol(SymbolElement::Params & params) - { - if (!m_drawSymbols) - return; + void OverlayRenderer::drawSymbol(SymbolElement::Params & params) + { + if (!m_drawSymbols) + return; - params.m_skin = skin().get(); + params.m_skin = skin().get(); - shared_ptr oe(new SymbolElement(params)); + shared_ptr oe(new SymbolElement(params)); - math::Matrix id = math::Identity(); + math::Matrix id = math::Identity(); - if (!m_overlay.get()) - oe->draw(this, id); - else - m_overlay->processOverlayElement(oe); - } + if (!m_overlay.get()) + oe->draw(this, id); + else + m_overlay->processOverlayElement(oe); + } - void OverlayRenderer::drawSymbol(m2::PointD const & pt, string const & symbolName, EPosition pos, int depth) - { - graphics::SymbolElement::Params params; - params.m_depth = depth; - params.m_position = pos; - params.m_pivot = pt; - params.m_symbolName = symbolName; + void OverlayRenderer::drawSymbol(m2::PointD const & pt, string const & symbolName, EPosition pos, int depth) + { + graphics::SymbolElement::Params params; + params.m_depth = depth; + params.m_position = pos; + params.m_pivot = pt; + params.m_symbolName = symbolName; - drawSymbol(params); - } + drawSymbol(params); + } - void OverlayRenderer::drawCircle(m2::PointD const & pt, - graphics::CircleInfo const & ci, - EPosition pos, - int depth) - { - CircleElement::Params params; + void OverlayRenderer::drawCircle(m2::PointD const & pt, + graphics::CircleInfo const & ci, + EPosition pos, + int depth) + { + CircleElement::Params params; - params.m_depth = depth; - params.m_position = pos; - params.m_pivot = pt; - params.m_ci = ci; + params.m_depth = depth; + params.m_position = pos; + params.m_pivot = pt; + params.m_ci = ci; - shared_ptr oe(new CircleElement(params)); + shared_ptr oe(new CircleElement(params)); - math::Matrix id = math::Identity(); + math::Matrix id = math::Identity(); - if (!m_overlay.get()) - oe->draw(this, id); - else - m_overlay->processOverlayElement(oe); - } + if (!m_overlay.get()) + oe->draw(this, id); + else + m_overlay->processOverlayElement(oe); + } - void OverlayRenderer::drawText(FontDesc const & fontDesc, + void OverlayRenderer::drawText(FontDesc const & fontDesc, + m2::PointD const & pt, + graphics::EPosition pos, + string const & utf8Text, + double depth, + bool log2vis, + bool doSplit) + { + if (!m_drawTexts) + return; + + StraightTextElement::Params params; + params.m_depth = depth; + params.m_fontDesc = fontDesc; + params.m_log2vis = log2vis; + params.m_pivot = pt; + params.m_position = pos; + params.m_glyphCache = glyphCache(); + params.m_logText = strings::MakeUniString(utf8Text); + params.m_doSplit = doSplit; + params.m_useAllParts = false; + + shared_ptr oe(new StraightTextElement(params)); + + math::Matrix id = math::Identity(); + + if (!m_overlay.get()) + oe->draw(this, id); + else + m_overlay->processOverlayElement(oe); + } + + void OverlayRenderer::drawTextEx(FontDesc const & primaryFont, + FontDesc const & secondaryFont, m2::PointD const & pt, graphics::EPosition pos, - string const & utf8Text, + string const & text, + string const & secondaryText, double depth, bool log2vis, bool doSplit) - { - if (!m_drawTexts) - return; + { + if (!m_drawTexts) + return; - StraightTextElement::Params params; - params.m_depth = depth; - params.m_fontDesc = fontDesc; - params.m_log2vis = log2vis; - params.m_pivot = pt; - params.m_position = pos; - params.m_glyphCache = glyphCache(); - params.m_logText = strings::MakeUniString(utf8Text); - params.m_doSplit = doSplit; - params.m_useAllParts = false; + StraightTextElement::Params params; + params.m_depth = depth; + params.m_fontDesc = primaryFont; + params.m_auxFontDesc = secondaryFont; + params.m_log2vis = log2vis; + params.m_pivot = pt; + params.m_position = pos; + params.m_glyphCache = glyphCache(); + params.m_logText = strings::MakeUniString(text); + params.m_auxLogText = strings::MakeUniString(secondaryText); + params.m_doSplit = doSplit; + params.m_useAllParts = false; - shared_ptr oe(new StraightTextElement(params)); + shared_ptr oe(new StraightTextElement(params)); - math::Matrix id = math::Identity(); + math::Matrix id = math::Identity(); - if (!m_overlay.get()) - oe->draw(this, id); - else - m_overlay->processOverlayElement(oe); - } + if (!m_overlay.get()) + oe->draw(this, id); + else + m_overlay->processOverlayElement(oe); + } - void OverlayRenderer::drawTextEx(FontDesc const & primaryFont, - FontDesc const & secondaryFont, - m2::PointD const & pt, - graphics::EPosition pos, - string const & text, - string const & secondaryText, - double depth, - bool log2vis, - bool doSplit) - { - if (!m_drawTexts) - return; - - StraightTextElement::Params params; - params.m_depth = depth; - params.m_fontDesc = primaryFont; - params.m_auxFontDesc = secondaryFont; - params.m_log2vis = log2vis; - params.m_pivot = pt; - params.m_position = pos; - params.m_glyphCache = glyphCache(); - params.m_logText = strings::MakeUniString(text); - params.m_auxLogText = strings::MakeUniString(secondaryText); - params.m_doSplit = doSplit; - params.m_useAllParts = false; - - shared_ptr oe(new StraightTextElement(params)); - - math::Matrix id = math::Identity(); - - if (!m_overlay.get()) - oe->draw(this, id); - else - m_overlay->processOverlayElement(oe); - } - - bool OverlayRenderer::drawPathText( + bool OverlayRenderer::drawPathText( FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text, double fullLength, double pathOffset, graphics::EPosition pos, double depth) - { - if (!m_drawTexts) - return false; + { + if (!m_drawTexts) + return false; - PathTextElement::Params params; + PathTextElement::Params params; - params.m_pts = path; - params.m_ptsCount = s; - params.m_fullLength = fullLength; - params.m_pathOffset = pathOffset; - params.m_fontDesc = fontDesc; - params.m_logText = strings::MakeUniString(utf8Text); - params.m_depth = depth; - params.m_log2vis = true; - params.m_glyphCache = glyphCache(); - params.m_pivot = path[0]; - params.m_position = pos; + params.m_pts = path; + params.m_ptsCount = s; + params.m_fullLength = fullLength; + params.m_pathOffset = pathOffset; + params.m_fontDesc = fontDesc; + params.m_logText = strings::MakeUniString(utf8Text); + params.m_depth = depth; + params.m_log2vis = true; + params.m_glyphCache = glyphCache(); + params.m_pivot = path[0]; + params.m_position = pos; - shared_ptr pte(new PathTextElement(params)); + shared_ptr pte(new PathTextElement(params)); - math::Matrix id = math::Identity(); + math::Matrix id = math::Identity(); - if (!m_overlay.get()) - pte->draw(this, id); - else - m_overlay->processOverlayElement(pte); + if (!m_overlay.get()) + pte->draw(this, id); + else + m_overlay->processOverlayElement(pte); - return true; - } + return true; + } - void OverlayRenderer::setOverlay(shared_ptr const & overlay) - { - m_overlay = overlay; - } + void OverlayRenderer::setOverlay(shared_ptr const & overlay) + { + m_overlay = overlay; + } - shared_ptr const & OverlayRenderer::overlay() const - { - return m_overlay; - } + shared_ptr const & OverlayRenderer::overlay() const + { + return m_overlay; + } - void OverlayRenderer::resetOverlay() - { - m_overlay.reset(); - } + void OverlayRenderer::resetOverlay() + { + m_overlay.reset(); } } diff --git a/graphics/overlay_renderer.hpp b/graphics/overlay_renderer.hpp index bb1bacfa40..4c58834f88 100644 --- a/graphics/overlay_renderer.hpp +++ b/graphics/overlay_renderer.hpp @@ -6,73 +6,70 @@ namespace graphics { - namespace gl + class OverlayRenderer : public TextRenderer { - class OverlayRenderer : public TextRenderer - { - private: + private: + bool m_drawTexts; + bool m_drawSymbols; + shared_ptr m_overlay; + + typedef map > TElements; + + TElements m_elements; + + public: + + struct Params : public TextRenderer::Params + { bool m_drawTexts; bool m_drawSymbols; shared_ptr m_overlay; + Params(); + }; - typedef map > TElements; + OverlayRenderer(Params const & p); - TElements m_elements; + /// Drawing POI symbol + void drawSymbol(SymbolElement::Params & params); + void drawSymbol(m2::PointD const & pt, string const & symbolName, EPosition pos, int depth); - public: + /// Drawing circle + void drawCircle(m2::PointD const & pt, graphics::CircleInfo const & ci, EPosition pos, int depth); - struct Params : public TextRenderer::Params - { - bool m_drawTexts; - bool m_drawSymbols; - shared_ptr m_overlay; - Params(); - }; + /// drawing straight text + void drawText(FontDesc const & fontDesc, + m2::PointD const & pt, + graphics::EPosition pos, + string const & utf8Text, + double depth, + bool log2vis, + bool doSplit = false); - OverlayRenderer(Params const & p); - - /// Drawing POI symbol - void drawSymbol(SymbolElement::Params & params); - void drawSymbol(m2::PointD const & pt, string const & symbolName, EPosition pos, int depth); - - /// Drawing circle - void drawCircle(m2::PointD const & pt, graphics::CircleInfo const & ci, EPosition pos, int depth); - - /// drawing straight text - void drawText(FontDesc const & fontDesc, + void drawTextEx(FontDesc const & primaryFont, + FontDesc const & secondaryFont, m2::PointD const & pt, graphics::EPosition pos, - string const & utf8Text, + string const & text, + string const & secondaryText, double depth, bool log2vis, bool doSplit = false); - void drawTextEx(FontDesc const & primaryFont, - FontDesc const & secondaryFont, - m2::PointD const & pt, + /// drawing text on the path + bool drawPathText(FontDesc const & fontDesc, + m2::PointD const * path, + size_t s, + string const & utf8Text, + double fullLength, + double pathOffset, graphics::EPosition pos, - string const & text, - string const & secondaryText, - double depth, - bool log2vis, - bool doSplit = false); + double depth); - /// drawing text on the path - bool drawPathText(FontDesc const & fontDesc, - m2::PointD const * path, - size_t s, - string const & utf8Text, - double fullLength, - double pathOffset, - graphics::EPosition pos, - double depth); + void setOverlay(shared_ptr const & overlay); - void setOverlay(shared_ptr const & overlay); + shared_ptr const & overlay() const; - shared_ptr const & overlay() const; - - void resetOverlay(); - }; - } + void resetOverlay(); + }; } diff --git a/graphics/packets_queue.cpp b/graphics/packets_queue.cpp index 83e964e3b0..c2fa838632 100644 --- a/graphics/packets_queue.cpp +++ b/graphics/packets_queue.cpp @@ -3,132 +3,129 @@ namespace graphics { - namespace gl + bool Command::isDebugging() const { - bool Command::isDebugging() const - { - return m_isDebugging; - } + return m_isDebugging; + } - void Command::setIsDebugging(bool flag) - { - m_isDebugging = flag; - } + void Command::setIsDebugging(bool flag) + { + m_isDebugging = flag; + } - Command::Command() - : m_isDebugging(false) + Command::Command() + : m_isDebugging(false) + {} + + Command::~Command() + {} + + void Command::cancel() + {} + + void Command::perform() + {} + + void Command::dump() + {} + + DumpCommand::DumpCommand(shared_ptr const & cmd) + : m_cmd(cmd) + {} + + void DumpCommand::perform() + { + m_cmd->dump(); + } + + Packet::Packet() + {} + + Packet::Packet(EType type) + : m_type(type) + {} + + Packet::Packet(shared_ptr const & command, + EType type) + : m_command(command), + m_type(type) + {} + + PacketsQueue::PacketsQueue() + : m_fenceManager(5) + {} + + struct SignalFence : public Command + { + int m_id; + FenceManager * m_fenceManager; + + SignalFence(int id, FenceManager * fenceManager) + : m_id(id), m_fenceManager(fenceManager) {} - Command::~Command() - {} - - void Command::cancel() - {} - - void Command::perform() - {} - - void Command::dump() - {} - - DumpCommand::DumpCommand(shared_ptr const & cmd) - : m_cmd(cmd) - {} - - void DumpCommand::perform() + void perform() { - m_cmd->dump(); + m_fenceManager->signalFence(m_id); } - Packet::Packet() - {} - - Packet::Packet(EType type) - : m_type(type) - {} - - Packet::Packet(shared_ptr const & command, - EType type) - : m_command(command), - m_type(type) - {} - - PacketsQueue::PacketsQueue() - : m_fenceManager(5) - {} - - struct SignalFence : public Command + void cancel() { - int m_id; - FenceManager * m_fenceManager; - - SignalFence(int id, FenceManager * fenceManager) - : m_id(id), m_fenceManager(fenceManager) - {} - - void perform() - { - m_fenceManager->signalFence(m_id); - } - - void cancel() - { - perform(); - } - }; - - int PacketsQueue::insertFence(Packet::EType type) - { - int id = m_fenceManager.insertFence(); - processPacket(Packet(make_shared_ptr(new SignalFence(id, &m_fenceManager)), type)); - return id; + perform(); } + }; - void PacketsQueue::joinFence(int id) - { - m_fenceManager.joinFence(id); - } + int PacketsQueue::insertFence(Packet::EType type) + { + int id = m_fenceManager.insertFence(); + processPacket(Packet(make_shared_ptr(new SignalFence(id, &m_fenceManager)), type)); + return id; + } - void PacketsQueue::completeCommands() - { - joinFence(insertFence(Packet::EFramePoint)); - } + void PacketsQueue::joinFence(int id) + { + m_fenceManager.joinFence(id); + } - void PacketsQueue::cancelCommands() - { - joinFence(insertFence(Packet::ECancelPoint)); - } + void PacketsQueue::completeCommands() + { + joinFence(insertFence(Packet::EFramePoint)); + } - void PacketsQueue::cancel() - { - m_packets.Cancel(); - m_fenceManager.cancel(); - } + void PacketsQueue::cancelCommands() + { + joinFence(insertFence(Packet::ECancelPoint)); + } - void PacketsQueue::cancelFences() - { - m_fenceManager.cancel(); - } + void PacketsQueue::cancel() + { + m_packets.Cancel(); + m_fenceManager.cancel(); + } - void PacketsQueue::processPacket(Packet const & packet) - { - if (m_packets.IsCancelled()) - { - if (packet.m_command) - packet.m_command->cancel(); - } - else - m_packets.PushBack(packet); - } + void PacketsQueue::cancelFences() + { + m_fenceManager.cancel(); + } - bool PacketsQueue::empty() const + void PacketsQueue::processPacket(Packet const & packet) + { + if (m_packets.IsCancelled()) { - return m_packets.Empty(); + if (packet.m_command) + packet.m_command->cancel(); } + else + m_packets.PushBack(packet); + } - size_t PacketsQueue::size() const - { - return m_packets.Size(); - } + bool PacketsQueue::empty() const + { + return m_packets.Empty(); + } + + size_t PacketsQueue::size() const + { + return m_packets.Size(); } } diff --git a/graphics/packets_queue.hpp b/graphics/packets_queue.hpp index bc9957eccb..0ccf910195 100644 --- a/graphics/packets_queue.hpp +++ b/graphics/packets_queue.hpp @@ -10,118 +10,113 @@ namespace graphics { - namespace gl + struct Command { - struct Command + private: + + bool m_isDebugging; + string m_name; + + public: + + bool isDebugging() const; + void setIsDebugging(bool flag); + + Command(); + + virtual ~Command(); + virtual void perform(); + virtual void cancel(); + virtual void dump(); + }; + + struct DumpCommand : Command + { + shared_ptr m_cmd; + + DumpCommand(shared_ptr const & cmd); + + void perform(); + }; + + template + struct FunctorCommand : Command + { + Fn m_fn; + bool m_performOnCancel; + + FunctorCommand(Fn fn, bool performOnCancel = false) + : m_fn(fn), m_performOnCancel(performOnCancel) + {} + + void perform() { - private: + m_fn(); + } - bool m_isDebugging; - string m_name; + void cancel() + { + if (m_performOnCancel) + m_fn(); + } + }; - public: - - bool isDebugging() const; - void setIsDebugging(bool flag); - - Command(); - - virtual ~Command(); - virtual void perform(); - virtual void cancel(); - virtual void dump(); - - friend class Renderer; + struct Packet + { + enum EType + { + ECommand, + ECheckPoint, + EFramePoint, + ECancelPoint }; - struct DumpCommand : Command - { - shared_ptr m_cmd; + shared_ptr m_command; + EType m_type; - DumpCommand(shared_ptr const & cmd); + Packet(); + /// empty packet act as a frame delimiter or a checkpoint. + explicit Packet(EType type); + /// simple command + Packet(shared_ptr const & command, + EType type); + }; - void perform(); - }; + class PacketsQueue + { + private: + + ThreadedList m_packets; + FenceManager m_fenceManager; + + public: + + PacketsQueue(); + + void processPacket(Packet const & packet); + void cancel(); + void cancelFences(); + bool empty() const; + size_t size() const; + + int insertFence(Packet::EType type); + void joinFence(int id); + + /// convenience functions + + void completeCommands(); + void cancelCommands(); template - struct FunctorCommand : Command + void processFn(Fn fn, bool performOnCancel = false) { - Fn m_fn; - bool m_performOnCancel; + processPacket(Packet(make_shared_ptr(new FunctorCommand(fn)), Packet::ECommand)); + } - FunctorCommand(Fn fn, bool performOnCancel = false) - : m_fn(fn), m_performOnCancel(performOnCancel) - {} - - void perform() - { - m_fn(); - } - - void cancel() - { - if (m_performOnCancel) - m_fn(); - } - }; - - struct Packet + template + void processList(Fn fn) { - enum EType - { - ECommand, - ECheckPoint, - EFramePoint, - ECancelPoint - }; - - shared_ptr m_command; - EType m_type; - - Packet(); - /// empty packet act as a frame delimiter or a checkpoint. - explicit Packet(EType type); - /// simple command - Packet(shared_ptr const & command, - EType type); - }; - - class PacketsQueue - { - private: - - ThreadedList m_packets; - FenceManager m_fenceManager; - - public: - - PacketsQueue(); - - void processPacket(Packet const & packet); - void cancel(); - void cancelFences(); - bool empty() const; - size_t size() const; - - int insertFence(Packet::EType type); - void joinFence(int id); - - /// Convenience functions - - void completeCommands(); - void cancelCommands(); - - template - void processFn(Fn fn, bool performOnCancel = false) - { - processPacket(Packet(make_shared_ptr(new FunctorCommand(fn)), Packet::ECommand)); - } - - template - void processList(Fn fn) - { - m_packets.ProcessList(fn); - } - }; - } + m_packets.ProcessList(fn); + } + }; } diff --git a/graphics/path_renderer.cpp b/graphics/path_renderer.cpp index 46b75f2434..ec365aa338 100644 --- a/graphics/path_renderer.cpp +++ b/graphics/path_renderer.cpp @@ -2,7 +2,8 @@ #include "resource_style.hpp" #include "skin.hpp" #include "skin_page.hpp" -#include "base_texture.hpp" + +#include "opengl/base_texture.hpp" #include "../base/logging.hpp" diff --git a/graphics/path_text_element.cpp b/graphics/path_text_element.cpp index 9f79389bfb..0f6ce30d40 100644 --- a/graphics/path_text_element.cpp +++ b/graphics/path_text_element.cpp @@ -46,7 +46,7 @@ namespace graphics return m_boundRects; } - void PathTextElement::draw(gl::OverlayRenderer * screen, math::Matrix const & m) const + void PathTextElement::draw(OverlayRenderer * screen, math::Matrix const & m) const { if (screen->isDebugging()) { diff --git a/graphics/path_text_element.hpp b/graphics/path_text_element.hpp index 8f849dd861..76332b072f 100644 --- a/graphics/path_text_element.hpp +++ b/graphics/path_text_element.hpp @@ -25,7 +25,7 @@ namespace graphics vector const & boundRects() const; - void draw(gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(OverlayRenderer * r, math::Matrix const & m) const; int visualRank() const; diff --git a/graphics/render_target.hpp b/graphics/render_target.hpp index 100ba7b78c..7ef18ce2a0 100644 --- a/graphics/render_target.hpp +++ b/graphics/render_target.hpp @@ -2,18 +2,15 @@ namespace graphics { - namespace gl + class RenderTarget { - class RenderTarget - { - public: - virtual ~RenderTarget() {} - /// attach render target to framebuffer and setup coordinate system - virtual unsigned int id() const = 0; - virtual void attachToFrameBuffer() = 0; - virtual void detachFromFrameBuffer() = 0; - virtual unsigned width() const = 0; - virtual unsigned height() const = 0; - }; - } + public: + virtual ~RenderTarget() {} + /// attach render target to framebuffer and setup coordinate system + virtual unsigned int id() const = 0; + virtual void attachToFrameBuffer() = 0; + virtual void detachFromFrameBuffer() = 0; + virtual unsigned width() const = 0; + virtual unsigned height() const = 0; + }; } diff --git a/graphics/resource_manager.cpp b/graphics/resource_manager.cpp index c997e29ce8..bc96953632 100644 --- a/graphics/resource_manager.cpp +++ b/graphics/resource_manager.cpp @@ -1,12 +1,13 @@ - -#include "internal/opengl.hpp" -#include "base_texture.hpp" -#include "data_traits.hpp" #include "resource_manager.hpp" + +#include "opengl/opengl.hpp" +#include "opengl/base_texture.hpp" +#include "opengl/data_traits.hpp" +#include "opengl/storage.hpp" +#include "opengl/texture.hpp" +#include "opengl/buffer_object.hpp" + #include "skin_loader.hpp" -#include "storage.hpp" -#include "texture.hpp" -#include "buffer_object.hpp" #include "../coding/file_reader.hpp" #include "../coding/parse_xml.hpp" diff --git a/graphics/resource_manager.hpp b/graphics/resource_manager.hpp index 07dc3a6e89..5ccd1a271e 100644 --- a/graphics/resource_manager.hpp +++ b/graphics/resource_manager.hpp @@ -9,7 +9,7 @@ #include "../base/mutex.hpp" #include "../base/resource_pool.hpp" -#include "storage.hpp" +#include "opengl/storage.hpp" #include "glyph_cache.hpp" #include "data_formats.hpp" diff --git a/graphics/resource_style.cpp b/graphics/resource_style.cpp index 78ac1f883c..c6d9d62f90 100644 --- a/graphics/resource_style.cpp +++ b/graphics/resource_style.cpp @@ -1,6 +1,6 @@ #include "resource_style.hpp" -#include "data_traits.hpp" +#include "opengl/data_traits.hpp" namespace graphics { diff --git a/graphics/screen.hpp b/graphics/screen.hpp index 8d563f4798..4ce0fe727c 100644 --- a/graphics/screen.hpp +++ b/graphics/screen.hpp @@ -4,17 +4,14 @@ namespace graphics { - namespace gl + class Screen : public OverlayRenderer { - class Screen : public OverlayRenderer - { - private: - public: + private: + public: - typedef OverlayRenderer::Params Params; + typedef OverlayRenderer::Params Params; - Screen(Params const & params) : OverlayRenderer(params) - {} - }; - } + Screen(Params const & params) : OverlayRenderer(params) + {} + }; } diff --git a/graphics/shape_renderer.cpp b/graphics/shape_renderer.cpp index 860dddaf89..816d646d7b 100644 --- a/graphics/shape_renderer.cpp +++ b/graphics/shape_renderer.cpp @@ -3,7 +3,8 @@ #include "pen_info.hpp" #include "resource_style.hpp" #include "skin_page.hpp" -#include "base_texture.hpp" + +#include "opengl/base_texture.hpp" #include "../geometry/point2d.hpp" diff --git a/graphics/skin.cpp b/graphics/skin.cpp index bc6ae971b5..bb9c4aab6f 100644 --- a/graphics/skin.cpp +++ b/graphics/skin.cpp @@ -11,9 +11,6 @@ #include "../std/bind.hpp" #include "../std/numeric.hpp" -#include "internal/opengl.hpp" - - namespace graphics { Skin::Skin(shared_ptr const & resourceManager, diff --git a/graphics/skin_page.cpp b/graphics/skin_page.cpp index bb85d81a30..ca6ff54915 100644 --- a/graphics/skin_page.cpp +++ b/graphics/skin_page.cpp @@ -1,10 +1,10 @@ #include "skin_page.hpp" -#include "texture.hpp" -#include "data_traits.hpp" +#include "opengl/texture.hpp" +#include "opengl/data_traits.hpp" + #include "resource_style.hpp" #include "resource_manager.hpp" -#include "internal/opengl.hpp" #include "../base/logging.hpp" diff --git a/graphics/straight_text_element.cpp b/graphics/straight_text_element.cpp index 1826258b2a..c03bd3d9dd 100644 --- a/graphics/straight_text_element.cpp +++ b/graphics/straight_text_element.cpp @@ -248,7 +248,7 @@ namespace graphics return m_boundRects; } - void StraightTextElement::draw(gl::OverlayRenderer * screen, math::Matrix const & m) const + void StraightTextElement::draw(OverlayRenderer * screen, math::Matrix const & m) const { if (screen->isDebugging()) { diff --git a/graphics/straight_text_element.hpp b/graphics/straight_text_element.hpp index 55b2100f8e..a2b024de3c 100644 --- a/graphics/straight_text_element.hpp +++ b/graphics/straight_text_element.hpp @@ -31,7 +31,7 @@ namespace graphics vector const & boundRects() const; - void draw(gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(OverlayRenderer * r, math::Matrix const & m) const; int visualRank() const; diff --git a/graphics/symbol_element.cpp b/graphics/symbol_element.cpp index 133de605a3..b9a382f20c 100644 --- a/graphics/symbol_element.cpp +++ b/graphics/symbol_element.cpp @@ -53,7 +53,7 @@ namespace graphics return m2::AnyRectD(m2::RectD(posPt, posPt + m2::PointD(texRect.SizeX(), texRect.SizeY()))); } - void SymbolElement::draw(gl::OverlayRenderer * r, math::Matrix const & m) const + void SymbolElement::draw(OverlayRenderer * r, math::Matrix const & m) const { if (!isNeedRedraw()) return; diff --git a/graphics/symbol_element.hpp b/graphics/symbol_element.hpp index c7769ff2ac..11d260f1aa 100644 --- a/graphics/symbol_element.hpp +++ b/graphics/symbol_element.hpp @@ -33,7 +33,7 @@ namespace graphics SymbolElement(SymbolElement const & se, math::Matrix const & m); vector const & boundRects() const; - void draw(gl::OverlayRenderer * s, math::Matrix const & m) const; + void draw(OverlayRenderer * s, math::Matrix const & m) const; uint32_t styleID() const; diff --git a/graphics/text_element.cpp b/graphics/text_element.cpp index 32c0dda9ad..9795d5841f 100644 --- a/graphics/text_element.cpp +++ b/graphics/text_element.cpp @@ -72,7 +72,7 @@ namespace graphics } void TextElement::drawTextImpl(GlyphLayout const & layout, - gl::OverlayRenderer * screen, + OverlayRenderer * screen, math::Matrix const & m, bool doTransformPivotOnly, bool doAlignPivot, diff --git a/graphics/text_element.hpp b/graphics/text_element.hpp index 97af332c64..5d68fee30b 100644 --- a/graphics/text_element.hpp +++ b/graphics/text_element.hpp @@ -17,11 +17,7 @@ namespace graphics class ResourceManager; class Skin; class SkinPage; - - namespace gl - { - class OverlayRenderer; - } + class OverlayRenderer; class TextElement : public OverlayElement { @@ -61,7 +57,7 @@ namespace graphics TextElement(Params const & p); void drawTextImpl(GlyphLayout const & layout, - gl::OverlayRenderer * r, + OverlayRenderer * r, math::Matrix const & m, bool doTransformPivotOnly, bool doAlignPivot, diff --git a/graphics/text_renderer.cpp b/graphics/text_renderer.cpp index 43c87a3e46..08b488ec74 100644 --- a/graphics/text_renderer.cpp +++ b/graphics/text_renderer.cpp @@ -12,67 +12,63 @@ namespace graphics { - namespace gl + TextRenderer::Params::Params() + : m_drawTexts(true), + m_glyphCacheID(-1) + {} + + TextRenderer::TextRenderer(Params const & params) + : base_t(params), + m_drawTexts(params.m_drawTexts), + m_glyphCacheID(params.m_glyphCacheID) + {} + + void TextRenderer::drawStraightGlyph(m2::PointD const & ptPivot, + m2::PointD const & ptOffs, + GlyphStyle const * p, + float depth) { + float x0 = ptOffs.x + (p->m_gi->m_metrics.m_xOffset - 1); + float y1 = ptOffs.y - (p->m_gi->m_metrics.m_yOffset - 1); + float y0 = y1 - (p->m_texRect.SizeY() - 2); + float x1 = x0 + (p->m_texRect.SizeX() - 2); - TextRenderer::Params::Params() - : m_drawTexts(true), - m_glyphCacheID(-1) - {} + drawStraightTexturedPolygon( + ptPivot, + p->m_texRect.minX() + 1, + p->m_texRect.minY() + 1, + p->m_texRect.maxX() - 1, + p->m_texRect.maxY() - 1, + x0, y0, x1, y1, + depth, + p->m_pipelineID + ); + } - TextRenderer::TextRenderer(Params const & params) - : base_t(params), - m_drawTexts(params.m_drawTexts), - m_glyphCacheID(params.m_glyphCacheID) - {} + void TextRenderer::drawGlyph(m2::PointD const & ptOrg, + m2::PointD const & ptGlyph, + ang::AngleD const & angle, + float /*blOffset*/, + GlyphStyle const * p, + double depth) + { + float x0 = ptGlyph.x + (p->m_gi->m_metrics.m_xOffset - 1); + float y1 = ptGlyph.y - (p->m_gi->m_metrics.m_yOffset - 1); + float y0 = y1 - (p->m_texRect.SizeY() - 2); + float x1 = x0 + (p->m_texRect.SizeX() - 2); - void TextRenderer::drawStraightGlyph(m2::PointD const & ptPivot, - m2::PointD const & ptOffs, - GlyphStyle const * p, - float depth) - { - float x0 = ptOffs.x + (p->m_gi->m_metrics.m_xOffset - 1); - float y1 = ptOffs.y - (p->m_gi->m_metrics.m_yOffset - 1); - float y0 = y1 - (p->m_texRect.SizeY() - 2); - float x1 = x0 + (p->m_texRect.SizeX() - 2); + drawTexturedPolygon(ptOrg, angle, + p->m_texRect.minX() + 1, + p->m_texRect.minY() + 1, + p->m_texRect.maxX() - 1, + p->m_texRect.maxY() - 1, + x0, y0, x1, y1, + depth, + p->m_pipelineID); + } - drawStraightTexturedPolygon( - ptPivot, - p->m_texRect.minX() + 1, - p->m_texRect.minY() + 1, - p->m_texRect.maxX() - 1, - p->m_texRect.maxY() - 1, - x0, y0, x1, y1, - depth, - p->m_pipelineID - ); - } - - void TextRenderer::drawGlyph(m2::PointD const & ptOrg, - m2::PointD const & ptGlyph, - ang::AngleD const & angle, - float /*blOffset*/, - GlyphStyle const * p, - double depth) - { - float x0 = ptGlyph.x + (p->m_gi->m_metrics.m_xOffset - 1); - float y1 = ptGlyph.y - (p->m_gi->m_metrics.m_yOffset - 1); - float y0 = y1 - (p->m_texRect.SizeY() - 2); - float x1 = x0 + (p->m_texRect.SizeX() - 2); - - drawTexturedPolygon(ptOrg, angle, - p->m_texRect.minX() + 1, - p->m_texRect.minY() + 1, - p->m_texRect.maxX() - 1, - p->m_texRect.maxY() - 1, - x0, y0, x1, y1, - depth, - p->m_pipelineID); - } - - GlyphCache * TextRenderer::glyphCache() const - { - return resourceManager()->glyphCache(m_glyphCacheID); - } + GlyphCache * TextRenderer::glyphCache() const + { + return resourceManager()->glyphCache(m_glyphCacheID); } } diff --git a/graphics/text_renderer.hpp b/graphics/text_renderer.hpp index 334353818d..bf65a4ec2e 100644 --- a/graphics/text_renderer.hpp +++ b/graphics/text_renderer.hpp @@ -12,42 +12,39 @@ namespace graphics { - namespace gl + class TextRenderer : public ImageRenderer { - class TextRenderer : public ImageRenderer - { - private: + private: + bool m_drawTexts; + int m_glyphCacheID; + + public: + + typedef ImageRenderer base_t; + + struct Params : base_t::Params + { bool m_drawTexts; int m_glyphCacheID; - - public: - - typedef ImageRenderer base_t; - - struct Params : base_t::Params - { - bool m_drawTexts; - int m_glyphCacheID; - Params(); - }; - - TextRenderer(Params const & params); - - void drawStraightGlyph(m2::PointD const & ptOrg, - m2::PointD const & ptGlyph, - GlyphStyle const * p, - float depth); - - void drawGlyph(m2::PointD const & ptOrg, - m2::PointD const & ptGlyph, - ang::AngleD const & angle, - float blOffset, - GlyphStyle const * p, - double depth); - - - GlyphCache * glyphCache() const; + Params(); }; - } + + TextRenderer(Params const & params); + + void drawStraightGlyph(m2::PointD const & ptOrg, + m2::PointD const & ptGlyph, + GlyphStyle const * p, + float depth); + + void drawGlyph(m2::PointD const & ptOrg, + m2::PointD const & ptGlyph, + ang::AngleD const & angle, + float blOffset, + GlyphStyle const * p, + double depth); + + + GlyphCache * glyphCache() const; + }; } diff --git a/gui/button.cpp b/gui/button.cpp index 785e3e2384..17549bbeb5 100644 --- a/gui/button.cpp +++ b/gui/button.cpp @@ -128,7 +128,7 @@ namespace gui return m_boundRects; } - void Button::draw(graphics::gl::OverlayRenderer * r, math::Matrix const & m) const + void Button::draw(graphics::OverlayRenderer * r, math::Matrix const & m) const { if (!isVisible()) return; diff --git a/gui/button.hpp b/gui/button.hpp index fb5e5d5f68..049cf16df1 100644 --- a/gui/button.hpp +++ b/gui/button.hpp @@ -73,7 +73,7 @@ namespace gui /// @{ vector const & boundRects() const; - void draw(graphics::gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(graphics::OverlayRenderer * r, math::Matrix const & m) const; /// @} }; diff --git a/gui/controller.cpp b/gui/controller.cpp index 45155aa945..dfc90e4e43 100644 --- a/gui/controller.cpp +++ b/gui/controller.cpp @@ -20,7 +20,7 @@ namespace gui Controller::RenderParams::RenderParams(double visualScale, TInvalidateFn invalidateFn, graphics::GlyphCache * glyphCache, - graphics::gl::Screen * cacheScreen) + graphics::Screen * cacheScreen) : m_VisualScale(visualScale), m_InvalidateFn(invalidateFn), m_GlyphCache(glyphCache), @@ -158,7 +158,7 @@ namespace gui PurgeElements(); } - void Controller::DrawFrame(graphics::gl::Screen * screen) + void Controller::DrawFrame(graphics::Screen * screen) { screen->beginFrame(); @@ -201,7 +201,7 @@ namespace gui return m_bundle; } - graphics::gl::Screen * Controller::GetCacheScreen() const + graphics::Screen * Controller::GetCacheScreen() const { return m_CacheScreen; } diff --git a/gui/controller.hpp b/gui/controller.hpp index 37956b91ab..b6be4ca257 100644 --- a/gui/controller.hpp +++ b/gui/controller.hpp @@ -12,11 +12,7 @@ namespace graphics { class GlyphCache; class OverlayElement; - - namespace gl - { - class Screen; - } + class Screen; } namespace gui @@ -58,7 +54,7 @@ namespace gui StringsBundle const * m_bundle; /// Screen, which is used to cache gui::Elements into display lists. - graphics::gl::Screen * m_CacheScreen; + graphics::Screen * m_CacheScreen; /// Should we call the onTapEnded when the tap finished(we should /// not if the tap was cancelled while moving). @@ -84,12 +80,12 @@ namespace gui double m_VisualScale; TInvalidateFn m_InvalidateFn; graphics::GlyphCache * m_GlyphCache; - graphics::gl::Screen * m_CacheScreen; + graphics::Screen * m_CacheScreen; RenderParams(); RenderParams(double visualScale, TInvalidateFn invalidateFn, graphics::GlyphCache * glyphCache, - graphics::gl::Screen * cacheScreen); + graphics::Screen * cacheScreen); }; /// Attach GUI Controller to the renderer @@ -110,11 +106,11 @@ namespace gui StringsBundle const * GetStringsBundle() const; /// Get GlyphCache graphics::GlyphCache * GetGlyphCache() const; - /// Get graphics::gl::Screen, which is used to cache gui::Element's + /// Get graphics::Screen, which is used to cache gui::Element's /// into display lists. - graphics::gl::Screen * GetCacheScreen() const; + graphics::Screen * GetCacheScreen() const; /// Redraw GUI - void DrawFrame(graphics::gl::Screen * screen); + void DrawFrame(graphics::Screen * screen); /// Calling gui::Element::update for every element. void UpdateElements(); /// Calling gui::Element::purge for every element. diff --git a/gui/element.cpp b/gui/element.cpp index c183e01602..48f2a18510 100644 --- a/gui/element.cpp +++ b/gui/element.cpp @@ -86,7 +86,7 @@ namespace gui return 0; } - void Element::draw(graphics::gl::OverlayRenderer *r, math::Matrix const & m) const + void Element::draw(graphics::OverlayRenderer *r, math::Matrix const & m) const { for (unsigned i = 0; i < boundRects().size(); ++i) r->drawRectangle(boundRects()[i], color(state()), depth()); diff --git a/gui/element.hpp b/gui/element.hpp index 88ba5dc624..5179101735 100644 --- a/gui/element.hpp +++ b/gui/element.hpp @@ -68,7 +68,7 @@ namespace gui double visualScale() const; graphics::OverlayElement * clone(math::Matrix const & m) const; - void draw(graphics::gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(graphics::OverlayRenderer * r, math::Matrix const & m) const; int visualRank() const; virtual void cache(); diff --git a/gui/text_view.cpp b/gui/text_view.cpp index 68ce7742d8..61be3de297 100644 --- a/gui/text_view.cpp +++ b/gui/text_view.cpp @@ -48,7 +48,7 @@ namespace gui m_elem.reset(new graphics::StraightTextElement(params)); } - void TextView::draw(graphics::gl::OverlayRenderer *r, math::Matrix const & m) const + void TextView::draw(graphics::OverlayRenderer *r, math::Matrix const & m) const { checkDirtyDrawing(); m_elem->draw(r, m); diff --git a/gui/text_view.hpp b/gui/text_view.hpp index 8ec2d6933d..5f949cafd7 100644 --- a/gui/text_view.hpp +++ b/gui/text_view.hpp @@ -36,7 +36,7 @@ namespace gui string const & text() const; vector const & boundRects() const; - void draw(graphics::gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(graphics::OverlayRenderer * r, math::Matrix const & m) const; bool onTapStarted(m2::PointD const & pt); bool onTapMoved(m2::PointD const & pt); diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index cacb544b5a..d4553778fa 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -9,7 +9,7 @@ #include "Framework.h" #include "../../graphics/resource_manager.hpp" -#include "../../graphics/internal/opengl.hpp" +#include "../../graphics/opengl/opengl.hpp" #include "../../graphics/data_formats.hpp" #include "../../map/render_policy.hpp" @@ -123,7 +123,7 @@ { frameBuffer->onSize(width, height); - shared_ptr screen = renderPolicy->GetDrawer()->screen(); + shared_ptr screen = renderPolicy->GetDrawer()->screen(); /// free old render buffer, as we would not create a new one. screen->resetRenderTarget(); @@ -143,7 +143,7 @@ GetFramework().OnSize(width, height); screen->beginFrame(); - screen->clear(graphics::gl::Screen::s_bgColor); + screen->clear(graphics::Screen::s_bgColor); screen->endFrame(); } diff --git a/iphone/Maps/Classes/RenderBuffer.hpp b/iphone/Maps/Classes/RenderBuffer.hpp index 1505c7ac20..cce1082d53 100644 --- a/iphone/Maps/Classes/RenderBuffer.hpp +++ b/iphone/Maps/Classes/RenderBuffer.hpp @@ -8,7 +8,7 @@ namespace iphone { - class RenderBuffer : public graphics::gl::RenderTarget + class RenderBuffer : public graphics::RenderTarget { private: diff --git a/iphone/Maps/Classes/RenderBuffer.mm b/iphone/Maps/Classes/RenderBuffer.mm index 029aa3e19c..c3fd3b01e2 100644 --- a/iphone/Maps/Classes/RenderBuffer.mm +++ b/iphone/Maps/Classes/RenderBuffer.mm @@ -2,8 +2,8 @@ #include "RenderBuffer.hpp" -#include "../../../graphics/internal/opengl.hpp" -#include "../../../graphics/utils.hpp" +#include "../../../graphics/opengl/opengl.hpp" +#include "../../../graphics/opengl/utils.hpp" namespace iphone { diff --git a/iphone/Maps/Classes/RenderContext.hpp b/iphone/Maps/Classes/RenderContext.hpp index 2ca70a56d3..d83dddec2d 100644 --- a/iphone/Maps/Classes/RenderContext.hpp +++ b/iphone/Maps/Classes/RenderContext.hpp @@ -13,7 +13,7 @@ #include #include -#include "../../../graphics/rendercontext.hpp" +#include "../../../graphics/opengl/rendercontext.hpp" #include "../../../std/shared_ptr.hpp" diff --git a/map/compass_arrow.cpp b/map/compass_arrow.cpp index 573b55e64c..78aa1743fd 100644 --- a/map/compass_arrow.cpp +++ b/map/compass_arrow.cpp @@ -52,7 +52,7 @@ vector const & CompassArrow::boundRects() const return m_boundRects; } -void CompassArrow::draw(graphics::gl::OverlayRenderer * r, +void CompassArrow::draw(graphics::OverlayRenderer * r, math::Matrix const & m) const { if (isVisible()) @@ -71,7 +71,7 @@ void CompassArrow::draw(graphics::gl::OverlayRenderer * r, void CompassArrow::cache() { - graphics::gl::Screen * cacheScreen = m_controller->GetCacheScreen(); + graphics::Screen * cacheScreen = m_controller->GetCacheScreen(); m_displayList.reset(); m_displayList.reset(cacheScreen->createDisplayList()); diff --git a/map/compass_arrow.hpp b/map/compass_arrow.hpp index efdec9525b..035aac25c2 100644 --- a/map/compass_arrow.hpp +++ b/map/compass_arrow.hpp @@ -27,7 +27,7 @@ private: graphics::Color const m_southRightColor; double m_angle; - scoped_ptr m_displayList; + scoped_ptr m_displayList; mutable vector m_boundRects; @@ -52,7 +52,7 @@ public: unsigned GetArrowHeight() const; vector const & boundRects() const; - void draw(graphics::gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(graphics::OverlayRenderer * r, math::Matrix const & m) const; bool onTapEnded(m2::PointD const & pt); diff --git a/map/country_status_display.cpp b/map/country_status_display.cpp index 5086356a0a..4c9b2fe350 100644 --- a/map/country_status_display.cpp +++ b/map/country_status_display.cpp @@ -235,7 +235,7 @@ void CountryStatusDisplay::setCountryName(string const & name) } } -void CountryStatusDisplay::draw(graphics::gl::OverlayRenderer *r, +void CountryStatusDisplay::draw(graphics::OverlayRenderer *r, math::Matrix const & m) const { if (!isVisible()) diff --git a/map/country_status_display.hpp b/map/country_status_display.hpp index 683bd958b6..6a6bc3b7f9 100644 --- a/map/country_status_display.hpp +++ b/map/country_status_display.hpp @@ -79,7 +79,7 @@ public: /// attach element to controller. void setController(gui::Controller *controller); /// render element - void draw(graphics::gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(graphics::OverlayRenderer * r, math::Matrix const & m) const; /// get bounding rects vector const & boundRects() const; diff --git a/map/coverage_generator.cpp b/map/coverage_generator.cpp index 1d7710ec19..7779746527 100644 --- a/map/coverage_generator.cpp +++ b/map/coverage_generator.cpp @@ -6,7 +6,7 @@ #include "tile_set.hpp" #include "../graphics/skin.hpp" -#include "../graphics/rendercontext.hpp" +#include "../graphics/opengl/rendercontext.hpp" #include "../base/logging.hpp" @@ -20,7 +20,7 @@ CoverageGenerator::CoverageGenerator( shared_ptr const & windowHandle, shared_ptr const & primaryRC, shared_ptr const & rm, - graphics::gl::PacketsQueue * glQueue, + graphics::PacketsQueue * glQueue, RenderPolicy::TCountryNameFn countryNameFn) : m_queue(1), m_tileRenderer(tileRenderer), @@ -52,7 +52,7 @@ CoverageGenerator::CoverageGenerator( ScreenCoverage * CoverageGenerator::CreateCoverage() { - graphics::gl::Screen::Params params; + graphics::Screen::Params params; params.m_resourceManager = m_resourceManager; params.m_renderQueue = m_glQueue; @@ -61,7 +61,7 @@ ScreenCoverage * CoverageGenerator::CreateCoverage() params.m_isSynchronized = false; params.m_glyphCacheID = m_resourceManager->cacheThreadGlyphCacheID(); - shared_ptr screen(new graphics::gl::Screen(params)); + shared_ptr screen(new graphics::Screen(params)); shared_ptr skin(loadSkin(m_resourceManager, m_skinName)); screen->setSkin(skin); diff --git a/map/coverage_generator.hpp b/map/coverage_generator.hpp index 65d22dbc89..b3b68b8e9f 100644 --- a/map/coverage_generator.hpp +++ b/map/coverage_generator.hpp @@ -60,7 +60,7 @@ private: RenderPolicy::TCountryNameFn m_countryNameFn; - graphics::gl::PacketsQueue * m_glQueue; + graphics::PacketsQueue * m_glQueue; string m_skinName; FenceManager m_fenceManager; @@ -78,7 +78,7 @@ public: shared_ptr const & windowHandle, shared_ptr const & primaryRC, shared_ptr const & rm, - graphics::gl::PacketsQueue * glQueue, + graphics::PacketsQueue * glQueue, RenderPolicy::TCountryNameFn countryNameFn); ~CoverageGenerator(); diff --git a/map/drawer.cpp b/map/drawer.cpp index 0a0ff77f97..41eaa30d37 100644 --- a/map/drawer.cpp +++ b/map/drawer.cpp @@ -54,7 +54,7 @@ void di::DrawRule::SetID(size_t threadID, uint32_t id) const Drawer::Drawer(Params const & params) : m_visualScale(params.m_visualScale), m_threadID(params.m_threadID) { - m_pScreen = shared_ptr(new graphics::gl::Screen(params)); + m_pScreen = shared_ptr(new graphics::Screen(params)); m_pSkin = params.m_skin; m_pScreen->setSkin(m_pSkin); @@ -276,7 +276,7 @@ void Drawer::drawPathNumber(di::PathInfo const & path, di::DrawInfo const * pInf } } -shared_ptr Drawer::screen() const +shared_ptr Drawer::screen() const { return m_pScreen; } diff --git a/map/drawer.hpp b/map/drawer.hpp index 729e26aa94..1eedf1a024 100644 --- a/map/drawer.hpp +++ b/map/drawer.hpp @@ -73,7 +73,7 @@ class Drawer int m_level; size_t m_threadID; - shared_ptr m_pScreen; + shared_ptr m_pScreen; shared_ptr m_pSkin; static void ClearSkinPage(size_t threadID, uint8_t pipelineID); @@ -97,7 +97,8 @@ protected: typedef shared_ptr frame_buffer_t; public: - struct Params : graphics::gl::Screen::Params + + struct Params : graphics::Screen::Params { size_t m_threadID; double m_visualScale; @@ -116,7 +117,7 @@ public: void onSize(int w, int h); - shared_ptr screen() const; + shared_ptr screen() const; double VisualScale() const; void SetScale(int level); diff --git a/map/framework.cpp b/map/framework.cpp index 0e53258280..bd0dbce5fb 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -27,7 +27,7 @@ #include "../coding/internal/file_data.hpp" -#include "../graphics/rendercontext.hpp" +#include "../graphics/opengl/rendercontext.hpp" #include "../geometry/angles.hpp" #include "../geometry/distance_on_sphere.hpp" @@ -706,7 +706,7 @@ void Framework::DrawAdditionalInfo(shared_ptr const & e) ASSERT ( m_renderPolicy, () ); Drawer * pDrawer = e->drawer(); - graphics::gl::Screen * pScreen = pDrawer->screen().get(); + graphics::Screen * pScreen = pDrawer->screen().get(); pScreen->beginFrame(); diff --git a/map/location_state.cpp b/map/location_state.cpp index d5102d4572..4b976d2186 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -214,9 +214,9 @@ namespace location void State::cacheArrowBorder(EState state) { - graphics::gl::Screen * cacheScreen = m_controller->GetCacheScreen(); + graphics::Screen * cacheScreen = m_controller->GetCacheScreen(); - shared_ptr & dl = m_arrowBorderLists[state]; + shared_ptr & dl = m_arrowBorderLists[state]; dl.reset(); dl.reset(cacheScreen->createDisplayList()); @@ -250,9 +250,9 @@ namespace location void State::cacheArrowBody(EState state) { - graphics::gl::Screen * cacheScreen = m_controller->GetCacheScreen(); + graphics::Screen * cacheScreen = m_controller->GetCacheScreen(); - shared_ptr & dl = m_arrowBodyLists[state]; + shared_ptr & dl = m_arrowBodyLists[state]; dl.reset(); dl.reset(cacheScreen->createDisplayList()); @@ -290,7 +290,7 @@ namespace location void State::cacheLocationMark() { - graphics::gl::Screen * cacheScreen = m_controller->GetCacheScreen(); + graphics::Screen * cacheScreen = m_controller->GetCacheScreen(); m_locationMarkDL.reset(); m_locationMarkDL.reset(cacheScreen->createDisplayList()); @@ -366,7 +366,7 @@ namespace location } } - void State::draw(graphics::gl::OverlayRenderer * r, + void State::draw(graphics::OverlayRenderer * r, math::Matrix const & m) const { if (isVisible()) @@ -395,7 +395,7 @@ namespace location screenAngle + headingRad), pivot()); - map >::const_iterator it; + map >::const_iterator it; it = m_arrowBodyLists.find(state()); if (it != m_arrowBodyLists.end()) @@ -429,7 +429,7 @@ namespace location /// and then arrow border if (m_hasCompass) { - map >::const_iterator it; + map >::const_iterator it; it = m_arrowBorderLists.find(state()); if (it != m_arrowBorderLists.end()) diff --git a/map/location_state.hpp b/map/location_state.hpp index 538b25218d..c34df1177c 100644 --- a/map/location_state.hpp +++ b/map/location_state.hpp @@ -22,10 +22,7 @@ namespace anim namespace graphics { - namespace gl - { - class DisplayList; - } + class DisplayList; } namespace location @@ -92,10 +89,10 @@ namespace location double m_arrowBackHeight; double m_arrowScale; - map > m_arrowBodyLists; - map > m_arrowBorderLists; - scoped_ptr m_locationMarkDL; - scoped_ptr m_positionMarkDL; + map > m_arrowBodyLists; + map > m_arrowBorderLists; + scoped_ptr m_locationMarkDL; + scoped_ptr m_positionMarkDL; /// @} @@ -177,8 +174,7 @@ namespace location /// graphics::OverlayElement and gui::Element related methods // @{ vector const & boundRects() const; - void draw(graphics::gl::OverlayRenderer * r, math::Matrix const & m) const; - bool roughHitTest(m2::PointD const & pt) const; + void draw(graphics::OverlayRenderer * r, math::Matrix const & m) const; bool hitTest(m2::PointD const & pt) const; bool onTapEnded(m2::PointD const & p); /// @} diff --git a/map/qgl_render_context.hpp b/map/qgl_render_context.hpp index bd8c788e6d..0e091443a5 100644 --- a/map/qgl_render_context.hpp +++ b/map/qgl_render_context.hpp @@ -1,10 +1,9 @@ #pragma once -#include "../graphics/rendercontext.hpp" +#include "../graphics/opengl/rendercontext.hpp" #include "../std/shared_ptr.hpp" - class QWidget; class QGLContext; class QGLWidget; diff --git a/map/queued_renderer.cpp b/map/queued_renderer.cpp index 3931ec181e..9134347ba3 100644 --- a/map/queued_renderer.cpp +++ b/map/queued_renderer.cpp @@ -1,5 +1,6 @@ #include "queued_renderer.hpp" -#include "../graphics/internal/opengl.hpp" + +#include "../graphics/opengl/opengl.hpp" QueuedRenderer::QueuedRenderer(int pipelinesCount) { @@ -87,12 +88,12 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum) cmdProcessed = m_Pipelines[pipelineNum].m_FrameCommands.size(); - list::iterator it; + list::iterator it; bool res = !m_Pipelines[pipelineNum].m_FrameCommands.empty(); bool partialExecution = m_Pipelines[pipelineNum].m_CouldExecutePartially; - graphics::gl::Packet::EType bucketType = m_Pipelines[pipelineNum].m_Type; + graphics::Packet::EType bucketType = m_Pipelines[pipelineNum].m_Type; while (!m_Pipelines[pipelineNum].m_FrameCommands.empty()) { @@ -100,20 +101,20 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum) if (it->m_command) it->m_command->setIsDebugging(m_IsDebugging); - if (bucketType == graphics::gl::Packet::ECancelPoint) + if (bucketType == graphics::Packet::ECancelPoint) { if (it->m_command) it->m_command->cancel(); } else { - ASSERT(bucketType == graphics::gl::Packet::EFramePoint, ()); + ASSERT(bucketType == graphics::Packet::EFramePoint, ()); if (it->m_command) it->m_command->perform(); } - bool isCheckpoint = (it->m_type == graphics::gl::Packet::ECheckPoint); + bool isCheckpoint = (it->m_type == graphics::Packet::ECheckPoint); m_Pipelines[pipelineNum].m_FrameCommands.pop_front(); @@ -136,24 +137,24 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum) // graphics::gl::g_doLogOGLCalls = false; } -void QueuedRenderer::PacketsPipeline::FillFrameCommands(list & renderQueue, int maxFrames) +void QueuedRenderer::PacketsPipeline::FillFrameCommands(list & renderQueue, int maxFrames) { ASSERT(m_FrameCommands.empty(), ()); /// searching for "delimiter" markers - list::iterator first = renderQueue.begin(); - list::iterator last = renderQueue.begin(); + list::iterator first = renderQueue.begin(); + list::iterator last = renderQueue.begin(); /// checking whether there are a CancelPoint packet in the queue. /// In this case - fill m_FrameCommands till this packet - for (list::iterator it = renderQueue.begin(); + for (list::iterator it = renderQueue.begin(); it != renderQueue.end(); ++it) { - graphics::gl::Packet p = *it; - if (p.m_type == graphics::gl::Packet::ECancelPoint) + graphics::Packet p = *it; + if (p.m_type == graphics::Packet::ECancelPoint) { copy(first, ++it, back_inserter(m_FrameCommands)); renderQueue.erase(first, it); @@ -170,9 +171,9 @@ void QueuedRenderer::PacketsPipeline::FillFrameCommands(list &l, list &r) +void QueuedRenderer::CopyQueuedCommands(list &l, list &r) { swap(l, r); } @@ -202,20 +203,20 @@ void QueuedRenderer::CancelQueuedCommands(int pipelineNum) m_Pipelines[pipelineNum].m_Queue.cancel(); - list l; + list l; m_Pipelines[pipelineNum].m_Queue.processList(bind(&QueuedRenderer::CopyQueuedCommands, this, _1, ref(l))); - for (list::iterator it = l.begin(); it != l.end(); ++it) + for (list::iterator it = l.begin(); it != l.end(); ++it) { - graphics::gl::Packet p = *it; + graphics::Packet p = *it; if (p.m_command) p.m_command->cancel(); } } -graphics::gl::PacketsQueue * QueuedRenderer::GetPacketsQueue(int pipelineNum) +graphics::PacketsQueue * QueuedRenderer::GetPacketsQueue(int pipelineNum) { return &m_Pipelines[pipelineNum].m_Queue; } diff --git a/map/queued_renderer.hpp b/map/queued_renderer.hpp index 63fcda5cc8..0e7306a950 100644 --- a/map/queued_renderer.hpp +++ b/map/queued_renderer.hpp @@ -1,7 +1,7 @@ #pragma once #include "../base/threaded_list.hpp" -#include "../graphics/renderer.hpp" +#include "../graphics/opengl/renderer.hpp" /// Mixture-class for rendering policies, used on the /// devices that do not support OpenGL context sharing @@ -15,9 +15,9 @@ private: /// of "heavy" commands. struct PacketsPipeline { - graphics::gl::PacketsQueue m_Queue; //< all enqueued commands - list m_FrameCommands; //< list of commands to execute on current frame - graphics::gl::Packet::EType m_Type; //< type of the actions to perform with FrameCommands + graphics::PacketsQueue m_Queue; //< all enqueued commands + list m_FrameCommands; //< list of commands to execute on current frame + graphics::Packet::EType m_Type; //< type of the actions to perform with FrameCommands bool m_CouldExecutePartially; @@ -26,10 +26,10 @@ private: /// skipping empty frames. /// - if there are a CancelPoint in the QueueData than the packets are copied up to /// CancelPoint packet ignoring maxCheckPoints param - void FillFrameCommands(list & QueueData, int maxCheckPoints); + void FillFrameCommands(list & QueueData, int maxCheckPoints); }; - /// couldn't use vector here as PacketsPipeline holds non-copyable graphics::gl::PacketsQueue + /// couldn't use vector here as PacketsPipeline holds non-copyable graphics::PacketsQueue PacketsPipeline * m_Pipelines; int m_PipelinesCount; @@ -50,7 +50,7 @@ public: QueuedRenderer(int pipelinesCount); ~QueuedRenderer(); - void CopyQueuedCommands(list & l, list & r); + void CopyQueuedCommands(list & l, list & r); bool RenderQueuedCommands(int pipelineNum); void CancelQueuedCommands(int pipelineNum); @@ -64,5 +64,5 @@ public: bool NeedRedraw() const; void SetSinglePipelineProcessing(bool flag); - graphics::gl::PacketsQueue * GetPacketsQueue(int pipelineNum); + graphics::PacketsQueue * GetPacketsQueue(int pipelineNum); }; diff --git a/map/render_policy.cpp b/map/render_policy.cpp index 9105860d30..467662d556 100644 --- a/map/render_policy.cpp +++ b/map/render_policy.cpp @@ -10,7 +10,7 @@ #include "../anim/controller.hpp" #include "../anim/task.hpp" -#include "../graphics/internal/opengl.hpp" +#include "../graphics/opengl/opengl.hpp" #include "../graphics/skin.hpp" #include "../indexer/scales.hpp" @@ -46,7 +46,7 @@ RenderPolicy::RenderPolicy(Params const & p, void RenderPolicy::InitCacheScreen() { - graphics::gl::Screen::Params cp; + graphics::Screen::Params cp; cp.m_doUnbindRT = false; cp.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID(); @@ -54,7 +54,7 @@ void RenderPolicy::InitCacheScreen() cp.m_isSynchronized = false; cp.m_resourceManager = m_resourceManager; - m_cacheScreen = make_shared_ptr(new graphics::gl::Screen(cp)); + m_cacheScreen = make_shared_ptr(new graphics::Screen(cp)); m_cacheScreen->setSkin(m_skin); } @@ -257,7 +257,7 @@ graphics::Color const RenderPolicy::GetBgColor() const return m_bgColor; } -shared_ptr const & RenderPolicy::GetCacheScreen() const +shared_ptr const & RenderPolicy::GetCacheScreen() const { return m_cacheScreen; } diff --git a/map/render_policy.hpp b/map/render_policy.hpp index e5360e3096..34eed05765 100644 --- a/map/render_policy.hpp +++ b/map/render_policy.hpp @@ -57,7 +57,7 @@ protected: graphics::Color m_bgColor; shared_ptr m_resourceManager; shared_ptr m_skin; - shared_ptr m_cacheScreen; + shared_ptr m_cacheScreen; shared_ptr m_primaryRC; shared_ptr m_windowHandle; shared_ptr m_drawer; @@ -155,7 +155,7 @@ public: virtual shared_ptr const GetOverlay() const; graphics::Color const GetBgColor() const; - shared_ptr const & GetCacheScreen() const; + shared_ptr const & GetCacheScreen() const; virtual void SetSkin(shared_ptr const & skin); shared_ptr const & GetSkin() const; diff --git a/map/ruler.cpp b/map/ruler.cpp index e545cd607a..be0a1290f1 100644 --- a/map/ruler.cpp +++ b/map/ruler.cpp @@ -268,7 +268,7 @@ vector const & Ruler::boundRects() const return m_boundRects; } -void Ruler::draw(graphics::gl::OverlayRenderer * s, math::Matrix const & m) const +void Ruler::draw(graphics::OverlayRenderer * s, math::Matrix const & m) const { if (m_isInitialized) { diff --git a/map/ruler.hpp b/map/ruler.hpp index e9d696a572..5b7983a9a8 100644 --- a/map/ruler.hpp +++ b/map/ruler.hpp @@ -78,7 +78,7 @@ public: vector const & boundRects() const; - void draw(graphics::gl::OverlayRenderer * r, math::Matrix const & m) const; + void draw(graphics::OverlayRenderer * r, math::Matrix const & m) const; int visualRank() const; graphics::OverlayElement * clone(math::Matrix const & m) const; diff --git a/map/screen_coverage.cpp b/map/screen_coverage.cpp index 1049f5d881..f12ea2b379 100644 --- a/map/screen_coverage.cpp +++ b/map/screen_coverage.cpp @@ -11,7 +11,7 @@ #include "../graphics/screen.hpp" #include "../graphics/display_list.hpp" #include "../graphics/skin.hpp" -#include "../graphics/base_texture.hpp" +#include "../graphics/opengl/base_texture.hpp" #include "screen_coverage.hpp" #include "tile_renderer.hpp" @@ -30,7 +30,7 @@ ScreenCoverage::ScreenCoverage() ScreenCoverage::ScreenCoverage(TileRenderer * tileRenderer, CoverageGenerator * coverageGenerator, - shared_ptr const & cacheScreen) + shared_ptr const & cacheScreen) : m_tileRenderer(tileRenderer), m_coverageGenerator(coverageGenerator), m_overlay(new graphics::Overlay()), @@ -178,7 +178,7 @@ bool ScreenCoverage::Cache(core::CommandsQueue::Environment const & env) m_cacheScreen->beginFrame(); m_cacheScreen->setDisplayList(m_primaryDL.get()); - vector infos; + vector infos; for (TTileSet::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { @@ -187,7 +187,7 @@ bool ScreenCoverage::Cache(core::CommandsQueue::Environment const & env) size_t tileWidth = tile->m_renderTarget->width(); size_t tileHeight = tile->m_renderTarget->height(); - graphics::gl::BlitInfo bi; + graphics::BlitInfo bi; bi.m_matrix = tile->m_tileScreen.PtoGMatrix() * m_screen.GtoPMatrix(); bi.m_srcRect = m2::RectI(0, 0, tileWidth - 2, tileHeight - 2); @@ -412,7 +412,7 @@ ScreenCoverage::~ScreenCoverage() Clear(); } -void ScreenCoverage::Draw(graphics::gl::Screen * s, ScreenBase const & screen) +void ScreenCoverage::Draw(graphics::Screen * s, ScreenBase const & screen) { math::Matrix m = m_screen.PtoGMatrix() * screen.GtoPMatrix(); diff --git a/map/screen_coverage.hpp b/map/screen_coverage.hpp index cf5ed32f15..8c058ce678 100644 --- a/map/screen_coverage.hpp +++ b/map/screen_coverage.hpp @@ -68,12 +68,12 @@ private: /// quick check. int m_leafTilesToRender; /// Screen, which is used for caching of this ScreenCoverage into DisplayList - shared_ptr m_cacheScreen; + shared_ptr m_cacheScreen; /// DisplayList which holds cached ScreenCoverage - shared_ptr m_primaryDL; + shared_ptr m_primaryDL; /// DisplayList to cache all straight texts. /// They are drawn with different shader. - shared_ptr m_sharpTextDL; + shared_ptr m_sharpTextDL; /// Direct copying is prohibited. ScreenCoverage(ScreenCoverage const & src); @@ -89,7 +89,7 @@ public: /// Constructor ScreenCoverage(TileRenderer * tileRenderer, CoverageGenerator * coverageGenerator, - shared_ptr const & cacheScreen); + shared_ptr const & cacheScreen); /// Destructor ~ScreenCoverage(); /// Copy all needed information into specified ScreenCoverage @@ -124,7 +124,7 @@ public: /// recalculate screen coverage, using as much info from prev coverage as possible void SetScreen(ScreenBase const & screen); /// draw screen coverage - void Draw(graphics::gl::Screen * s, ScreenBase const & currentScreen); + void Draw(graphics::Screen * s, ScreenBase const & currentScreen); /// get draw scale for the tiles in the current coverage /// Not all tiles in coverage could correspond to this value, /// as there could be tiles from lower and higher level in the diff --git a/map/simple_render_policy.cpp b/map/simple_render_policy.cpp index 92c29e880b..29a0644909 100644 --- a/map/simple_render_policy.cpp +++ b/map/simple_render_policy.cpp @@ -2,8 +2,9 @@ #include "events.hpp" #include "drawer.hpp" #include "window_handle.hpp" + #include "../graphics/overlay.hpp" -#include "../graphics/internal/opengl.hpp" +#include "../graphics/opengl/opengl.hpp" #include "../graphics/skin.hpp" #include "../indexer/scales.hpp" diff --git a/map/test_render_policy.cpp b/map/test_render_policy.cpp index 2e5435db5d..1cdfd9d731 100644 --- a/map/test_render_policy.cpp +++ b/map/test_render_policy.cpp @@ -3,9 +3,9 @@ #include "drawer.hpp" #include "window_handle.hpp" -#include "../graphics/base_texture.hpp" -#include "../graphics/internal/opengl.hpp" -#include "../graphics/utils.hpp" +#include "../graphics/opengl/base_texture.hpp" +#include "../graphics/opengl/opengl.hpp" +#include "../graphics/opengl/utils.hpp" #include "../graphics/skin.hpp" #include "../geometry/screenbase.hpp" @@ -171,10 +171,10 @@ void TestRenderPolicy::DrawFrame(shared_ptr const & e, OGLCHECK(glClear(GL_COLOR_BUFFER_BIT));*/ - shared_ptr immDrawTexturedRect; + shared_ptr immDrawTexturedRect; immDrawTexturedRect.reset( - new Blitter::IMMDrawTexturedRect(m2::RectF(0, 0, m_backBuffer->width(), m_backBuffer->height()), + new GeometryRenderer::IMMDrawTexturedRect(m2::RectF(0, 0, m_backBuffer->width(), m_backBuffer->height()), m2::RectF(0, 0, 1, 1), m_backBuffer, m_resourceManager)); @@ -204,7 +204,7 @@ void TestRenderPolicy::DrawFrame(shared_ptr const & e, OGLCHECK(glClear(GL_COLOR_BUFFER_BIT));*/ immDrawTexturedRect.reset( - new Blitter::IMMDrawTexturedRect(m2::RectF(0, 0, m_backBuffer->width(), m_backBuffer->height()), + new GeometryRenderer::IMMDrawTexturedRect(m2::RectF(0, 0, m_backBuffer->width(), m_backBuffer->height()), m2::RectF(0, 0, 1, 1), m_backBuffer, m_resourceManager)); @@ -222,7 +222,7 @@ void TestRenderPolicy::DrawFrame(shared_ptr const & e, OGLCHECK(glFramebufferTexture2DFn(GL_FRAMEBUFFER_MWM, GL_COLOR_ATTACHMENT0_MWM, GL_TEXTURE_2D, m_actualTarget->id(), 0)); immDrawTexturedRect.reset( - new Blitter::IMMDrawTexturedRect(m2::RectF(0, 0, m_backBuffer->width(), m_backBuffer->height()), + new GeometryRenderer::IMMDrawTexturedRect(m2::RectF(0, 0, m_backBuffer->width(), m_backBuffer->height()), m2::RectF(0, 0, 1, 1), m_backBuffer, m_resourceManager)); diff --git a/map/test_render_policy.hpp b/map/test_render_policy.hpp index 77e963bcbd..7fe445a2f5 100644 --- a/map/test_render_policy.hpp +++ b/map/test_render_policy.hpp @@ -13,8 +13,8 @@ private: shared_ptr m_actualTarget; shared_ptr m_backBuffer; - shared_ptr m_auxScreen; - shared_ptr m_drawerScreen; + shared_ptr m_auxScreen; + shared_ptr m_drawerScreen; bool m_hasScreen; ScreenBase m_screen; diff --git a/map/tile.cpp b/map/tile.cpp index 961d0a1d35..9a08bcd5d6 100644 --- a/map/tile.cpp +++ b/map/tile.cpp @@ -1,8 +1,6 @@ -#include "../base/SRC_FIRST.hpp" - #include "tile.hpp" -#include "../graphics/base_texture.hpp" +#include "../graphics/opengl/base_texture.hpp" Tile::Tile() {} diff --git a/map/tile_renderer.cpp b/map/tile_renderer.cpp index 798c24b9a0..8367e6c118 100644 --- a/map/tile_renderer.cpp +++ b/map/tile_renderer.cpp @@ -3,9 +3,10 @@ #include "tile_renderer.hpp" #include "window_handle.hpp" -#include "../graphics/internal/opengl.hpp" -#include "../graphics/rendercontext.hpp" -#include "../graphics/base_texture.hpp" +#include "../graphics/opengl/opengl.hpp" +#include "../graphics/opengl/rendercontext.hpp" +#include "../graphics/opengl/base_texture.hpp" + #include "../graphics/packets_queue.hpp" #include "../graphics/skin.hpp" @@ -26,7 +27,7 @@ TileRenderer::TileRenderer( shared_ptr const & primaryRC, shared_ptr const & rm, double visualScale, - graphics::gl::PacketsQueue ** packetsQueues + graphics::PacketsQueue ** packetsQueues ) : m_queue(executorsCount), m_tileSize(tileSize), m_renderFn(renderFn), @@ -115,7 +116,7 @@ void TileRenderer::FinalizeThreadGL(core::CommandsQueue::Environment const & env threadData.m_renderContext->endThreadDrawing(); } -void TileRenderer::ReadPixels(graphics::gl::PacketsQueue * glQueue, core::CommandsQueue::Environment const & env) +void TileRenderer::ReadPixels(graphics::PacketsQueue * glQueue, core::CommandsQueue::Environment const & env) { ThreadData & threadData = m_threadData[env.threadNum()]; @@ -123,7 +124,7 @@ void TileRenderer::ReadPixels(graphics::gl::PacketsQueue * glQueue, core::Comman if (glQueue) { - glQueue->processFn(bind(&TileRenderer::ReadPixels, this, (graphics::gl::PacketsQueue*)0, ref(env)), true); + glQueue->processFn(bind(&TileRenderer::ReadPixels, this, (graphics::PacketsQueue*)0, ref(env)), true); return; } @@ -154,7 +155,7 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env, ThreadData & threadData = m_threadData[env.threadNum()]; - graphics::gl::PacketsQueue * glQueue = threadData.m_drawerParams.m_renderQueue; + graphics::PacketsQueue * glQueue = threadData.m_drawerParams.m_renderQueue; Drawer * drawer = threadData.m_drawer; diff --git a/map/tile_renderer.hpp b/map/tile_renderer.hpp index 7664176efc..96e6d97b3f 100644 --- a/map/tile_renderer.hpp +++ b/map/tile_renderer.hpp @@ -18,10 +18,11 @@ namespace graphics { class ResourceManager; + class PacketsQueue; + namespace gl { class RenderContext; - class PacketsQueue; } } @@ -77,7 +78,7 @@ protected: Tiler::RectInfo const & rectInfo, int sequenceID); - void ReadPixels(graphics::gl::PacketsQueue * glQueue, core::CommandsQueue::Environment const & env); + void ReadPixels(graphics::PacketsQueue * glQueue, core::CommandsQueue::Environment const & env); public: @@ -90,7 +91,7 @@ public: shared_ptr const & primaryRC, shared_ptr const & rm, double visualScale, - graphics::gl::PacketsQueue ** packetsQueue); + graphics::PacketsQueue ** packetsQueue); /// destructor. virtual ~TileRenderer(); /// add command to the commands queue. diff --git a/map/tiling_render_policy_mt.cpp b/map/tiling_render_policy_mt.cpp index a8273f1f5f..ae78ea5688 100644 --- a/map/tiling_render_policy_mt.cpp +++ b/map/tiling_render_policy_mt.cpp @@ -2,7 +2,6 @@ #include "../platform/platform.hpp" -#include "../graphics/internal/opengl.hpp" #include "../graphics/skin.hpp" #include "window_handle.hpp" diff --git a/map/tiling_render_policy_st.cpp b/map/tiling_render_policy_st.cpp index db746b94e0..bf8a58babf 100644 --- a/map/tiling_render_policy_st.cpp +++ b/map/tiling_render_policy_st.cpp @@ -2,7 +2,7 @@ #include "../platform/platform.hpp" -#include "../graphics/internal/opengl.hpp" +#include "../graphics/opengl/opengl.hpp" #include "../graphics/skin.hpp" #include "window_handle.hpp" @@ -216,7 +216,7 @@ void TilingRenderPolicyST::SetRenderFn(TRenderFn renderFn) int cpuCores = GetPlatform().CpuCores(); string skinName = SkinName(); - graphics::gl::PacketsQueue ** queues = new graphics::gl::PacketsQueue*[cpuCores]; + graphics::PacketsQueue ** queues = new graphics::PacketsQueue*[cpuCores]; for (unsigned i = 0; i < cpuCores; ++i) queues[i] = m_QueuedRenderer->GetPacketsQueue(i); diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 3da8b3b89a..e3bc358084 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -6,7 +6,7 @@ #include "../gui/controller.hpp" -#include "../graphics/internal/opengl.hpp" +#include "../graphics/opengl/opengl.hpp" #include "../platform/settings.hpp" #include "../platform/platform.hpp" diff --git a/qt_tstfrm/macros.hpp b/qt_tstfrm/macros.hpp index fc249faf64..5e8f4696ea 100644 --- a/qt_tstfrm/macros.hpp +++ b/qt_tstfrm/macros.hpp @@ -109,7 +109,7 @@ class GLTestWidget : public tst::GLDrawWidget public: - virtual void DoDraw(shared_ptr p) + virtual void DoDraw(shared_ptr p) { test.DoDraw(p); } diff --git a/qt_tstfrm/tstwidgets.cpp b/qt_tstfrm/tstwidgets.cpp index 7d6ab3a293..ea87ed7bb8 100644 --- a/qt_tstfrm/tstwidgets.cpp +++ b/qt_tstfrm/tstwidgets.cpp @@ -3,17 +3,18 @@ #include "screen_qt.hpp" #include "../graphics/screen.hpp" -#include "../graphics/utils.hpp" #include "../graphics/skin.hpp" -#include "../graphics/framebuffer.hpp" -#include "../graphics/renderbuffer.hpp" #include "../graphics/resource_manager.hpp" -#include "../graphics/internal/opengl.hpp" + +#include "../graphics/opengl/utils.hpp" +#include "../graphics/opengl/framebuffer.hpp" +#include "../graphics/opengl/renderbuffer.hpp" +#include "../graphics/opengl/opengl.hpp" #include "../platform/platform.hpp" -template class qt::GLDrawWidgetT; +template class qt::GLDrawWidgetT; namespace tst { @@ -141,7 +142,7 @@ void GLDrawWidget::initializeGL() params.m_frameBuffer = m_frameBuffer; params.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID(); - m_p = make_shared_ptr(new graphics::gl::Screen(params)); + m_p = make_shared_ptr(new graphics::Screen(params)); m_primaryFrameBuffer = make_shared_ptr(new graphics::gl::FrameBuffer(true)); @@ -149,7 +150,7 @@ void GLDrawWidget::initializeGL() m_p->setSkin(m_skin); params.m_frameBuffer = m_primaryFrameBuffer; - m_primaryScreen = make_shared_ptr(new graphics::gl::Screen(params)); + m_primaryScreen = make_shared_ptr(new graphics::Screen(params)); } void GLDrawWidget::resizeGL(int w, int h) diff --git a/qt_tstfrm/tstwidgets.hpp b/qt_tstfrm/tstwidgets.hpp index 93a4f62b33..a55e0680e3 100644 --- a/qt_tstfrm/tstwidgets.hpp +++ b/qt_tstfrm/tstwidgets.hpp @@ -2,9 +2,11 @@ #include "widgets.hpp" -#include "../graphics/texture.hpp" +#include "../graphics/opengl/texture.hpp" +#include "../graphics/opengl/renderbuffer.hpp" + #include "../graphics/resource_manager.hpp" -#include "../graphics/renderbuffer.hpp" + #include "../map/drawer.hpp" #include "../map/qgl_render_context.hpp" @@ -24,10 +26,10 @@ namespace qt { class Screen; } namespace tst { - class GLDrawWidget : public qt::GLDrawWidgetT + class GLDrawWidget : public qt::GLDrawWidgetT { protected: - typedef qt::GLDrawWidgetT base_type; + typedef qt::GLDrawWidgetT base_type; shared_ptr m_resourceManager; @@ -37,7 +39,7 @@ namespace tst shared_ptr m_depthBuffer; shared_ptr m_skin; shared_ptr m_primaryContext; - shared_ptr m_primaryScreen; + shared_ptr m_primaryScreen; public: