Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  SkWritePixelsRec.cpp

  Sprache: C
 

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


#include "src/core/SkWritePixelsRec.h"

#include "include/core/SkRect.h"
#include "src/base/SkSafeMath.h"

bool SkWritePixelsRec::trim(int dstWidth, int dstHeight) {
    // fInfo.minRowBytes() returns 0 if the size doesn't fit in `size_t`.
    const size_t minRowBytes = fInfo.minRowBytes();
    if (nullptr == fPixels || fRowBytes < minRowBytes || minRowBytes == 0) {
        return false;
    }
    if (0 >= fInfo.width() || 0 >= fInfo.height()) {
        return false;
    }
    // negating the largest negative integer (below) is UB
    if (fX == INT_MIN || fY == INT_MIN) {
        return false;
    }

    int x = fX;
    int y = fY;
    SkIRect dstR = SkIRect::MakeXYWH(x, y, fInfo.width(), fInfo.height());
    if (!dstR.intersect({00, dstWidth, dstHeight})) {
        return false;
    }

    // if x or y are negative, then we have to adjust pixels
    if (x > 0) {
        x = 0;
    }
    if (y > 0) {
        y = 0;
    }
    // here x,y are either 0 or negative (safe to cast to size_t)
    // we negate and add them so UBSAN (pointer-overflow) doesn't get confused.
    SkSafeMath safeMath;
    const size_t y_offset = safeMath.mul(-y, fRowBytes);
    const size_t x_offset = safeMath.mul(-x, fInfo.bytesPerPixel());
    const size_t total = safeMath.add(y_offset, x_offset);
    if (!safeMath.ok()) {
        return false;
    }

    fPixels = ((const char*)fPixels + total);
    // the intersect may have shrunk info's logical size
    fInfo = fInfo.makeDimensions(dstR.size());
    fX = dstR.x();
    fY = dstR.y();

    return true;
}

Messung V0.5 in Prozent
C=95 H=97 G=95

¤ 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002