summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-11-09 11:17:47 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-12-03 12:44:43 -0800
commit398ab663beec937d85c518c465770ffa0b8d38b4 (patch)
tree1e29a41a3be520ee853f0acd7e6b43710e1b1b76 /src
parent964a1e7b62c3a7e8fd742e16fe842f8a702437e5 (diff)
downloadqtlocation-mapboxgl-398ab663beec937d85c518c465770ffa0b8d38b4.tar.gz
[core] Clean up Painter
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/painter.cpp83
-rw-r--r--src/mbgl/renderer/painter.hpp30
2 files changed, 30 insertions, 83 deletions
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index e4991b8086..f678414d0f 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -45,67 +45,30 @@ using namespace mbgl;
Painter::Painter(MapData& data_, TransformState& state_)
: data(data_), state(state_) {
- setup();
-}
-
-Painter::~Painter() = default;
-
-bool Painter::needsAnimation() const {
- return frameHistory.needsAnimation(data.getDefaultFadeDuration());
-}
-
-void Painter::setup() {
gl::debugging::enable();
- setupShaders();
-
- assert(iconShader);
- assert(plainShader);
- assert(outlineShader);
- assert(lineShader);
- assert(linepatternShader);
- assert(patternShader);
- assert(rasterShader);
- assert(sdfGlyphShader);
- assert(sdfIconShader);
- assert(dotShader);
- assert(circleShader);
+ plainShader = std::make_unique<PlainShader>();
+ outlineShader = std::make_unique<OutlineShader>();
+ lineShader = std::make_unique<LineShader>();
+ linesdfShader = std::make_unique<LineSDFShader>();
+ linepatternShader = std::make_unique<LinepatternShader>();
+ patternShader = std::make_unique<PatternShader>();
+ iconShader = std::make_unique<IconShader>();
+ rasterShader = std::make_unique<RasterShader>();
+ sdfGlyphShader = std::make_unique<SDFGlyphShader>();
+ sdfIconShader = std::make_unique<SDFIconShader>();
+ dotShader = std::make_unique<DotShader>();
+ collisionBoxShader = std::make_unique<CollisionBoxShader>();
+ circleShader = std::make_unique<CircleShader>();
// Reset GL values
config.reset();
}
-void Painter::setupShaders() {
- if (!plainShader) plainShader = std::make_unique<PlainShader>();
- if (!outlineShader) outlineShader = std::make_unique<OutlineShader>();
- if (!lineShader) lineShader = std::make_unique<LineShader>();
- if (!linesdfShader) linesdfShader = std::make_unique<LineSDFShader>();
- if (!linepatternShader) linepatternShader = std::make_unique<LinepatternShader>();
- if (!patternShader) patternShader = std::make_unique<PatternShader>();
- if (!iconShader) iconShader = std::make_unique<IconShader>();
- if (!rasterShader) rasterShader = std::make_unique<RasterShader>();
- if (!sdfGlyphShader) sdfGlyphShader = std::make_unique<SDFGlyphShader>();
- if (!sdfIconShader) sdfIconShader = std::make_unique<SDFIconShader>();
- if (!dotShader) dotShader = std::make_unique<DotShader>();
- if (!collisionBoxShader) collisionBoxShader = std::make_unique<CollisionBoxShader>();
- if (!circleShader) circleShader = std::make_unique<CircleShader>();
-}
-
-void Painter::resize() {
- config.viewport = { 0, 0, frame.framebufferSize[0], frame.framebufferSize[1] };
-}
-
-void Painter::changeMatrix() {
-
- state.getProjMatrix(projMatrix);
-
- // The extrusion matrix.
- matrix::ortho(extrudeMatrix, 0, state.getWidth(), state.getHeight(), 0, 0, -1);
+Painter::~Painter() = default;
- // The native matrix is a 1:1 matrix that paints the coordinates at the
- // same screen position as the vertex specifies.
- matrix::identity(nativeMatrix);
- matrix::multiply(nativeMatrix, projMatrix, nativeMatrix);
+bool Painter::needsAnimation() const {
+ return frameHistory.needsAnimation(data.getDefaultFadeDuration());
}
void Painter::prepareTile(const Tile& tile) {
@@ -126,8 +89,18 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
const std::set<Source*>& sources = renderData.sources;
const Color& background = renderData.backgroundColor;
- resize();
- changeMatrix();
+ config.viewport = { 0, 0, frame.framebufferSize[0], frame.framebufferSize[1] };
+
+ // Update the default matrices to the current viewport dimensions.
+ state.getProjMatrix(projMatrix);
+
+ // The extrusion matrix.
+ matrix::ortho(extrudeMatrix, 0, state.getWidth(), state.getHeight(), 0, 0, -1);
+
+ // The native matrix is a 1:1 matrix that paints the coordinates at the
+ // same screen position as the vertex specifies.
+ matrix::identity(nativeMatrix);
+ matrix::multiply(nativeMatrix, projMatrix, nativeMatrix);
// - UPLOAD PASS -------------------------------------------------------------------------------
// Uploads all required buffers and images before we do any actual rendering.
diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp
index 3a49b36183..7189bcc19b 100644
--- a/src/mbgl/renderer/painter.hpp
+++ b/src/mbgl/renderer/painter.hpp
@@ -34,7 +34,6 @@ class LineAtlas;
class Source;
struct FrameData;
-
class DebugBucket;
class FillBucket;
class FillLayer;
@@ -48,8 +47,6 @@ class RasterBucket;
class RasterLayer;
class BackgroundLayer;
-struct RasterProperties;
-
class SDFShader;
class PlainShader;
class OutlineShader;
@@ -73,9 +70,6 @@ public:
Painter(MapData&, TransformState&);
~Painter();
- // Updates the default matrices to the current viewport dimensions.
- void changeMatrix();
-
void render(const Style& style,
const FrameData& frame,
SpriteAtlas& annotationSpriteAtlas);
@@ -98,29 +92,12 @@ public:
float contrastFactor(float contrast);
std::array<float, 3> spinWeights(float spin_value);
- void preparePrerender(RasterBucket &bucket);
-
- void renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix, const RasterProperties& properties);
-
- void createPrerendered(RasterBucket& bucket, const StyleLayer &layer_desc, const TileID& id);
-
- // Adjusts the dimensions of the OpenGL viewport
- void resize();
-
void drawClippingMasks(const std::set<Source*>&);
void drawClippingMask(const mat4& matrix, const ClipID& clip);
- void resetFramebuffer();
- void bindFramebuffer();
- void pushFramebuffer();
- GLuint popFramebuffer();
- void discardFramebuffers();
-
bool needsAnimation() const;
private:
- void setup();
- void setupShaders();
mat4 translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const TileID &id, TranslateAnchorType anchor);
std::vector<RenderItem> determineRenderOrder(const Style& style);
@@ -145,7 +122,6 @@ private:
void setDepthSublayer(int n);
-public:
mat4 projMatrix;
mat4 nativeMatrix;
mat4 extrudeMatrix;
@@ -164,7 +140,6 @@ public:
return identity;
}();
-private:
MapData& data;
TransformState& state;
FrameData frame;
@@ -180,13 +155,12 @@ private:
float depthRangeSize;
const float depthEpsilon = 1.0f / (1 << 16);
-public:
- FrameHistory frameHistory;
-
SpriteAtlas* spriteAtlas;
GlyphAtlas* glyphAtlas;
LineAtlas* lineAtlas;
+ FrameHistory frameHistory;
+
std::unique_ptr<PlainShader> plainShader;
std::unique_ptr<OutlineShader> outlineShader;
std::unique_ptr<LineShader> lineShader;