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]; | |
57 static const uint32_t kFlags = kExact_ScratchTextureFlag | | 56 static const uint32_t kFlags = kExact_ScratchTextureFlag | |
58 kNoCreate_ScratchTextureFlag; | 57 kNoCreate_ScratchTextureFlag; |
59 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { | 58 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { |
60 if (!texels || texture->writePixels(0, 0, desc.fWidth, desc.fHei
ght, desc.fConfig, | 59 if (!mipLevelCount || |
61 baseMipLevel.fPixels, baseMi
pLevel.fRowBytes)) { | 60 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.f
Config, |
| 61 texels[0].fPixels, texels[0].fRowBytes)
) { |
62 if (SkBudgeted::kNo == budgeted) { | 62 if (SkBudgeted::kNo == budgeted) { |
63 texture->resourcePriv().makeUnbudgeted(); | 63 texture->resourcePriv().makeUnbudgeted(); |
64 } | 64 } |
65 return texture; | 65 return texture; |
66 } | 66 } |
67 texture->unref(); | 67 texture->unref(); |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke
y) { | 192 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke
y) { |
193 ASSERT_SINGLE_OWNER | 193 ASSERT_SINGLE_OWNER |
194 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); | 194 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); |
195 if (resource) { | 195 if (resource) { |
196 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); | 196 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); |
197 SkASSERT(texture); | 197 SkASSERT(texture); |
198 return texture; | 198 return texture; |
199 } | 199 } |
200 return NULL; | 200 return NULL; |
201 } | 201 } |
OLD | NEW |