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

Side by Side 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: Fixing iOS. 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9 #include "GrTextureProvider.h" 8 #include "GrTextureProvider.h"
10 #include "GrTexturePriv.h" 9 #include "GrTexturePriv.h"
11 #include "GrResourceCache.h" 10 #include "GrResourceCache.h"
12 #include "GrGpu.h" 11 #include "GrGpu.h"
13 12
14 enum ScratchTextureFlags { 13 enum ScratchTextureFlags {
15 kExact_ScratchTextureFlag = 0x1, 14 kExact_ScratchTextureFlag = 0x1,
16 kNoPendingIO_ScratchTextureFlag = 0x2, 15 kNoPendingIO_ScratchTextureFlag = 0x2,
17 kNoCreate_ScratchTextureFlag = 0x4, 16 kNoCreate_ScratchTextureFlag = 0x4,
18 }; 17 };
19 18
20 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg eted, 19 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg eted,
21 const void* srcData, size_t rowBytes ) { 20 const SkTArray<SkMipMapLevel>& texel s) {
22 if (this->isAbandoned()) { 21 if (this->isAbandoned()) {
23 return nullptr; 22 return nullptr;
24 } 23 }
25 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && 24 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) &&
26 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { 25 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
27 return nullptr; 26 return nullptr;
28 } 27 }
29 if (!GrPixelConfigIsCompressed(desc.fConfig)) { 28 if (!GrPixelConfigIsCompressed(desc.fConfig)) {
30 static const uint32_t kFlags = kExact_ScratchTextureFlag | 29 // In the case of mipmaps, do not use a scratch texture
31 kNoCreate_ScratchTextureFlag; 30 if (texels.count() < 2) {
32 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { 31 const SkMipMapLevel& baseMipLevel = texels[0];
33 if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight , desc.fConfig, 32 static const uint32_t kFlags = kExact_ScratchTextureFlag |
34 srcData, rowBytes)) { 33 kNoCreate_ScratchTextureFlag;
35 if (!budgeted) { 34 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
36 texture->resourcePriv().makeUnbudgeted(); 35 if (texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.f Config,
bsalomon 2016/01/08 16:43:29 This works when writePixels uses an intermediate t
cblume 2016/01/09 01:26:56 I think I don't follow what you are asking. This p
bsalomon 2016/01/11 17:16:38 Got it, my misunderstanding.
36 baseMipLevel.fTexelsOrOffset, baseMipLe vel.fRowBytes)) {
37 if (!budgeted) {
38 texture->resourcePriv().makeUnbudgeted();
39 }
40 return texture;
37 } 41 }
38 return texture; 42 texture->unref();
39 } 43 }
40 texture->unref();
41 } 44 }
42 } 45 }
43 return fGpu->createTexture(desc, budgeted, srcData, rowBytes); 46 return fGpu->createTexture(desc, budgeted, texels);
47 }
48
49 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg eted,
50 const void* srcData, size_t rowBytes ) {
51 SkMipMapLevel level(srcData, rowBytes, desc.fWidth, desc.fHeight);
52 const int mipLevelCount = 1;
53 SkTArray<SkMipMapLevel> texels(mipLevelCount);
54 texels.push_back(level);
55
56 return this->createTexture(desc, budgeted, texels);
44 } 57 }
45 58
46 GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) { 59 GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) {
47 return this->internalCreateApproxTexture(desc, 0); 60 return this->internalCreateApproxTexture(desc, 0);
48 } 61 }
49 62
50 GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& d esc, 63 GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& d esc,
51 uint32_t scratchFlags) { 64 uint32_t scratchFlags) {
52 if (this->isAbandoned()) { 65 if (this->isAbandoned()) {
53 return nullptr; 66 return nullptr;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 resource->resourcePriv().setUniqueKey(key); 139 resource->resourcePriv().setUniqueKey(key);
127 } 140 }
128 141
129 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons t { 142 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons t {
130 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); 143 return this->isAbandoned() ? false : fCache->hasUniqueKey(key);
131 } 144 }
132 145
133 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe y& key) { 146 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe y& key) {
134 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key) ; 147 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key) ;
135 } 148 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698