OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkScaledImageCache.h" | 8 #include "SkScaledImageCache.h" |
9 #include "SkMipMap.h" | 9 #include "SkMipMap.h" |
10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return hash; | 41 return hash; |
42 } | 42 } |
43 | 43 |
44 struct Key { | 44 struct Key { |
45 bool init(const SkBitmap& bm, SkScalar scaleX, SkScalar scaleY) { | 45 bool init(const SkBitmap& bm, SkScalar scaleX, SkScalar scaleY) { |
46 SkPixelRef* pr = bm.pixelRef(); | 46 SkPixelRef* pr = bm.pixelRef(); |
47 if (!pr) { | 47 if (!pr) { |
48 return false; | 48 return false; |
49 } | 49 } |
50 | 50 |
51 size_t offset = bm.pixelRefOffset(); | 51 size_t x, y; |
52 size_t rowBytes = bm.rowBytes(); | 52 SkTDivMod(bm.pixelRefOffset(), bm.rowBytes(), &y, &x); |
53 int x = (offset % rowBytes) >> 2; | 53 x >>= 2; |
54 int y = offset / rowBytes; | |
55 | 54 |
56 fGenID = pr->getGenerationID(); | 55 fGenID = pr->getGenerationID(); |
57 fBounds.set(x, y, x + bm.width(), y + bm.height()); | 56 fBounds.set(x, y, x + bm.width(), y + bm.height()); |
58 fScaleX = scaleX; | 57 fScaleX = scaleX; |
59 fScaleY = scaleY; | 58 fScaleY = scaleY; |
60 | 59 |
61 fHash = compute_hash(&fGenID, 7); | 60 fHash = compute_hash(&fGenID, 7); |
62 return true; | 61 return true; |
63 } | 62 } |
64 | 63 |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 return SkScaledImageCache::GetBytesUsed(); | 515 return SkScaledImageCache::GetBytesUsed(); |
517 } | 516 } |
518 | 517 |
519 size_t SkGraphics::GetImageCacheByteLimit() { | 518 size_t SkGraphics::GetImageCacheByteLimit() { |
520 return SkScaledImageCache::GetByteLimit(); | 519 return SkScaledImageCache::GetByteLimit(); |
521 } | 520 } |
522 | 521 |
523 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) { | 522 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) { |
524 return SkScaledImageCache::SetByteLimit(newLimit); | 523 return SkScaledImageCache::SetByteLimit(newLimit); |
525 } | 524 } |
OLD | NEW |