diff options
author | cblume <cblume@chromium.org> | 2016-06-03 11:17:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-03 11:17:42 -0700 |
commit | 186d2d430ba248fea1e00669154b95252ac9a486 (patch) | |
tree | 6fa2d732a1b93f776444421a62d4f5a01ba7c820 | |
parent | 976f5f0dc5e907d1ca50685fad117bd15d7fc87b (diff) |
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
-rw-r--r-- | include/core/SkImage.h | 6 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 8 | ||||
-rw-r--r-- | src/gpu/SkGrPriv.h | 6 | ||||
-rw-r--r-- | src/image/SkImage.cpp | 5 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 13 |
5 files changed, 37 insertions, 1 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h index c9579b610c..50a9f57612 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -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; diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 2127c36744..60736da572 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -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()) { diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h index 46be3a53cf..ac21669bd8 100644 --- a/src/gpu/SkGrPriv.h +++ b/src/gpu/SkGrPriv.h @@ -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); diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 8bf1f247b0..1c1b311b93 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -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; +} diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index f67d7aa34b..a728c3dae5 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -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); +} |