OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 SkGrPixelRef_DEFINED | 8 #ifndef SkGrPixelRef_DEFINED |
9 #define SkGrPixelRef_DEFINED | 9 #define SkGrPixelRef_DEFINED |
10 | 10 |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkPixelRef.h" | 12 #include "SkPixelRef.h" |
13 #include "GrTexture.h" | 13 #include "GrTexture.h" |
14 #include "GrRenderTarget.h" | 14 #include "GrRenderTarget.h" |
15 | 15 |
16 | 16 |
17 /** | 17 /** |
18 * Common baseclass that implements onLockPixels() by calling onReadPixels(). | 18 * Common baseclass that implements onLockPixels() by calling onReadPixels(). |
19 * Since it has a copy, it always returns false for onLockPixelsAreWritable(). | 19 * Since it has a copy, it always returns false for onLockPixelsAreWritable(). |
20 */ | 20 */ |
21 class SK_API SkROLockPixelsPixelRef : public SkPixelRef { | 21 class SK_API SkROLockPixelsPixelRef : public SkPixelRef { |
22 public: | 22 public: |
| 23 SK_DECLARE_INST_COUNT(SkROLockPixelsPixelRef) |
23 SkROLockPixelsPixelRef(const SkImageInfo&); | 24 SkROLockPixelsPixelRef(const SkImageInfo&); |
24 virtual ~SkROLockPixelsPixelRef(); | 25 virtual ~SkROLockPixelsPixelRef(); |
25 | 26 |
26 protected: | 27 protected: |
27 virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; | 28 virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; |
28 virtual void onUnlockPixels() SK_OVERRIDE; | 29 virtual void onUnlockPixels() SK_OVERRIDE; |
29 virtual bool onLockPixelsAreWritable() const SK_OVERRIDE; // return false; | 30 virtual bool onLockPixelsAreWritable() const SK_OVERRIDE; // return false; |
30 | 31 |
31 private: | 32 private: |
32 SkBitmap fBitmap; | 33 SkBitmap fBitmap; |
33 typedef SkPixelRef INHERITED; | 34 typedef SkPixelRef INHERITED; |
34 }; | 35 }; |
35 | 36 |
36 /** | 37 /** |
37 * PixelRef that wraps a GrSurface | 38 * PixelRef that wraps a GrSurface |
38 */ | 39 */ |
39 class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef { | 40 class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef { |
40 public: | 41 public: |
| 42 SK_DECLARE_INST_COUNT(SkGrPixelRef) |
41 /** | 43 /** |
42 * Constructs a pixel ref around a GrSurface. If the caller has locked the G
rSurface in the | 44 * Constructs a pixel ref around a GrSurface. If the caller has locked the G
rSurface in the |
43 * cache and would like the pixel ref to unlock it in its destructor then tr
ansferCacheLock | 45 * cache and would like the pixel ref to unlock it in its destructor then tr
ansferCacheLock |
44 * should be set to true. | 46 * should be set to true. |
45 */ | 47 */ |
46 SkGrPixelRef(const SkImageInfo&, GrSurface*, bool transferCacheLock = false)
; | 48 SkGrPixelRef(const SkImageInfo&, GrSurface*, bool transferCacheLock = false)
; |
47 virtual ~SkGrPixelRef(); | 49 virtual ~SkGrPixelRef(); |
48 | 50 |
49 // override from SkPixelRef | 51 // override from SkPixelRef |
50 virtual GrTexture* getTexture() SK_OVERRIDE; | 52 virtual GrTexture* getTexture() SK_OVERRIDE; |
51 | 53 |
52 SK_DECLARE_UNFLATTENABLE_OBJECT() | 54 SK_DECLARE_UNFLATTENABLE_OBJECT() |
53 | 55 |
54 protected: | 56 protected: |
55 // overrides from SkPixelRef | 57 // overrides from SkPixelRef |
56 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE; | 58 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE; |
57 virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig, const SkIRect* subs
et) SK_OVERRIDE; | 59 virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig, const SkIRect* subs
et) SK_OVERRIDE; |
58 | 60 |
59 private: | 61 private: |
60 GrSurface* fSurface; | 62 GrSurface* fSurface; |
61 bool fUnlock; // if true the pixel ref owns a texture cache lock on
fSurface | 63 bool fUnlock; // if true the pixel ref owns a texture cache lock on
fSurface |
62 | 64 |
63 typedef SkROLockPixelsPixelRef INHERITED; | 65 typedef SkROLockPixelsPixelRef INHERITED; |
64 }; | 66 }; |
65 | 67 |
66 #endif | 68 #endif |
OLD | NEW |