// 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<const 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(SkRecorder*, 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<SkSurface> SkImage_Lazy::onMakeSurface(SkRecorder* recorder, const SkImageInfo& info) const { if (!recorder) { // TODO(kjlubick) remove this after old SkImage::makeScaled(image info, sampling) API gone
recorder = skcpu::Recorder::TODO();
} const SkSurfaceProps* props = nullptr;
constexpr size_t rowBytes = 0; return recorder->cpuRecorder()->makeBitmapSurface(info, rowBytes, 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 SkImages::RasterFromBitmap(bitmap);
}
} 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.