Format C / C++ with Chromium style

This commit is contained in:
Ingvar Stepanyan
2020-05-12 18:36:38 +01:00
committed by Ingvar Stepanyan
parent de543b3206
commit a95cb740bf
5 changed files with 149 additions and 156 deletions

View File

@@ -1,8 +1,8 @@
#include <string>
#include "emscripten/bind.h"
#include "emscripten/val.h"
#include "src/webp/decode.h"
#include "src/webp/demux.h"
#include <string>
using namespace emscripten;
@@ -11,24 +11,19 @@ int version() {
}
class RawImage {
public:
public:
val buffer;
int width;
int height;
RawImage(val b, int w, int h)
: buffer(b), width(w), height(h) {}
RawImage(val b, int w, int h) : buffer(b), width(w), height(h) {}
};
uint8_t* last_result;
RawImage decode(std::string buffer) {
int width, height;
last_result = WebPDecodeRGBA((const uint8_t*)buffer.c_str(), buffer.size(), &width, &height);
return RawImage(
val(typed_memory_view(width*height*4, last_result)),
width,
height
);
return RawImage(val(typed_memory_view(width * height * 4, last_result)), width, height);
}
void free_result() {
@@ -37,9 +32,9 @@ void free_result() {
EMSCRIPTEN_BINDINGS(my_module) {
class_<RawImage>("RawImage")
.property("buffer", &RawImage::buffer)
.property("width", &RawImage::width)
.property("height", &RawImage::height);
.property("buffer", &RawImage::buffer)
.property("width", &RawImage::width)
.property("height", &RawImage::height);
function("decode", &decode);
function("version", &version);