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

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

Issue 304443003: add colortable support to imagegenerator (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix spelling Created 6 years, 6 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
« no previous file with comments | « src/images/SkImageGenerator.cpp ('k') | src/lazy/SkDiscardablePixelRef.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SkDiscardablePixelRef_DEFINED 8 #ifndef SkDiscardablePixelRef_DEFINED
9 #define SkDiscardablePixelRef_DEFINED 9 #define SkDiscardablePixelRef_DEFINED
10 10
11 #include "SkDiscardableMemory.h" 11 #include "SkDiscardableMemory.h"
12 #include "SkImageGenerator.h" 12 #include "SkImageGenerator.h"
13 #include "SkImageInfo.h" 13 #include "SkImageInfo.h"
14 #include "SkPixelRef.h" 14 #include "SkPixelRef.h"
15 15
16 /** 16 /**
17 * A PixelRef backed by SkDiscardableMemory, with the ability to 17 * A PixelRef backed by SkDiscardableMemory, with the ability to
18 * re-generate the pixels (via a SkImageGenerator) if the DM is 18 * re-generate the pixels (via a SkImageGenerator) if the DM is
19 * purged. 19 * purged.
20 *
21 * Since SkColorTable is reference-counted, we do not support indexed
22 * color with this class; there would be no way for the discardable
23 * memory system to unref the color table.
24 */ 20 */
25 class SkDiscardablePixelRef : public SkPixelRef { 21 class SkDiscardablePixelRef : public SkPixelRef {
26 public: 22 public:
27 SK_DECLARE_INST_COUNT(SkDiscardablePixelRef) 23 SK_DECLARE_INST_COUNT(SkDiscardablePixelRef)
28 SK_DECLARE_UNFLATTENABLE_OBJECT() 24 SK_DECLARE_UNFLATTENABLE_OBJECT()
29 25
30 protected: 26 protected:
31 ~SkDiscardablePixelRef(); 27 ~SkDiscardablePixelRef();
32 28
33 virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; 29 virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE;
34 virtual void onUnlockPixels() SK_OVERRIDE; 30 virtual void onUnlockPixels() SK_OVERRIDE;
35 virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; } 31 virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; }
36 32
37 virtual SkData* onRefEncodedData() SK_OVERRIDE { 33 virtual SkData* onRefEncodedData() SK_OVERRIDE {
38 return fGenerator->refEncodedData(); 34 return fGenerator->refEncodedData();
39 } 35 }
40 36
41 private: 37 private:
42 SkImageGenerator* const fGenerator; 38 SkImageGenerator* const fGenerator;
43 SkDiscardableMemory::Factory* const fDMFactory; 39 SkDiscardableMemory::Factory* const fDMFactory;
44 const size_t fRowBytes; 40 const size_t fRowBytes;
45 // These const members should not change over the life of the 41 // These const members should not change over the life of the
46 // PixelRef, since the SkBitmap doesn't expect them to change. 42 // PixelRef, since the SkBitmap doesn't expect them to change.
47 43
48 SkDiscardableMemory* fDiscardableMemory; 44 SkDiscardableMemory* fDiscardableMemory;
45 SkAutoTUnref<SkColorTable> fCTable;
49 46
50 /* Takes ownership of SkImageGenerator. */ 47 /* Takes ownership of SkImageGenerator. */
51 SkDiscardablePixelRef(const SkImageInfo&, SkImageGenerator*, 48 SkDiscardablePixelRef(const SkImageInfo&, SkImageGenerator*,
52 size_t rowBytes, 49 size_t rowBytes,
53 SkDiscardableMemory::Factory* factory); 50 SkDiscardableMemory::Factory* factory);
54 51
55 friend bool SkInstallDiscardablePixelRef(SkImageGenerator*, SkBitmap*, 52 friend bool SkInstallDiscardablePixelRef(SkImageGenerator*, SkBitmap*,
56 SkDiscardableMemory::Factory*); 53 SkDiscardableMemory::Factory*);
57 54
58 typedef SkPixelRef INHERITED; 55 typedef SkPixelRef INHERITED;
59 }; 56 };
60 57
61 #endif // SkDiscardablePixelRef_DEFINED 58 #endif // SkDiscardablePixelRef_DEFINED
OLDNEW
« no previous file with comments | « src/images/SkImageGenerator.cpp ('k') | src/lazy/SkDiscardablePixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698