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

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: Removing the concept of a dirty mipmap. It is expected that the texture upload provides the mipmaps. Created 5 years, 3 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 471c9721cf55bd5357dc186a0f6f6f9ea3fd8cc5..6fd1a1090b7cb60a5ad6e82b9d5c6bce89b18bdc 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -19,6 +19,7 @@
#include "SkErrorInternals.h"
#include "SkGrPixelRef.h"
#include "SkMessageBus.h"
+#include "SkMipMap.h"
#include "SkPixelRef.h"
#include "SkResourceCache.h"
#include "SkTextureCompressor.h"
@@ -636,6 +637,37 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx,
return GrRefCachedBitmapTexture(ctx, bitmap, &params);
}
+GrTexture* GrMipMapTexture(GrContext* ctx,
+ const SkBitmap& bitmap,
+ SkDiscardableFactoryProc fact) {
+ // If the SkBitmap is already backed by a texture, we do not want to read the contents back
+ // to the cpu and generate the mipmap only to send it back to the GPU.
+ SkASSERT(!bitmap.getTexture());
+
+ 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();
+ desc.fIsMipMapped = mipLevelCount > 1;
+ 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