diff options
author | 2015-09-25 02:31:09 -0700 | |
---|---|---|
committer | 2015-09-25 02:31:09 -0700 | |
commit | fe05707c356d2a8c2c69222591d4cafbd456b4e5 (patch) | |
tree | c490b4a707c52d58fc1bcadf1fb4d5d816db392f /src/image/SkImage_Gpu.cpp | |
parent | 00d6e515e5835f7df6163ceb5f5ceb1770552bf7 (diff) |
Revert[2] of add ImageShader, sharing code with its Bitmap cousin
Adjustment from previous land : runtime check for npot-support when texture is requested for tiling.
(patchset #10 id:180001 of https://codereview.chromium.org/1342113002/ )
This reverts commit f2608513626264459a00388537175600b515cae2.
BUG=skia:4365
Review URL: https://codereview.chromium.org/1352293002
Diffstat (limited to 'src/image/SkImage_Gpu.cpp')
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 1a63a0d6ba..4417c7bc93 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -7,6 +7,7 @@ #include "SkBitmapCache.h" #include "SkImage_Gpu.h" +#include "GrCaps.h" #include "GrContext.h" #include "GrDrawContext.h" #include "effects/GrYUVtoRGBEffect.h" @@ -35,13 +36,6 @@ extern void SkTextureImageApplyBudgetedDecision(SkImage* image) { } } -SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, SkShader::TileMode tileY, - const SkMatrix* localMatrix) const { - SkBitmap bm; - GrWrapTextureInBitmap(fTexture, this->width(), this->height(), this->isOpaque(), &bm); - return SkShader::CreateBitmapShader(bm, tileX, tileY, localMatrix); -} - bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { if (SkBitmapCache::Find(this->uniqueID(), dst)) { SkASSERT(dst->getGenerationID() == this->uniqueID()); @@ -66,6 +60,19 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { } GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, SkImageUsageType usage) const { + const bool is_pow2 = SkIsPow2(this->width()) && SkIsPow2(this->height()); + const bool npot_tex_supported = ctx->caps()->npotTextureTileSupport(); + if (!is_pow2 && kUntiled_SkImageUsageType != usage && !npot_tex_supported) { + // load as bitmap, since the GPU can support tiling a non-pow2 texture + // related to skbug.com/4365 + SkBitmap bitmap; + if (this->getROPixels(&bitmap)) { + return GrRefCachedBitmapTexture(ctx, bitmap, usage); + } else { + return nullptr; + } + } + fTexture->ref(); return fTexture; } |