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

Commit

Permalink
[core] Make Depth::mask an enum; use Painter::depthForSublayer
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Oct 14, 2016
1 parent c3e9a9c commit 7dba523
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
9 changes: 7 additions & 2 deletions src/mbgl/gl/depth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ class Depth {
Always = 0x0207
};

enum Mask : bool {
ReadOnly = false,
ReadWrite = true
};

Function func;
bool mask;
Mask mask;
Range<float> range;

static Depth disabled() {
return Depth { Always, false, { 0.0, 1.0 } };
return Depth { Always, ReadOnly, { 0.0, 1.0 } };
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/renderer/painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void Painter::renderPass(PaintParameters& parameters,
} else if (layer.is<CustomLayer>()) {
MBGL_DEBUG_GROUP(layer.baseImpl->id + " - custom");
context.resetState();
context.setDepth(gl::Depth { gl::Depth::LessEqual, false, depthRangeForSublayer(0) });
context.setDepth(depthForSublayer(0, gl::Depth::ReadOnly));
context.setStencil(gl::Stencil::disabled());
context.setColor(colorForRenderPass());
layer.as<CustomLayer>()->impl->render(state);
Expand All @@ -277,10 +277,10 @@ mat4 Painter::matrixForTile(const UnwrappedTileID& tileID) {
return matrix;
}

Range<float> Painter::depthRangeForSublayer(int n) const {
gl::Depth Painter::depthForSublayer(uint8_t n, gl::Depth::Mask mask) const {
float nearDepth = ((1 + currentLayer) * numSublayers + n) * depthEpsilon;
float farDepth = nearDepth + depthRangeSize;
return { nearDepth, farDepth };
return gl::Depth { gl::Depth::LessEqual, mask, { nearDepth, farDepth } };
}

gl::Stencil Painter::stencilForClipping(const ClipID& id) const {
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/painter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Painter : private util::noncopyable {
uint32_t i, int8_t increment);

mat4 matrixForTile(const UnwrappedTileID&);
Range<float> depthRangeForSublayer(int n) const;
gl::Depth depthForSublayer(uint8_t n, gl::Depth::Mask) const;
gl::Stencil stencilForClipping(const ClipID&) const;
gl::Color colorForRenderPass() const;

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 @@ -29,7 +29,7 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye

for (const auto& tileID : util::tileCover(state, state.getIntegerZoom())) {
context.draw({
gl::Depth { gl::Depth::LessEqual, false, depthRangeForSublayer(0) },
depthForSublayer(0, gl::Depth::ReadOnly),
gl::Stencil::disabled(),
colorForRenderPass(),
parameters.shaders.fillPattern,
Expand All @@ -49,7 +49,7 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
} else {
for (const auto& tileID : util::tileCover(state, state.getIntegerZoom())) {
context.draw({
gl::Depth { gl::Depth::LessEqual, false, depthRangeForSublayer(0), },
depthForSublayer(0, gl::Depth::ReadOnly),
gl::Stencil::disabled(),
colorForRenderPass(),
parameters.shaders.fill,
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/painter_circle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void Painter::renderCircle(PaintParameters& parameters,
const CirclePaintProperties& properties = layer.impl->paint;

context.draw({
gl::Depth { gl::Depth::LessEqual, false, depthRangeForSublayer(0) },
depthForSublayer(0, gl::Depth::ReadOnly),
frame.mapMode == MapMode::Still
? stencilForClipping(tile.clip)
: gl::Stencil::disabled(),
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/renderer/painter_fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void Painter::renderFill(PaintParameters& parameters,

auto draw = [&] (uint8_t sublayer, auto& shader, const auto& subject) {
context.draw({
gl::Depth { gl::Depth::LessEqual, true, depthRangeForSublayer(sublayer) },
depthForSublayer(sublayer, gl::Depth::ReadWrite),
stencilForClipping(tile.clip),
colorForRenderPass(),
shader,
Expand Down Expand Up @@ -78,7 +78,7 @@ void Painter::renderFill(PaintParameters& parameters,
} else {
auto draw = [&] (uint8_t sublayer, auto& shader, Color outlineColor, const auto& subject) {
context.draw({
gl::Depth { gl::Depth::LessEqual, true, depthRangeForSublayer(sublayer) },
depthForSublayer(sublayer, gl::Depth::ReadWrite),
stencilForClipping(tile.clip),
colorForRenderPass(),
shader,
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/painter_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void Painter::renderLine(PaintParameters& parameters,

auto draw = [&] (auto& shader, auto&& uniformValues) {
context.draw({
gl::Depth { gl::Depth::LessEqual, false, depthRangeForSublayer(0) },
depthForSublayer(0, gl::Depth::ReadOnly),
stencilForClipping(tile.clip),
colorForRenderPass(),
shader,
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/painter_raster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Painter::renderRaster(PaintParameters& parameters,
context.bindTexture(*bucket.texture, 1, gl::TextureFilter::Linear);

context.draw({
gl::Depth { gl::Depth::LessEqual, false, depthRangeForSublayer(0) },
depthForSublayer(0, gl::Depth::ReadOnly),
gl::Stencil::disabled(),
colorForRenderPass(),
parameters.shaders.raster,
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/painter_symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Painter::renderSymbol(PaintParameters& parameters,

context.draw({
values_.pitchAlignment == AlignmentType::Map
? gl::Depth { gl::Depth::LessEqual, false, depthRangeForSublayer(0) }
? depthForSublayer(0, gl::Depth::ReadOnly)
: gl::Depth::disabled(),
drawAcrossEdges
? gl::Stencil::disabled()
Expand Down

0 comments on commit 7dba523

Please sign in to comment.