Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/gfx/skia/skia/src/core/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  SkWriter32.cpp

  Sprache: C
 

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


#include "src/core/SkWriter32.h"

#include "include/core/SkSamplingOptions.h"
#include "include/private/base/SkTo.h"
#include "src/core/SkMatrixPriv.h"

#include <algorithm>

class SkMatrix;

void SkWriter32::writeMatrix(const SkMatrix& matrix) {
    size_t size = SkMatrixPriv::WriteToMemory(matrix, nullptr);
    SkASSERT(SkAlign4(size) == size);
    SkMatrixPriv::WriteToMemory(matrix, this->reserve(size));
}

void SkWriter32::writeSampling(const SkSamplingOptions& sampling) {
    this->write32(sampling.maxAniso);
    if (!sampling.isAniso()) {
        this->writeBool(sampling.useCubic);
        if (sampling.useCubic) {
            this->writeScalar(sampling.cubic.B);
            this->writeScalar(sampling.cubic.C);
        } else {
            this->write32((unsigned)sampling.filter);
            this->write32((unsigned)sampling.mipmap);
        }
    }
}

void SkWriter32::writeString(const char str[], size_t len) {
    if (nullptr == str) {
        str = "";
        len = 0;
    }
    if ((long)len < 0) {
        len = strlen(str);
    }

    // [ 4 byte len ] [ str ... ] [1 - 4 \0s]
    uint32_t* ptr = this->reservePad(sizeof(uint32_t) + len + 1);
    *ptr = SkToU32(len);
    char* chars = (char*)(ptr + 1);
    memcpy(chars, str, len);
    chars[len] = '\0';
}

size_t SkWriter32::WriteStringSize(const char* str, size_t len) {
    if ((long)len < 0) {
        SkASSERT(str);
        len = strlen(str);
    }
    const size_t lenBytes = 4;    // we use 4 bytes to record the length
    // add 1 since we also write a terminating 0
    return SkAlign4(lenBytes + len + 1);
}

void SkWriter32::growToAtLeast(size_t size) {
    const bool wasExternal = (fExternal != nullptr) && (fData == fExternal);

    fCapacity = 4096 + std::max(size, fCapacity + (fCapacity / 2));
    fInternal.realloc(fCapacity);
    fData = fInternal.get();

    if (wasExternal) {
        // we were external, so copy in the data
        memcpy(fData, fExternal, fUsed);
    }
}

sk_sp<SkData> SkWriter32::snapshotAsData() const {
    return SkData::MakeWithCopy(fData, fUsed);
}

Messung V0.5 in Prozent
C=91 H=95 G=92

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.