[core] Methods don't need to be Painter instance methods

This commit is contained in:
John Firebaugh
2016-10-10 16:35:22 -07:00
parent fa96612888
commit ee3235708f
2 changed files with 28 additions and 32 deletions

View File

@@ -99,10 +99,6 @@ public:
void renderRaster(PaintParameters&, RasterBucket&, const style::RasterLayer&, const RenderTile&);
void renderBackground(PaintParameters&, const style::BackgroundLayer&);
float saturationFactor(float saturation);
float contrastFactor(float contrast);
std::array<float, 3> spinWeights(float spin_value);
void drawClippingMasks(PaintParameters&, const std::map<UnwrappedTileID, ClipID>&);
bool needsAnimation() const;

View File

@@ -11,6 +11,34 @@ namespace mbgl {
using namespace style;
static float saturationFactor(float saturation) {
if (saturation > 0) {
return 1 - 1 / (1.001 - saturation);
} else {
return -saturation;
}
}
static float contrastFactor(float contrast) {
if (contrast > 0) {
return 1 / (1 - contrast);
} else {
return 1 + contrast;
}
}
static std::array<float, 3> spinWeights(float spin) {
spin *= util::DEG2RAD;
float s = std::sin(spin);
float c = std::cos(spin);
std::array<float, 3> spin_weights = {{
(2 * c + 1) / 3,
(-std::sqrt(3.0f) * s - c + 1) / 3,
(std::sqrt(3.0f) * s - c + 1) / 3
}};
return spin_weights;
}
void Painter::renderRaster(PaintParameters& parameters,
RasterBucket& bucket,
const RasterLayer& layer,
@@ -51,32 +79,4 @@ void Painter::renderRaster(PaintParameters& parameters,
}
}
float Painter::saturationFactor(float saturation) {
if (saturation > 0) {
return 1 - 1 / (1.001 - saturation);
} else {
return -saturation;
}
}
float Painter::contrastFactor(float contrast) {
if (contrast > 0) {
return 1 / (1 - contrast);
} else {
return 1 + contrast;
}
}
std::array<float, 3> Painter::spinWeights(float spin) {
spin *= util::DEG2RAD;
float s = std::sin(spin);
float c = std::cos(spin);
std::array<float, 3> spin_weights = {{
(2 * c + 1) / 3,
(-std::sqrt(3.0f) * s - c + 1) / 3,
(std::sqrt(3.0f) * s - c + 1) / 3
}};
return spin_weights;
}
} // namespace mbgl