OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrTextureProvider.h" | 8 #include "GrTextureProvider.h" |
9 #include "GrTexturePriv.h" | 9 #include "GrTexturePriv.h" |
10 #include "GrResourceCache.h" | 10 #include "GrResourceCache.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && | 49 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && |
50 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { | 50 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { |
51 return nullptr; | 51 return nullptr; |
52 } | 52 } |
53 if (!GrPixelConfigIsCompressed(desc.fConfig) && | 53 if (!GrPixelConfigIsCompressed(desc.fConfig) && |
54 !desc.fTextureStorageAllocator.fAllocateTextureStorage) { | 54 !desc.fTextureStorageAllocator.fAllocateTextureStorage) { |
55 if (mipLevelCount < 2) { | 55 if (mipLevelCount < 2) { |
56 const GrMipLevel& baseMipLevel = texels[0]; | 56 const void* basePixels = nullptr; |
57 size_t baseRowBytes = 0; | |
robertphillips
2016/03/09 15:46:20
> 0 ?
| |
58 if (1 == mipLevelCount) { | |
59 basePixels = texels[0].fPixels; | |
60 baseRowBytes = texels[0].fRowBytes; | |
61 } | |
57 static const uint32_t kFlags = kExact_ScratchTextureFlag | | 62 static const uint32_t kFlags = kExact_ScratchTextureFlag | |
58 kNoCreate_ScratchTextureFlag; | 63 kNoCreate_ScratchTextureFlag; |
59 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { | 64 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { |
60 if (!texels || texture->writePixels(0, 0, desc.fWidth, desc.fHei ght, desc.fConfig, | 65 if (!texels || texture->writePixels(0, 0, desc.fWidth, desc.fHei ght, desc.fConfig, |
61 baseMipLevel.fPixels, baseMi pLevel.fRowBytes)) { | 66 basePixels, baseRowBytes)) { |
62 if (SkBudgeted::kNo == budgeted) { | 67 if (SkBudgeted::kNo == budgeted) { |
63 texture->resourcePriv().makeUnbudgeted(); | 68 texture->resourcePriv().makeUnbudgeted(); |
64 } | 69 } |
65 return texture; | 70 return texture; |
66 } | 71 } |
67 texture->unref(); | 72 texture->unref(); |
68 } | 73 } |
69 } | 74 } |
70 } | 75 } |
71 | 76 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke y) { | 197 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke y) { |
193 ASSERT_SINGLE_OWNER | 198 ASSERT_SINGLE_OWNER |
194 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); | 199 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); |
195 if (resource) { | 200 if (resource) { |
196 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); | 201 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); |
197 SkASSERT(texture); | 202 SkASSERT(texture); |
198 return texture; | 203 return texture; |
199 } | 204 } |
200 return NULL; | 205 return NULL; |
201 } | 206 } |
OLD | NEW |