Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Rationalize shader names
Browse files Browse the repository at this point in the history
{layer type}{subtype}Shader
  • Loading branch information
jfirebaugh committed Oct 5, 2016
1 parent f438bb6 commit 13ca45f
Show file tree
Hide file tree
Showing 37 changed files with 176 additions and 174 deletions.
36 changes: 18 additions & 18 deletions cmake/core-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -178,33 +178,33 @@ set(MBGL_CORE_FILES
src/mbgl/shader/collision_box_shader.hpp
src/mbgl/shader/collision_box_vertex.cpp
src/mbgl/shader/collision_box_vertex.hpp
src/mbgl/shader/icon_shader.cpp
src/mbgl/shader/icon_shader.hpp
src/mbgl/shader/fill_outline_pattern_shader.cpp
src/mbgl/shader/fill_outline_pattern_shader.hpp
src/mbgl/shader/fill_outline_shader.cpp
src/mbgl/shader/fill_outline_shader.hpp
src/mbgl/shader/fill_pattern_shader.cpp
src/mbgl/shader/fill_pattern_shader.hpp
src/mbgl/shader/fill_shader.cpp
src/mbgl/shader/fill_shader.hpp
src/mbgl/shader/fill_vertex.cpp
src/mbgl/shader/fill_vertex.hpp
src/mbgl/shader/line_pattern_shader.cpp
src/mbgl/shader/line_pattern_shader.hpp
src/mbgl/shader/line_sdf_shader.cpp
src/mbgl/shader/line_sdf_shader.hpp
src/mbgl/shader/line_shader.cpp
src/mbgl/shader/line_shader.hpp
src/mbgl/shader/line_vertex.cpp
src/mbgl/shader/line_vertex.hpp
src/mbgl/shader/linepattern_shader.cpp
src/mbgl/shader/linepattern_shader.hpp
src/mbgl/shader/linesdf_shader.cpp
src/mbgl/shader/linesdf_shader.hpp
src/mbgl/shader/outline_shader.cpp
src/mbgl/shader/outline_shader.hpp
src/mbgl/shader/outlinepattern_shader.cpp
src/mbgl/shader/outlinepattern_shader.hpp
src/mbgl/shader/pattern_shader.cpp
src/mbgl/shader/pattern_shader.hpp
src/mbgl/shader/plain_shader.cpp
src/mbgl/shader/plain_shader.hpp
src/mbgl/shader/plain_vertex.cpp
src/mbgl/shader/plain_vertex.hpp
src/mbgl/shader/raster_shader.cpp
src/mbgl/shader/raster_shader.hpp
src/mbgl/shader/raster_vertex.cpp
src/mbgl/shader/raster_vertex.hpp
src/mbgl/shader/sdf_shader.cpp
src/mbgl/shader/sdf_shader.hpp
src/mbgl/shader/shaders.hpp
src/mbgl/shader/symbol_icon_shader.cpp
src/mbgl/shader/symbol_icon_shader.hpp
src/mbgl/shader/symbol_sdf_shader.cpp
src/mbgl/shader/symbol_sdf_shader.hpp
src/mbgl/shader/symbol_vertex.cpp
src/mbgl/shader/symbol_vertex.hpp

Expand Down
12 changes: 6 additions & 6 deletions src/mbgl/renderer/debug_bucket.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <mbgl/renderer/debug_bucket.hpp>
#include <mbgl/renderer/painter.hpp>
#include <mbgl/shader/plain_shader.hpp>
#include <mbgl/shader/plain_vertex.hpp>
#include <mbgl/shader/fill_shader.hpp>
#include <mbgl/shader/fill_vertex.hpp>
#include <mbgl/geometry/debug_font_data.hpp>
#include <mbgl/util/string.hpp>

Expand All @@ -13,13 +13,13 @@

namespace mbgl {

std::vector<PlainVertex> buildTextVertices(const OverscaledTileID& id,
std::vector<FillVertex> buildTextVertices(const OverscaledTileID& id,
const bool renderable,
const bool complete,
optional<Timestamp> modified,
optional<Timestamp> expires,
MapDebugOptions debugMode) {
std::vector<PlainVertex> textPoints;
std::vector<FillVertex> textPoints;

auto addText = [&] (const std::string& text, double left, double baseline, double scale) {
for (uint8_t c : text) {
Expand Down Expand Up @@ -85,14 +85,14 @@ DebugBucket::DebugBucket(const OverscaledTileID& id,
vertexBuffer(context.createVertexBuffer(buildTextVertices(id, renderable_, complete_, modified_, expires_, debugMode_))) {
}

void DebugBucket::drawLines(PlainShader& shader, gl::Context& context) {
void DebugBucket::drawLines(FillShader& shader, gl::Context& context) {
if (vertexBuffer.vertexCount != 0) {
array.bind(shader, vertexBuffer, BUFFER_OFFSET_0, context);
MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(vertexBuffer.vertexCount)));
}
}

void DebugBucket::drawPoints(PlainShader& shader, gl::Context& context) {
void DebugBucket::drawPoints(FillShader& shader, gl::Context& context) {
if (vertexBuffer.vertexCount != 0) {
array.bind(shader, vertexBuffer, BUFFER_OFFSET_0, context);
MBGL_CHECK_ERROR(glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(vertexBuffer.vertexCount)));
Expand Down
10 changes: 5 additions & 5 deletions src/mbgl/renderer/debug_bucket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/gl/vao.hpp>
#include <mbgl/shader/plain_vertex.hpp>
#include <mbgl/shader/fill_vertex.hpp>

namespace mbgl {

class OverscaledTileID;
class PlainShader;
class FillShader;

namespace gl {
class Context;
Expand All @@ -28,8 +28,8 @@ class DebugBucket : private util::noncopyable {
MapDebugOptions,
gl::Context&);

void drawLines(PlainShader&, gl::Context&);
void drawPoints(PlainShader&, gl::Context&);
void drawLines(FillShader&, gl::Context&);
void drawPoints(FillShader&, gl::Context&);

const bool renderable;
const bool complete;
Expand All @@ -38,7 +38,7 @@ class DebugBucket : private util::noncopyable {
const MapDebugOptions debugMode;

private:
gl::VertexBuffer<PlainVertex> vertexBuffer;
gl::VertexBuffer<FillVertex> vertexBuffer;
gl::VertexArrayObject array;
};

Expand Down
16 changes: 8 additions & 8 deletions src/mbgl/renderer/fill_bucket.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <mbgl/renderer/fill_bucket.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
#include <mbgl/renderer/painter.hpp>
#include <mbgl/shader/plain_shader.hpp>
#include <mbgl/shader/pattern_shader.hpp>
#include <mbgl/shader/outline_shader.hpp>
#include <mbgl/shader/outlinepattern_shader.hpp>
#include <mbgl/shader/fill_shader.hpp>
#include <mbgl/shader/fill_pattern_shader.hpp>
#include <mbgl/shader/fill_outline_shader.hpp>
#include <mbgl/shader/fill_outline_pattern_shader.hpp>
#include <mbgl/gl/gl.hpp>
#include <mbgl/platform/log.hpp>

Expand Down Expand Up @@ -121,7 +121,7 @@ bool FillBucket::needsClipping() const {
return true;
}

void FillBucket::drawElements(PlainShader& shader,
void FillBucket::drawElements(FillShader& shader,
gl::Context& context,
PaintMode paintMode) {
GLbyte* vertex_index = BUFFER_OFFSET(0);
Expand All @@ -136,7 +136,7 @@ void FillBucket::drawElements(PlainShader& shader,
}
}

void FillBucket::drawElements(PatternShader& shader,
void FillBucket::drawElements(FillPatternShader& shader,
gl::Context& context,
PaintMode paintMode) {
GLbyte* vertex_index = BUFFER_OFFSET(0);
Expand All @@ -151,7 +151,7 @@ void FillBucket::drawElements(PatternShader& shader,
}
}

void FillBucket::drawVertices(OutlineShader& shader,
void FillBucket::drawVertices(FillOutlineShader& shader,
gl::Context& context,
PaintMode paintMode) {
GLbyte* vertex_index = BUFFER_OFFSET(0);
Expand All @@ -166,7 +166,7 @@ void FillBucket::drawVertices(OutlineShader& shader,
}
}

void FillBucket::drawVertices(OutlinePatternShader& shader,
void FillBucket::drawVertices(FillOutlinePatternShader& shader,
gl::Context& context,
PaintMode paintMode) {
GLbyte* vertex_index = BUFFER_OFFSET(0);
Expand Down
26 changes: 13 additions & 13 deletions src/mbgl/renderer/fill_bucket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
#include <mbgl/tile/geometry_tile_data.hpp>
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/gl/index_buffer.hpp>
#include <mbgl/shader/plain_vertex.hpp>
#include <mbgl/shader/fill_vertex.hpp>

#include <vector>
#include <memory>

namespace mbgl {

class OutlinePatternShader;
class PlainShader;
class PatternShader;
class OutlineShader;
class FillShader;
class FillPatternShader;
class FillOutlineShader;
class FillOutlinePatternShader;

class FillBucket : public Bucket {
public:
Expand All @@ -29,20 +29,20 @@ class FillBucket : public Bucket {

void addGeometry(const GeometryCollection&);

void drawElements(PlainShader&, gl::Context&, PaintMode);
void drawElements(PatternShader&, gl::Context&, PaintMode);
void drawVertices(OutlineShader&, gl::Context&, PaintMode);
void drawVertices(OutlinePatternShader&, gl::Context&, PaintMode);
void drawElements(FillShader&, gl::Context&, PaintMode);
void drawElements(FillPatternShader&, gl::Context&, PaintMode);
void drawVertices(FillOutlineShader&, gl::Context&, PaintMode);
void drawVertices(FillOutlinePatternShader&, gl::Context&, PaintMode);

private:
std::vector<PlainVertex> vertices;
std::vector<FillVertex> vertices;
std::vector<gl::Line> lines;
std::vector<gl::Triangle> triangles;

std::vector<ElementGroup<OutlineShader, OutlinePatternShader>> lineGroups;
std::vector<ElementGroup<PlainShader, PatternShader>> triangleGroups;
std::vector<ElementGroup<FillOutlineShader, FillOutlinePatternShader>> lineGroups;
std::vector<ElementGroup<FillShader, FillPatternShader>> triangleGroups;

optional<gl::VertexBuffer<PlainVertex>> vertexBuffer;
optional<gl::VertexBuffer<FillVertex>> vertexBuffer;
optional<gl::IndexBuffer<gl::Line>> lineIndexBuffer;
optional<gl::IndexBuffer<gl::Triangle>> triangleIndexBuffer;
};
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/renderer/line_bucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/renderer/painter.hpp>
#include <mbgl/shader/line_shader.hpp>
#include <mbgl/shader/linesdf_shader.hpp>
#include <mbgl/shader/linepattern_shader.hpp>
#include <mbgl/shader/line_sdf_shader.hpp>
#include <mbgl/shader/line_pattern_shader.hpp>
#include <mbgl/util/math.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/gl/gl.hpp>
Expand Down Expand Up @@ -493,7 +493,7 @@ void LineBucket::drawLineSDF(LineSDFShader& shader,
}
}

void LineBucket::drawLinePatterns(LinepatternShader& shader,
void LineBucket::drawLinePatterns(LinePatternShader& shader,
gl::Context& context,
PaintMode paintMode) {
GLbyte* vertex_index = BUFFER_OFFSET(0);
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/renderer/line_bucket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace mbgl {

class LineShader;
class LineSDFShader;
class LinepatternShader;
class LinePatternShader;

class LineBucket : public Bucket {

Expand All @@ -32,7 +32,7 @@ class LineBucket : public Bucket {

void drawLines(LineShader&, gl::Context&, PaintMode);
void drawLineSDF(LineSDFShader&, gl::Context&, PaintMode);
void drawLinePatterns(LinepatternShader&, gl::Context&, PaintMode);
void drawLinePatterns(LinePatternShader&, gl::Context&, PaintMode);

private:
struct TriangleElement {
Expand All @@ -53,7 +53,7 @@ class LineBucket : public Bucket {
std::vector<LineVertex> vertices;
std::vector<gl::Triangle> triangles;

std::vector<ElementGroup<LineShader, LineSDFShader, LinepatternShader>> groups;
std::vector<ElementGroup<LineShader, LineSDFShader, LinePatternShader>> groups;

optional<gl::VertexBuffer<LineVertex>> vertexBuffer;
optional<gl::IndexBuffer<gl::Triangle>> indexBuffer;
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/renderer/painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ using namespace style;

Painter::Painter(const TransformState& state_)
: state(state_),
tileTriangleVertexBuffer(context.createVertexBuffer(std::vector<PlainVertex> {{
tileTriangleVertexBuffer(context.createVertexBuffer(std::vector<FillVertex> {{
{ 0, 0 },
{ util::EXTENT, 0 },
{ 0, util::EXTENT },
{ util::EXTENT, 0 },
{ 0, util::EXTENT },
{ util::EXTENT, util::EXTENT }
}})),
tileLineStripVertexBuffer(context.createVertexBuffer(std::vector<PlainVertex> {{
tileLineStripVertexBuffer(context.createVertexBuffer(std::vector<FillVertex> {{
{ 0, 0 },
{ util::EXTENT, 0 },
{ util::EXTENT, util::EXTENT },
Expand Down
12 changes: 6 additions & 6 deletions src/mbgl/renderer/painter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <mbgl/gl/vao.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/shader/plain_vertex.hpp>
#include <mbgl/shader/fill_vertex.hpp>
#include <mbgl/shader/raster_vertex.hpp>

#include <mbgl/style/style.hpp>
Expand Down Expand Up @@ -41,7 +41,7 @@ class SymbolBucket;
class RasterBucket;

class Shaders;
class SDFShader;
class SymbolSDFShader;
class PaintParameters;

struct ClipID;
Expand Down Expand Up @@ -121,8 +121,8 @@ class Painter : private util::noncopyable {
const RenderTile&,
float scaleDivisor,
std::array<float, 2> texsize,
SDFShader& sdfShader,
void (SymbolBucket::*drawSDF)(SDFShader&, gl::Context&, PaintMode),
SymbolSDFShader& sdfShader,
void (SymbolBucket::*drawSDF)(SymbolSDFShader&, gl::Context&, PaintMode),

// Layout
style::AlignmentType rotationAlignment,
Expand Down Expand Up @@ -188,8 +188,8 @@ class Painter : private util::noncopyable {
std::unique_ptr<Shaders> overdrawShaders;
#endif

gl::VertexBuffer<PlainVertex> tileTriangleVertexBuffer;
gl::VertexBuffer<PlainVertex> tileLineStripVertexBuffer;
gl::VertexBuffer<FillVertex> tileTriangleVertexBuffer;
gl::VertexBuffer<FillVertex> tileLineStripVertexBuffer;
gl::VertexBuffer<RasterVertex> rasterVertexBuffer;

gl::VertexArrayObject tileBorderArray;
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/renderer/painter_background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
optional<SpriteAtlasPosition> imagePosA;
optional<SpriteAtlasPosition> imagePosB;

auto& patternShader = parameters.shaders.pattern;
auto& plainShader = parameters.shaders.plain;
auto& patternShader = parameters.shaders.fillPattern;
auto& plainShader = parameters.shaders.fill;
auto& arrayBackgroundPattern = parameters.shaders.backgroundPatternArray;
auto& arrayBackground = parameters.shaders.backgroundArray;

Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/painter_clipping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace mbgl {
void Painter::drawClippingMasks(PaintParameters& parameters, const std::map<UnwrappedTileID, ClipID>& stencils) {
MBGL_DEBUG_GROUP("clipping masks");

auto& plainShader = parameters.shaders.plain;
auto& plainShader = parameters.shaders.fill;
auto& arrayCoveringPlain = parameters.shaders.coveringPlainArray;

mat4 matrix;
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/renderer/painter_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Painter::renderDebugText(Tile& tile, const mat4 &matrix) {
tile.expires, frame.debugOptions, context);
}

auto& plainShader = shaders->plain;
auto& plainShader = shaders->fill;
context.program = plainShader.getID();
plainShader.u_matrix = matrix;
plainShader.u_opacity = 1.0f;
Expand Down Expand Up @@ -74,7 +74,7 @@ void Painter::renderDebugFrame(const mat4 &matrix) {
gl::StencilTestOperation::Replace };
context.stencilTest = true;

auto& plainShader = shaders->plain;
auto& plainShader = shaders->fill;
context.program = plainShader.getID();
plainShader.u_matrix = matrix;
plainShader.u_opacity = 1.0f;
Expand Down
8 changes: 4 additions & 4 deletions src/mbgl/renderer/painter_fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ void Painter::renderFill(PaintParameters& parameters,
context.depthMask = true;
context.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio!

auto& outlineShader = parameters.shaders.outline;
auto& patternShader = parameters.shaders.pattern;
auto& outlinePatternShader = parameters.shaders.outlinePattern;
auto& plainShader = parameters.shaders.plain;
auto& outlineShader = parameters.shaders.fillOutline;
auto& patternShader = parameters.shaders.fillPattern;
auto& outlinePatternShader = parameters.shaders.fillOutlinePattern;
auto& plainShader = parameters.shaders.fill;

// Because we're drawing top-to-bottom, and we update the stencil mask
// befrom, we have to draw the outline first (!)
Expand Down
Loading

0 comments on commit 13ca45f

Please sign in to comment.