viewer
* add export to cairo svg * fix gpu/gl
This commit is contained in:
parent
9089671ddd
commit
88e29148ea
5 changed files with 62 additions and 27 deletions
|
@ -263,10 +263,9 @@ void MainWindow::export_as()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef SKIA_RENDERER
|
||||
void MainWindow::export_as_skia_pdf()
|
||||
{
|
||||
std::cerr << "Skia PDF" << std::endl;
|
||||
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
QByteArray fileFormat("pdf");
|
||||
QString initialPath = QDir::currentPath() + "/map-skia." + fileFormat;
|
||||
|
@ -283,11 +282,29 @@ void MainWindow::export_as_skia_pdf()
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CAIRO
|
||||
void MainWindow::export_as_cairo_pdf()
|
||||
{
|
||||
std::cerr << "Cairo PDF" << std::endl;
|
||||
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
QByteArray fileFormat("pdf");
|
||||
QString initialPath = QDir::currentPath() + "/map-cairo." + fileFormat;
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export As Cairo PDF"),
|
||||
initialPath,
|
||||
tr("%1 Files (*.%2);;All Files (*)")
|
||||
.arg(QString(fileFormat.toUpper()))
|
||||
.arg(QString(fileFormat)));
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
std::cerr << "Cairo PDF" << std::endl;
|
||||
mapWidget_->export_cairo_pdf(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::print()
|
||||
{
|
||||
|
@ -360,11 +377,15 @@ void MainWindow::createActions()
|
|||
connect(action, SIGNAL(triggered()), this, SLOT(export_as()));
|
||||
exportAsActs.append(action);
|
||||
}
|
||||
|
||||
#ifdef SKIA_RENDERER
|
||||
exportSkiaPdf = new QAction("Skia",this);
|
||||
connect(exportSkiaPdf, SIGNAL(triggered()), this, SLOT(export_as_skia_pdf()));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CAIRO
|
||||
exportCairoPdf = new QAction("Cairo",this);
|
||||
connect(exportCairoPdf, SIGNAL(triggered()), this, SLOT(export_as_cairo_pdf()));
|
||||
#endif
|
||||
|
||||
printAct = new QAction(QIcon(":/images/print.png"),tr("&Print ..."),this);
|
||||
printAct->setShortcut(tr("Ctrl+E"));
|
||||
|
@ -425,9 +446,7 @@ void MainWindow::createToolBars()
|
|||
#endif
|
||||
#ifdef SKIA_RENDERER
|
||||
renderer_selector_->addItem("Skia");
|
||||
//#ifdef SK_SUPPORT_GPU
|
||||
renderer_selector_->addItem("Skia-Gpu");
|
||||
//#endif
|
||||
#endif
|
||||
renderer_selector_->addItem("Grid");
|
||||
fileToolBar->addWidget(renderer_selector_);
|
||||
|
|
|
@ -41,7 +41,7 @@ class QDoubleSpinBox;
|
|||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
MainWindow();
|
||||
virtual ~MainWindow();
|
||||
void set_default_extent(double x0,double y0,double x1, double y1);
|
||||
|
|
|
@ -53,8 +53,8 @@
|
|||
#if SK_SUPPORT_GPU
|
||||
#include <gl/GrGLFunctions.h>
|
||||
#include <GrContextFactory.h>
|
||||
//#include <gl/GrGLDefines.h>
|
||||
//#include <gl/GrGLUtil.h>
|
||||
#include <gl/GrGLDefines.h>
|
||||
#include <gl/GrGLUtil.h>
|
||||
#include <gl/GrGLExtensions.h>
|
||||
GrContextFactory gGrContextFactory;
|
||||
#endif
|
||||
|
@ -554,7 +554,7 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef SKIA_RENDERER
|
||||
void render_skia(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||
{
|
||||
boost::timer::auto_cpu_timer t;
|
||||
|
@ -590,8 +590,7 @@ void render_skia(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void render_skia_gpu(GrGLInterface const * cur_interface, mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||
void render_skia_gpu(GrGLInterface const * cur_interface, mapnik::Map const& map, double scaling_factor)
|
||||
{
|
||||
std::cerr << "SKIA GPU start " << cur_interface << std::endl ;
|
||||
boost::timer::auto_cpu_timer t;
|
||||
|
@ -603,15 +602,15 @@ void render_skia_gpu(GrGLInterface const * cur_interface, mapnik::Map const& map
|
|||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fWidth = width;
|
||||
desc.fHeight = height;
|
||||
GrGLExtensions extensions;
|
||||
GrGLBinding binding;
|
||||
GrGLInterface interface;
|
||||
interface.validate(binding);
|
||||
extensions.init(binding, cur_interface);
|
||||
//GR_GL_GetIntegerv(cur_interface, GR_GL_SAMPLES, &desc.fSampleCnt);
|
||||
//GR_GL_GetIntegerv(cur_interface, GR_GL_STENCIL_BITS, &desc.fStencilBits);
|
||||
//GrGLExtensions extensions;
|
||||
//GrGLBinding binding;
|
||||
//GrGLInterface interface;
|
||||
//interface.validate(binding);
|
||||
//extensions.init(binding, cur_interface);
|
||||
GR_GL_GetIntegerv(cur_interface, GR_GL_SAMPLES, &desc.fSampleCnt);
|
||||
GR_GL_GetIntegerv(cur_interface, GR_GL_STENCIL_BITS, &desc.fStencilBits);
|
||||
GrGLint buffer;
|
||||
//GR_GL_GetIntegerv(cur_interface, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
||||
GR_GL_GetIntegerv(cur_interface, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
||||
desc.fRenderTargetHandle = buffer;
|
||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
|
||||
|
@ -619,7 +618,6 @@ void render_skia_gpu(GrGLInterface const * cur_interface, mapnik::Map const& map
|
|||
SkGpuDevice device(context, curRenderTarget);
|
||||
SkCanvas canvas(&device);
|
||||
|
||||
|
||||
mapnik::skia_renderer ren(map,canvas,scaling_factor);
|
||||
ren.apply();
|
||||
context->resetContext();
|
||||
|
@ -627,7 +625,6 @@ void render_skia_gpu(GrGLInterface const * cur_interface, mapnik::Map const& map
|
|||
std::cerr << "SKIA GPU Done" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void MapWidget::export_skia_pdf(QString const& filename)
|
||||
{
|
||||
unsigned width = map_->width();
|
||||
|
@ -665,17 +662,22 @@ void MapWidget::export_skia_pdf(QString const& filename)
|
|||
}
|
||||
std::cerr << "Done" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void render_grid(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||
{
|
||||
std::cerr << "Not supported" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_CAIRO
|
||||
void MapWidget::export_cairo_pdf(QString const& filename)
|
||||
{
|
||||
save_to_cairo_file(*map_,filename.toStdString(),scaling_factor_);
|
||||
}
|
||||
void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||
{
|
||||
|
||||
#ifdef HAVE_CAIRO
|
||||
boost::timer::auto_cpu_timer t;
|
||||
mapnik::cairo_surface_ptr image_surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,map.width(),map.height()),
|
||||
mapnik::cairo_surface_closer());
|
||||
|
@ -684,8 +686,9 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|||
image_32 buf(image_surface);
|
||||
QImage image((uchar*)buf.raw_data(),buf.width(),buf.height(),QImage::Format_ARGB32);
|
||||
pix = QPixmap::fromImage(image.rgbSwapped());
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void MapWidget::updateRenderer(QString const& txt)
|
||||
{
|
||||
|
@ -719,14 +722,17 @@ void MapWidget::updateMap()
|
|||
{
|
||||
render_agg(*map_, scaling_factor_, pix_);
|
||||
}
|
||||
#ifdef HAVE_CAIRO
|
||||
else if (cur_renderer_ == Cairo)
|
||||
{
|
||||
render_cairo(*map_, scaling_factor_, pix_);
|
||||
}
|
||||
#endif
|
||||
else if (cur_renderer_ == Grid)
|
||||
{
|
||||
render_grid(*map_, scaling_factor_, pix_);
|
||||
}
|
||||
#ifdef SKIA_RENDERER
|
||||
else if (cur_renderer_ == Skia)
|
||||
{
|
||||
render_skia(*map_, scaling_factor_, pix_);
|
||||
|
@ -734,9 +740,10 @@ void MapWidget::updateMap()
|
|||
else if (cur_renderer_ == Skia_Gpu)
|
||||
{
|
||||
GrGLInterface const* cur_interface = GrGLCreateNativeInterface();
|
||||
render_skia_gpu(cur_interface, *map_, scaling_factor_, pix_);
|
||||
render_skia_gpu(cur_interface, *map_, scaling_factor_);
|
||||
swapBuffers();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
std::cerr << "Unknown renderer..." << std::endl;
|
||||
|
|
|
@ -90,7 +90,14 @@ public:
|
|||
void panUp();
|
||||
void panDown();
|
||||
void set_scaling_factor(double);
|
||||
#ifdef SKIA_RENDERER
|
||||
void export_skia_pdf(QString const& filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CAIRO
|
||||
void export_cairo_pdf(QString const& filename);
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void zoomToLevel(int level);
|
||||
void updateMap();
|
||||
|
|
|
@ -11,11 +11,13 @@ QMAKE_CXXFLAGS += $$system(mapnik-config --cxxflags --defines)
|
|||
QMAKE_CXXFLAGS += $$system(mapnik-config --includes --dep-includes)
|
||||
QMAKE_CXXFLAGS += "-I/Users/artem/Projects/skia/trunk/include/gpu"
|
||||
QMAKE_CXXFLAGS += "-I/Users/artem/Projects/skia/trunk/include/pdf"
|
||||
QMAKE_CXXFLAGS += "-I/Users/artem/Projects/skia/trunk/src/gpu"
|
||||
|
||||
QMAKE_LFLAGS += $$system(mapnik-config --libs)
|
||||
QMAKE_LFLAGS += $$system(mapnik-config --ldflags --dep-libs)
|
||||
QMAKE_LFLAGS += -lboost_timer
|
||||
QMAKE_LFLAGS += -lskia_pdf
|
||||
QMAKE_LFLAGS += -lskia_skgpu
|
||||
QMAKE_LFLAGS += -lzlib
|
||||
QMAKE_LFLAGS += "-framework Cocoa"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue