[graphite] Add isGaneshBacked and isGraphiteBacked

Bug: skia:12845
Change-Id: Ib0b87966b1559b368759ce69c48f0fd27597503a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/514836
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Jim Van Verth 2022-03-02 16:46:01 -05:00 committed by SkCQ
parent d1b52f58a7
commit e43d00a219
9 changed files with 17 additions and 10 deletions

View File

@ -43,7 +43,7 @@ sk_sp<SkImage> SkImage::makeTextureImage(skgpu::Recorder* recorder,
mipmapped = skgpu::Mipmapped::kNo;
}
if (this->isTextureBacked()) {
if (as_IB(this)->isGraphiteBacked()) {
if (mipmapped == skgpu::Mipmapped::kNo || this->hasMipmaps()) {
const SkImage* image = this;
return sk_ref_sp(const_cast<SkImage*>(image));

View File

@ -29,6 +29,8 @@ public:
bool onHasMipmaps() const override { return false; }
bool isGraphiteBacked() const override { return true; }
bool getROPixels(GrDirectContext*,
SkBitmap*,
CachingHint = kAllow_CachingHint) const override { return false; }

View File

@ -731,7 +731,7 @@ public:
*/
bool peekPixels(SkPixmap* pixmap) const;
/** Returns true the contents of SkImage was created on or uploaded to GPU memory,
/** Returns true if the contents of SkImage was created on or uploaded to GPU memory,
and is available as a GPU texture.
@return true if SkImage is a GPU texture

View File

@ -216,7 +216,9 @@ sk_sp<SkImage> SkImage::makeSubset(const SkIRect& subset, GrDirectContext* direc
#if SK_SUPPORT_GPU
bool SkImage::isTextureBacked() const { return as_IB(this)->onIsTextureBacked(); }
bool SkImage::isTextureBacked() const {
return as_IB(this)->isGaneshBacked() || as_IB(this)->isGraphiteBacked();
}
size_t SkImage::textureSize() const { return as_IB(this)->onTextureSize(); }

View File

@ -153,8 +153,11 @@ public:
// True for picture-backed and codec-backed
virtual bool onIsLazyGenerated() const { return false; }
// True for images instantiated in GPU memory
virtual bool onIsTextureBacked() const { return false; }
// True for images instantiated by Ganesh in GPU memory
virtual bool isGaneshBacked() const { return false; }
// True for images instantiated by Graphite in GPU memory
virtual bool isGraphiteBacked() const { return false; }
// Amount of texture memory used by texture-backed images.
virtual size_t onTextureSize() const { return 0; }

View File

@ -540,12 +540,12 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrDirectContext* dContext,
mipmapped = GrMipmapped::kNo;
}
if (this->isTextureBacked()) {
if (as_IB(this)->isGaneshBacked()) {
if (!as_IB(this)->context()->priv().matches(dContext)) {
return nullptr;
}
if (this->isTextureBacked() && (mipmapped == GrMipmapped::kNo || this->hasMipmaps())) {
if (mipmapped == GrMipmapped::kNo || this->hasMipmaps()) {
return sk_ref_sp(const_cast<SkImage*>(this));
}
}

View File

@ -46,7 +46,7 @@ public:
GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const final;
bool onIsTextureBacked() const override { return true; }
bool isGaneshBacked() const override { return true; }
size_t onTextureSize() const override;

View File

@ -32,7 +32,7 @@ public:
GrSemaphoresSubmitted onFlush(GrDirectContext*, const GrFlushInfo&) const override;
bool onIsTextureBacked() const override { return true; }
bool isGaneshBacked() const override { return true; }
size_t onTextureSize() const override;

View File

@ -29,7 +29,7 @@
namespace sk_gpu_test {
GrTextureProxy* GetTextureImageProxy(SkImage* image, GrRecordingContext* rContext) {
if (!image->isTextureBacked() || as_IB(image)->isYUVA()) {
if (!as_IB(image)->isGaneshBacked() || as_IB(image)->isYUVA()) {
return nullptr;
}
if (!rContext) {