| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/thumbnail/thumbnail_cache.h" | 5 #include "chrome/browser/android/thumbnail/thumbnail_cache.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/android/path_utils.h" | 10 #include "base/android/path_utils.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 cache_.Remove(key_to_remove); | 466 cache_.Remove(key_to_remove); |
| 467 } | 467 } |
| 468 | 468 |
| 469 void ThumbnailCache::RemoveFromReadQueue(TabId tab_id) { | 469 void ThumbnailCache::RemoveFromReadQueue(TabId tab_id) { |
| 470 TabIdList::iterator read_iter = | 470 TabIdList::iterator read_iter = |
| 471 std::find(read_queue_.begin(), read_queue_.end(), tab_id); | 471 std::find(read_queue_.begin(), read_queue_.end(), tab_id); |
| 472 if (read_iter != read_queue_.end()) | 472 if (read_iter != read_queue_.end()) |
| 473 read_queue_.erase(read_iter); | 473 read_queue_.erase(read_iter); |
| 474 } | 474 } |
| 475 | 475 |
| 476 void ThumbnailCache::OnUIResourcesWereEvicted() { |
| 477 cache_.Clear(); |
| 478 approximation_cache_.Clear(); |
| 479 } |
| 480 |
| 476 void ThumbnailCache::InvalidateCachedThumbnail(Thumbnail* thumbnail) { | 481 void ThumbnailCache::InvalidateCachedThumbnail(Thumbnail* thumbnail) { |
| 477 DCHECK(thumbnail); | 482 DCHECK(thumbnail); |
| 478 TabId tab_id = thumbnail->tab_id(); | 483 TabId tab_id = thumbnail->tab_id(); |
| 479 cc::UIResourceId uid = thumbnail->ui_resource_id(); | 484 cc::UIResourceId uid = thumbnail->ui_resource_id(); |
| 480 | 485 |
| 481 Thumbnail* cached_thumbnail = cache_.Get(tab_id); | 486 Thumbnail* cached_thumbnail = cache_.Get(tab_id); |
| 482 if (cached_thumbnail && cached_thumbnail->ui_resource_id() == uid) | 487 if (cached_thumbnail && cached_thumbnail->ui_resource_id() == uid) |
| 483 cache_.Remove(tab_id); | 488 cache_.Remove(tab_id); |
| 484 | 489 |
| 485 cached_thumbnail = approximation_cache_.Get(tab_id); | 490 cached_thumbnail = approximation_cache_.Get(tab_id); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 dst_bitmap.eraseColor(0); | 929 dst_bitmap.eraseColor(0); |
| 925 SkAutoLockPixels dst_bitmap_lock(dst_bitmap); | 930 SkAutoLockPixels dst_bitmap_lock(dst_bitmap); |
| 926 | 931 |
| 927 SkCanvas canvas(dst_bitmap); | 932 SkCanvas canvas(dst_bitmap); |
| 928 canvas.scale(new_scale, new_scale); | 933 canvas.scale(new_scale, new_scale); |
| 929 canvas.drawBitmap(bitmap, 0, 0, NULL); | 934 canvas.drawBitmap(bitmap, 0, 0, NULL); |
| 930 dst_bitmap.setImmutable(); | 935 dst_bitmap.setImmutable(); |
| 931 | 936 |
| 932 return std::make_pair(dst_bitmap, new_scale * scale); | 937 return std::make_pair(dst_bitmap, new_scale * scale); |
| 933 } | 938 } |
| OLD | NEW |