Plumbing mipmaps to the point of creation.
When creating a DeferredTextureImage we may create mipmaps. Those mipmaps need to then be passed along for when the texture is actually created. R=bsalomon@google.com BUG=578304 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2031273002 Review-Url: https://codereview.chromium.org/2031273002
This commit is contained in:
parent
976f5f0dc5
commit
186d2d430b
@ -396,7 +396,7 @@ public:
|
||||
* to empty.
|
||||
*/
|
||||
bool asLegacyBitmap(SkBitmap*, LegacyBitmapMode) const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the image is backed by an image-generator or other src that creates
|
||||
* (and caches) its pixels / texture on-demand.
|
||||
@ -443,6 +443,10 @@ protected:
|
||||
SkImage(int width, int height, uint32_t uniqueID);
|
||||
|
||||
private:
|
||||
static sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&,
|
||||
const GrMipLevel* texels, int mipLevelCount,
|
||||
SkBudgeted);
|
||||
|
||||
const int fWidth;
|
||||
const int fHeight;
|
||||
const uint32_t fUniqueID;
|
||||
|
@ -394,6 +394,14 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b
|
||||
mipLevelCount);
|
||||
}
|
||||
|
||||
GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info,
|
||||
const GrMipLevel* texels, int mipLevelCount) {
|
||||
const GrCaps* caps = ctx->caps();
|
||||
return ctx->textureProvider()->createMipMappedTexture(GrImageInfoToSurfaceDesc(info, *caps),
|
||||
SkBudgeted::kYes, texels,
|
||||
mipLevelCount);
|
||||
}
|
||||
|
||||
GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
|
||||
const GrTextureParams& params) {
|
||||
if (bitmap.getTexture()) {
|
||||
|
@ -131,6 +131,12 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext*, const SkBitmap&);
|
||||
*/
|
||||
GrTexture* GrUploadPixmapToTexture(GrContext*, const SkPixmap&, SkBudgeted budgeted);
|
||||
|
||||
/**
|
||||
* Creates a new texture populated with the mipmap levels.
|
||||
*/
|
||||
GrTexture* GrUploadMipMapToTexture(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
|
||||
int mipLevelCount);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkXfermode::kZero_Coeff);
|
||||
|
@ -499,3 +499,8 @@ SkImage* SkImage::NewFromDeferredTextureImageData(GrContext* ctx, const void* da
|
||||
return MakeFromDeferredTextureImageData(ctx, data, budgeted).release();
|
||||
}
|
||||
#endif
|
||||
|
||||
sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
|
||||
int mipLevelCount, SkBudgeted) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -468,3 +468,16 @@ GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) {
|
||||
return dst;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo& info,
|
||||
const GrMipLevel* texels, int mipLevelCount,
|
||||
SkBudgeted budgeted) {
|
||||
if (!ctx) {
|
||||
return nullptr;
|
||||
}
|
||||
SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevelCount));
|
||||
if (!texture) {
|
||||
return nullptr;
|
||||
}
|
||||
return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
|
||||
info.alphaType(), texture, budgeted);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user