/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/ #include"include/ports/SkImageGeneratorCG.h"
if (SkEncodedOriginSwapsWidthHeight(origin)) {
info = SkPixmapUtils::SwapWidthHeight(info);
}
// FIXME: We have the opportunity to extract color space information here, // though I think it makes sense to wait until we understand how // we want to communicate it to the generator.
bool ImageGeneratorCG::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options&)
{ if (kN32_SkColorType != info.colorType()) { // FIXME: Support other colorTypes. returnfalse;
}
switch (info.alphaType()) { case kOpaque_SkAlphaType: if (kOpaque_SkAlphaType != this->getInfo().alphaType()) { returnfalse;
} break; case kPremul_SkAlphaType: break; default: returnfalse;
}
SkUniqueCFRef<CGImageRef> image(CGImageSourceCreateImageAtIndex(fImageSrc.get(), 0, nullptr)); if (!image) { returnfalse;
}
SkPixmap dst(info, pixels, rowBytes); auto decode = [&image](const SkPixmap& pm) { // FIXME: Using SkCopyPixelsFromCGImage (as opposed to swizzling // ourselves) greatly restricts the color and alpha types that we // support. If we swizzle ourselves, we can add support for: // kUnpremul_SkAlphaType // 16-bit per component RGBA // kGray_8_SkColorType // Additionally, it would be interesting to compare the performance // of SkSwizzler with CG's built in swizzler. return SkCopyPixelsFromCGImage(pm, image.get());
}; return SkPixmapUtils::Orient(dst, fOrigin, decode);
}
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.