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