[core] Updated Size::isEmpty and TransformState::valid checks
This commit is contained in:
@@ -45,9 +45,13 @@ Transform::Transform(MapObserver& observer_,
|
||||
|
||||
#pragma mark - Map View
|
||||
|
||||
bool Transform::resize(const Size size) {
|
||||
void Transform::resize(const Size size) {
|
||||
if (size.isEmpty()) {
|
||||
throw std::runtime_error("failed to resize: size is empty");
|
||||
}
|
||||
|
||||
if (state.size == size) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
observer.onCameraWillChange(MapObserver::CameraChangeMode::Immediate);
|
||||
@@ -56,8 +60,6 @@ bool Transform::resize(const Size size) {
|
||||
state.constrain(state.scale, state.x, state.y);
|
||||
|
||||
observer.onCameraDidChange(MapObserver::CameraChangeMode::Immediate);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma mark - Camera
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
Transform(const TransformState &state_) : observer(MapObserver::nullObserver()), state(state_) {}
|
||||
|
||||
// Map view
|
||||
bool resize(Size size);
|
||||
void resize(Size size);
|
||||
|
||||
// Camera
|
||||
/** Returns the current camera options. */
|
||||
|
||||
@@ -27,6 +27,9 @@ void TransformState::matrixFor(mat4& matrix, const UnwrappedTileID& tileID) cons
|
||||
}
|
||||
|
||||
void TransformState::getProjMatrix(mat4& projMatrix) const {
|
||||
if (size.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the distance from the center point [width/2, height/2] to the
|
||||
// center top point [width/2, 0] in Z units, using the law of sines.
|
||||
@@ -216,7 +219,7 @@ double TransformState::scaleZoom(double s) const {
|
||||
}
|
||||
|
||||
ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng) const {
|
||||
if (!size) {
|
||||
if (size.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -229,7 +232,7 @@ ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng)
|
||||
}
|
||||
|
||||
LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point, LatLng::WrapMode wrapMode) const {
|
||||
if (!size) {
|
||||
if (size.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,10 @@ public:
|
||||
double zoomScale(double zoom) const;
|
||||
double scaleZoom(double scale) const;
|
||||
|
||||
bool valid() const {
|
||||
return !size.isEmpty() && (scale >= min_scale && scale <= max_scale);
|
||||
}
|
||||
|
||||
private:
|
||||
bool rotatedNorth() const;
|
||||
void constrain(double& scale, double& x, double& y) const;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace mbgl {
|
||||
class OffscreenTexture::Impl {
|
||||
public:
|
||||
Impl(gl::Context& context_, const Size size_) : context(context_), size(std::move(size_)) {
|
||||
assert(size);
|
||||
assert(!size.isEmpty());
|
||||
}
|
||||
|
||||
void bind() {
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
|
||||
OffscreenTexture::OffscreenTexture(gl::Context& context, const Size size)
|
||||
: impl(std::make_unique<Impl>(context, std::move(size))) {
|
||||
assert(size);
|
||||
assert(!size.isEmpty());
|
||||
}
|
||||
|
||||
OffscreenTexture::~OffscreenTexture() = default;
|
||||
|
||||
@@ -156,6 +156,8 @@ std::vector<UnwrappedTileID> tileCover(const LatLngBounds& bounds_, int32_t z) {
|
||||
}
|
||||
|
||||
std::vector<UnwrappedTileID> tileCover(const TransformState& state, int32_t z) {
|
||||
assert(state.valid());
|
||||
|
||||
const double w = state.getSize().width;
|
||||
const double h = state.getSize().height;
|
||||
return tileCover(
|
||||
|
||||
Reference in New Issue
Block a user