105 if (!backendFormat.
isValid()) {
140 if (!
dst->tryAllocPixels(this->imageInfo()) || !
dst->peekPixels(&pmap)) {
151 auto sContext = dContext->
priv().
makeSC(std::move(view), std::move(colorInfo));
156 if (!sContext->readPixels(dContext, pmap, {0, 0})) {
206 "ImageGpuBase_MakeSubset");
212 return sk_make_sp<SkImage_Ganesh>(
sk_ref_sp(direct),
221 SkDEBUGFAIL(
"Cannot convert Ganesh-backed image to Graphite");
229 SkDEBUGFAIL(
"Cannot convert Ganesh-backed image to Graphite");
249 auto sContext = dContext->
priv().
makeSC(std::move(view), colorInfo);
254 return sContext->readPixels(dContext, {dstInfo, dstPixels, dstRB}, {srcX, srcY});
277 auto myContext = this->
context();
279 if (!myContext || !myContext->priv().matches(dContext)) {
328 class PromiseLazyInstantiateCallback {
332 : fFulfillProc(fulfillProc), fReleaseHelper(std::move(releaseHelper)) {}
333 PromiseLazyInstantiateCallback(PromiseLazyInstantiateCallback&&) =
default;
334 PromiseLazyInstantiateCallback(
const PromiseLazyInstantiateCallback&) {
339 PromiseLazyInstantiateCallback& operator=(PromiseLazyInstantiateCallback&&) =
default;
340 PromiseLazyInstantiateCallback& operator=(
const PromiseLazyInstantiateCallback&) {
345 ~PromiseLazyInstantiateCallback() {
356 static constexpr auto kKeySyncMode =
362 static constexpr auto kReleaseCallbackOnInstantiation =
false;
367 return {fTexture, kReleaseCallbackOnInstantiation, kKeySyncMode};
368 }
else if (fFulfillProcFailed) {
377 if (!promiseTexture) {
378 fFulfillProcFailed =
true;
383 if (!backendTexture.
isValid()) {
393 auto dContext = fTexture->getContext();
394 fTextureContextID = dContext->directContextID();
395 return {fTexture, kReleaseCallbackOnInstantiation, kKeySyncMode};
403 bool fFulfillProcFailed =
false;
404 }
callback(fulfillProc, std::move(releaseHelper));
414 if (context ==
nullptr || img ==
nullptr) {
417 auto subsetImg = img->
makeSubset(context, subset);
428 if (!rContext || !
src || !filter) {
435 origin =
base->origin();
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kBorrow_GrWrapOwnership
static bool GrTextureTypeHasRestrictedSampling(GrTextureType type)
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
@ kTopLeft_GrSurfaceOrigin
@ kUnknown_SkAlphaType
uninitialized
#define SkDEBUGFAIL(message)
SkColorSpace * sk_srgb_singleton()
@ kUnknown_SkColorType
uninitialized
static SkImageFilter_Base * as_IFB(SkImageFilter *filter)
static bool SkColorInfoIsValid(const SkColorInfo &info)
static bool SkImageInfoValidConversion(const SkImageInfo &dst, const SkImageInfo &src)
static SkImage_Base * as_IB(SkImage *image)
sk_sp< T > sk_ref_sp(T *obj)
GrBackendFormat getBackendFormat() const
bool matches(GrContext_Base *candidate) const
int maxTextureSize() const
bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat &format) const
bool isFormatCompressed(const GrBackendFormat &format) const
GrDirectContextPriv priv()
GrImageContextPriv priv()
virtual SK_API bool abandoned()
GrBackendTexture backendTexture() const
static sk_sp< GrTextureProxy > CreatePromiseProxy(GrContextThreadSafeProxy *, LazyInstantiateCallback &&, const GrBackendFormat &, SkISize dimensions, skgpu::Mipmapped)
std::unique_ptr< skgpu::ganesh::SurfaceContext > makeSC(GrSurfaceProxyView readView, const GrColorInfo &)
static std::enable_if_t< std::is_base_of_v< GrGpuResource, T >, void > ReturnResourceFromThread(sk_sp< T > &&resource, GrDirectContext::DirectContextID id)
sk_sp< GrTexture > wrapBackendTexture(const GrBackendTexture &tex, GrWrapOwnership, GrWrapCacheable, GrIOType)
static GrSurfaceProxyView Copy(GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Mipmapped mipmapped, SkIRect srcRect, SkBackingFit fit, skgpu::Budgeted budgeted, std::string_view label)
void setRelease(sk_sp< skgpu::RefCntedCallback > releaseHelper)
std::unique_ptr< Rec, RecDeleter > RecPtr
static RecPtr Alloc(const SkBitmapCacheDesc &, const SkImageInfo &, SkPixmap *)
static bool Find(const SkBitmapCacheDesc &, SkBitmap *result)
static void Add(RecPtr, SkBitmap *)
static bool Equals(const SkColorSpace *, const SkColorSpace *)
sk_sp< SkImage > makeImageWithFilter(sk_sp< skif::Backend > backend, sk_sp< SkImage > src, const SkIRect &subset, const SkIRect &clipBounds, SkIRect *outSubset, SkIPoint *offset) const
virtual GrDirectContext * directContext() const
virtual void notifyAddedToRasterCache() const
static bool ValidateBackendTexture(const GrCaps *, const GrBackendTexture &tex, GrColorType grCT, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
bool isValid(GrRecordingContext *) const final
sk_sp< SkImage > onMakeSubset(GrDirectContext *, const SkIRect &subset) const final
virtual sk_sp< SkImage > onMakeColorTypeAndColorSpace(SkColorType, sk_sp< SkColorSpace >, GrDirectContext *) const=0
sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const final
SkImage_GaneshBase(sk_sp< GrImageContext >, SkImageInfo, uint32_t uniqueID)
static bool ValidateCompressedBackendTexture(const GrCaps *, const GrBackendTexture &tex, SkAlphaType)
sk_sp< SkImage > makeColorTypeAndColorSpace(GrDirectContext *dContext, SkColorType targetColorType, sk_sp< SkColorSpace > targetCS) const final
sk_sp< GrImageContext > fContext
GrImageContext * context() const final
static sk_sp< GrTextureProxy > MakePromiseImageLazyProxy(GrContextThreadSafeProxy *, SkISize dimensions, const GrBackendFormat &, skgpu::Mipmapped, SkImages::PromiseImageTextureFulfillProc, sk_sp< skgpu::RefCntedCallback > releaseHelper)
bool getROPixels(GrDirectContext *, SkBitmap *, CachingHint) const final
bool onReadPixels(GrDirectContext *dContext, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRB, int srcX, int srcY, CachingHint) const override
const SkImageInfo & imageInfo() const
SkColorSpace * colorSpace() const
SkISize dimensions() const
SkAlphaType alphaType() const
SkColorType colorType() const
@ kAllow_CachingHint
allows internally caching decoded and copied pixels
sk_sp< SkColorSpace > refColorSpace() const
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
void * PromiseImageTextureContext
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
SK_API sk_sp< SkImage > SubsetTextureFrom(GrDirectContext *context, const SkImage *img, const SkIRect &subset)
SK_API sk_sp< SkImage > MakeWithFilter(sk_sp< SkImage > src, const SkImageFilter *filter, const SkIRect &subset, const SkIRect &clipBounds, SkIRect *outSubset, SkIPoint *offset)
SK_API GrDirectContext * GetContext(const SkImage *src)
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
sk_sp< Backend > MakeGaneshBackend(sk_sp< GrRecordingContext > context, GrSurfaceOrigin origin, const SkSurfaceProps &surfaceProps, SkColorType colorType)
static SkBitmapCacheDesc Make(const SkImage *)
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
bool contains(int32_t x, int32_t y) const