mirror of
https://github.com/hyprwm/hyprgraphics.git
synced 2026-01-03 14:30:10 +01:00
internal: fix style as determined by clang (#27)
This commit is contained in:
parent
5f9c68e3f8
commit
a71c0529d1
2 changed files with 6 additions and 8 deletions
|
|
@ -1,8 +1,6 @@
|
|||
#include "Png.hpp"
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
|
@ -39,13 +37,13 @@ std::expected<cairo_surface_t*, std::string> PNG::createSurfaceFromPNG(co
|
|||
return loadPNG(png, info);
|
||||
}
|
||||
|
||||
struct ReadState {
|
||||
struct SReadState {
|
||||
const std::span<uint8_t>& data;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
void custom_read_function(png_structp png, png_bytep data, png_size_t length) {
|
||||
ReadState* state = static_cast<ReadState*>(png_get_io_ptr(png));
|
||||
static void customReadFunction(png_structp png, png_bytep data, png_size_t length) {
|
||||
SReadState* state = static_cast<SReadState*>(png_get_io_ptr(png));
|
||||
if (state->offset + length > state->data.size()) {
|
||||
png_error(png, "read error");
|
||||
return;
|
||||
|
|
@ -66,9 +64,9 @@ std::expected<cairo_surface_t*, std::string> PNG::createSurfaceFromPNG(const std
|
|||
if (setjmp(png_jmpbuf(png)))
|
||||
return std::unexpected("loading png: couldn't setjmp");
|
||||
|
||||
ReadState readState = {data, 0};
|
||||
SReadState readState = {.data = data, .offset = 0};
|
||||
|
||||
png_set_read_fn(png, &readState, custom_read_function);
|
||||
png_set_read_fn(png, &readState, customReadFunction);
|
||||
png_set_sig_bytes(png, 0);
|
||||
|
||||
return loadPNG(png, info);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ static bool tryLoadImageFromBuffer(const std::span<uint8_t>& data) {
|
|||
return cairo_surface_write_to_png(image.cairoSurface()->cairo(), (TEST_DIR + "/" + name + ".png").c_str()) == CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> getImageBuffer(const std::string& path) {
|
||||
static std::vector<uint8_t> getImageBuffer(const std::string& path) {
|
||||
std::vector<uint8_t> buffer;
|
||||
|
||||
std::ifstream file("./resource/images/hyprland.png", std::ios::binary | std::ios::ate);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue