OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 | 9 |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 GrTexture* GrContext::createTexture(const GrTextureParams* params, | 381 GrTexture* GrContext::createTexture(const GrTextureParams* params, |
382 const GrTextureDesc& desc, | 382 const GrTextureDesc& desc, |
383 const GrCacheID& cacheID, | 383 const GrCacheID& cacheID, |
384 const void* srcData, | 384 const void* srcData, |
385 size_t rowBytes, | 385 size_t rowBytes, |
386 GrResourceKey* cacheKey) { | 386 GrResourceKey* cacheKey) { |
387 GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, ca
cheID); | 387 GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, ca
cheID); |
388 | 388 |
389 GrTexture* texture; | 389 GrTexture* texture; |
390 if (GrTextureImpl::NeedsResizing(resourceKey)) { | 390 if (GrTextureImpl::NeedsResizing(resourceKey)) { |
| 391 // We do not know how to resize compressed textures. |
| 392 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig)); |
| 393 |
391 texture = this->createResizedTexture(desc, cacheID, | 394 texture = this->createResizedTexture(desc, cacheID, |
392 srcData, rowBytes, | 395 srcData, rowBytes, |
393 GrTextureImpl::NeedsBilerp(resource
Key)); | 396 GrTextureImpl::NeedsBilerp(resource
Key)); |
394 } else { | 397 } else { |
395 texture= fGpu->createTexture(desc, srcData, rowBytes); | 398 if(GrPixelConfigIsCompressed(desc.fConfig)) { |
| 399 texture = fGpu->createCompressedTexture(desc, srcData); |
| 400 } else { |
| 401 texture = fGpu->createTexture(desc, srcData, rowBytes); |
| 402 } |
396 } | 403 } |
397 | 404 |
398 if (NULL != texture) { | 405 if (NULL != texture) { |
399 // Adding a resource could put us overbudget. Try to free up the | 406 // Adding a resource could put us overbudget. Try to free up the |
400 // necessary space before adding it. | 407 // necessary space before adding it. |
401 fResourceCache->purgeAsNeeded(1, texture->gpuMemorySize()); | 408 fResourceCache->purgeAsNeeded(1, texture->gpuMemorySize()); |
402 fResourceCache->addResource(resourceKey, texture); | 409 fResourceCache->addResource(resourceKey, texture); |
403 | 410 |
404 if (NULL != cacheKey) { | 411 if (NULL != cacheKey) { |
405 *cacheKey = resourceKey; | 412 *cacheKey = resourceKey; |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 SkSafeRef(resource); | 1842 SkSafeRef(resource); |
1836 return resource; | 1843 return resource; |
1837 } | 1844 } |
1838 | 1845 |
1839 /////////////////////////////////////////////////////////////////////////////// | 1846 /////////////////////////////////////////////////////////////////////////////// |
1840 #if GR_CACHE_STATS | 1847 #if GR_CACHE_STATS |
1841 void GrContext::printCacheStats() const { | 1848 void GrContext::printCacheStats() const { |
1842 fResourceCache->printStats(); | 1849 fResourceCache->printStats(); |
1843 } | 1850 } |
1844 #endif | 1851 #endif |
OLD | NEW |