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 21 matching lines...) Expand all Loading... |
32 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg
eted, | 32 GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg
eted, |
33 const void* srcData, size_t rowBytes
) { | 33 const void* srcData, size_t rowBytes
) { |
34 ASSERT_SINGLE_OWNER | 34 ASSERT_SINGLE_OWNER |
35 if (this->isAbandoned()) { | 35 if (this->isAbandoned()) { |
36 return nullptr; | 36 return nullptr; |
37 } | 37 } |
38 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && | 38 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && |
39 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { | 39 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { |
40 return nullptr; | 40 return nullptr; |
41 } | 41 } |
42 if (!GrPixelConfigIsCompressed(desc.fConfig) && | 42 if (!GrPixelConfigIsCompressed(desc.fConfig)) { |
43 !desc.fTextureStorageAllocator.fAllocateTextureStorage) { | |
44 static const uint32_t kFlags = kExact_ScratchTextureFlag | | 43 static const uint32_t kFlags = kExact_ScratchTextureFlag | |
45 kNoCreate_ScratchTextureFlag; | 44 kNoCreate_ScratchTextureFlag; |
46 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { | 45 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { |
47 if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight
, desc.fConfig, | 46 if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight
, desc.fConfig, |
48 srcData, rowBytes)) { | 47 srcData, rowBytes)) { |
49 if (!budgeted) { | 48 if (!budgeted) { |
50 texture->resourcePriv().makeUnbudgeted(); | 49 texture->resourcePriv().makeUnbudgeted(); |
51 } | 50 } |
52 return texture; | 51 return texture; |
53 } | 52 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke
y) { | 158 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke
y) { |
160 ASSERT_SINGLE_OWNER | 159 ASSERT_SINGLE_OWNER |
161 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); | 160 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); |
162 if (resource) { | 161 if (resource) { |
163 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); | 162 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); |
164 SkASSERT(texture); | 163 SkASSERT(texture); |
165 return texture; | 164 return texture; |
166 } | 165 } |
167 return NULL; | 166 return NULL; |
168 } | 167 } |
OLD | NEW |