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

Unified Diff: src/core/SkPictureShader.cpp

Issue 1101513004: SkPictureShader: scale down if width or height is larger than maxTextureSize (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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/core/SkPictureShader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureShader.cpp
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index cd2301b91b5f0f640896990cc58ed33717e43f5c..e831320a7ec38649a578a96cf70da29d60a6feb1 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -141,7 +141,8 @@ void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
fPicture->flatten(buffer);
}
-SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatrix* localM) const {
+SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatrix* localM,
+ const int maxTextureSize) const {
SkASSERT(fPicture && !fPicture->cullRect().isEmpty());
SkMatrix m;
@@ -171,6 +172,17 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri
scaledSize.set(SkScalarMul(scaledSize.width(), clampScale),
SkScalarMul(scaledSize.height(), clampScale));
}
+#if SK_SUPPORT_GPU
+ // Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture
+ if (maxTextureSize) {
+ if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxTextureSize) {
+ SkScalar downScale = SkScalarDiv(maxTextureSize,
+ SkMax32(scaledSize.width(), scaledSize.height()));
+ scaledSize.set(SkScalarMul(scaledSize.width(), downScale),
+ SkScalarMul(scaledSize.height(), downScale));
+ }
+ }
+#endif
SkISize tileSize = scaledSize.toRound();
if (tileSize.isEmpty()) {
@@ -299,7 +311,11 @@ bool SkPictureShader::asFragmentProcessor(GrContext* context, const SkPaint& pai
const SkMatrix& viewM, const SkMatrix* localMatrix,
GrColor* paintColor,
GrFragmentProcessor** fp) const {
- SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix));
+ int maxTextureSize = 0;
+ if (context) {
+ maxTextureSize = context->getMaxTextureSize();
+ }
+ SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTextureSize));
if (!bitmapShader) {
return false;
}
« no previous file with comments | « src/core/SkPictureShader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698