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

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: Cleaning up the allocated SkMipMap object. 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 1c2f36535a0166ce143d66ca34936f9874ec1cb8..1f6d6f1c7008edce15377afffbe276d9b9a0ea26 100644
--- a/src/gpu/GrTextureProvider.cpp
+++ b/src/gpu/GrTextureProvider.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2015 Google Inc.
*
@@ -31,8 +30,9 @@ GrTextureProvider::GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingl
}
GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budgeted,
- const void* srcData, size_t rowBytes) {
+ const SkTArray<SkMipMapLevel>& texels) {
ASSERT_SINGLE_OWNER
+
if (this->isAbandoned()) {
return nullptr;
}
@@ -41,20 +41,33 @@ 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);
+ SkSTArray<1, SkMipMapLevel> texels;
+ 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