Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: src/gpu/SkGr.cpp

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: No longer exposing SkMipMap and SkCachedData. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698