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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea)); | 171 SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea)); |
172 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), | 172 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), |
173 SkScalarMul(scaledSize.height(), clampScale)); | 173 SkScalarMul(scaledSize.height(), clampScale)); |
174 } | 174 } |
175 #if SK_SUPPORT_GPU | 175 #if SK_SUPPORT_GPU |
176 // Scale down the tile size if larger than maxTextureSize for GPU Path or it
should fail on create texture | 176 // Scale down the tile size if larger than maxTextureSize for GPU Path or it
should fail on create texture |
177 if (maxTextureSize) { | 177 if (maxTextureSize) { |
178 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxText
ureSize) { | 178 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxText
ureSize) { |
179 SkScalar downScale = SkScalarDiv(maxTextureSize, | 179 SkScalar downScale = SkScalarDiv(maxTextureSize, |
180 SkMax32(scaledSize.width(), scaledSi
ze.height())); | 180 SkMax32(scaledSize.width(), scaledSi
ze.height())); |
181 scaledSize.set(SkScalarMul(scaledSize.width(), downScale), | 181 scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(),
downScale)), |
182 SkScalarMul(scaledSize.height(), downScale)); | 182 SkScalarFloorToScalar(SkScalarMul(scaledSize.height()
, downScale))); |
183 } | 183 } |
184 } | 184 } |
185 #endif | 185 #endif |
186 | 186 |
187 SkISize tileSize = scaledSize.toRound(); | 187 SkISize tileSize = scaledSize.toRound(); |
188 if (tileSize.isEmpty()) { | 188 if (tileSize.isEmpty()) { |
189 return NULL; | 189 return NULL; |
190 } | 190 } |
191 | 191 |
192 // The actual scale, compensating for rounding & clamping. | 192 // The actual scale, compensating for rounding & clamping. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC
olor, fp); | 322 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC
olor, fp); |
323 } | 323 } |
324 #else | 324 #else |
325 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, | 325 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, |
326 const SkMatrix*, GrColor*, | 326 const SkMatrix*, GrColor*, |
327 GrFragmentProcessor**) const { | 327 GrFragmentProcessor**) const { |
328 SkDEBUGFAIL("Should not call in GPU-less build"); | 328 SkDEBUGFAIL("Should not call in GPU-less build"); |
329 return false; | 329 return false; |
330 } | 330 } |
331 #endif | 331 #endif |
OLD | NEW |