forked from organicmaps/organicmaps
add map_server project. Simple png generation
This commit is contained in:
parent
4de329aa5b
commit
68d75aeeb4
7 changed files with 238 additions and 5 deletions
|
@ -183,6 +183,9 @@ namespace gui
|
|||
|
||||
void Controller::DrawFrame(graphics::Screen * screen)
|
||||
{
|
||||
if (m_CacheScreen == NULL)
|
||||
return;
|
||||
|
||||
screen->beginFrame();
|
||||
|
||||
math::Matrix<double, 3, 3> m = math::Identity<double, 3>();
|
||||
|
|
|
@ -22,6 +22,8 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
|
|||
graphics::ResourceManager::TexturePoolParams tpp;
|
||||
graphics::ResourceManager::StoragePoolParams spp;
|
||||
|
||||
double k = VisualScale();
|
||||
|
||||
spp = graphics::ResourceManager::StoragePoolParams(50000 * sizeof(graphics::gl::Vertex),
|
||||
sizeof(graphics::gl::Vertex),
|
||||
10000 * sizeof(unsigned short),
|
||||
|
@ -52,9 +54,19 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
|
|||
|
||||
rmp.m_storageParams[spp.m_storageType] = spp;
|
||||
|
||||
spp = graphics::ResourceManager::StoragePoolParams(100 * sizeof(graphics::gl::Vertex),
|
||||
sizeof(graphics::gl::Vertex),
|
||||
200 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
1,
|
||||
graphics::ETinyStorage,
|
||||
true);
|
||||
|
||||
tpp = graphics::ResourceManager::TexturePoolParams(512,
|
||||
256,
|
||||
rmp.m_storageParams[spp.m_storageType] = spp;
|
||||
|
||||
|
||||
tpp = graphics::ResourceManager::TexturePoolParams(512 * k,
|
||||
256 * k,
|
||||
10,
|
||||
rmp.m_texFormat,
|
||||
graphics::ELargeTexture,
|
||||
|
@ -62,8 +74,8 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
|
|||
|
||||
rmp.m_textureParams[tpp.m_textureType] = tpp;
|
||||
|
||||
tpp = graphics::ResourceManager::TexturePoolParams(512,
|
||||
256,
|
||||
tpp = graphics::ResourceManager::TexturePoolParams(512 * k,
|
||||
256 * k,
|
||||
5,
|
||||
rmp.m_texFormat,
|
||||
graphics::EMediumTexture,
|
||||
|
@ -71,6 +83,15 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
|
|||
|
||||
rmp.m_textureParams[tpp.m_textureType] = tpp;
|
||||
|
||||
tpp = graphics::ResourceManager::TexturePoolParams(128 * k,
|
||||
128 * k,
|
||||
4,
|
||||
rmp.m_texFormat,
|
||||
graphics::ESmallTexture,
|
||||
false);
|
||||
|
||||
rmp.m_textureParams[tpp.m_textureType] = tpp;
|
||||
|
||||
rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
|
||||
"fonts_whitelist.txt",
|
||||
"fonts_blacklist.txt",
|
||||
|
@ -98,9 +119,12 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
|
|||
dp.m_threadSlot = m_resourceManager->guiThreadSlot();
|
||||
dp.m_visualScale = VisualScale();
|
||||
dp.m_isSynchronized = true;
|
||||
dp.m_renderContext = m_primaryRC;
|
||||
|
||||
m_drawer.reset(new Drawer(dp));
|
||||
|
||||
InitCacheScreen();
|
||||
|
||||
m_windowHandle.reset(new WindowHandle());
|
||||
|
||||
m_windowHandle->setUpdatesEnabled(false);
|
||||
|
@ -121,6 +145,7 @@ void SimpleRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
|
|||
glbRect);
|
||||
|
||||
shared_ptr<graphics::Overlay> overlay(new graphics::Overlay());
|
||||
overlay->setCouldOverlap(false);
|
||||
|
||||
Drawer * pDrawer = e->drawer();
|
||||
graphics::Screen * pScreen = pDrawer->screen();
|
||||
|
|
138
map_server/main.cpp
Normal file
138
map_server/main.cpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
#include "render_context.hpp"
|
||||
#include "../map_server_utils/viewport.hpp"
|
||||
#include "../map_server_utils/request.hpp"
|
||||
#include "../map_server_utils/response.hpp"
|
||||
|
||||
#include "../graphics/resource_manager.hpp"
|
||||
|
||||
#include "../map/render_policy.hpp"
|
||||
#include "../map/simple_render_policy.hpp"
|
||||
#include "../map/framework.hpp"
|
||||
|
||||
#include "../gui/controller.hpp"
|
||||
|
||||
#include "../platform/platform.hpp"
|
||||
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
|
||||
#include <QGLPixelBuffer>
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
namespace
|
||||
{
|
||||
void empty()
|
||||
{}
|
||||
|
||||
class EmptyVideoTimer : public VideoTimer
|
||||
{
|
||||
public:
|
||||
EmptyVideoTimer()
|
||||
: VideoTimer(bind(&empty))
|
||||
{}
|
||||
|
||||
~EmptyVideoTimer()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
void start()
|
||||
{
|
||||
if (m_state == EStopped)
|
||||
m_state = ERunning;
|
||||
}
|
||||
|
||||
void resume()
|
||||
{
|
||||
if (m_state == EPaused)
|
||||
{
|
||||
m_state = EStopped;
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
void pause()
|
||||
{
|
||||
stop();
|
||||
m_state = EPaused;
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
if (m_state == ERunning)
|
||||
m_state = EStopped;
|
||||
}
|
||||
|
||||
void perform()
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
srv::Request request = srv::GetRequest(cin);
|
||||
srv::Viewport v = request.GetViewport();
|
||||
|
||||
QGLPixelBuffer * pb = new QGLPixelBuffer(QSize(v.GetWidth(), v.GetHeight()));
|
||||
pb->makeCurrent();
|
||||
|
||||
Framework framework;
|
||||
|
||||
shared_ptr<srv::RenderContext> primaryRC(new srv::RenderContext());
|
||||
|
||||
graphics::ResourceManager::Params rmParams;
|
||||
rmParams.m_rtFormat = graphics::Data8Bpp;
|
||||
rmParams.m_texFormat = graphics::Data8Bpp;
|
||||
rmParams.m_texRtFormat = graphics::Data4Bpp;
|
||||
rmParams.m_videoMemoryLimit = GetPlatform().VideoMemoryLimit();
|
||||
|
||||
RenderPolicy::Params rpParams;
|
||||
|
||||
shared_ptr<VideoTimer> timer(new EmptyVideoTimer());
|
||||
|
||||
rpParams.m_videoTimer = timer.get();
|
||||
rpParams.m_useDefaultFB = true;
|
||||
rpParams.m_rmParams = rmParams;
|
||||
rpParams.m_primaryRC = primaryRC;
|
||||
rpParams.m_density = request.GetDensity();
|
||||
rpParams.m_skinName = "basic.skn";
|
||||
rpParams.m_screenWidth = v.GetWidth();
|
||||
rpParams.m_screenHeight = v.GetHeight();
|
||||
|
||||
try
|
||||
{
|
||||
framework.SetRenderPolicy(new SimpleRenderPolicy(rpParams));
|
||||
framework.GetGuiController()->ResetRenderParams();
|
||||
}
|
||||
catch (graphics::gl::platform_unsupported const & e)
|
||||
{
|
||||
LOG(LERROR, ("OpenGL platform is unsupported, reason: ", e.what()));
|
||||
}
|
||||
|
||||
framework.OnSize(v.GetWidth(), v.GetHeight());
|
||||
framework.GetNavigator().SetFromRect(v.GetAnyRect());
|
||||
|
||||
shared_ptr<PaintEvent> pe(new PaintEvent(framework.GetRenderPolicy()->GetDrawer().get()));
|
||||
|
||||
framework.BeginPaint(pe);
|
||||
framework.DoPaint(pe);
|
||||
framework.EndPaint(pe);
|
||||
|
||||
pb->doneCurrent();
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer b(&ba);
|
||||
b.open(QIODevice::WriteOnly);
|
||||
|
||||
pb->toImage().save(&b, "PNG");
|
||||
|
||||
pb->makeCurrent();
|
||||
framework.SetRenderPolicy(0);
|
||||
pb->doneCurrent();
|
||||
|
||||
srv::Response * response = request.CreateResponse(ba);
|
||||
response->DoResponse();
|
||||
delete response;
|
||||
}
|
30
map_server/map_server.pro
Normal file
30
map_server/map_server.pro
Normal file
|
@ -0,0 +1,30 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2013-07-13T08:23:48
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui opengl
|
||||
TARGET = map_server
|
||||
CONFIG += console warn_on
|
||||
CONFIG -= app_bundle
|
||||
TEMPLATE = app
|
||||
|
||||
DEPENDENCIES = map gui search storage indexer graphics platform anim geometry coding base \
|
||||
map_server_utils bzip2 freetype expat fribidi tomcrypt jansson protobuf
|
||||
|
||||
ROOT_DIR = ..
|
||||
include($$ROOT_DIR/common.pri)
|
||||
|
||||
INCLUDEPATH += $$ROOT_DIR/3party/jansson/src
|
||||
|
||||
macx* {
|
||||
LIBS *= "-framework Foundation" "-framework CoreWLAN" \
|
||||
"-framework QuartzCore" "-framework IOKit"
|
||||
}
|
||||
|
||||
SOURCES += main.cpp \
|
||||
render_context.cpp
|
||||
|
||||
HEADERS += \
|
||||
render_context.hpp
|
17
map_server/render_context.cpp
Normal file
17
map_server/render_context.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "render_context.hpp"
|
||||
|
||||
namespace srv
|
||||
{
|
||||
RenderContext::RenderContext()
|
||||
{
|
||||
}
|
||||
|
||||
void RenderContext::makeCurrent()
|
||||
{
|
||||
}
|
||||
|
||||
RenderContext * RenderContext::createShared()
|
||||
{
|
||||
return new RenderContext();
|
||||
}
|
||||
}
|
15
map_server/render_context.hpp
Normal file
15
map_server/render_context.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include "../graphics/opengl/gl_render_context.hpp"
|
||||
|
||||
namespace srv
|
||||
{
|
||||
class RenderContext : public graphics::gl::RenderContext
|
||||
{
|
||||
public:
|
||||
RenderContext();
|
||||
|
||||
virtual void makeCurrent();
|
||||
virtual RenderContext * createShared();
|
||||
};
|
||||
}
|
7
omim.pro
7
omim.pro
|
@ -35,7 +35,8 @@ SUBDIRS = 3party \
|
|||
indexer/indexer_tests \
|
||||
graphics/graphics_tests \
|
||||
gui/gui_tests \
|
||||
qt
|
||||
qt \
|
||||
map_server
|
||||
} else {
|
||||
# libraries which are used on mobile devices
|
||||
SUBDIRS = 3party \
|
||||
|
@ -51,3 +52,7 @@ SUBDIRS = 3party \
|
|||
search \
|
||||
map \
|
||||
}
|
||||
|
||||
SUBDIRS += \
|
||||
map_server/map_server_tests \
|
||||
map_server_utils
|
||||
|
|
Loading…
Add table
Reference in a new issue