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

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

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: new convention: require SkImageInfo in constructor Created 7 years 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 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 #ifndef SkLazyCachingPixelRef_DEFINED 8 #ifndef SkLazyCachingPixelRef_DEFINED
9 #define SkLazyCachingPixelRef_DEFINED 9 #define SkLazyCachingPixelRef_DEFINED
10 10
(...skipping 10 matching lines...) Expand all
21 class SkLazyCachingPixelRef : public SkCachingPixelRef { 21 class SkLazyCachingPixelRef : public SkCachingPixelRef {
22 public: 22 public:
23 /** 23 /**
24 * @param data Encoded data representing the pixels. NULL is 24 * @param data Encoded data representing the pixels. NULL is
25 * equivalent to an empty data, and will be passed to 25 * equivalent to an empty data, and will be passed to
26 * DecodeProc with length zero. 26 * DecodeProc with length zero.
27 * 27 *
28 * @param procedure Called to decode the pixels when 28 * @param procedure Called to decode the pixels when
29 * needed. If NULL, use SkImageDecoder::DecodeMemoryToTarget. 29 * needed. If NULL, use SkImageDecoder::DecodeMemoryToTarget.
30 */ 30 */
31 SkLazyCachingPixelRef(SkData* data, 31 SkLazyCachingPixelRef(const SkImageInfo&, SkData* data,
32 SkBitmapFactory::DecodeProc procedure); 32 SkBitmapFactory::DecodeProc procedure);
33 33
34 virtual ~SkLazyCachingPixelRef(); 34 virtual ~SkLazyCachingPixelRef();
35 35
36 virtual SkData* onRefEncodedData() SK_OVERRIDE { return SkSafeRef(fData); } 36 virtual SkData* onRefEncodedData() SK_OVERRIDE { return SkSafeRef(fData); }
37 37
38 /** 38 /**
39 * A simplified version of SkBitmapFactory. Installs a new 39 * A simplified version of SkBitmapFactory. Installs a new
40 * SkLazyCachingPixelRef into the provided bitmap. Will 40 * SkLazyCachingPixelRef into the provided bitmap. Will
41 * immediately call onDecodeInfo() to configure the bitmap, but 41 * immediately call onDecodeInfo() to configure the bitmap, but
(...skipping 17 matching lines...) Expand all
59 59
60 // No need to flatten this object. When flattening an SkBitmap, 60 // No need to flatten this object. When flattening an SkBitmap,
61 // SkOrderedWriteBuffer will check the encoded data and write that 61 // SkOrderedWriteBuffer will check the encoded data and write that
62 // instead. 62 // instead.
63 // Future implementations of SkFlattenableWriteBuffer will need to 63 // Future implementations of SkFlattenableWriteBuffer will need to
64 // special case for onRefEncodedData as well. 64 // special case for onRefEncodedData as well.
65 SK_DECLARE_UNFLATTENABLE_OBJECT() 65 SK_DECLARE_UNFLATTENABLE_OBJECT()
66 66
67 protected: 67 protected:
68 /** 68 /**
69 * Return some information about the pixels, allowing this class
70 * to allocate pixels. @return false if anything goes wrong.
71 *
72 * This implementation calls SkBitmapFactory::DecodeProc with a
73 * NULL target.
74 */
75 virtual bool onDecodeInfo(SkImageInfo* info) SK_OVERRIDE;
76 /**
77 * Decode into the given pixels, a block of memory of size 69 * Decode into the given pixels, a block of memory of size
78 * (info.fHeight * rowBytes) bytes. 70 * (info.fHeight * rowBytes) bytes.
79 * 71 *
80 * @param info Should be identical to the info returned by 72 * @param info Should be identical to the info returned by
81 * onDecodeInfo so that the implementation can confirm 73 * onDecodeInfo so that the implementation can confirm
82 * that the caller knows what its asking for (config, 74 * that the caller knows what its asking for (config,
83 * size). 75 * size).
84 * 76 *
85 * @return false if anything goes wrong. 77 * @return false if anything goes wrong.
86 */ 78 */
87 virtual bool onDecodePixels(const SkImageInfo& info, 79 virtual bool onDecodePixels(void* pixels,
88 void* pixels,
89 size_t rowBytes) SK_OVERRIDE; 80 size_t rowBytes) SK_OVERRIDE;
90 81
91 private: 82 private:
92 SkData* fData; 83 SkData* fData;
93 SkBitmapFactory::DecodeProc fDecodeProc; 84 SkBitmapFactory::DecodeProc fDecodeProc;
94 85
95 typedef SkCachingPixelRef INHERITED; 86 typedef SkCachingPixelRef INHERITED;
96 }; 87 };
97 88
98 #endif // SkLazyCachingPixelRef_DEFINED 89 #endif // SkLazyCachingPixelRef_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698