@@ -30,15 +30,15 @@ public:
|
||||
ShapeAnnotationGeometry geometry;
|
||||
float opacity = 1;
|
||||
float width = 1;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
Color color = { 0, 0, 0, 1 };
|
||||
};
|
||||
|
||||
class FillAnnotation {
|
||||
public:
|
||||
ShapeAnnotationGeometry geometry;
|
||||
float opacity = 1;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
Color outlineColor = {{ 0, 0, 0, -1 }};
|
||||
Color color = { 0, 0, 0, 1 };
|
||||
Color outlineColor = { 0, 0, 0, -1 };
|
||||
};
|
||||
|
||||
// An annotation whose type and properties are sourced from a style layer.
|
||||
|
||||
@@ -5,6 +5,20 @@
|
||||
namespace mbgl {
|
||||
|
||||
// Stores a premultiplied color, with all four channels ranging from 0..1
|
||||
using Color = std::array<float, 4>;
|
||||
class Color {
|
||||
public:
|
||||
float r = 0.0f;
|
||||
float g = 0.0f;
|
||||
float b = 0.0f;
|
||||
float a = 0.0f;
|
||||
};
|
||||
|
||||
inline bool operator== (const Color& colorA, const Color& colorB) {
|
||||
return colorA.r == colorB.r && colorA.g == colorB.g && colorA.b == colorB.b && colorA.a == colorB.a;
|
||||
}
|
||||
|
||||
inline bool operator!= (const Color& colorA, const Color& colorB) {
|
||||
return !(colorA.r == colorB.r && colorA.g == colorB.g && colorA.b == colorB.b && colorA.a == colorB.a);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -711,7 +711,7 @@ static mbgl::Color toColor(jint color) {
|
||||
float g = (color >> 8) & 0xFF;
|
||||
float b = (color) & 0xFF;
|
||||
float a = (color >> 24) & 0xFF;
|
||||
return {{ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }};
|
||||
return { r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f };
|
||||
}
|
||||
|
||||
template <class Geometry>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
mbgl::Color MGLColorObjectFromCGColorRef(CGColorRef cgColor) {
|
||||
if (!cgColor) {
|
||||
return {{ 0, 0, 0, 0 }};
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
NSCAssert(CGColorGetNumberOfComponents(cgColor) >= 4, @"Color must have at least 4 components");
|
||||
const CGFloat *components = CGColorGetComponents(cgColor);
|
||||
return {{ (float)components[0], (float)components[1], (float)components[2], (float)components[3] }};
|
||||
return { (float)components[0], (float)components[1], (float)components[2], (float)components[3] };
|
||||
}
|
||||
|
||||
@implementation MGLMultiPoint
|
||||
|
||||
@@ -126,11 +126,11 @@ mbgl::Color MGLColorObjectFromUIColor(UIColor *color)
|
||||
{
|
||||
if (!color)
|
||||
{
|
||||
return {{ 0, 0, 0, 0 }};
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
CGFloat r, g, b, a;
|
||||
[color getRed:&r green:&g blue:&b alpha:&a];
|
||||
return {{ (float)r, (float)g, (float)b, (float)a }};
|
||||
return { (float)r, (float)g, (float)b, (float)a };
|
||||
}
|
||||
|
||||
@interface MGLAnnotationAccessibilityElement : UIAccessibilityElement
|
||||
|
||||
@@ -126,11 +126,11 @@ mbgl::util::UnitBezier MGLUnitBezierForMediaTimingFunction(CAMediaTimingFunction
|
||||
/// Converts the given color into an mbgl::Color in calibrated RGB space.
|
||||
mbgl::Color MGLColorObjectFromNSColor(NSColor *color) {
|
||||
if (!color) {
|
||||
return {{ 0, 0, 0, 0 }};
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
CGFloat r, g, b, a;
|
||||
[[color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r green:&g blue:&b alpha:&a];
|
||||
return {{ (float)r, (float)g, (float)b, (float)a }};
|
||||
return { (float)r, (float)g, (float)b, (float)a };
|
||||
}
|
||||
|
||||
/// Lightweight container for metadata about an annotation, including the annotation itself.
|
||||
|
||||
@@ -63,7 +63,7 @@ global.defaultValue = function (property) {
|
||||
return `${propertyType(property)}::${camelize(property.default)}`;
|
||||
}
|
||||
case 'color':
|
||||
return `{{ ${parseCSSColor(property.default).join(', ')} }}`
|
||||
return `{ ${parseCSSColor(property.default).join(', ')} }`
|
||||
case 'array':
|
||||
const defaults = (property.default || []).map((e) => defaultValue({ type: property.value, default: e }));
|
||||
if (property.length) {
|
||||
|
||||
@@ -146,7 +146,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
|
||||
if (frame.debugOptions & MapDebugOptions::Wireframe) {
|
||||
config.clearColor = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
} else {
|
||||
config.clearColor = { background[0], background[1], background[2], background[3] };
|
||||
config.clearColor = { background.r, background.g, background.b, background.a };
|
||||
}
|
||||
config.clearStencil = 0;
|
||||
config.clearDepth = 1;
|
||||
|
||||
@@ -45,7 +45,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
|
||||
|
||||
} else {
|
||||
if (wireframe) {
|
||||
plainShader->u_color = {{ 0.0f, 0.0f, 0.0f, 1.0f }};
|
||||
plainShader->u_color = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
plainShader->u_opacity = 1.0f;
|
||||
} else {
|
||||
plainShader->u_color = properties.backgroundColor;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/gl_values.hpp>
|
||||
#include <mbgl/gl/gl_helper.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
@@ -43,7 +44,7 @@ void Painter::renderDebugText(Tile& tile, const mat4 &matrix) {
|
||||
plainShader->u_matrix = matrix;
|
||||
|
||||
// Draw white outline
|
||||
plainShader->u_color = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
|
||||
plainShader->u_color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
config.lineWidth = 4.0f * frame.pixelRatio;
|
||||
tile.debugBucket->drawLines(*plainShader, store);
|
||||
|
||||
@@ -54,7 +55,7 @@ void Painter::renderDebugText(Tile& tile, const mat4 &matrix) {
|
||||
#endif
|
||||
|
||||
// Draw black text.
|
||||
plainShader->u_color = {{ 0.0f, 0.0f, 0.0f, 1.0f }};
|
||||
plainShader->u_color = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
config.lineWidth = 2.0f * frame.pixelRatio;
|
||||
tile.debugBucket->drawLines(*plainShader, store);
|
||||
|
||||
@@ -77,7 +78,7 @@ void Painter::renderDebugFrame(const mat4 &matrix) {
|
||||
|
||||
// draw tile outline
|
||||
tileBorderArray.bind(*plainShader, tileBorderBuffer, BUFFER_OFFSET_0, store);
|
||||
plainShader->u_color = {{ 1.0f, 0.0f, 0.0f, 1.0f }};
|
||||
plainShader->u_color = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
config.lineWidth = 4.0f * frame.pixelRatio;
|
||||
MBGL_CHECK_ERROR(glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index()));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ void Painter::renderFill(FillBucket& bucket,
|
||||
float opacity = properties.fillOpacity;
|
||||
|
||||
Color stroke_color = properties.fillOutlineColor;
|
||||
if (stroke_color[3] < 0) {
|
||||
if (stroke_color.a < 0) {
|
||||
stroke_color = fill_color;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ void Painter::renderFill(FillBucket& bucket,
|
||||
|
||||
bool wireframe = frame.debugOptions & MapDebugOptions::Wireframe;
|
||||
if (wireframe) {
|
||||
fill_color = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
|
||||
stroke_color = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
|
||||
fill_color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
stroke_color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
opacity = 1.0f;
|
||||
pattern = false;
|
||||
outline = true;
|
||||
@@ -161,7 +161,7 @@ void Painter::renderFill(FillBucket& bucket,
|
||||
}
|
||||
} else if (!wireframe) {
|
||||
// No image fill.
|
||||
if ((fill_color[3] >= 1.0f && opacity >= 1.0f) == (pass == RenderPass::Opaque)) {
|
||||
if ((fill_color.a >= 1.0f && opacity >= 1.0f) == (pass == RenderPass::Opaque)) {
|
||||
// Only draw the fill when it's either opaque and we're drawing opaque
|
||||
// fragments or when it's translucent and we're drawing translucent
|
||||
// fragments
|
||||
|
||||
@@ -37,7 +37,7 @@ void Painter::renderLine(LineBucket& bucket,
|
||||
|
||||
float blur = properties.lineBlur + antialiasing;
|
||||
|
||||
Color color = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
|
||||
Color color { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
float opacity = 1.0f;
|
||||
if (!wireframe) {
|
||||
color = properties.lineColor;
|
||||
|
||||
@@ -88,7 +88,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
|
||||
|
||||
// We're drawing in the translucent pass which is bottom-to-top, so we need
|
||||
// to draw the halo first.
|
||||
if (haloColor[3] > 0.0f && haloWidth > 0.0f) {
|
||||
if (haloColor.a > 0.0f && haloWidth > 0.0f) {
|
||||
sdfShader.u_gamma = (haloBlur * blurOffset / fontScale / sdfPx + gamma) * gammaScale;
|
||||
sdfShader.u_color = haloColor;
|
||||
sdfShader.u_opacity = opacity;
|
||||
@@ -99,7 +99,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
|
||||
}
|
||||
|
||||
// Then, we draw the text/icon over the halo
|
||||
if (color[3] > 0.0f) {
|
||||
if (color.a > 0.0f) {
|
||||
sdfShader.u_gamma = gamma * gammaScale;
|
||||
sdfShader.u_color = color;
|
||||
sdfShader.u_opacity = opacity;
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
|
||||
class RenderData {
|
||||
public:
|
||||
Color backgroundColor = {{ 0, 0, 0, 0 }};
|
||||
Color backgroundColor = { 0, 0, 0, 0 };
|
||||
std::set<style::Source*> sources;
|
||||
std::vector<RenderItem> order;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/shader/shader.hpp>
|
||||
#include <mbgl/shader/uniform.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -14,7 +15,7 @@ public:
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<GLfloat, 2>> u_extrude_scale = {"u_extrude_scale", *this};
|
||||
Uniform<GLfloat> u_devicepixelratio = {"u_devicepixelratio", *this};
|
||||
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
|
||||
Uniform<Color> u_color = {"u_color", *this};
|
||||
Uniform<GLfloat> u_radius = {"u_radius", *this};
|
||||
Uniform<GLfloat> u_blur = {"u_blur", *this};
|
||||
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/shader/shader.hpp>
|
||||
#include <mbgl/shader/uniform.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -12,7 +13,7 @@ public:
|
||||
void bind(GLbyte *offset) final;
|
||||
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
|
||||
Uniform<Color> u_color = {"u_color", *this};
|
||||
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
|
||||
Uniform<GLfloat> u_ratio = {"u_ratio", *this};
|
||||
Uniform<GLfloat> u_linewidth = {"u_linewidth", *this};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/shader/shader.hpp>
|
||||
#include <mbgl/shader/uniform.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -12,7 +13,7 @@ public:
|
||||
void bind(GLbyte *offset) final;
|
||||
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
|
||||
Uniform<Color> u_color = {"u_color", *this};
|
||||
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
|
||||
Uniform<GLfloat> u_linewidth = {"u_linewidth", *this};
|
||||
Uniform<GLfloat> u_gapwidth = {"u_gapwidth", *this};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/shader/shader.hpp>
|
||||
#include <mbgl/shader/uniform.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -12,7 +13,7 @@ public:
|
||||
void bind(GLbyte *offset) final;
|
||||
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<GLfloat, 4>> u_outline_color = {"u_outline_color", *this};
|
||||
Uniform<Color> u_outline_color = {"u_outline_color", *this};
|
||||
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
|
||||
Uniform<std::array<GLfloat, 2>> u_world = {"u_world", *this};
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/shader/shader.hpp>
|
||||
#include <mbgl/shader/uniform.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -12,7 +13,7 @@ public:
|
||||
void bind(GLbyte *offset) final;
|
||||
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
|
||||
Uniform<Color> u_color = {"u_color", *this};
|
||||
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/shader/shader.hpp>
|
||||
#include <mbgl/shader/uniform.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -11,7 +12,7 @@ public:
|
||||
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<GLfloat, 2>> u_extrude_scale = {"u_extrude_scale", *this};
|
||||
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
|
||||
Uniform<Color> u_color = {"u_color", *this};
|
||||
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
|
||||
Uniform<std::array<GLfloat, 2>> u_texsize = {"u_texsize", *this};
|
||||
Uniform<GLfloat> u_buffer = {"u_buffer", *this};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shader/uniform.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -27,6 +28,12 @@ void Uniform<std::array<GLfloat, 4>>::bind(const std::array<GLfloat, 4>& t) {
|
||||
MBGL_CHECK_ERROR(glUniform4fv(location, 1, t.data()));
|
||||
}
|
||||
|
||||
template <>
|
||||
void Uniform<Color>::bind(const Color& t) {
|
||||
std::array<GLfloat, 4> a = {{ t.r, t.g, t.b, t.a }};
|
||||
MBGL_CHECK_ERROR(glUniform4fv(location, 1, a.data()));
|
||||
}
|
||||
|
||||
template <>
|
||||
void UniformMatrix<2>::bind(const std::array<GLfloat, 4>& t) {
|
||||
MBGL_CHECK_ERROR(glUniformMatrix2fv(location, 1, GL_FALSE, t.data()));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
|
||||
|
||||
#include <mbgl/style/layers/background_layer_properties.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void cascade(const CascadeParameters&);
|
||||
bool recalculate(const CalculationParameters&);
|
||||
|
||||
PaintProperty<Color> backgroundColor { {{ 0, 0, 0, 1 }} };
|
||||
PaintProperty<Color> backgroundColor { { 0, 0, 0, 1 } };
|
||||
PaintProperty<std::string, CrossFadedPropertyEvaluator> backgroundPattern { "" };
|
||||
PaintProperty<float> backgroundOpacity { 1 };
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ void CircleLayer::Impl::cascade(const CascadeParameters& parameters) {
|
||||
bool CircleLayer::Impl::recalculate(const CalculationParameters& parameters) {
|
||||
bool hasTransitions = paint.recalculate(parameters);
|
||||
|
||||
passes = (paint.circleRadius > 0 && paint.circleColor.value[3] > 0 && paint.circleOpacity > 0)
|
||||
passes = (paint.circleRadius > 0 && paint.circleColor.value.a > 0 && paint.circleOpacity > 0)
|
||||
? RenderPass::Translucent : RenderPass::None;
|
||||
|
||||
return hasTransitions;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
|
||||
|
||||
#include <mbgl/style/layers/circle_layer_properties.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
bool recalculate(const CalculationParameters&);
|
||||
|
||||
PaintProperty<float> circleRadius { 5 };
|
||||
PaintProperty<Color> circleColor { {{ 0, 0, 0, 1 }} };
|
||||
PaintProperty<Color> circleColor { { 0, 0, 0, 1 } };
|
||||
PaintProperty<float> circleBlur { 0 };
|
||||
PaintProperty<float> circleOpacity { 1 };
|
||||
PaintProperty<std::array<float, 2>> circleTranslate { {{ 0, 0 }} };
|
||||
|
||||
@@ -25,7 +25,7 @@ bool FillLayer::Impl::recalculate(const CalculationParameters& parameters) {
|
||||
passes |= RenderPass::Translucent;
|
||||
}
|
||||
|
||||
if (!paint.fillPattern.value.from.empty() || (paint.fillColor.value[3] * paint.fillOpacity) < 1.0f) {
|
||||
if (!paint.fillPattern.value.from.empty() || (paint.fillColor.value.a * paint.fillOpacity) < 1.0f) {
|
||||
passes |= RenderPass::Translucent;
|
||||
} else {
|
||||
passes |= RenderPass::Opaque;
|
||||
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
|
||||
PaintProperty<bool> fillAntialias { true };
|
||||
PaintProperty<float> fillOpacity { 1 };
|
||||
PaintProperty<Color> fillColor { {{ 0, 0, 0, 1 }} };
|
||||
PaintProperty<Color> fillOutlineColor { {{ 0, 0, 0, -1 }} };
|
||||
PaintProperty<Color> fillColor { { 0, 0, 0, 1 } };
|
||||
PaintProperty<Color> fillOutlineColor { { 0, 0, 0, -1 } };
|
||||
PaintProperty<std::array<float, 2>> fillTranslate { {{ 0, 0 }} };
|
||||
PaintProperty<TranslateAnchorType> fillTranslateAnchor { TranslateAnchorType::Map };
|
||||
PaintProperty<std::string, CrossFadedPropertyEvaluator> fillPattern { "" };
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
<% if (/-pattern$/.test(property.name) || property.name === 'line-dasharray') { -%>
|
||||
PaintProperty<<%- propertyType(property) %>, CrossFadedPropertyEvaluator> <%- camelizeWithLeadingLowercase(property.name) %> { <%- defaultValue(property) %> };
|
||||
<% } else if (property.name === 'fill-outline-color') { -%>
|
||||
PaintProperty<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %> { {{ 0, 0, 0, -1 }} };
|
||||
PaintProperty<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %> { { 0, 0, 0, -1 } };
|
||||
<% } else { -%>
|
||||
PaintProperty<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %> { <%- defaultValue(property) %> };
|
||||
<% } -%>
|
||||
|
||||
@@ -29,7 +29,7 @@ bool LineLayer::Impl::recalculate(const CalculationParameters& parameters) {
|
||||
|
||||
bool hasTransitions = paint.recalculate(parameters);
|
||||
|
||||
passes = (paint.lineOpacity > 0 && paint.lineColor.value[3] > 0 && paint.lineWidth > 0)
|
||||
passes = (paint.lineOpacity > 0 && paint.lineColor.value.a > 0 && paint.lineWidth > 0)
|
||||
? RenderPass::Translucent : RenderPass::None;
|
||||
|
||||
return hasTransitions;
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
bool recalculate(const CalculationParameters&);
|
||||
|
||||
PaintProperty<float> lineOpacity { 1 };
|
||||
PaintProperty<Color> lineColor { {{ 0, 0, 0, 1 }} };
|
||||
PaintProperty<Color> lineColor { { 0, 0, 0, 1 } };
|
||||
PaintProperty<std::array<float, 2>> lineTranslate { {{ 0, 0 }} };
|
||||
PaintProperty<TranslateAnchorType> lineTranslateAnchor { TranslateAnchorType::Map };
|
||||
PaintProperty<float> lineWidth { 1 };
|
||||
|
||||
@@ -26,8 +26,8 @@ bool SymbolLayer::Impl::recalculate(const CalculationParameters& parameters) {
|
||||
iconSize = layout.iconSize;
|
||||
textSize = layout.textSize;
|
||||
|
||||
passes = ((paint.iconOpacity > 0 && (paint.iconColor.value[3] > 0 || paint.iconHaloColor.value[3] > 0) && iconSize > 0)
|
||||
|| (paint.textOpacity > 0 && (paint.textColor.value[3] > 0 || paint.textHaloColor.value[3] > 0) && textSize > 0))
|
||||
passes = ((paint.iconOpacity > 0 && (paint.iconColor.value.a > 0 || paint.iconHaloColor.value.a > 0) && iconSize > 0)
|
||||
|| (paint.textOpacity > 0 && (paint.textColor.value.a > 0 || paint.textHaloColor.value.a > 0) && textSize > 0))
|
||||
? RenderPass::Translucent : RenderPass::None;
|
||||
|
||||
return hasTransitions;
|
||||
|
||||
@@ -58,15 +58,15 @@ public:
|
||||
bool recalculate(const CalculationParameters&);
|
||||
|
||||
PaintProperty<float> iconOpacity { 1 };
|
||||
PaintProperty<Color> iconColor { {{ 0, 0, 0, 1 }} };
|
||||
PaintProperty<Color> iconHaloColor { {{ 0, 0, 0, 0 }} };
|
||||
PaintProperty<Color> iconColor { { 0, 0, 0, 1 } };
|
||||
PaintProperty<Color> iconHaloColor { { 0, 0, 0, 0 } };
|
||||
PaintProperty<float> iconHaloWidth { 0 };
|
||||
PaintProperty<float> iconHaloBlur { 0 };
|
||||
PaintProperty<std::array<float, 2>> iconTranslate { {{ 0, 0 }} };
|
||||
PaintProperty<TranslateAnchorType> iconTranslateAnchor { TranslateAnchorType::Map };
|
||||
PaintProperty<float> textOpacity { 1 };
|
||||
PaintProperty<Color> textColor { {{ 0, 0, 0, 1 }} };
|
||||
PaintProperty<Color> textHaloColor { {{ 0, 0, 0, 0 }} };
|
||||
PaintProperty<Color> textColor { { 0, 0, 0, 1 } };
|
||||
PaintProperty<Color> textHaloColor { { 0, 0, 0, 0 } };
|
||||
PaintProperty<float> textHaloWidth { 0 };
|
||||
PaintProperty<float> textHaloBlur { 0 };
|
||||
PaintProperty<std::array<float, 2>> textTranslate { {{ 0, 0 }} };
|
||||
|
||||
@@ -15,7 +15,7 @@ inline T defaultStopsValue();
|
||||
|
||||
template <> inline bool defaultStopsValue() { return true; }
|
||||
template <> inline float defaultStopsValue() { return 1.0f; }
|
||||
template <> inline Color defaultStopsValue() { return {{ 0, 0, 0, 1 }}; }
|
||||
template <> inline Color defaultStopsValue() { return { 0, 0, 0, 1 }; }
|
||||
template <> inline std::vector<float> defaultStopsValue() { return {{ 1, 0 }}; }
|
||||
template <> inline std::vector<std::string> defaultStopsValue() { return {{}}; }
|
||||
template <> inline std::array<float, 2> defaultStopsValue() { return {{ 0, 0 }}; }
|
||||
|
||||
@@ -49,10 +49,10 @@ optional<Color> parseConstant(const char* name, const JSValue& value) {
|
||||
// Premultiply the color.
|
||||
const float factor = css_color.a / 255;
|
||||
|
||||
return Color{{(float)css_color.r * factor,
|
||||
return Color{ (float)css_color.r * factor,
|
||||
(float)css_color.g * factor,
|
||||
(float)css_color.b * factor,
|
||||
css_color.a}};
|
||||
css_color.a };
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
@@ -267,10 +267,10 @@ RenderData Style::getRenderData() const {
|
||||
if (layer.get() == layers[0].get() && paint.backgroundPattern.value.from.empty()) {
|
||||
// This is a solid background. We can use glClear().
|
||||
result.backgroundColor = paint.backgroundColor;
|
||||
result.backgroundColor[0] *= paint.backgroundOpacity;
|
||||
result.backgroundColor[1] *= paint.backgroundOpacity;
|
||||
result.backgroundColor[2] *= paint.backgroundOpacity;
|
||||
result.backgroundColor[3] *= paint.backgroundOpacity;
|
||||
result.backgroundColor.r *= paint.backgroundOpacity;
|
||||
result.backgroundColor.g *= paint.backgroundOpacity;
|
||||
result.backgroundColor.b *= paint.backgroundOpacity;
|
||||
result.backgroundColor.a *= paint.backgroundOpacity;
|
||||
} else {
|
||||
// This is a textured background, or not the bottommost layer. We need to render it with a quad.
|
||||
result.order.emplace_back(*layer);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
@@ -41,6 +42,19 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Interpolator<Color> {
|
||||
public:
|
||||
Color operator()(const Color& a, const Color& b, const double t) {
|
||||
return {
|
||||
interpolate(a.r, b.r, t),
|
||||
interpolate(a.g, b.g, t),
|
||||
interpolate(a.b, b.b, t),
|
||||
interpolate(a.a, b.a, t)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
struct Uninterpolated {
|
||||
template <class T>
|
||||
T operator()(const T&, const T& b, const double) const {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <mbgl/platform/default/headless_view.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
@@ -48,7 +49,7 @@ TEST(Annotations, LineAnnotation) {
|
||||
|
||||
LineString<double> line = {{ { 0, 0 }, { 45, 45 }, { 30, 0 } }};
|
||||
LineAnnotation annotation { line };
|
||||
annotation.color = {{ 255, 0, 0, 1 }};
|
||||
annotation.color = { 255, 0, 0, 1 };
|
||||
annotation.width = 5;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
@@ -61,7 +62,7 @@ TEST(Annotations, FillAnnotation) {
|
||||
|
||||
Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
|
||||
FillAnnotation annotation { polygon };
|
||||
annotation.color = {{ 255, 0, 0, 1 }};
|
||||
annotation.color = { 255, 0, 0, 1 };
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotation(annotation);
|
||||
@@ -99,7 +100,7 @@ TEST(Annotations, NonImmediateAdd) {
|
||||
|
||||
Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
|
||||
FillAnnotation annotation { polygon };
|
||||
annotation.color = {{ 255, 0, 0, 1 }};
|
||||
annotation.color = { 255, 0, 0, 1 };
|
||||
|
||||
test.map.addAnnotation(annotation);
|
||||
test.checkRendering("non_immediate_add");
|
||||
@@ -153,7 +154,7 @@ TEST(Annotations, RemoveShape) {
|
||||
|
||||
LineString<double> line = {{ { 0, 0 }, { 45, 45 } }};
|
||||
LineAnnotation annotation { line };
|
||||
annotation.color = {{ 255, 0, 0, 1 }};
|
||||
annotation.color = { 255, 0, 0, 1 };
|
||||
annotation.width = 5;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/util/io.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/style/layers/background_layer.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
using namespace mbgl::style;
|
||||
@@ -67,7 +68,7 @@ TEST(Map, AddLayer) {
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
|
||||
auto layer = std::make_unique<BackgroundLayer>("background");
|
||||
layer->setBackgroundColor({{{ 1, 0, 0, 1 }}});
|
||||
layer->setBackgroundColor({{ 1, 0, 0, 1 }});
|
||||
map.addLayer(std::move(layer));
|
||||
|
||||
test::checkImage("test/fixtures/map/add_layer", test::render(map));
|
||||
@@ -80,7 +81,7 @@ TEST(Map, RemoveLayer) {
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
|
||||
auto layer = std::make_unique<BackgroundLayer>("background");
|
||||
layer->setBackgroundColor({{{ 1, 0, 0, 1 }}});
|
||||
layer->setBackgroundColor({{ 1, 0, 0, 1 }});
|
||||
map.addLayer(std::move(layer));
|
||||
map.removeLayer("background");
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <mbgl/style/layers/raster_layer_impl.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer_impl.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
using namespace mbgl::style;
|
||||
@@ -28,7 +29,7 @@ template <class T, class... Params> void testClone(Params... params) {
|
||||
EXPECT_EQ("test", layer->baseImpl->clone()->getID());
|
||||
}
|
||||
|
||||
const auto color = PropertyValue<Color> {{{ 1, 0, 0, 1 }}};
|
||||
const auto color = PropertyValue<Color> {{ 1, 0, 0, 1 }};
|
||||
const auto opacity = PropertyValue<float> { 1.0f };
|
||||
const auto radius = PropertyValue<float> { 1.0f };
|
||||
const auto blur = PropertyValue<float> { 1.0f };
|
||||
|
||||
Reference in New Issue
Block a user