OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrTextureProvider.h" | 9 #include "GrTextureProvider.h" |
10 #include "GrTexturePriv.h" | 10 #include "GrTexturePriv.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg eted, | 33 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg eted, |
34 const void* srcData, size_t rowBytes ) { | 34 const void* srcData, size_t rowBytes ) { |
35 ASSERT_SINGLE_OWNER | 35 ASSERT_SINGLE_OWNER |
36 if (this->isAbandoned()) { | 36 if (this->isAbandoned()) { |
37 return nullptr; | 37 return nullptr; |
38 } | 38 } |
39 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && | 39 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && |
40 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { | 40 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { |
41 return nullptr; | 41 return nullptr; |
42 } | 42 } |
43 if (!GrPixelConfigIsCompressed(desc.fConfig)) { | 43 if (!GrPixelConfigIsCompressed(desc.fConfig) && |
44 !desc.fTextureStorageAllocator.fAllocateTextureStorage) { | |
bsalomon
2016/02/04 16:27:08
nit, style aligns this ! with the one above (not c
erikchen
2016/02/04 18:44:07
Done.
| |
44 static const uint32_t kFlags = kExact_ScratchTextureFlag | | 45 static const uint32_t kFlags = kExact_ScratchTextureFlag | |
45 kNoCreate_ScratchTextureFlag; | 46 kNoCreate_ScratchTextureFlag; |
46 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { | 47 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { |
47 if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight , desc.fConfig, | 48 if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight , desc.fConfig, |
48 srcData, rowBytes)) { | 49 srcData, rowBytes)) { |
49 if (!budgeted) { | 50 if (!budgeted) { |
50 texture->resourcePriv().makeUnbudgeted(); | 51 texture->resourcePriv().makeUnbudgeted(); |
51 } | 52 } |
52 return texture; | 53 return texture; |
53 } | 54 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke y) { | 160 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke y) { |
160 ASSERT_SINGLE_OWNER | 161 ASSERT_SINGLE_OWNER |
161 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); | 162 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); |
162 if (resource) { | 163 if (resource) { |
163 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); | 164 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); |
164 SkASSERT(texture); | 165 SkASSERT(texture); |
165 return texture; | 166 return texture; |
166 } | 167 } |
167 return NULL; | 168 return NULL; |
168 } | 169 } |
OLD | NEW |