| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_UI_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // Returns the icon of the |row|th row. | 26 // Returns the icon of the |row|th row. |
| 27 virtual SkBitmap GetIcon(int row) const = 0; | 27 virtual SkBitmap GetIcon(int row) const = 0; |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 virtual ~Table() {} | 30 virtual ~Table() {} |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 // |model| must outlive the cache. | 33 // |model| must outlive the cache. |
| 34 explicit TableRowNSImageCache(Table* model); | 34 explicit TableRowNSImageCache(Table* model); |
| 35 ~TableRowNSImageCache(); |
| 35 | 36 |
| 36 // Lazily converts the image at the given row and caches it in |icon_images_|. | 37 // Lazily converts the image at the given row and caches it in |icon_images_|. |
| 37 NSImage* GetImageForRow(int row); | 38 NSImage* GetImageForRow(int row); |
| 38 | 39 |
| 39 // Call these functions every time the table changes, to update the cache. | 40 // Call these functions every time the table changes, to update the cache. |
| 40 void OnModelChanged(); | 41 void OnModelChanged(); |
| 41 void OnItemsChanged(int start, int length); | 42 void OnItemsChanged(int start, int length); |
| 42 void OnItemsAdded(int start, int length); | 43 void OnItemsAdded(int start, int length); |
| 43 void OnItemsRemoved(int start, int length); | 44 void OnItemsRemoved(int start, int length); |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 // The table model we query for row count and icons. | 47 // The table model we query for row count and icons. |
| 47 Table* model_; // weak | 48 Table* model_; // weak |
| 48 | 49 |
| 49 // Stores strong NSImage refs for icons. If an entry is NULL, it will be | 50 // Stores strong NSImage refs for icons. If an entry is NULL, it will be |
| 50 // created in GetImageForRow(). | 51 // created in GetImageForRow(). |
| 51 scoped_nsobject<NSPointerArray> icon_images_; | 52 scoped_nsobject<NSPointerArray> icon_images_; |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 #endif // CHROME_BROWSER_UI_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_ | 55 #endif // CHROME_BROWSER_UI_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_ |
| 55 | 56 |
| OLD | NEW |