Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  SkMipmapDrawDownSampler.cpp   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.
 */


#include "include/core/SkTypes.h"

#ifdef SK_USE_DRAWING_MIPMAP_DOWNSAMPLER

#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkScalar.h"
#include "src/core/SkDraw.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkRasterClip.h"
#include <memory>

namespace {

struct DrawDownSampler : SkMipmapDownSampler {
    SkPaint fPaint;

    DrawDownSampler() {
        // For efficiency, we want to be in src mode when building levels
        // to avoid any extra trying to "blend".
        fPaint.setBlendMode(SkBlendMode::kSrc);
    }

    void buildLevel(const SkPixmap& dst, const SkPixmap& src) override;
};

static SkSamplingOptions choose_options(const SkPixmap& dst, const SkPixmap& src) {
    // if we're a perfect 2x2 downscale, just use bilerp
    if (dst.width() * 2 == src.width() && dst.height() * 2 == src.height()) {
        return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone);
    }
    // general case -- might experiment with different cubic parameter values
    const auto cubic = SkCubicResampler::CatmullRom();
    return SkSamplingOptions(cubic);
}

void DrawDownSampler::buildLevel(const SkPixmap& dst, const SkPixmap& src) {
    const SkRasterClip rclip(dst.bounds());
    const SkMatrix mx = SkMatrix::Scale(SkIntToScalar(dst.width())  / src.width(),
                                        SkIntToScalar(dst.height()) / src.height());
    const auto sampling = choose_options(dst, src);

    SkDraw draw;
    draw.fDst = dst;
    draw.fCTM = &mx;
    draw.fRC = &rclip;

    SkBitmap bitmap;
    bitmap.installPixels(src.info(), const_cast<void*>(src.addr()), src.rowBytes());

    draw.drawBitmap(bitmap, SkMatrix::I(), nullptr, sampling, fPaint);
}

// namespace

std::unique_ptr<SkMipmapDownSampler> SkMipmap::MakeDownSampler(const SkPixmap& root) {
    return std::make_unique<DrawDownSampler>();
}

#endif

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

¤ Dauer der Verarbeitung: 0.12 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge