Index: src/gpu/SkGr.cpp |
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp |
index bb041312450ae278c8ede6bf70dfedc6d02be3ba..7ae0671ccb9178bc51a8f4262abcc16e63c6a476 100644 |
--- a/src/gpu/SkGr.cpp |
+++ b/src/gpu/SkGr.cpp |
@@ -646,6 +646,41 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, |
return NULL; |
} |
+ |
+GrTexture* GrMipMapTexture(GrContext& ctx, |
+ const SkBitmap& bitmap, |
+ SkDiscardableFactoryProc fact) { |
+ GrTexture* result = bitmap.getTexture(); |
+ // TODO: What if the bitmap already contains a non-mipmapped texture? |
bsalomon
2015/08/26 18:30:11
Maybe just preserve the existing glGenMipmaps()? t
cblume
2015/08/26 18:58:00
Hrmmm the point of all this was to try to remove t
bsalomon
2015/08/27 13:22:49
The GrTexture tracks whether it's MIPs are "dirty"
|
+ if (result) { |
+ // TODO: Add stretching. After reading get_stretch(), it appears small |
+ // textures can have issues. |
+ return SkRef(result); |
+ } |
+ |
+ GrSurfaceDesc desc; |
+ generate_bitmap_texture_desc(bitmap, &desc); |
+ |
+ auto mipmap = SkMipMap::Build(bitmap, fact); |
+ if (mipmap == NULL) { |
+ // could not create the mipmap |
+ return NULL; |
+ } else { |
+ auto mipLevelCount = mipmap->getLevelsCount(); |
+ SkTArray<SkMipMapLevel> texels(mipLevelCount); |
+ for (int i = 0; i < mipLevelCount; i++) { |
+ SkMipMap::Level level; |
+ mipmap->getLevel(i, &level); |
+ |
+ SkMipMapLevel currentMipLevel(level.fPixels, level.fRowBytes); |
+ |
+ texels.push_back(currentMipLevel); |
+ } |
+ return ctx.textureProvider()->createTexture(desc, true, texels); |
+ // TODO: BitmapInvalidator support |
+ } |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
// alphatype is ignore for now, but if GrPixelConfig is expanded to encompass |