// The following generator accessors are safe without acquiring the mutex (const getters). // TODO: refactor to use a ScopedGenerator instead, for clarity.
fInfo = fSharedGenerator->fGenerator->getInfo(); if (fInfo.isEmpty()) {
fSharedGenerator.reset(); return;
}
sk_sp<SkData> SkImage_Lazy::onRefEncoded() const { // check that we aren't a subset or colortype/etc modification of the original if (fSharedGenerator->fGenerator->uniqueID() == this->uniqueID()) {
ScopedGenerator generator(fSharedGenerator); return generator->refEncodedData();
} return nullptr;
}
sk_sp<SkImage> SkImage_Lazy::onMakeSubset(GrDirectContext*, const SkIRect& subset) const { // neither picture-backed nor codec-backed lazy images need the context to do readbacks. // The subclass for cross-context images *does* use the direct context. auto pixels = this->makeRasterImage(nullptr); return pixels ? pixels->makeSubset(nullptr, subset) : nullptr;
}
sk_sp<SkImage> SkImage_Lazy::onMakeSubset(skgpu::graphite::Recorder*, const SkIRect& subset,
RequiredProperties props) const { // TODO: can we do this more efficiently, by telling the generator we want to // "realize" a subset?
sk_sp<SkImage> nonLazyImg = this->makeRasterImage(nullptr); if (!nonLazyImg) { return nullptr;
} return nonLazyImg->makeSubset(nullptr, subset, props);
}
sk_sp<SkImage> SkImage_Lazy::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS) const { // TODO: The correct thing is to clone the generator, and modify its color space. That's hard, // because we don't have a clone method, and generator is public (and derived-from by clients). // So do the simple/inefficient thing here, and fallback to raster when this is called.
// We allocate the bitmap with the new color space, then generate the image using the original.
SkBitmap bitmap; if (bitmap.tryAllocPixels(this->imageInfo().makeColorSpace(std::move(newCS)))) {
SkPixmap pixmap = bitmap.pixmap();
pixmap.setColorSpace(this->refColorSpace()); if (ScopedGenerator(fSharedGenerator)->getPixels(pixmap)) {
bitmap.setImmutable(); return bitmap.asImage();
}
} return nullptr;
}
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.