OLD | NEW |
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 SkCachingPixelRef_DEFINED | 8 #ifndef SkCachingPixelRef_DEFINED |
9 #define SkCachingPixelRef_DEFINED | 9 #define SkCachingPixelRef_DEFINED |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 | 29 |
30 /** | 30 /** |
31 * Takes ownership of SkImageGenerator. If this method fails for | 31 * Takes ownership of SkImageGenerator. If this method fails for |
32 * whatever reason, it will return false and immediatetely delete | 32 * whatever reason, it will return false and immediatetely delete |
33 * the generator. If it succeeds, it will modify destination | 33 * the generator. If it succeeds, it will modify destination |
34 * bitmap. | 34 * bitmap. |
35 * | 35 * |
36 * If Install fails or when the SkCachingPixelRef that is | 36 * If Install fails or when the SkCachingPixelRef that is |
37 * installed into destination is destroyed, it will call | 37 * installed into destination is destroyed, it will call |
38 * SkDELETE() on the generator. Therefore, generator should be | 38 * `delete` on the generator. Therefore, generator should be |
39 * allocated with SkNEW() or SkNEW_ARGS(). | 39 * allocated with `new`. |
40 */ | 40 */ |
41 static bool Install(SkImageGenerator* gen, SkBitmap* dst); | 41 static bool Install(SkImageGenerator* gen, SkBitmap* dst); |
42 | 42 |
43 protected: | 43 protected: |
44 virtual ~SkCachingPixelRef(); | 44 virtual ~SkCachingPixelRef(); |
45 bool onNewLockPixels(LockRec*) override; | 45 bool onNewLockPixels(LockRec*) override; |
46 void onUnlockPixels() override; | 46 void onUnlockPixels() override; |
47 bool onLockPixelsAreWritable() const override { return false; } | 47 bool onLockPixelsAreWritable() const override { return false; } |
48 | 48 |
49 SkData* onRefEncodedData() override { | 49 SkData* onRefEncodedData() override { |
50 return fImageGenerator->refEncodedData(); | 50 return fImageGenerator->refEncodedData(); |
51 } | 51 } |
52 | 52 |
53 bool onIsLazyGenerated() const override { return true; } | 53 bool onIsLazyGenerated() const override { return true; } |
54 | 54 |
55 private: | 55 private: |
56 SkImageGenerator* const fImageGenerator; | 56 SkImageGenerator* const fImageGenerator; |
57 bool fErrorInDecoding; | 57 bool fErrorInDecoding; |
58 const size_t fRowBytes; | 58 const size_t fRowBytes; |
59 | 59 |
60 SkBitmap fLockedBitmap; | 60 SkBitmap fLockedBitmap; |
61 | 61 |
62 SkCachingPixelRef(const SkImageInfo&, SkImageGenerator*, size_t rowBytes); | 62 SkCachingPixelRef(const SkImageInfo&, SkImageGenerator*, size_t rowBytes); |
63 | 63 |
64 typedef SkPixelRef INHERITED; | 64 typedef SkPixelRef INHERITED; |
65 }; | 65 }; |
66 | 66 |
67 #endif // SkCachingPixelRef_DEFINED | 67 #endif // SkCachingPixelRef_DEFINED |
OLD | NEW |