惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
罗磊的独立博客
C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
I
InfoQ
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
B
Blog RSS Feed

Martin Owens activity

Martin Owens deleted project branch average-color-divide at Inkscape / inkscape Fix divide-by-zero crash when using calligraphy tool (!7923) · Merge requests · Inkscape / inkscape · GitLab Add selection file to bypass Windows command length limits (correction) (865df7a5) · Commits · Inkscape / inkscape · GitLab Draft: Fix AppImage crashing during save on older distros (!7922) · Merge requests · Inkscape / inkscape · GitLab e71fa7f8e0858aab87b7fc0814a30a8c88da9b43 to fe225a6b9e1042c7221d95173be22a02b3725337 · Martin Owens / inkscape · GitLab 403 Forbidden on Inkscape web server (#693) · Issues · Inkscape / inkscape-web · GitLab 403 Forbidden on Inkscape web server (#13509) · Issues · Inkscape / Inbox · GitLab Add selection file to bypass Windows command length limits (correction) (!7917) · 合并请求 · Inkscape / inkscape · GitLab Non-vertical axonometric axis implementation (!7912) · Merge requests · Inkscape / inkscape · GitLab Update split mode on tab switch (!7915) · Merge requests · Inkscape / inkscape · GitLab inset/offset as app functions so they can be used from CLI (!7914) · Merge requests · Inkscape / inkscape · GitLab Performace regresion in last month (#5879) · Issues · Inkscape / inkscape · GitLab [Regression] Right-aligned text has a new gap in 1.4.4 (#6130) · Issues · Inkscape / inkscape · GitLab [Regression] Right-aligned text has a new gap in 1.4.4 (#13498) · Issues · Inkscape / Inbox · GitLab c503804e014994d611de1b225bee8158c06448a8 to a4588d8ead1e7049b90c5a126962746ed286ab17 · Inkscape / inkscape-web · GitLab Validate the extensions of signature file uploads (a4588d8e) · 提交 · Inkscape / inkscape-web · GitLab Allow color conversions using static arrays instead of just vectors (e71fa7f8) · 提交 · Martin Owens / inkscape · GitLab Speed up ungroup on thousands of items (!7908) · Merge requests · Inkscape / inkscape · GitLab Incorrect handling of FontMatrix and transformation matrices with internal PDF import (#4845) · Issues · Inkscape / inkscape · GitLab Handling edge case of negative fonts in PDF (59040229) · 提交 · Inkscape / inkscape · GitLab Handling edge case of negative fonts in PDF (!7911) · 合并请求 · Inkscape / inkscape · GitLab Allow color conversions using static arrays instead of just vectors (33e65d1b) · Commits · Martin Owens / inkscape · GitLab Allow color conversions using static arrays instead of just vectors (9be5f867) · Commits · Martin Owens / inkscape · GitLab a9672ea1dff483b5b3aa8c6b5d88cd223001bef5 to 512a5e57602ac52e1d35782a7dcebae04262b2b8 · Martin Owens / inkscape · GitLab Add selection file to bypass Windows command length limits (!7905) · 合并请求 · Inkscape / inkscape · GitLab Revert Pango label changes (1.4.x) (!7907) · 合并请求 · Inkscape / inkscape · GitLab Crash on selecting a `<text>` object without a `<tspan>` inside (#5462) · Issues · Inkscape / inkscape · GitLab Fix breakage with Ubuntu 26.04 CI (!7904) · 合并请求 · Inkscape / inkscape · GitLab c673fdd5148253276826d4eda3951daaefb82607 to 356b31383ba324396a225686613236484305533d · Martin Owens / inkscape · GitLab Revert Text tool cursor changes (1.4.x) (!7903) · 合并请求 · Inkscape / inkscape · GitLab
Allow color conversions using static arrays instead of ju...
Martin Owens · 2026-05-19 · via Martin Owens activity
Commit 8e8c93de authored by Martin Owens's avatar Martin Owens 🕘
Browse files
Most color conversion will be done with std::vectors of doubles
but to speed up and provide compile time checks for color converting
on Surfaces we want the ability to take an array directly at some
but not all of the various levels.

Formalise the interface for ProfileSpace and the Convertable type
using a self-referential templating pattern.

Move most conversion code to static functions and make as agnostic
to the array type as possible, allowing for convertors to use them
directly without expensive vector types.
+1 −4
Original line number Diff line number Diff line
@@ -9,13 +9,11 @@ set(colors_unit_SRC
	parser.cpp
	printer.cpp
	gradient-averager.cpp
	spaces/alpha.cpp
	spaces/base.cpp
	spaces/cms.cpp
	spaces/cmyk.cpp
	spaces/components.cpp
	spaces/gamut.cpp
	spaces/gray.cpp
	spaces/hsl.cpp
	spaces/hsluv.cpp
	spaces/hsv.cpp
@@ -24,8 +22,6 @@ set(colors_unit_SRC
	spaces/linear-rgb.cpp
	spaces/luv.cpp
	spaces/ok-color.cpp
	spaces/okhsl.cpp
	spaces/okhsv.cpp
	spaces/oklab.cpp
	spaces/oklch.cpp
	spaces/named.cpp
@@ -49,6 +45,7 @@ set(colors_unit_SRC
	spaces/cms.h
	spaces/cmyk.h
	spaces/components.h
	spaces/convert-static.h
	spaces/enum.h
	spaces/gamut.h
	spaces/gray.h
+6 −6
Original line number Diff line number Diff line
@@ -264,14 +264,14 @@ const std::shared_ptr<TransformSurface> &System::getDisplayTransform()
            // No High bit depths here! Just low resolution gamma curved sRGB.
            // TODO: Replace with something with a better gammut and depth.
            TransformSurface::Format in = {
                Profile::create_srgb(), // sRGB profile input
                sizeof(char),           // Char 8 per channel
                true,                   // Integral
                .profile = Profile::create_srgb(),
                .byte_count = sizeof(char), // Char 8 per channel
                .integral = true,
            };
            TransformSurface::Format out = {
                display_profile,
                sizeof(char),
                true,
                .profile = display_profile,
                .byte_count = sizeof(char),
                .integral = true,
            };
            _display_transform = std::make_shared<TransformSurface>(in, out);
        } else {
+8 −0
Original line number Diff line number Diff line
@@ -26,6 +26,14 @@ public:

    bool do_transform(std::vector<double> &io) const;

    template <typename In, typename Out>
    bool do_transform(In const &i, Out &o)
    {
        assert(i.size() >= _channels_in && o.size() >= _channels_out);
        cmsDoTransform(_handle, &i.front(), &o.front(), 1);
        return true;
    }

private:

    int _channels_in;
+6 −3
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ class TransformContext
         fprintf(stderr, "  ---- LCMS error: %s (ErrorCode: %d)\n", Text, ErrorCode);
    }  
public:
    TransformContext(TransformContext const &) = delete;
    TransformContext &operator=(TransformContext const &) = delete;

    TransformContext()
        : _context{cmsCreateContext(nullptr, nullptr)}
    {
@@ -60,7 +63,7 @@ public:
     */
    struct Format
    {
        std::shared_ptr<Profile> const profile;
        std::shared_ptr<Profile> profile;

        int  byte_count;
        bool integral;
@@ -78,8 +81,8 @@ public:
     * @arg proof_intent - An optional intent for the proofing conversion
     * @arg gamut_warn   - Optional flag for rendering out of gamut colors with a warning color.
     */
    TransformSurface(Format input,
                     Format output,
    TransformSurface(Format const &input,
                     Format const &output,
                     RenderingIntent intent = RenderingIntent::PERCEPTUAL,
                     std::shared_ptr<Profile> const &proof = nullptr,
                     RenderingIntent proof_intent = RenderingIntent::AUTO,
+1 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ bool Color::convert(Color const &other)
 */
bool Color::convert(std::shared_ptr<Space::AnySpace> to_space)
{
    if (!to_space || !to_space->isValid()) {
    if (!to_space || !to_space->hasValidCmsProfile()) {
        return false;
    }