Add onImageInfo call to SkImage_Base.
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1903483003 Review URL: https://codereview.chromium.org/1903483003
This commit is contained in:
parent
e05bbbba79
commit
a7c9d6303a
@ -26,6 +26,11 @@ public:
|
||||
SkImage_Base(int width, int height, uint32_t uniqueID);
|
||||
virtual ~SkImage_Base();
|
||||
|
||||
// User: returns image info for this SkImage.
|
||||
// Implementors: if you can not return the value, return an invalid ImageInfo with w=0 & h=0
|
||||
// & unknown color space.
|
||||
virtual SkImageInfo onImageInfo() const = 0;
|
||||
|
||||
virtual bool onPeekPixels(SkPixmap*) const { return false; }
|
||||
|
||||
// Default impl calls onDraw
|
||||
|
@ -21,6 +21,10 @@ public:
|
||||
, fCache(cache) // take ownership
|
||||
{}
|
||||
|
||||
virtual SkImageInfo onImageInfo() const override {
|
||||
return fCache->info();
|
||||
}
|
||||
|
||||
bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, CachingHint) const override;
|
||||
SkImageCacherator* peekCacherator() const override { return fCache; }
|
||||
SkData* onRefEncoded(GrContext*) const override;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "GrTexture.h"
|
||||
#include "GrGpuResourcePriv.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkGr.h"
|
||||
#include "SkImage_Base.h"
|
||||
#include "SkImagePriv.h"
|
||||
#include "SkSurface.h"
|
||||
@ -25,6 +26,10 @@ public:
|
||||
SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*, SkBudgeted);
|
||||
~SkImage_Gpu() override;
|
||||
|
||||
SkImageInfo onImageInfo() const override {
|
||||
return GrMakeInfoFromTexture(fTexture, fTexture->width(), fTexture->height(), isOpaque());
|
||||
}
|
||||
|
||||
void applyBudgetDecision() const {
|
||||
if (SkBudgeted::kYes == fBudgeted) {
|
||||
fTexture->resourcePriv().makeBudgeted();
|
||||
|
@ -74,6 +74,10 @@ public:
|
||||
SkImage_Raster(const SkImageInfo&, sk_sp<SkData>, size_t rb, SkColorTable*);
|
||||
virtual ~SkImage_Raster();
|
||||
|
||||
SkImageInfo onImageInfo() const override {
|
||||
return fBitmap.info();
|
||||
}
|
||||
|
||||
bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, CachingHint) const override;
|
||||
bool onPeekPixels(SkPixmap*) const override;
|
||||
SkData* onRefEncoded(GrContext*) const override;
|
||||
@ -178,7 +182,7 @@ GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
|
||||
|
||||
return GrRefCachedBitmapTexture(ctx, fBitmap, params);
|
||||
#endif
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user