summaryrefslogtreecommitdiff
path: root/platform/macos
diff options
context:
space:
mode:
Diffstat (limited to 'platform/macos')
-rw-r--r--platform/macos/src/MGLMapView.mm21
-rw-r--r--platform/macos/src/NSImage+MGLAdditions.mm4
2 files changed, 13 insertions, 12 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index ebcd8e00b0..2630a361a0 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -266,10 +266,8 @@ public:
mbgl::DefaultFileSource* mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource;
- const std::array<uint16_t, 2> size = {{ static_cast<uint16_t>(self.bounds.size.width),
- static_cast<uint16_t>(self.bounds.size.height) }};
_mbglThreadPool = new mbgl::ThreadPool(4);
- _mbglMap = new mbgl::Map(*_mbglView, size, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
+ _mbglMap = new mbgl::Map(*_mbglView, self.size, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
[self validateTileCacheSize];
// Install the OpenGL layer. Interface Builder’s synchronous drawing means
@@ -308,6 +306,11 @@ public:
_pendingLongitude = NAN;
}
+- (mbgl::Size)size {
+ return { static_cast<uint32_t>(self.bounds.size.width),
+ static_cast<uint32_t>(self.bounds.size.height) };
+}
+
/// Adds zoom controls to the lower-right corner.
- (void)installZoomControls {
_zoomControls = [[NSSegmentedControl alloc] initWithFrame:NSZeroRect];
@@ -639,8 +642,7 @@ public:
[self validateTileCacheSize];
}
if (!_isTargetingInterfaceBuilder) {
- _mbglMap->setSize({{ static_cast<uint16_t>(self.bounds.size.width),
- static_cast<uint16_t>(self.bounds.size.height) }});
+ _mbglMap->setSize(self.size);
}
}
@@ -2561,8 +2563,7 @@ public:
}
mbgl::gl::value::Viewport::Type getViewport() const {
- return { 0, 0, static_cast<uint16_t>(nativeView.bounds.size.width),
- static_cast<uint16_t>(nativeView.bounds.size.height) };
+ return { 0, 0, nativeView.size };
}
void updateViewBinding() {
@@ -2578,9 +2579,9 @@ public:
mbgl::PremultipliedImage readStillImage() {
NSRect bounds = [nativeView convertRectToBacking:nativeView.bounds];
- const uint16_t width = bounds.size.width;
- const uint16_t height = bounds.size.height;
- mbgl::PremultipliedImage image{ width, height };
+ const uint32_t width = bounds.size.width;
+ const uint32_t height = bounds.size.height;
+ mbgl::PremultipliedImage image({ width, height });
MBGL_CHECK_ERROR(
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, image.data.get()));
diff --git a/platform/macos/src/NSImage+MGLAdditions.mm b/platform/macos/src/NSImage+MGLAdditions.mm
index 7d02271bb3..2c4b16800e 100644
--- a/platform/macos/src/NSImage+MGLAdditions.mm
+++ b/platform/macos/src/NSImage+MGLAdditions.mm
@@ -13,8 +13,8 @@
// Get the image’s raw pixel data as an RGBA buffer.
std::string pixelString((const char *)rep.bitmapData, rep.pixelsWide * rep.pixelsHigh * 4 /* RGBA */);
- mbgl::PremultipliedImage cPremultipliedImage(rep.pixelsWide, rep.pixelsHigh);
- std::copy(rep.bitmapData, rep.bitmapData + cPremultipliedImage.size(), cPremultipliedImage.data.get());
+ mbgl::PremultipliedImage cPremultipliedImage({ static_cast<uint32_t>(rep.pixelsWide), static_cast<uint32_t>(rep.pixelsHigh) });
+ std::copy(rep.bitmapData, rep.bitmapData + cPremultipliedImage.bytes(), cPremultipliedImage.data.get());
return std::make_unique<mbgl::SpriteImage>(std::move(cPremultipliedImage),
(float)(rep.pixelsWide / self.size.width));
}