Reduce inconsistencies
This commit is contained in:
+1
-1
@@ -866,7 +866,7 @@ if (APPLE AND DAWN_WITH_WIP)
|
||||
|
||||
foreach (dn_launch_id IN ITEMS CropJpeg Commander)
|
||||
if (dn_launch_id STREQUAL CropJpeg)
|
||||
set(DN_LAUNCH_NAME "Dawn JPEG Cropper")
|
||||
set(DN_LAUNCH_NAME "Dawn Lossless JPEG Cropper")
|
||||
set(DN_LAUNCH_MODE cropjpeg)
|
||||
set(DN_LAUNCH_TYPE_NAME JPEG)
|
||||
set(DN_LAUNCH_UTI public.jpeg)
|
||||
|
||||
+1
-1
@@ -545,7 +545,7 @@ static constexpr ModeDef kModes[] = {
|
||||
// translate the word.
|
||||
{"view", N_("Dawn"), kViewerMenu, kViewerKeys},
|
||||
{"browse", N_("Dawn"), kBrowserMenu, kBrowserKeys},
|
||||
{"cropjpeg", N_("Dawn JPEG Cropper"), kCropJpegMenu, {}},
|
||||
{"cropjpeg", N_("Dawn Lassless JPEG Cropper"), kCropJpegMenu, {}},
|
||||
{"commander", N_("Dawn Commander"), kCommanderMenu, {}},
|
||||
};
|
||||
static_assert(size(kModes) == size_t(Mode::Count));
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ struct Browser : Widget {
|
||||
std::shared_ptr<dawn::Profile> screen_profile_;
|
||||
std::shared_ptr<const std::vector<uint8_t>> screen_icc_;
|
||||
|
||||
bool show_names_ = false;
|
||||
bool show_names_ = true;
|
||||
// The toolbar search field, whose text narrows the listing; it is
|
||||
// deliberately per-window, and not part of BrowseSetup.
|
||||
Entry *search_ = nullptr;
|
||||
|
||||
+9
-2
@@ -32,6 +32,7 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QLibraryInfo>
|
||||
#include <QLocale>
|
||||
#include <QStringList>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
#include <QtLogging>
|
||||
@@ -186,8 +187,14 @@ main(int argc, char **argv)
|
||||
QString::fromUtf8(_("Remove invalid wide thumbnails and exit.")));
|
||||
parser.addOption(invalidate_opt);
|
||||
|
||||
// These are stable command-line spellings, so they are never translated.
|
||||
QStringList mode_names;
|
||||
for (const dn::ModeDef &mode : dn::modes())
|
||||
mode_names += QLatin1String(mode.name);
|
||||
|
||||
const QCommandLineOption mode_opt(QStringLiteral("mode"),
|
||||
QString::fromUtf8(_("Application: view, browse, cropjpeg, commander.")),
|
||||
// TRANSLATORS: %1 is a comma-separated list of mode names.
|
||||
QString::fromUtf8(_("Application: %1.")).arg(mode_names.join(u", ")),
|
||||
QStringLiteral("mode"));
|
||||
parser.addOption(mode_opt);
|
||||
|
||||
@@ -272,7 +279,7 @@ main(int argc, char **argv)
|
||||
try_remote_open(session, to_open, mode, reported_mismatch))
|
||||
return *code;
|
||||
|
||||
// XXX: It might make more sense to do always do this.
|
||||
// XXX: It might make more sense to always do this.
|
||||
auto listen =
|
||||
dawn::ipc::Endpoint::listen(dawn::ipc::instance::kService);
|
||||
if (listen.status == dawn::ipc::Endpoint::ListenStatus::InUse) {
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ Options
|
||||
*--list-supported-extensions*::
|
||||
Output supported media types or file extensions and exit.
|
||||
|
||||
*-V*, *--version*::
|
||||
*-v*, *--version*::
|
||||
Output version information and exit.
|
||||
|
||||
Reporting bugs
|
||||
|
||||
+2
-2
@@ -64,7 +64,7 @@ function view_array_type(type) {
|
||||
}
|
||||
|
||||
function array_encode(f, type, ser) {
|
||||
ser = "\tencoder.u32(static_cast<uint32_t>(" f ".size()));\n"
|
||||
ser = "\tencoder.u32(uint32_t(" f ".size()));\n"
|
||||
if (type == "u8")
|
||||
return ser "\tencoder.bytes(" f ");\n"
|
||||
if (type == "i8")
|
||||
@@ -217,7 +217,7 @@ function emit_enum(name, cg, fields) {
|
||||
print "inline void encode(const " name \
|
||||
" &value, dawn::ipc::Encoder &encoder)"
|
||||
print "{"
|
||||
print "\tencoder.i8(static_cast<int8_t>(value));"
|
||||
print "\tencoder.i8(int8_t(value));"
|
||||
print "}"
|
||||
|
||||
print ""
|
||||
|
||||
@@ -46,7 +46,7 @@ to_utf8(CFStringRef value, Error *error)
|
||||
const CFIndex length = CFStringGetLength(value);
|
||||
const CFIndex maximum =
|
||||
CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
|
||||
vector<char> bytes(static_cast<size_t>(maximum));
|
||||
vector<char> bytes((size_t)maximum);
|
||||
if (!CFStringGetCString(
|
||||
value, bytes.data(), maximum, kCFStringEncodingUTF8)) {
|
||||
fail(error, _("cannot convert configuration string to UTF-8"));
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// libdn/gettext.h: message translation macros
|
||||
// libdn/gettext.hpp: message translation macros
|
||||
//
|
||||
// Copyright The Dawn Authors
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// libdn-loaders.h: internal loader entry points
|
||||
// libdn-loaders.hpp: internal loader entry points
|
||||
//
|
||||
// Copyright The Dawn Authors
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
+5
-3
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <lcms2.h>
|
||||
@@ -1581,6 +1581,7 @@ constexpr Loader kLoaders[] = {
|
||||
|
||||
{"libwebp", &load_webp, N_("WebP"), {"image/webp"}, {}},
|
||||
|
||||
// NIE not mentioned as it is practically a Wuffs internal format.
|
||||
{"Wuffs", &load_wuffs,
|
||||
N_("BMP, GIF, JPEG (subset), PNG, PNM, QOI, TARGA, WBMP, "
|
||||
"WebP (subset)"),
|
||||
@@ -1606,8 +1607,9 @@ constexpr Loader kLoaders[] = {
|
||||
{"image/openraster", "application/x-krita"}, {}},
|
||||
|
||||
// Try to extract full-size previews from TIFF/EP-compatible raws.
|
||||
{"TIFF/EP previews", &load_tiff_ep, N_("raw photos"),
|
||||
{"image/x-dcraw"}, {}},
|
||||
// XXX: The name should be translated, though it is an exception.
|
||||
{"TIFF/EP previews", &load_tiff_ep, N_("raw photos"), {"image/x-dcraw"},
|
||||
{}},
|
||||
|
||||
{"LibRaw",
|
||||
#if DAWN_WITH_LIBRAW
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
+2
-3
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <libdnrs.h>
|
||||
@@ -196,8 +196,7 @@ dnrs_media_types()
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_dnrs(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_dnrs(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
dnrs_error *raw_error = nullptr;
|
||||
DecoderPtr decoder(dnrs_decoder_new(
|
||||
|
||||
+3
-4
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#if DAWN_WITH_LIBHEIF
|
||||
@@ -178,7 +178,7 @@ load_heif_aux_images(const OpenContext &ctx, heif_image_handle *top,
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
vector<heif_item_id> ids(static_cast<size_t>(n));
|
||||
vector<heif_item_id> ids((size_t) n);
|
||||
n = heif_image_handle_get_list_of_auxiliary_image_IDs(
|
||||
top, filter, ids.data(), n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
@@ -202,8 +202,7 @@ load_heif_aux_images(const OpenContext &ctx, heif_image_handle *top,
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_heif(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_heif(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
// libheif will throw C++ exceptions on allocation failures.
|
||||
// The library is generally awful through and through.
|
||||
|
||||
+2
-3
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -484,8 +484,7 @@ decode_entry(const Entry &entry, const vector<Entry> &entries,
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_icns(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_icns(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
if (data.size() < 8 || memcmp(data.data(), "icns", 4)) {
|
||||
set_error(error, _("not an ICNS image"));
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
+2
-3
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <jpeglib.h>
|
||||
@@ -712,8 +712,7 @@ open_libjpeg_turbo(
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_jpeg(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_jpeg(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
if (data.size() < 2 || data[0] != 0xff || data[1] != 0xd8)
|
||||
return nullptr;
|
||||
|
||||
+2
-3
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#if DAWN_WITH_LIBJXL
|
||||
@@ -301,8 +301,7 @@ process_event(JxlLoadContext &ctx, bool *done, Error *error)
|
||||
// --- Public entry point ------------------------------------------------------
|
||||
|
||||
ImagePtr
|
||||
load_jxl(
|
||||
span<const uint8_t> data, const OpenContext &octx, Error *error)
|
||||
load_jxl(span<const uint8_t> data, const OpenContext &octx, Error *error)
|
||||
{
|
||||
JxlLoadContext ctx;
|
||||
ctx.octx = &octx;
|
||||
|
||||
+2
-3
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
// jxrlib's headers only parse as C++ in their ANSI configuration.
|
||||
@@ -269,8 +269,7 @@ decode_image(JxrLoadContext &ctx, const OpenContext &octx, Error *error)
|
||||
// --- Public entry point ------------------------------------------------------
|
||||
|
||||
ImagePtr
|
||||
load_jxr(
|
||||
span<const uint8_t> data, const OpenContext &octx, Error *error)
|
||||
load_jxr(span<const uint8_t> data, const OpenContext &octx, Error *error)
|
||||
{
|
||||
// This sits ahead of the fallback loaders, so it needs to say no quickly.
|
||||
// The rest of the container is jxrlib's business.
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#if DAWN_WITH_LIBRAW
|
||||
@@ -70,8 +70,7 @@ load_libraw_page(libraw_data_t *iprc, const OpenContext &ctx, Error *error)
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_libraw(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_libraw(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
// https://github.com/LibRaw/LibRaw/issues/418
|
||||
// Memory allocation failures are reported via return codes and need no
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <cairo.h>
|
||||
@@ -136,8 +136,7 @@ LibrsvgRenderClosure::render_internal(
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_librsvg(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_librsvg(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
GFile *base_file = g_file_new_for_uri(ctx.uri.c_str());
|
||||
GInputStream *is = g_memory_input_stream_new_from_data(
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <libwmf/api.h>
|
||||
@@ -185,8 +185,7 @@ render_wmf(vector<uint8_t> &data, uint32_t *width, uint32_t *height,
|
||||
: wmf_error_string(status));
|
||||
return nullptr;
|
||||
}
|
||||
return load_wuffs(
|
||||
{(const uint8_t *) device->memory, length}, ctx, error);
|
||||
return load_wuffs({(const uint8_t *) device->memory, length}, ctx, error);
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
@@ -216,8 +215,7 @@ WmfRenderClosure::render_internal(
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_libwmf(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_libwmf(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
vector<uint8_t> owned(data.begin(), data.end());
|
||||
uint32_t width = 0, height = 0;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#if DAWN_WITH_OPENJPEG
|
||||
@@ -405,8 +405,7 @@ build_image(OpenJpegLoadContext &ctx, Error *error)
|
||||
// --- Public entry point ------------------------------------------------------
|
||||
|
||||
ImagePtr
|
||||
load_openjpeg(
|
||||
span<const uint8_t> data, const OpenContext &octx, Error *error)
|
||||
load_openjpeg(span<const uint8_t> data, const OpenContext &octx, Error *error)
|
||||
{
|
||||
OPJ_CODEC_FORMAT format = detect_codec(data);
|
||||
if (format == OPJ_CODEC_UNKNOWN) {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <poppler-document.h>
|
||||
@@ -146,8 +146,7 @@ PopplerRenderClosure::render_internal(
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_poppler(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_poppler(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
if (!poppler::page_renderer::can_render()) {
|
||||
set_error(error, _("Poppler has been built without Splash"));
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <resvg.h>
|
||||
@@ -122,8 +122,7 @@ ResvgRenderClosure::render_internal(
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_resvg(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_resvg(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
resvg_options *opt = resvg_options_create();
|
||||
resvg_options_load_system_fonts(opt);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#define TIFF_TABLES_CONSTANTS_ONLY
|
||||
@@ -249,8 +249,8 @@ load_tiff_ep_page(const tiffer *T, const OpenContext &ctx, Error *error)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ImagePtr image = load_jpeg(
|
||||
span<const uint8_t>(out.jpeg, out.jpeg_length), ctx, error);
|
||||
ImagePtr image =
|
||||
load_jpeg(span<const uint8_t>(out.jpeg, out.jpeg_length), ctx, error);
|
||||
if (!image)
|
||||
return nullptr;
|
||||
|
||||
@@ -268,8 +268,7 @@ load_tiff_ep_page(const tiffer *T, const OpenContext &ctx, Error *error)
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_tiff_ep(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_tiff_ep(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
tiffer T = {};
|
||||
if (!tiffer_init(&T, data.data(), data.size())) {
|
||||
|
||||
+2
-3
@@ -15,7 +15,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <tiff.h>
|
||||
@@ -363,8 +363,7 @@ load_tiff_directory(TIFF *tiff, const OpenContext &ctx, Error *error)
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_tiff(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_tiff(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
// libtiff error handlers are process-global; serialize installs.
|
||||
static mutex tiff_handler_mutex;
|
||||
|
||||
+2
-3
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <webp/decode.h>
|
||||
@@ -218,8 +218,7 @@ load_webp_metadata(Image &image, const WebPData &wd, const OpenContext &ctx)
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_webp(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_webp(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
if (data.size() < 12 || memcmp(data.data(), "RIFF", 4) ||
|
||||
memcmp(data.data() + 8, "WEBP", 4))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// load-wuffs.cpp: BMP/GIF/NIE/PNG/PNM/QOI/TGA/WBMP loading via Wuffs
|
||||
// load-wuffs.cpp: Wuffs BMP/GIF/JPEG/NIE/PNG/PNM/QOI/TARGA/WBMP/WebP loader
|
||||
//
|
||||
// Copyright The Dawn Authors
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <cmath>
|
||||
@@ -555,8 +555,7 @@ inflate_raw(span<const uint8_t> src, span<uint8_t> dst)
|
||||
}
|
||||
|
||||
ImagePtr
|
||||
load_wuffs(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_wuffs(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
wuffs_base__slice_u8 prefix =
|
||||
wuffs_base__make_slice_u8((uint8_t *) data.data(), data.size());
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "libdn-loaders.h"
|
||||
#include "libdn-loaders.hpp"
|
||||
#include "libdn.hpp"
|
||||
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
@@ -127,8 +127,7 @@ load_xcursor_image(const XcursorImage *src)
|
||||
//
|
||||
// Unlike other formats, there is no meaningful colour management to apply.
|
||||
ImagePtr
|
||||
load_xcursor(
|
||||
span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
load_xcursor(span<const uint8_t> data, const OpenContext &ctx, Error *error)
|
||||
{
|
||||
if (data.size() > size_t(LONG_MAX)) {
|
||||
set_error(error, _("size overflow"));
|
||||
|
||||
@@ -103,8 +103,7 @@ check_vk(VkResult r, const char *what, string *error)
|
||||
{
|
||||
if (r != VK_SUCCESS) {
|
||||
if (error)
|
||||
*error = string(what) + " failed: VkResult " +
|
||||
to_string(static_cast<int>(r));
|
||||
*error = string(what) + " failed: VkResult " + to_string(int(r));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -59,7 +59,7 @@ reduced_dim(uint32_t n, uint32_t k)
|
||||
static bool
|
||||
higher(ThumbScaler::Priority a, ThumbScaler::Priority b)
|
||||
{
|
||||
return static_cast<uint8_t>(a) < static_cast<uint8_t>(b);
|
||||
return uint8_t(a) < uint8_t(b);
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -68,8 +68,7 @@ check_vk(VkResult r, const char *what, string *error)
|
||||
if (r == VK_SUCCESS)
|
||||
return true;
|
||||
if (error)
|
||||
*error = string(what) + " failed: VkResult " +
|
||||
to_string(static_cast<int>(r));
|
||||
*error = string(what) + " failed: VkResult " + to_string(int(r));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// libdnrs: image-rs and other decoders exposed through a small C ABI
|
||||
// lib.rs: image-rs and other Rust image decoders exposed through a small C ABI
|
||||
//
|
||||
// Copyright The Dawn Authors
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
Arguments='"%USERPROFILE%"'
|
||||
Icon='dn.ico' />
|
||||
<?if @DAWN_MSI_WIP@ = ON ?>
|
||||
<Shortcut Id='CropJpegShortcut' Name='Dawn JPEG Cropper'
|
||||
<Shortcut Id='CropJpegShortcut' Name='Dawn Lossless JPEG Cropper'
|
||||
Target='[INSTALLDIR]\dn.exe' WorkingDirectory='INSTALLDIR'
|
||||
Arguments='--mode=cropjpeg' Icon='dn.ico' />
|
||||
<Shortcut Id='CommanderShortcut' Name='Dawn Commander'
|
||||
|
||||
@@ -4,7 +4,7 @@ Name=dn
|
||||
GenericName=Image Browser
|
||||
X-GNOME-FullName=Dawn Colour-Managed Image Browser
|
||||
Icon=name.janouch.Dawn
|
||||
Exec=dn --mode=browse -- %u
|
||||
Exec=dn --mode=browse -- %U
|
||||
NoDisplay=true
|
||||
Terminal=false
|
||||
StartupNotify=true
|
||||
|
||||
@@ -81,6 +81,7 @@ endif()
|
||||
|
||||
if (APPLE AND DAWN_WITH_IMAGEIO)
|
||||
add_executable(test-imageio test-imageio.cpp)
|
||||
add_dependencies(test-imageio test-fixtures)
|
||||
target_link_libraries(test-imageio PRIVATE libdn)
|
||||
target_compile_definitions(test-imageio PRIVATE
|
||||
DAWN_TEST_FIXTURES_DIR="${DAWN_TEST_FIXTURES_DIR}"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "libdn/libdn-loaders.h"
|
||||
#include "libdn/libdn-loaders.hpp"
|
||||
#include "libdn/libdn.hpp"
|
||||
#include "test.hpp"
|
||||
|
||||
|
||||
+15
-13
@@ -5,52 +5,55 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
//
|
||||
|
||||
#include "libdn/libdn-loaders.h"
|
||||
#include "libdn/libdn-loaders.hpp"
|
||||
#include "libdn/libdn.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
const uint8_t pnm[] = "P6\n1 1\n255\n\x12\x34\x56";
|
||||
|
||||
dawn::OpenContext context;
|
||||
context.first_frame_only = false;
|
||||
dawn::Error error;
|
||||
dawn::ImagePtr image = dawn::load_dnrs(
|
||||
std::span(pnm, sizeof pnm - 1), context, &error);
|
||||
dawn::ImagePtr image =
|
||||
dawn::load_dnrs(span(pnm, sizeof pnm - 1), context, &error);
|
||||
if (!image || error)
|
||||
return 1;
|
||||
|
||||
if (image->width != 1 || image->height != 1 || image->frame_next ||
|
||||
image->page_next)
|
||||
return 2;
|
||||
|
||||
const uint16_t *pixel = dawn::row_u16(*image, 0);
|
||||
if (pixel[0] != 0x5656 || pixel[1] != 0x3434 || pixel[2] != 0x1212 ||
|
||||
pixel[3] != 0xffff)
|
||||
return 3;
|
||||
|
||||
image =
|
||||
dawn::open_from_data(std::span(pnm, sizeof pnm - 1), context, &error);
|
||||
image = dawn::open_from_data(span(pnm, sizeof pnm - 1), context, &error);
|
||||
if (!image || error || !image->loader ||
|
||||
std::string_view(image->loader) != "Wuffs")
|
||||
string_view(image->loader) != "Wuffs")
|
||||
return 4;
|
||||
|
||||
const uint8_t xbm[] = "#define dot_width 1\n"
|
||||
"#define dot_height 1\n"
|
||||
"static unsigned char dot_bits[] = { 0x01 };\n";
|
||||
image =
|
||||
dawn::open_from_data(std::span(xbm, sizeof xbm - 1), context, &error);
|
||||
if (!image || error || !image->loader ||
|
||||
std::string_view(image->loader) == "")
|
||||
dawn::open_from_data(span(xbm, sizeof xbm - 1), context, &error);
|
||||
if (!image || error || !image->loader || string_view(image->loader) == "")
|
||||
return 5;
|
||||
|
||||
const uint8_t pnm16[] = "P6\n1 1\n65535\n\x12\x34\x56\x78\x9a\xbc";
|
||||
image = dawn::load_dnrs(
|
||||
std::span(pnm16, sizeof pnm16 - 1), context, &error);
|
||||
image = dawn::load_dnrs(span(pnm16, sizeof pnm16 - 1), context, &error);
|
||||
if (!image || error)
|
||||
return 6;
|
||||
|
||||
pixel = dawn::row_u16(*image, 0);
|
||||
if (pixel[0] != 0x9abc || pixel[1] != 0x5678 || pixel[2] != 0x1234 ||
|
||||
pixel[3] != 0xffff)
|
||||
@@ -58,8 +61,7 @@ main()
|
||||
|
||||
const uint8_t junk[] = "not an image";
|
||||
error = {};
|
||||
image = dawn::load_dnrs(
|
||||
std::span(junk, sizeof junk - 1), context, &error);
|
||||
image = dawn::load_dnrs(span(junk, sizeof junk - 1), context, &error);
|
||||
if (image || !error)
|
||||
return 8;
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <dawn-config.h>
|
||||
|
||||
#include "libdn/libdn-loaders.h"
|
||||
#include "libdn/libdn-loaders.hpp"
|
||||
#include "libdn/libdn.hpp"
|
||||
#include "test.hpp"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user