Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/gfx/skia/skia/src/core/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  SkRasterPipelineContextUtils.h   Sprache: C

 
/*
 * Copyright 2023 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#ifndef SkRasterPipelineContextUtils_DEFINED
#define SkRasterPipelineContextUtils_DEFINED

#include "src/base/SkArenaAlloc.h"
#include "src/base/SkUtils.h"

#include <cstring>
#include <type_traits>

namespace SkRPCtxUtils {

template <typename T>
using UnpackedType = typename std::conditional<sizeof(T) <= sizeof(void*), T, const T&>::type;

/**
 * SkRPCtxUtils::Pack will check if the passed-in struct is small enough to fit directly in the
 * context field. If so, it will return the data bit-casted into a void pointer. If not, it
 * allocates a copy of the struct inside the alloc and then returns a pointer to the copy.
 */

template <typename T>
[[maybe_unused]] static voidPack(const T& ctx, SkArenaAlloc* alloc) {
    // If the context is small enough to fit in a pointer, bit-cast it; if not, alloc a copy.
    if constexpr (sizeof(T) <= sizeof(void*)) {
        return sk_bit_cast<void*>(ctx);
    } else {
        return alloc->make<T>(ctx);
    }
}

/**
 * SkRPCtxUtils::Unpack performs the reverse operation: either un-bitcasting the object back to its
 * original form, or returning the pointer as-is, depending on the size of the type.
 */

template <typename T>
[[maybe_unused]] static UnpackedType<T> Unpack(const T* ctx) {
    // If the context struct fits in a pointer, reinterpret the bits; if it doesn't, return
    // a reference. This can vary based on the architecture (32-bit pointers vs 64-bit) so we
    // let the compiler decide which is right, rather than hard-coding it.
    if constexpr (sizeof(T) <= sizeof(void*)) {
        return sk_bit_cast<T>(ctx);
    } else {
        return *ctx;
    }
}

}  // namespace SkRPCtxUtils

#endif  // SkRasterPipelineContextUtils_DEFINED

Messung V0.5
C=98 H=94 G=95

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.