[core] Added Viewport mode

Satisfies embedding platforms that requires the viewport coordinate
systems to be set according to its standards e.g. viewport mirrored
vertically.
This commit is contained in:
Bruno de Oliveira Abinader
2016-05-11 14:10:17 +03:00
parent 659c2568ec
commit c13dd32242
14 changed files with 85 additions and 33 deletions

View File

@@ -7,8 +7,9 @@
namespace mbgl {
TransformState::TransformState(ConstrainMode constrainMode_)
TransformState::TransformState(ConstrainMode constrainMode_, ViewportMode viewportMode_)
: constrainMode(constrainMode_)
, viewportMode(viewportMode_)
{
}
@@ -39,7 +40,8 @@ void TransformState::getProjMatrix(mat4& projMatrix) const {
// After the rotateX, z values are in pixel units. Convert them to
// altitude unites. 1 altitude unit = the screen height.
matrix::scale(projMatrix, projMatrix, 1, -1, 1.0f / (rotatedNorth() ? getWidth() : getHeight()));
const bool flippedY = viewportMode == ViewportMode::FlippedY;
matrix::scale(projMatrix, projMatrix, 1, flippedY ? 1 : -1, 1.0f / (rotatedNorth() ? getWidth() : getHeight()));
using NO = NorthOrientation;
switch (getNorthOrientation()) {
@@ -89,6 +91,12 @@ ConstrainMode TransformState::getConstrainMode() const {
return constrainMode;
}
#pragma mark - ViewportMode
ViewportMode TransformState::getViewportMode() const {
return viewportMode;
}
#pragma mark - Position
LatLng TransformState::getLatLng(LatLng::WrapMode wrapMode) const {