aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPictureShader.cpp
diff options
context:
space:
mode:
authorGravatar gen.kim <gen.kim@samsung.com>2015-05-03 22:36:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-03 22:36:30 -0700
commitb9ed8845783ec3c59b2b185d26801f251adbf68d (patch)
treeca787552851a53f22475dfcc0715994329837c5f /src/core/SkPictureShader.cpp
parent05f7d5cbd83ab30653c79d81dc9829a97b845e38 (diff)
SkPictureShader: scale down if width or height is larger than maxTextureSize
Grdient renders black because of failure onCreateTexture if one of width or height is larger than maxTextureSize with --force-gpu-rasterization. BUG=chromium:473166 Review URL: https://codereview.chromium.org/1101513004
Diffstat (limited to 'src/core/SkPictureShader.cpp')
-rw-r--r--src/core/SkPictureShader.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index cd2301b91b..e831320a7e 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;
}