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;
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()) {
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;
}
private:
SkPictureShader(const SkPicture*, TileMode, TileMode, const SkMatrix*, const SkRect*);
- SkShader* refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix) const;
+ SkShader* refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix, const int maxTextureSize = 0) const;
const SkPicture* fPicture;
SkRect fTile;