Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: Source/platform/graphics/ImageDecodingStore.h

Issue 131003004: Update platform classes to use OVERRIDE / FINAL when needed (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 const ImageFrameGenerator* m_generator; 190 const ImageFrameGenerator* m_generator;
191 int m_useCount; 191 int m_useCount;
192 bool m_isDiscardable; 192 bool m_isDiscardable;
193 bool m_isAccountingEnabled; 193 bool m_isAccountingEnabled;
194 194
195 private: 195 private:
196 CacheEntry* m_prev; 196 CacheEntry* m_prev;
197 CacheEntry* m_next; 197 CacheEntry* m_next;
198 }; 198 };
199 199
200 class ImageCacheEntry : public CacheEntry { 200 class ImageCacheEntry FINAL : public CacheEntry {
201 public: 201 public:
202 static PassOwnPtr<ImageCacheEntry> createAndUse(const ImageFrameGenerato r* generator, PassOwnPtr<ScaledImageFragment> image) 202 static PassOwnPtr<ImageCacheEntry> createAndUse(const ImageFrameGenerato r* generator, PassOwnPtr<ScaledImageFragment> image)
203 { 203 {
204 return adoptPtr(new ImageCacheEntry(generator, 1, image)); 204 return adoptPtr(new ImageCacheEntry(generator, 1, image));
205 } 205 }
206 206
207 ImageCacheEntry(const ImageFrameGenerator* generator, int count, PassOwn Ptr<ScaledImageFragment> image) 207 ImageCacheEntry(const ImageFrameGenerator* generator, int count, PassOwn Ptr<ScaledImageFragment> image)
208 : CacheEntry(generator, count, DiscardablePixelRef::isDiscardable(im age->bitmap().pixelRef())) 208 : CacheEntry(generator, count, DiscardablePixelRef::isDiscardable(im age->bitmap().pixelRef()))
209 , m_cachedImage(image) 209 , m_cachedImage(image)
210 { 210 {
211 } 211 }
212 212
213 // FIXME: getSafeSize() returns size in bytes truncated to a 32-bits int eger. 213 // FIXME: getSafeSize() returns size in bytes truncated to a 32-bits int eger.
214 // Find a way to get the size in 64-bits. 214 // Find a way to get the size in 64-bits.
215 virtual size_t memoryUsageInBytes() const { return cachedImage()->bitmap ().getSafeSize(); } 215 virtual size_t memoryUsageInBytes() const OVERRIDE { return cachedImage( )->bitmap().getSafeSize(); }
216 virtual CacheType type() const { return TypeImage; } 216 virtual CacheType type() const OVERRIDE { return TypeImage; }
217 217
218 static ImageCacheKey makeCacheKey(const ImageFrameGenerator* generator, const SkISize& size, size_t index, size_t generation) 218 static ImageCacheKey makeCacheKey(const ImageFrameGenerator* generator, const SkISize& size, size_t index, size_t generation)
219 { 219 {
220 return std::make_pair(std::make_pair(generator, size), std::make_pai r(index, generation)); 220 return std::make_pair(std::make_pair(generator, size), std::make_pai r(index, generation));
221 } 221 }
222 ImageCacheKey cacheKey() const { return makeCacheKey(m_generator, m_cach edImage->scaledSize(), m_cachedImage->index(), m_cachedImage->generation()); } 222 ImageCacheKey cacheKey() const { return makeCacheKey(m_generator, m_cach edImage->scaledSize(), m_cachedImage->index(), m_cachedImage->generation()); }
223 const ScaledImageFragment* cachedImage() const { return m_cachedImage.ge t(); } 223 const ScaledImageFragment* cachedImage() const { return m_cachedImage.ge t(); }
224 ScaledImageFragment* cachedImage() { return m_cachedImage.get(); } 224 ScaledImageFragment* cachedImage() { return m_cachedImage.get(); }
225 225
226 private: 226 private:
227 OwnPtr<ScaledImageFragment> m_cachedImage; 227 OwnPtr<ScaledImageFragment> m_cachedImage;
228 }; 228 };
229 229
230 class DecoderCacheEntry : public CacheEntry { 230 class DecoderCacheEntry FINAL : public CacheEntry {
231 public: 231 public:
232 static PassOwnPtr<DecoderCacheEntry> create(const ImageFrameGenerator* g enerator, PassOwnPtr<ImageDecoder> decoder, bool isDiscardable) 232 static PassOwnPtr<DecoderCacheEntry> create(const ImageFrameGenerator* g enerator, PassOwnPtr<ImageDecoder> decoder, bool isDiscardable)
233 { 233 {
234 return adoptPtr(new DecoderCacheEntry(generator, 0, decoder, isDisca rdable)); 234 return adoptPtr(new DecoderCacheEntry(generator, 0, decoder, isDisca rdable));
235 } 235 }
236 236
237 DecoderCacheEntry(const ImageFrameGenerator* generator, int count, PassO wnPtr<ImageDecoder> decoder, bool isDiscardable) 237 DecoderCacheEntry(const ImageFrameGenerator* generator, int count, PassO wnPtr<ImageDecoder> decoder, bool isDiscardable)
238 : CacheEntry(generator, count, isDiscardable) 238 : CacheEntry(generator, count, isDiscardable)
239 , m_cachedDecoder(decoder) 239 , m_cachedDecoder(decoder)
240 , m_size(SkISize::Make(m_cachedDecoder->decodedSize().width(), m_cac hedDecoder->decodedSize().height())) 240 , m_size(SkISize::Make(m_cachedDecoder->decodedSize().width(), m_cac hedDecoder->decodedSize().height()))
241 { 241 {
242 } 242 }
243 243
244 virtual size_t memoryUsageInBytes() const { return m_size.width() * m_si ze.height() * 4; } 244 virtual size_t memoryUsageInBytes() const OVERRIDE { return m_size.width () * m_size.height() * 4; }
245 virtual CacheType type() const { return TypeDecoder; } 245 virtual CacheType type() const OVERRIDE { return TypeDecoder; }
246 246
247 static DecoderCacheKey makeCacheKey(const ImageFrameGenerator* generator , const SkISize& size) 247 static DecoderCacheKey makeCacheKey(const ImageFrameGenerator* generator , const SkISize& size)
248 { 248 {
249 return std::make_pair(generator, size); 249 return std::make_pair(generator, size);
250 } 250 }
251 static DecoderCacheKey makeCacheKey(const ImageFrameGenerator* generator , const ImageDecoder* decoder) 251 static DecoderCacheKey makeCacheKey(const ImageFrameGenerator* generator , const ImageDecoder* decoder)
252 { 252 {
253 return std::make_pair(generator, SkISize::Make(decoder->decodedSize( ).width(), decoder->decodedSize().height())); 253 return std::make_pair(generator, SkISize::Make(decoder->decodedSize( ).width(), decoder->decodedSize().height()));
254 } 254 }
255 DecoderCacheKey cacheKey() const { return makeCacheKey(m_generator, m_si ze); } 255 DecoderCacheKey cacheKey() const { return makeCacheKey(m_generator, m_si ze); }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // m_cacheLimitInBytes 333 // m_cacheLimitInBytes
334 // m_memoryUsageInBytes 334 // m_memoryUsageInBytes
335 // This mutex also protects calls to underlying skBitmap's 335 // This mutex also protects calls to underlying skBitmap's
336 // lockPixels()/unlockPixels() as they are not threadsafe. 336 // lockPixels()/unlockPixels() as they are not threadsafe.
337 Mutex m_mutex; 337 Mutex m_mutex;
338 }; 338 };
339 339
340 } // namespace WebCore 340 } // namespace WebCore
341 341
342 #endif 342 #endif
OLDNEW
« no previous file with comments | « Source/platform/graphics/DiscardablePixelRef.h ('k') | Source/platform/graphics/LazyDecodingPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698