114 bool flushPendingGrContextIO,
119 auto ib =
as_IB(img);
151 std::move(releaseHelper));
161 return sk_make_sp<SkImage_Ganesh>(
sk_ref_sp(context),
164 SkColorInfo(ct, alphaType, std::move(colorSpace)));
190 return sk_make_sp<SkImage_Ganesh>(
216 caps, backendTexture, grColorType,
colorType, alphaType, colorSpace)) {
225 std::move(colorSpace),
227 std::move(releaseHelper));
258 const GrCaps* caps = dContext->priv().caps();
266 caps, backendTexture, grColorType,
colorType, alphaType, colorSpace)) {
275 std::move(colorSpace),
287 if (!direct || !data) {
310 return sk_make_sp<SkImage_Ganesh>(
sk_ref_sp(direct),
329 textureReleaseProc = textureReleaseProc ? textureReleaseProc : [](
void*) {};
336 if (!threadSafeProxy) {
349 if (!threadSafeProxy->priv().caps()->areColorTypeAndFormatCompatible(grColorType,
359 std::move(releaseHelper));
364 threadSafeProxy->priv().caps()->getReadSwizzle(backendFormat, grColorType);
367 return sk_make_sp<SkImage_Ganesh>(std::move(ctx),
376 bool limitToMaxTextureSize) {
387 const SkPixmap* pixmap = &originalPixmap;
390 int maxDim = std::max(originalPixmap.
width(), originalPixmap.
height());
391 if (limitToMaxTextureSize && maxDim > maxTextureSize) {
392 float scale =
static_cast<float>(maxTextureSize) / maxDim;
393 int newWidth = std::min(
static_cast<int>(originalPixmap.
width() *
scale), maxTextureSize);
394 int newHeight = std::min(
static_cast<int>(originalPixmap.
height() *
scale), maxTextureSize);
405 skgpu::Mipmapped mipmapped = buildMips ? skgpu::Mipmapped::kYes : skgpu::Mipmapped::kNo;
433 if (!dContext || !img) {
436 auto ib =
as_IB(img);
438 mipmapped = skgpu::Mipmapped::kNo;
441 if (ib->isGaneshBacked()) {
442 if (!ib->context()->priv().matches(dContext)) {
446 if (mipmapped == skgpu::Mipmapped::kNo || ib->hasMipmaps()) {
459 SkASSERT(mipmapped == skgpu::Mipmapped::kNo ||
460 view.asTextureProxy()->mipmapped() == skgpu::Mipmapped::kYes);
462 return sk_make_sp<SkImage_Ganesh>(
463 sk_ref_sp(dContext), ib->uniqueID(), std::move(view), std::move(colorInfo));
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kBorrow_GrWrapOwnership
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct)
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
std::tuple< GrSurfaceProxyView, GrColorType > GrMakeUncachedBitmapProxyView(GrRecordingContext *rContext, const SkBitmap &bitmap, skgpu::Mipmapped mipmapped, SkBackingFit fit, skgpu::Budgeted budgeted)
@ kNew_Uncached_Unbudgeted
static void releaseProc(const void *ptr, void *context)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static bool SkImageInfoIsValid(const SkImageInfo &info)
static SkImage_Base * as_IB(SkImage *image)
sk_sp< T > sk_ref_sp(T *obj)
Type::kYUV Type::kRGBA() int(0.7 *637)
static std::unique_ptr< GrTextureGenerator > Make(const sk_sp< GrTexture > &, GrSurfaceOrigin, std::unique_ptr< GrSemaphore >, SkColorType, SkAlphaType, sk_sp< SkColorSpace >)
GrBackendFormat getBackendFormat() const
const GrCaps * caps() const
bool mipmapSupport() const
bool crossContextTextureSupport() const
int maxTextureSize() const
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
SK_API GrBackendFormat compressedBackendFormat(SkTextureCompressionType) const
GrSemaphoresSubmitted flushSurface(GrSurfaceProxy *proxy, SkSurfaces::BackendSurfaceAccess access=SkSurfaces::BackendSurfaceAccess::kNoAccess, const GrFlushInfo &info={}, const skgpu::MutableTextureState *newState=nullptr)
GrDirectContextPriv priv()
virtual std::unique_ptr< GrSemaphore > prepareTextureForCrossContextUsage(GrTexture *)=0
static sk_sp< GrImageContext > MakeForPromiseImage(sk_sp< GrContextThreadSafeProxy > tsp)
sk_sp< GrTextureProxy > wrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType, sk_sp< skgpu::RefCntedCallback >=nullptr)
sk_sp< GrTextureProxy > wrapCompressedBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, sk_sp< skgpu::RefCntedCallback >)
sk_sp< GrTextureProxy > createCompressedTextureProxy(SkISize dimensions, skgpu::Budgeted, skgpu::Mipmapped, GrProtected, SkTextureCompressionType, sk_sp< SkData > data)
GrProxyProvider * proxyProvider()
GrRecordingContextPriv priv()
static bool StealBackendTexture(sk_sp< GrTexture >, GrBackendTexture *, SkImages::BackendTextureReleaseProc *)
bool tryAlloc(const SkImageInfo &)
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
virtual sk_sp< SkImage > onMakeSubset(GrDirectContext *, const SkIRect &) const =0
static bool ValidateBackendTexture(const GrCaps *, const GrBackendTexture &tex, GrColorType grCT, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
static bool ValidateCompressedBackendTexture(const GrCaps *, const GrBackendTexture &tex, SkAlphaType)
static sk_sp< GrTextureProxy > MakePromiseImageLazyProxy(GrContextThreadSafeProxy *, SkISize dimensions, const GrBackendFormat &, skgpu::Mipmapped, SkImages::PromiseImageTextureFulfillProc, sk_sp< skgpu::RefCntedCallback > releaseHelper)
bool getExistingBackendTexture(GrBackendTexture *outTexture, bool flushPendingGrContextIO, GrSurfaceOrigin *origin) const
bool scalePixels(const SkPixmap &dst, const SkSamplingOptions &) const
const SkImageInfo & info() const
SkAlphaType alphaType() const
static sk_sp< RefCntedCallback > Make(Callback proc, Context ctx)
static constexpr Swizzle RGBA()
SK_API sk_sp< SkImage > DeferredFromTextureGenerator(std::unique_ptr< GrTextureGenerator > gen)
void * PromiseImageTextureContext
SK_API sk_sp< SkImage > TextureFromCompressedTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
SK_API sk_sp< SkImage > AdoptTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin textureOrigin, SkColorType colorType)
SK_API sk_sp< SkImage > CrossContextTextureFromPixmap(GrDirectContext *context, const SkPixmap &pixmap, bool buildMips, bool limitToMaxTextureSize=false)
SK_API sk_sp< SkImage > RasterFromPixmapCopy(const SkPixmap &pixmap)
SK_API sk_sp< SkImage > TextureFromCompressedTextureData(GrDirectContext *direct, sk_sp< SkData > data, int width, int height, SkTextureCompressionType type, skgpu::Mipmapped mipmapped=skgpu::Mipmapped::kNo, GrProtected isProtected=GrProtected::kNo)
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
void(*)(PromiseImageTextureContext) PromiseImageTextureReleaseProc
SK_API bool GetBackendTextureFromImage(const SkImage *img, GrBackendTexture *outTexture, bool flushPendingGrContextIO, GrSurfaceOrigin *origin=nullptr)
SK_API sk_sp< SkImage > PromiseTextureFrom(skgpu::graphite::Recorder *, SkISize dimensions, const skgpu::graphite::TextureInfo &, const SkColorInfo &, skgpu::Origin origin, skgpu::graphite::Volatile, GraphitePromiseTextureFulfillProc, GraphitePromiseImageReleaseProc, GraphitePromiseTextureReleaseProc, GraphitePromiseImageContext)
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkImage > RasterFromCompressedTextureData(sk_sp< SkData > data, int width, int height, SkTextureCompressionType type)
void(*)(ReleaseContext) TextureReleaseProc
static sk_sp< SkImage > new_wrapped_texture_common(GrRecordingContext *rContext, const GrBackendTexture &backendTex, GrColorType colorType, GrSurfaceOrigin origin, SkAlphaType at, sk_sp< SkColorSpace > colorSpace, GrWrapOwnership ownership, sk_sp< skgpu::RefCntedCallback > releaseHelper)
SK_API bool MakeBackendTextureFromImage(GrDirectContext *context, sk_sp< SkImage > image, GrBackendTexture *backendTexture, BackendTextureReleaseProc *backendTextureReleaseProc)
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
static constexpr SkColorType CompressionTypeToSkColorType(SkTextureCompressionType compression)
SkImageInfo makeWH(int newWidth, int newHeight) const
sk_sp< SkColorSpace > refColorSpace() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)