OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 SkASSERT(SkPaint::kMedium_FilterLevel == fFilterLevel); | 253 SkASSERT(SkPaint::kMedium_FilterLevel == fFilterLevel); |
254 | 254 |
255 /** | 255 /** |
256 * Medium quality means use a mipmap for down-scaling, and just bilper | 256 * Medium quality means use a mipmap for down-scaling, and just bilper |
257 * for upscaling. Since we're examining the inverse matrix, we look for | 257 * for upscaling. Since we're examining the inverse matrix, we look for |
258 * a scale > 1 to indicate down scaling by the CTM. | 258 * a scale > 1 to indicate down scaling by the CTM. |
259 */ | 259 */ |
260 if (scaleSqd > SK_Scalar1) { | 260 if (scaleSqd > SK_Scalar1) { |
261 fCurrMip.reset(SkMipMapCache::FindAndRef(fOrigBitmap)); | 261 fCurrMip.reset(SkMipMapCache::FindAndRef(fOrigBitmap)); |
262 if (NULL == fCurrMip.get()) { | 262 if (NULL == fCurrMip.get()) { |
263 fCurrMip.reset(SkMipMap::Build(fOrigBitmap)); | 263 fCurrMip.reset(SkMipMapCache::AddAndRef(fOrigBitmap)); |
264 if (NULL == fCurrMip.get()) { | 264 if (NULL == fCurrMip.get()) { |
265 return false; | 265 return false; |
266 } | 266 } |
267 SkMipMapCache::Add(fOrigBitmap, fCurrMip); | |
268 } | 267 } |
269 | 268 |
270 SkScalar levelScale = SkScalarInvert(SkScalarSqrt(scaleSqd)); | 269 SkScalar levelScale = SkScalarInvert(SkScalarSqrt(scaleSqd)); |
271 SkMipMap::Level level; | 270 SkMipMap::Level level; |
272 if (fCurrMip->extractLevel(levelScale, &level)) { | 271 if (fCurrMip->extractLevel(levelScale, &level)) { |
273 SkScalar invScaleFixup = level.fScale; | 272 SkScalar invScaleFixup = level.fScale; |
274 fInvMatrix.postScale(invScaleFixup, invScaleFixup); | 273 fInvMatrix.postScale(invScaleFixup, invScaleFixup); |
275 | 274 |
276 const SkImageInfo info = fOrigBitmap.info().makeWH(level.fWidth, lev
el.fHeight); | 275 const SkImageInfo info = fOrigBitmap.info().makeWH(level.fWidth, lev
el.fHeight); |
277 // todo: if we could wrap the fCurrMip in a pixelref, then we could
just install | 276 // todo: if we could wrap the fCurrMip in a pixelref, then we could
just install |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 } else { | 1005 } else { |
1007 size >>= 2; | 1006 size >>= 2; |
1008 } | 1007 } |
1009 | 1008 |
1010 if (fFilterLevel != SkPaint::kNone_FilterLevel) { | 1009 if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
1011 size >>= 1; | 1010 size >>= 1; |
1012 } | 1011 } |
1013 | 1012 |
1014 return size; | 1013 return size; |
1015 } | 1014 } |
OLD | NEW |