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

Unified Diff: src/gpu/GrTextureProvider.cpp

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Moving glTexStorage over to a separate CL. Created 4 years, 11 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/GrTextureProvider.cpp
diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp
index cb652f7a7fd8c2e27b46fb7a4c802a4031b900e1..814659c88f7dfa7df85eb56fe48eb504e3fe16d7 100644
--- a/src/gpu/GrTextureProvider.cpp
+++ b/src/gpu/GrTextureProvider.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2015 Google Inc.
*
@@ -18,7 +17,7 @@ enum ScratchTextureFlags {
};
GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budgeted,
- const void* srcData, size_t rowBytes) {
+ const SkTArray<SkMipMapLevel>& texels) {
if (this->isAbandoned()) {
return nullptr;
}
@@ -27,20 +26,34 @@ GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg
return nullptr;
}
if (!GrPixelConfigIsCompressed(desc.fConfig)) {
- static const uint32_t kFlags = kExact_ScratchTextureFlag |
- kNoCreate_ScratchTextureFlag;
- if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
- if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
- srcData, rowBytes)) {
- if (!budgeted) {
- texture->resourcePriv().makeUnbudgeted();
+ // In the case of mipmaps, do not use a scratch texture
+ if (texels.count() < 2) {
+ const SkMipMapLevel& baseMipLevel = texels[0];
+ static const uint32_t kFlags = kExact_ScratchTextureFlag |
+ kNoCreate_ScratchTextureFlag;
+ if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
+ if (texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
+ baseMipLevel.fTexelsOrOffset, baseMipLevel.fRowBytes)) {
+ if (!budgeted) {
+ texture->resourcePriv().makeUnbudgeted();
+ }
+ return texture;
}
- return texture;
+ texture->unref();
}
- texture->unref();
}
}
- return fGpu->createTexture(desc, budgeted, srcData, rowBytes);
+ return fGpu->createTexture(desc, budgeted, texels);
+}
+
+GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budgeted,
+ const void* srcData, size_t rowBytes) {
+ SkMipMapLevel level(srcData, rowBytes, desc.fWidth, desc.fHeight);
+ const int mipLevelCount = 1;
+ SkTArray<SkMipMapLevel> texels(mipLevelCount);
bsalomon 2016/01/11 17:16:38 Can avoid a heap allocation by making this SkSTArr
Chris Blume 2016/01/12 12:49:33 Done, including elsewhere in the CL.
+ texels.push_back(level);
+
+ return this->createTexture(desc, budgeted, texels);
}
GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) {

Powered by Google App Engine
This is Rietveld 408576698