/* * Copyright 2012 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/ #include"src/image/SkImage_Raster.h"
// SkImage::withMipmaps will always make a copy for us so we can temporarily share // the pixel ref with fBitmap
SkBitmap tmpSubset; if (!fBitmap.extractSubset(&tmpSubset, subset)) { return nullptr;
}
// withMipmaps will auto generate the mipmaps if a nullptr is passed in
SkASSERT(!mips || mips->validForRootLevel(tmp->imageInfo()));
img = tmp->withMipmaps(std::move(mips));
} else {
SkBitmap copy = copy_bitmap_subset(fBitmap, subset); if (!copy.isNull()) {
img = copy.asImage();
}
}
bool SkImage_Raster::onAsLegacyBitmap(GrDirectContext*, SkBitmap* bitmap) const { // When we're a snapshot from a surface, our bitmap may not be marked immutable // even though logically always we are, but in that case we can't physically share our // pixelref since the caller might call setImmutable() themselves // (thus changing our state). if (fBitmap.isImmutable()) {
SkIPoint origin = fBitmap.pixelRefOrigin();
bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
bitmap->setPixelRef(sk_ref_sp(fBitmap.pixelRef()), origin.x(), origin.y()); returntrue;
} return this->SkImage_Base::onAsLegacyBitmap(nullptr, bitmap);
}
sk_sp<SkImage> SkImage_Raster::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS) const{ // TODO: If our bitmap is immutable, then we could theoretically create another image sharing // our pixelRef. That doesn't work (without more invasive logic), because the image gets its // gen ID from the bitmap, which gets it from the pixelRef.
SkPixmap pixmap = fBitmap.pixmap();
pixmap.setColorSpace(std::move(newCS)); return SkImages::RasterFromPixmapCopy(pixmap);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
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.