| 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) | |
| 24 SkROLockPixelsPixelRef(const SkImageInfo&); | 23 SkROLockPixelsPixelRef(const SkImageInfo&); |
| 25 virtual ~SkROLockPixelsPixelRef(); | 24 virtual ~SkROLockPixelsPixelRef(); |
| 26 | 25 |
| 27 protected: | 26 protected: |
| 28 bool onNewLockPixels(LockRec*) override; | 27 bool onNewLockPixels(LockRec*) override; |
| 29 void onUnlockPixels() override; | 28 void onUnlockPixels() override; |
| 30 bool onLockPixelsAreWritable() const override; // return false; | 29 bool onLockPixelsAreWritable() const override; // return false; |
| 31 | 30 |
| 32 private: | 31 private: |
| 33 SkBitmap fBitmap; | 32 SkBitmap fBitmap; |
| 34 typedef SkPixelRef INHERITED; | 33 typedef SkPixelRef INHERITED; |
| 35 }; | 34 }; |
| 36 | 35 |
| 37 /** | 36 /** |
| 38 * PixelRef that wraps a GrSurface | 37 * PixelRef that wraps a GrSurface |
| 39 */ | 38 */ |
| 40 class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef { | 39 class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef { |
| 41 public: | 40 public: |
| 42 SK_DECLARE_INST_COUNT(SkGrPixelRef) | |
| 43 /** | 41 /** |
| 44 * Constructs a pixel ref around a GrSurface. | 42 * Constructs a pixel ref around a GrSurface. |
| 45 */ | 43 */ |
| 46 SkGrPixelRef(const SkImageInfo&, GrSurface*); | 44 SkGrPixelRef(const SkImageInfo&, GrSurface*); |
| 47 virtual ~SkGrPixelRef(); | 45 virtual ~SkGrPixelRef(); |
| 48 | 46 |
| 49 // override from SkPixelRef | 47 // override from SkPixelRef |
| 50 GrTexture* getTexture() override; | 48 GrTexture* getTexture() override; |
| 51 | 49 |
| 52 protected: | 50 protected: |
| 53 // overrides from SkPixelRef | 51 // overrides from SkPixelRef |
| 54 bool onReadPixels(SkBitmap* dst, const SkIRect* subset) override; | 52 bool onReadPixels(SkBitmap* dst, const SkIRect* subset) override; |
| 55 SkPixelRef* deepCopy(SkColorType, SkColorProfileType, | 53 SkPixelRef* deepCopy(SkColorType, SkColorProfileType, |
| 56 const SkIRect* subset) override; | 54 const SkIRect* subset) override; |
| 57 void onNotifyPixelsChanged() override; | 55 void onNotifyPixelsChanged() override; |
| 58 | 56 |
| 59 private: | 57 private: |
| 60 GrSurface* fSurface; | 58 GrSurface* fSurface; |
| 61 typedef SkROLockPixelsPixelRef INHERITED; | 59 typedef SkROLockPixelsPixelRef INHERITED; |
| 62 }; | 60 }; |
| 63 | 61 |
| 64 #endif | 62 #endif |
| OLD | NEW |