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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 / SkMaxScalar(scaledSize.width()
, scaledSize.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 #ifdef SK_SUPPORT_LEGACY_PICTURESHADER_ROUNDING |
| 201 const SkISize tileSize = scaledSize.toRound(); |
| 202 #else |
| 203 const SkISize tileSize = scaledSize.toCeil(); |
| 204 #endif |
201 if (tileSize.isEmpty()) { | 205 if (tileSize.isEmpty()) { |
202 return SkShader::CreateEmptyShader(); | 206 return SkShader::CreateEmptyShader(); |
203 } | 207 } |
204 | 208 |
205 // The actual scale, compensating for rounding & clamping. | 209 // The actual scale, compensating for rounding & clamping. |
206 SkSize tileScale = SkSize::Make(SkIntToScalar(tileSize.width()) / fTile.widt
h(), | 210 const SkSize tileScale = SkSize::Make(SkIntToScalar(tileSize.width()) / fTil
e.width(), |
207 SkIntToScalar(tileSize.height()) / fTile.hei
ght()); | 211 SkIntToScalar(tileSize.height()) / fTi
le.height()); |
208 | 212 |
209 SkAutoTUnref<SkShader> tileShader; | 213 SkAutoTUnref<SkShader> tileShader; |
210 BitmapShaderKey key(fPicture->uniqueID(), | 214 BitmapShaderKey key(fPicture->uniqueID(), |
211 fTile, | 215 fTile, |
212 fTmx, | 216 fTmx, |
213 fTmy, | 217 fTmy, |
214 tileScale, | 218 tileScale, |
215 this->getLocalMatrix()); | 219 this->getLocalMatrix()); |
216 | 220 |
217 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { | 221 if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if (context) { | 325 if (context) { |
322 maxTextureSize = context->caps()->maxTextureSize(); | 326 maxTextureSize = context->caps()->maxTextureSize(); |
323 } | 327 } |
324 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix
, maxTextureSize)); | 328 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix
, maxTextureSize)); |
325 if (!bitmapShader) { | 329 if (!bitmapShader) { |
326 return nullptr; | 330 return nullptr; |
327 } | 331 } |
328 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq); | 332 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq); |
329 } | 333 } |
330 #endif | 334 #endif |
OLD | NEW |