summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Morris <michael.patrick.morris@gmail.com>2015-05-15 13:24:04 -0400
committerMike Morris <michael.patrick.morris@gmail.com>2015-05-15 13:24:04 -0400
commit830a9b3972a1934e6b059da54a0ff282a8581088 (patch)
tree8082bcfbd4165f1b87dbe6a23c622b43c09aebf7
parent2d5a73b25b601d876047663832d4a0c71a2a4830 (diff)
downloadqtlocation-mapboxgl-830a9b3972a1934e6b059da54a0ff282a8581088.tar.gz
drop CompressPNG
-rw-r--r--binding.gyp2
-rw-r--r--src/compress_png.cpp106
-rw-r--r--src/compress_png.hpp14
-rw-r--r--src/node_mapbox_gl_native.cpp2
4 files changed, 0 insertions, 124 deletions
diff --git a/binding.gyp b/binding.gyp
index 9c7cade1d9..a5fb583399 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -11,8 +11,6 @@
'sources': [
'src/node_mapbox_gl_native.cpp',
- 'src/compress_png.hpp',
- 'src/compress_png.cpp',
'src/node_log.hpp',
'src/node_log.cpp',
'src/node_file_source.hpp',
diff --git a/src/compress_png.cpp b/src/compress_png.cpp
deleted file mode 100644
index 99cec5b1b1..0000000000
--- a/src/compress_png.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "compress_png.hpp"
-#include <mbgl/util/image.hpp>
-
-namespace node_mbgl {
-
-class CompressPNGWorker : public NanAsyncWorker {
-public:
- CompressPNGWorker(NanCallback *callback_, v8::Local<v8::Object> buffer_, uint32_t width_,
- uint32_t height_)
- : NanAsyncWorker(callback_),
- data(node::Buffer::Data(buffer_)),
- width(width_),
- height(height_) {
- NanAssignPersistent(buffer, buffer_);
- assert(width * height * 4 == node::Buffer::Length(buffer_));
- }
-
- ~CompressPNGWorker() {
- NanDisposePersistent(buffer);
- }
-
- void Execute() {
- result = mbgl::util::compress_png(width, height, data);
- }
-
- void HandleOKCallback() {
- NanScope();
-
- auto img = new std::string(std::move(result));
-
- v8::Local<v8::Value> argv[] = {
- NanNull(),
- NanNewBufferHandle(
- const_cast<char *>(img->data()),
- img->size(),
- // Retain the std::string until the buffer is deleted.
- [](char *, void *hint) {
- delete reinterpret_cast<std::string *>(hint);
- },
- img
- )
- };
-
- callback->Call(2, argv);
- };
-
-private:
- // Retains the buffer while this worker is processing. The user may not modify the buffer.
- v8::Persistent<v8::Object> buffer;
- void *data;
- const uint32_t width;
- const uint32_t height;
-
- // Stores the compressed PNG.
- std::string result;
-};
-
-NAN_METHOD(CompressPNG) {
- NanScope();
-
- if (args.Length() <= 0 || !args[0]->IsObject()) {
- return NanThrowTypeError("First argument must be the data object");
- }
-
- uint32_t width = 0;
- uint32_t height = 0;
- v8::Local<v8::Object> buffer;
-
- auto options = args[0]->ToObject();
- if (options->Has(NanNew("width"))) {
- width = options->Get(NanNew("width"))->Uint32Value();
- }
- if (!width) {
- NanThrowRangeError("Image width must be greater than 0");
- }
- if (options->Has(NanNew("height"))) {
- height = options->Get(NanNew("height"))->Uint32Value();
- }
- if (!height) {
- NanThrowRangeError("Image height must be greater than 0");
- }
- if (options->Has(NanNew("pixels"))) {
- buffer = options->Get(NanNew("pixels")).As<v8::Object>();
- }
- if (!node::Buffer::HasInstance(buffer)) {
- NanThrowTypeError("Pixels must be a Buffer object");
- }
- if (width * height * 4 != node::Buffer::Length(buffer)) {
- NanThrowError("Pixel buffer doesn't match image dimensions");
- }
-
- if (args.Length() < 2) {
- NanThrowTypeError("Second argument must be a callback function");
- }
- NanCallback *callback = new NanCallback(args[1].As<v8::Function>());
-
- NanAsyncQueueWorker(new CompressPNGWorker(callback, buffer, width, height));
- NanReturnUndefined();
-}
-
-void InitCompressPNG(v8::Handle<v8::Object> target) {
- target->Set(NanNew<v8::String>("compressPNG"),
- NanNew<v8::FunctionTemplate>(CompressPNG)->GetFunction());
-}
-
-}
diff --git a/src/compress_png.hpp b/src/compress_png.hpp
deleted file mode 100644
index 805181a634..0000000000
--- a/src/compress_png.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#pragma GCC diagnostic ignored "-Wshadow"
-#include <node.h>
-#include <nan.h>
-#pragma GCC diagnostic pop
-
-namespace node_mbgl {
-
-void InitCompressPNG(v8::Handle<v8::Object> target);
-
-}
diff --git a/src/node_mapbox_gl_native.cpp b/src/node_mapbox_gl_native.cpp
index a7a0f0fcf6..f4788802e3 100644
--- a/src/node_mapbox_gl_native.cpp
+++ b/src/node_mapbox_gl_native.cpp
@@ -9,7 +9,6 @@
#include "node_map.hpp"
#include "node_log.hpp"
#include "node_request.hpp"
-#include "compress_png.hpp"
void RegisterModule(v8::Handle<v8::Object> exports) {
NanScope();
@@ -17,7 +16,6 @@ void RegisterModule(v8::Handle<v8::Object> exports) {
node_mbgl::NodeFileSource::Init(exports);
node_mbgl::NodeMap::Init(exports);
node_mbgl::NodeRequest::Init(exports);
- node_mbgl::InitCompressPNG(exports);
// Exports Resource constants.
auto ConstantProperty = static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);