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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); | 183 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); |
184 if (tileArea > kMaxTileArea) { | 184 if (tileArea > kMaxTileArea) { |
185 SkScalar clampScale = SkScalarSqrt(kMaxTileArea / tileArea); | 185 SkScalar clampScale = SkScalarSqrt(kMaxTileArea / tileArea); |
186 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), | 186 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), |
187 SkScalarMul(scaledSize.height(), clampScale)); | 187 SkScalarMul(scaledSize.height(), clampScale)); |
188 } | 188 } |
189 #if SK_SUPPORT_GPU | 189 #if SK_SUPPORT_GPU |
190 // Scale down the tile size if larger than maxTextureSize for GPU Path or it
should fail on create texture | 190 // Scale down the tile size if larger than maxTextureSize for GPU Path or it
should fail on create texture |
191 if (maxTextureSize) { | 191 if (maxTextureSize) { |
192 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxText
ureSize) { | 192 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxText
ureSize) { |
193 SkScalar downScale = maxTextureSize / SkMax32(scaledSize.width(), sc
aledSize.height()); | 193 SkScalar downScale = maxTextureSize / SkMaxScalar(scaledSize.width()
, scaledSize.height()); |
194 scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(),
downScale)), | 194 scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(),
downScale)), |
195 SkScalarFloorToScalar(SkScalarMul(scaledSize.height()
, downScale))); | 195 SkScalarFloorToScalar(SkScalarMul(scaledSize.height()
, downScale))); |
196 } | 196 } |
197 } | 197 } |
198 #endif | 198 #endif |
199 | 199 |
200 SkISize tileSize = scaledSize.toRound(); | 200 SkISize tileSize = scaledSize.toRound(); |
201 if (tileSize.isEmpty()) { | 201 if (tileSize.isEmpty()) { |
202 return SkShader::CreateEmptyShader(); | 202 return SkShader::CreateEmptyShader(); |
203 } | 203 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 if (context) { | 323 if (context) { |
324 maxTextureSize = context->caps()->maxTextureSize(); | 324 maxTextureSize = context->caps()->maxTextureSize(); |
325 } | 325 } |
326 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix
, maxTextureSize)); | 326 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix
, maxTextureSize)); |
327 if (!bitmapShader) { | 327 if (!bitmapShader) { |
328 return nullptr; | 328 return nullptr; |
329 } | 329 } |
330 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq); | 330 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq); |
331 } | 331 } |
332 #endif | 332 #endif |
OLD | NEW |