| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkPictureShader.h" | 8 #include "SkPictureShader.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 m.preConcat(*localM); | 150 m.preConcat(*localM); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Use a rotation-invariant scale | 153 // Use a rotation-invariant scale |
| 154 SkPoint scale; | 154 SkPoint scale; |
| 155 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) { | 155 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) { |
| 156 // Decomposition failed, use an approximation. | 156 // Decomposition failed, use an approximation. |
| 157 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m.
getSkewX()), | 157 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m.
getSkewX()), |
| 158 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m.
getSkewY())); | 158 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m.
getSkewY())); |
| 159 } | 159 } |
| 160 SkSize scaledSize = SkSize::Make(scale.x() * fTile.width(), scale.y() * fTil
e.height()); | 160 SkSize scaledSize = SkSize::Make(SkScalarAbs(scale.x() * fTile.width()), |
| 161 SkScalarAbs(scale.y() * fTile.height())); |
| 161 | 162 |
| 162 // Clamp the tile size to about 16M pixels | 163 // Clamp the tile size to about 16M pixels |
| 163 static const SkScalar kMaxTileArea = 4096 * 4096; | 164 static const SkScalar kMaxTileArea = 4096 * 4096; |
| 164 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); | 165 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); |
| 165 if (tileArea > kMaxTileArea) { | 166 if (tileArea > kMaxTileArea) { |
| 166 SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea)); | 167 SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea)); |
| 167 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), | 168 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), |
| 168 SkScalarMul(scaledSize.height(), clampScale)); | 169 SkScalarMul(scaledSize.height(), clampScale)); |
| 169 } | 170 } |
| 170 | 171 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC
olor, fp); | 301 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC
olor, fp); |
| 301 } | 302 } |
| 302 #else | 303 #else |
| 303 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, | 304 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, |
| 304 const SkMatrix*, GrColor*, | 305 const SkMatrix*, GrColor*, |
| 305 GrFragmentProcessor**) const { | 306 GrFragmentProcessor**) const { |
| 306 SkDEBUGFAIL("Should not call in GPU-less build"); | 307 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 307 return false; | 308 return false; |
| 308 } | 309 } |
| 309 #endif | 310 #endif |
| OLD | NEW |