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

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

Issue 54203006: Break up SkLazyPixelRef functionally into class hierarchy. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove SkCachingPixelRef::fCache Created 7 years, 1 month 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
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/lazy/SkCachingPixelRef.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkCachingPixelRef_DEFINED
9 #define SkCachingPixelRef_DEFINED
10
11 #include "SkImage.h"
12 #include "SkPixelRef.h"
13
14 class SkColorTable;
15
16 /**
17 * PixelRef which defers decoding until SkBitmap::lockPixels() is
18 * called. Caches the decoded images in the global
19 * SkScaledImageCache. When the pixels are unlocked, this cache may
20 * or be destroyed before the next lock. If so, onLockPixels will
21 * attempt to re-decode.
22 *
23 * Decoding is handled by the pure-virtual functions onDecodeInfo()
24 * and onDecode(). Subclasses of this class need only provide those
25 * two functions.
26 */
27 class SkCachingPixelRef : public SkPixelRef {
28 public:
29 explicit SkCachingPixelRef();
reed1 2013/11/04 14:49:06 don't need this word if there is no parameter
hal.canary 2013/11/04 15:25:22 Done.
30 virtual ~SkCachingPixelRef();
31
32 protected:
33 virtual void* onLockPixels(SkColorTable** colorTable) SK_OVERRIDE;
34 virtual void onUnlockPixels() SK_OVERRIDE;
35 virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; }
36 virtual bool onImplementsDecodeInto() SK_OVERRIDE { return true; }
37 virtual bool onDecodeInto(int pow2, SkBitmap*) SK_OVERRIDE;
38
39 /**
40 * Configure the supplied bitmap for this pixelRef, based on
41 * information provided by onDecodeInfo(). Does not set the
42 * bitmap's pixelRef. */
43 bool configure(SkBitmap* bitmap);
44
45 /**
46 * Cache info from onDecodeInfo(). Returns NULL on failure.
47 */
48 const SkImageInfo* getInfo();
49
50 /**
51 * Return some information about the pixels, allowing this class
52 * to allocate pixels. @return false if anything goes wrong.
53 */
54 virtual bool onDecodeInfo(SkImageInfo* info) = 0;
55 /**
56 * Decode into the given pixels, a block of memory of size
57 * (info->fHeight * rowBytes) bytes. Should follow the format
58 * reported by onDecodeInfo().
59 * @return false if anything goes wrong.
60 */
61 virtual bool onDecode(void* pixels, size_t rowBytes) = 0;
reed1 2013/11/04 14:49:06 nit: I think onDecodePixels would be clearer, sinc
hal.canary 2013/11/04 15:25:22 Done
62
63 private:
64 bool fErrorInDecoding;
65 void* fScaledCacheId;
66 SkImageInfo fInfo;
67
68 typedef SkPixelRef INHERITED;
69 };
70
71 #endif // SkCachingPixelRef_DEFINED
72
OLDNEW
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/lazy/SkCachingPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698