| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } else { | 353 } else { |
| 354 // TODO: Our CPU stretch doesn't filter. But we create separate | 354 // TODO: Our CPU stretch doesn't filter. But we create separate |
| 355 // stretched textures when the texture params is either filtered or | 355 // stretched textures when the texture params is either filtered or |
| 356 // not. Either implement filtered stretch blit on CPU or just create | 356 // not. Either implement filtered stretch blit on CPU or just create |
| 357 // one when FBO case fails. | 357 // one when FBO case fails. |
| 358 | 358 |
| 359 rtDesc.fFlags = kNone_GrTextureFlags; | 359 rtDesc.fFlags = kNone_GrTextureFlags; |
| 360 // no longer need to clamp at min RT size. | 360 // no longer need to clamp at min RT size. |
| 361 rtDesc.fWidth = GrNextPow2(desc.fWidth); | 361 rtDesc.fWidth = GrNextPow2(desc.fWidth); |
| 362 rtDesc.fHeight = GrNextPow2(desc.fHeight); | 362 rtDesc.fHeight = GrNextPow2(desc.fHeight); |
| 363 |
| 364 // We shouldn't be resizing a compressed texture. |
| 365 SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig)); |
| 366 |
| 363 size_t bpp = GrBytesPerPixel(desc.fConfig); | 367 size_t bpp = GrBytesPerPixel(desc.fConfig); |
| 364 SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fH
eight); | 368 SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fH
eight); |
| 365 stretch_image(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight, | 369 stretch_image(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight, |
| 366 srcData, desc.fWidth, desc.fHeight, bpp); | 370 srcData, desc.fWidth, desc.fHeight, bpp); |
| 367 | 371 |
| 368 size_t stretchedRowBytes = rtDesc.fWidth * bpp; | 372 size_t stretchedRowBytes = rtDesc.fWidth * bpp; |
| 369 | 373 |
| 370 texture = fGpu->createTexture(rtDesc, stretchedPixels.get(), stretchedRo
wBytes); | 374 texture = fGpu->createTexture(rtDesc, stretchedPixels.get(), stretchedRo
wBytes); |
| 371 SkASSERT(NULL != texture); | 375 SkASSERT(NULL != texture); |
| 372 } | 376 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 | 604 |
| 601 GrRenderTarget* GrContext::wrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& desc) { | 605 GrRenderTarget* GrContext::wrapBackendRenderTarget(const GrBackendRenderTargetDe
sc& desc) { |
| 602 return fGpu->wrapBackendRenderTarget(desc); | 606 return fGpu->wrapBackendRenderTarget(desc); |
| 603 } | 607 } |
| 604 | 608 |
| 605 /////////////////////////////////////////////////////////////////////////////// | 609 /////////////////////////////////////////////////////////////////////////////// |
| 606 | 610 |
| 607 bool GrContext::supportsIndex8PixelConfig(const GrTextureParams* params, | 611 bool GrContext::supportsIndex8PixelConfig(const GrTextureParams* params, |
| 608 int width, int height) const { | 612 int width, int height) const { |
| 609 const GrDrawTargetCaps* caps = fGpu->caps(); | 613 const GrDrawTargetCaps* caps = fGpu->caps(); |
| 610 if (!caps->eightBitPaletteSupport()) { | 614 if (!caps->isConfigTexturable(kIndex_8_GrPixelConfig)) { |
| 611 return false; | 615 return false; |
| 612 } | 616 } |
| 613 | 617 |
| 614 bool isPow2 = GrIsPow2(width) && GrIsPow2(height); | 618 bool isPow2 = GrIsPow2(width) && GrIsPow2(height); |
| 615 | 619 |
| 616 if (!isPow2) { | 620 if (!isPow2) { |
| 617 bool tiled = NULL != params && params->isTiled(); | 621 bool tiled = NULL != params && params->isTiled(); |
| 618 if (tiled && !caps->npotTextureTileSupport()) { | 622 if (tiled && !caps->npotTextureTileSupport()) { |
| 619 return false; | 623 return false; |
| 620 } | 624 } |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 SkSafeRef(resource); | 1835 SkSafeRef(resource); |
| 1832 return resource; | 1836 return resource; |
| 1833 } | 1837 } |
| 1834 | 1838 |
| 1835 /////////////////////////////////////////////////////////////////////////////// | 1839 /////////////////////////////////////////////////////////////////////////////// |
| 1836 #if GR_CACHE_STATS | 1840 #if GR_CACHE_STATS |
| 1837 void GrContext::printCacheStats() const { | 1841 void GrContext::printCacheStats() const { |
| 1838 fResourceCache->printStats(); | 1842 fResourceCache->printStats(); |
| 1839 } | 1843 } |
| 1840 #endif | 1844 #endif |
| OLD | NEW |