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

Side by Side Diff: src/lazy/SkLazyPixelRef.h

Issue 37343002: Allow SkLazyPixelRef to use SkScaledImageCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: more changes Created 7 years, 2 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 2012 Google Inc. 2 * Copyright 2012 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 #ifndef SkLazyPixelRef_DEFINED 8 #ifndef SkLazyPixelRef_DEFINED
9 #define SkLazyPixelRef_DEFINED 9 #define SkLazyPixelRef_DEFINED
10 10
(...skipping 15 matching lines...) Expand all
26 /** 26 /**
27 * PixelRef which defers decoding until SkBitmap::lockPixels() is called. 27 * PixelRef which defers decoding until SkBitmap::lockPixels() is called.
28 */ 28 */
29 class SkLazyPixelRef : public SkPixelRef { 29 class SkLazyPixelRef : public SkPixelRef {
30 30
31 public: 31 public:
32 /** 32 /**
33 * Create a new SkLazyPixelRef. 33 * Create a new SkLazyPixelRef.
34 * @param SkData Encoded data representing the pixels. 34 * @param SkData Encoded data representing the pixels.
35 * @param DecodeProc Called to decode the pixels when needed. Must be non-N ULL. 35 * @param DecodeProc Called to decode the pixels when needed. Must be non-N ULL.
36 * @param SkImageCache Object that handles allocating and freeing the pixel memory, as needed. 36 * @param SkImageCache Object that handles allocating and freeing
37 * Must not be NULL. 37 * the pixel memory, as needed. If NULL, use the global
38 * SkScaledImageCache.
38 */ 39 */
39 SkLazyPixelRef(SkData*, SkBitmapFactory::DecodeProc, SkImageCache*); 40 SkLazyPixelRef(SkData*, SkBitmapFactory::DecodeProc, SkImageCache*);
40 41
41 virtual ~SkLazyPixelRef(); 42 virtual ~SkLazyPixelRef();
42 43
43 #ifdef SK_DEBUG 44 #ifdef SK_DEBUG
44 intptr_t getCacheId() const { return fCacheId; } 45 intptr_t getCacheId() const { return fCacheId; }
45 #endif 46 #endif
46 47
47 #if LAZY_CACHE_STATS 48 #if LAZY_CACHE_STATS
48 static int32_t GetCacheHits() { return gCacheHits; } 49 static int32_t GetCacheHits() { return gCacheHits; }
49 static int32_t GetCacheMisses() { return gCacheMisses; } 50 static int32_t GetCacheMisses() { return gCacheMisses; }
50 static void ResetCacheStats() { gCacheHits = gCacheMisses = 0; } 51 static void ResetCacheStats() { gCacheHits = gCacheMisses = 0; }
51 #endif 52 #endif
52 53
54 /**
55 * The allocator is used when (fImageCache==NULL) to allocate
56 * concrete PixelRefs as needed. If NULL, use the default allocator.
57 * This is passed directly into SkBitmap::allocPixels().
58 */
59 virtual void setAllocator(SkBitmap::Allocator * allocator = NULL);
mtklein 2013/10/24 17:03:25 *
60
53 // No need to flatten this object. When flattening an SkBitmap, SkOrderedWri teBuffer will check 61 // No need to flatten this object. When flattening an SkBitmap, SkOrderedWri teBuffer will check
54 // the encoded data and write that instead. 62 // the encoded data and write that instead.
55 // Future implementations of SkFlattenableWriteBuffer will need to special c ase for 63 // Future implementations of SkFlattenableWriteBuffer will need to special c ase for
56 // onRefEncodedData as well. 64 // onRefEncodedData as well.
57 SK_DECLARE_UNFLATTENABLE_OBJECT() 65 SK_DECLARE_UNFLATTENABLE_OBJECT()
58 66
59 protected: 67 protected:
60 virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE; 68 virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE;
61 virtual void onUnlockPixels() SK_OVERRIDE; 69 virtual void onUnlockPixels() SK_OVERRIDE;
62 virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; } 70 virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; }
63 virtual SkData* onRefEncodedData() SK_OVERRIDE; 71 virtual SkData* onRefEncodedData() SK_OVERRIDE;
64 virtual bool onImplementsDecodeInto() SK_OVERRIDE; 72 virtual bool onImplementsDecodeInto() SK_OVERRIDE;
65 virtual bool onDecodeInto(int pow2, SkBitmap*) SK_OVERRIDE; 73 virtual bool onDecodeInto(int pow2, SkBitmap*) SK_OVERRIDE;
66 74
67 private: 75 private:
68 bool fErrorInDecoding; 76 bool fErrorInDecoding;
69 SkData* fData; 77 SkData* fData;
70 SkBitmapFactory::DecodeProc fDecodeProc; 78 SkBitmapFactory::DecodeProc fDecodeProc;
71 SkImageCache* fImageCache; 79 SkImageCache* fImageCache;
80 // fCacheId is a (SkScaledImageCache::ID*) or a (SkImageCache::ID).
72 intptr_t fCacheId; 81 intptr_t fCacheId;
73 size_t fRowBytes; 82 size_t fRowBytes;
74 SkImage::Info fLazilyCachedInfo; 83 SkImage::Info fLazilyCachedInfo;
84 SkBitmap::Allocator* fAllocator;
75 85
76 #if LAZY_CACHE_STATS 86 #if LAZY_CACHE_STATS
77 static int32_t gCacheHits; 87 static int32_t gCacheHits;
78 static int32_t gCacheMisses; 88 static int32_t gCacheMisses;
79 #endif 89 #endif
80 90
81 // lazily initialized our cached info. Returns NULL on failure. 91 // lazily initialized our cached info. Returns NULL on failure.
82 const SkImage::Info* getCachedInfo(); 92 const SkImage::Info* getCachedInfo();
93 void* lockScaledImageCachePixels();
94 void* lockImageCachePixels();
95
83 96
84 typedef SkPixelRef INHERITED; 97 typedef SkPixelRef INHERITED;
85 }; 98 };
86 99
87 #endif // SkLazyPixelRef_DEFINED 100 #endif // SkLazyPixelRef_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698