Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 1352293002: Revert[2] of add ImageShader, sharing code with its Bitmap cousin (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Gpu.cpp
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 1a63a0d6ba3cf51af625d616d77cb27de4c459fb..4417c7bc939bdb3c143fec0dd70f4c1c86a1b788 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;
}
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698