summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/src/bitmap.cpp10
-rw-r--r--platform/android/src/map/image.cpp2
-rwxr-xr-xplatform/android/src/native_map_view.cpp2
-rw-r--r--platform/android/src/text/local_glyph_rasterizer.cpp5
-rw-r--r--platform/default/jpeg_reader.cpp2
-rw-r--r--platform/default/png_reader.cpp2
-rw-r--r--platform/default/png_writer.cpp8
-rw-r--r--platform/glfw/glfw_view.cpp2
-rw-r--r--platform/node/src/node_map.cpp14
-rw-r--r--platform/qt/src/qt_image.cpp2
10 files changed, 25 insertions, 24 deletions
diff --git a/platform/android/src/bitmap.cpp b/platform/android/src/bitmap.cpp
index eb7c676b12..e664a2d406 100644
--- a/platform/android/src/bitmap.cpp
+++ b/platform/android/src/bitmap.cpp
@@ -89,7 +89,7 @@ PremultipliedImage Bitmap::GetImage(jni::JNIEnv& env, const jni::Object<Bitmap>&
}
jni::Local<jni::Object<Bitmap>> Bitmap::CreateBitmap(jni::JNIEnv& env, const PremultipliedImage& image) {
- auto bitmap = CreateBitmap(env, image.size.width, image.size.height, Config::ARGB_8888);
+ auto bitmap = CreateBitmap(env, image.size().width, image.size().height, Config::ARGB_8888);
AndroidBitmapInfo info;
const int result = AndroidBitmap_getInfo(&env, jni::Unwrap(*bitmap), &info);
@@ -98,15 +98,15 @@ jni::Local<jni::Object<Bitmap>> Bitmap::CreateBitmap(jni::JNIEnv& env, const Pre
throw std::runtime_error("bitmap creation: couldn't get bitmap info");
}
- assert(info.width == image.size.width);
- assert(info.height == image.size.height);
+ assert(info.width == image.size().width);
+ assert(info.height == image.size().height);
assert(info.format == ANDROID_BITMAP_FORMAT_RGBA_8888);
PixelGuard guard(env, bitmap);
// Copy the PremultipliedImage into the Android Bitmap
- for (uint32_t y = 0; y < image.size.height; y++) {
- auto begin = image.data.get() + y * image.stride();
+ for (uint32_t y = 0; y < image.size().height; y++) {
+ auto begin = image.data() + y * image.stride();
std::copy(begin, begin + image.stride(), guard.get() + y * info.stride);
}
diff --git a/platform/android/src/map/image.cpp b/platform/android/src/map/image.cpp
index a91cc938ed..76b7a02a9b 100644
--- a/platform/android/src/map/image.cpp
+++ b/platform/android/src/map/image.cpp
@@ -29,7 +29,7 @@ mbgl::style::Image Image::getImage(jni::JNIEnv& env, const jni::Object<Image>& i
throw mbgl::util::SpriteImageException("Sprite image pixel count mismatch");
}
- jni::GetArrayRegion(env, *pixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data.get()));
+ jni::GetArrayRegion(env, *pixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data()));
return mbgl::style::Image {name, std::move(premultipliedImage), pixelRatio, sdf};
}
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 1c744a6b57..dfe330dab4 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -601,7 +601,7 @@ void NativeMapView::addAnnotationIcon(JNIEnv& env, const jni::String& symbol, ji
throw mbgl::util::SpriteImageException("Sprite image pixel count mismatch");
}
- jni::GetArrayRegion(env, *jpixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data.get()));
+ jni::GetArrayRegion(env, *jpixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data()));
map->addAnnotationImage(std::make_unique<mbgl::style::Image>(
symbolName, std::move(premultipliedImage), float(scale)));
}
diff --git a/platform/android/src/text/local_glyph_rasterizer.cpp b/platform/android/src/text/local_glyph_rasterizer.cpp
index 8892ee3f37..534f323172 100644
--- a/platform/android/src/text/local_glyph_rasterizer.cpp
+++ b/platform/android/src/text/local_glyph_rasterizer.cpp
@@ -120,8 +120,9 @@ Glyph LocalGlyphRasterizer::rasterizeGlyph(const FontStack& fontStack, GlyphID g
// Copy alpha values from RGBA bitmap into the AlphaImage output
fixedMetrics.bitmap = AlphaImage(size);
- for (uint32_t i = 0; i < size.width * size.height; i++) {
- fixedMetrics.bitmap.data[i] = rgbaBitmap.data[4 * i + 3];
+ uint32_t sizeArea = size.area();
+ for (uint32_t i = 0; i < sizeArea; ++i) {
+ fixedMetrics.bitmap.data()[i] = rgbaBitmap.data()[4 * i + 3];
}
return fixedMetrics;
diff --git a/platform/default/jpeg_reader.cpp b/platform/default/jpeg_reader.cpp
index 5f613f9423..93740649f0 100644
--- a/platform/default/jpeg_reader.cpp
+++ b/platform/default/jpeg_reader.cpp
@@ -120,7 +120,7 @@ PremultipliedImage decodeJPEG(const uint8_t* data, size_t size) {
size_t rowStride = components * width;
PremultipliedImage image({ static_cast<uint32_t>(width), static_cast<uint32_t>(height) });
- uint8_t* dst = image.data.get();
+ uint8_t* dst = image.data();
JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE, rowStride, 1);
diff --git a/platform/default/png_reader.cpp b/platform/default/png_reader.cpp
index 4d4ee29d1f..8046db7449 100644
--- a/platform/default/png_reader.cpp
+++ b/platform/default/png_reader.cpp
@@ -131,7 +131,7 @@ PremultipliedImage decodePNG(const uint8_t* data, size_t size) {
// alloc row pointers
const std::unique_ptr<png_bytep[]> rows(new png_bytep[height]);
for (unsigned row = 0; row < height; ++row)
- rows[row] = image.data.get() + row * width * 4;
+ rows[row] = image.data() + row * width * 4;
png_read_image(png_ptr, rows.get());
png_read_end(png_ptr, nullptr);
diff --git a/platform/default/png_writer.cpp b/platform/default/png_writer.cpp
index b89e253f85..ffc02126a9 100644
--- a/platform/default/png_writer.cpp
+++ b/platform/default/png_writer.cpp
@@ -44,8 +44,8 @@ std::string encodePNG(const PremultipliedImage& pre) {
// IHDR chunk for our RGBA image.
const char ihdr[13] = {
- NETWORK_BYTE_UINT32(src.size.width), // width
- NETWORK_BYTE_UINT32(src.size.height), // height
+ NETWORK_BYTE_UINT32(src.size().width), // width
+ NETWORK_BYTE_UINT32(src.size().height), // height
8, // bit depth == 8 bits
6, // color type == RGBA
0, // compression method == deflate
@@ -56,10 +56,10 @@ std::string encodePNG(const PremultipliedImage& pre) {
// Prepare the (compressed) data chunk.
const auto stride = src.stride();
std::string idat;
- for (uint32_t y = 0; y < src.size.height; y++) {
+ for (uint32_t y = 0; y < src.size().height; y++) {
// Every scanline needs to be prefixed with one byte that indicates the filter type.
idat.append(1, 0); // filter type 0
- idat.append((const char*)(src.data.get() + y * stride), stride);
+ idat.append((const char*)(src.data() + y * stride), stride);
}
idat = util::compress(idat);
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp
index 9179113139..101f18212f 100644
--- a/platform/glfw/glfw_view.cpp
+++ b/platform/glfw/glfw_view.cpp
@@ -324,7 +324,7 @@ GLFWView::makeImage(const std::string& id, int width, int height, float pixelRat
const int h = std::ceil(pixelRatio * height);
mbgl::PremultipliedImage image({ static_cast<uint32_t>(w), static_cast<uint32_t>(h) });
- auto data = reinterpret_cast<uint32_t*>(image.data.get());
+ auto* data = reinterpret_cast<uint32_t*>(image.data());
const int dist = (w / 2) * (w / 2);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index 6dccdf5292..bb7a5121f9 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -421,7 +421,7 @@ void NodeMap::Render(const Nan::FunctionCallbackInfo<v8::Value>& info) {
try {
auto options = ParseOptions(Nan::To<v8::Object>(info[0]).ToLocalChecked());
assert(!nodeMap->req);
- assert(!nodeMap->image.data);
+ assert(!nodeMap->image.valid());
nodeMap->req = std::make_unique<RenderRequest>(Nan::To<v8::Function>(info[1]).ToLocalChecked());
nodeMap->startRender(std::move(options));
@@ -463,7 +463,7 @@ void NodeMap::startRender(NodeMap::RenderOptions options) {
error = std::move(eptr);
uv_async_send(async);
} else {
- assert(!image.data);
+ assert(!image.valid());
image = frontend->readStillImage();
uv_async_send(async);
}
@@ -498,7 +498,7 @@ void NodeMap::renderFinished() {
// These have to be empty to be prepared for the next render call.
assert(!req);
- assert(!image.data);
+ assert(!image.valid());
v8::Local<v8::Function> callback = Nan::New(request->callback);
v8::Local<v8::Object> target = Nan::New<v8::Object>();
@@ -524,16 +524,16 @@ void NodeMap::renderFinished() {
assert(!error);
request->runInAsyncScope(target, callback, 1, argv);
- } else if (img.data) {
+ } else if (img.valid()) {
v8::Local<v8::Object> pixels = Nan::NewBuffer(
- reinterpret_cast<char *>(img.data.get()), img.bytes(),
+ reinterpret_cast<char *>(img.data()), img.bytes(),
// Retain the data until the buffer is deleted.
[](char *, void * hint) {
delete [] reinterpret_cast<uint8_t*>(hint);
},
- img.data.get()
+ img.data()
).ToLocalChecked();
- img.data.release();
+ img.takeData().release();
v8::Local<v8::Value> argv[] = {
Nan::Null(),
diff --git a/platform/qt/src/qt_image.cpp b/platform/qt/src/qt_image.cpp
index 302d398739..2a4dd23f40 100644
--- a/platform/qt/src/qt_image.cpp
+++ b/platform/qt/src/qt_image.cpp
@@ -7,7 +7,7 @@
namespace mbgl {
std::string encodePNG(const PremultipliedImage& pre) {
- QImage image(pre.data.get(), pre.size.width, pre.size.height,
+ QImage image(pre.data(), pre.size().width, pre.size().height,
QImage::Format_ARGB32_Premultiplied);
QByteArray array;