reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2010 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. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
robertphillips@google.com | d881bc1 | 2012-06-28 20:02:39 +0000 | [diff] [blame] | 8 | #ifndef SkGrPixelRef_DEFINED |
| 9 | #define SkGrPixelRef_DEFINED |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 10 | |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 11 | #include "SkBitmap.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 12 | #include "SkPixelRef.h" |
bsalomon@google.com | bbfa100 | 2011-08-16 15:13:54 +0000 | [diff] [blame] | 13 | #include "GrTexture.h" |
| 14 | #include "GrRenderTarget.h" |
| 15 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 16 | |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 17 | /** |
| 18 | * Common baseclass that implements onLockPixels() by calling onReadPixels(). |
| 19 | * Since it has a copy, it always returns false for onLockPixelsAreWritable(). |
| 20 | */ |
senorblanco@chromium.org | 2976765 | 2012-02-08 20:27:16 +0000 | [diff] [blame] | 21 | class SK_API SkROLockPixelsPixelRef : public SkPixelRef { |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 22 | public: |
commit-bot@chromium.org | 227c246 | 2014-01-24 18:33:07 +0000 | [diff] [blame] | 23 | SK_DECLARE_INST_COUNT(SkROLockPixelsPixelRef) |
reed@google.com | bf79023 | 2013-12-13 19:45:58 +0000 | [diff] [blame] | 24 | SkROLockPixelsPixelRef(const SkImageInfo&); |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 25 | virtual ~SkROLockPixelsPixelRef(); |
| 26 | |
| 27 | protected: |
reed@google.com | d0419b1 | 2014-01-06 17:08:27 +0000 | [diff] [blame] | 28 | virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; |
| 29 | virtual void onUnlockPixels() SK_OVERRIDE; |
| 30 | virtual bool onLockPixelsAreWritable() const SK_OVERRIDE; // return false; |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 31 | |
| 32 | private: |
| 33 | SkBitmap fBitmap; |
| 34 | typedef SkPixelRef INHERITED; |
| 35 | }; |
| 36 | |
| 37 | /** |
robertphillips@google.com | d881bc1 | 2012-06-28 20:02:39 +0000 | [diff] [blame] | 38 | * PixelRef that wraps a GrSurface |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 39 | */ |
robertphillips@google.com | d881bc1 | 2012-06-28 20:02:39 +0000 | [diff] [blame] | 40 | class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 41 | public: |
commit-bot@chromium.org | 227c246 | 2014-01-24 18:33:07 +0000 | [diff] [blame] | 42 | SK_DECLARE_INST_COUNT(SkGrPixelRef) |
bsalomon@google.com | 8090e65 | 2012-08-28 15:07:11 +0000 | [diff] [blame] | 43 | /** |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 44 | * Constructs a pixel ref around a GrSurface. |
bsalomon@google.com | 8090e65 | 2012-08-28 15:07:11 +0000 | [diff] [blame] | 45 | */ |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 46 | SkGrPixelRef(const SkImageInfo&, GrSurface*); |
robertphillips@google.com | d881bc1 | 2012-06-28 20:02:39 +0000 | [diff] [blame] | 47 | virtual ~SkGrPixelRef(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 48 | |
| 49 | // override from SkPixelRef |
commit-bot@chromium.org | b8d00db | 2013-06-26 19:18:23 +0000 | [diff] [blame] | 50 | virtual GrTexture* getTexture() SK_OVERRIDE; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 51 | |
| 52 | protected: |
robertphillips@google.com | d881bc1 | 2012-06-28 20:02:39 +0000 | [diff] [blame] | 53 | // overrides from SkPixelRef |
| 54 | virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE; |
reed | e4538f5 | 2014-06-11 06:09:50 -0700 | [diff] [blame] | 55 | virtual SkPixelRef* deepCopy(SkColorType, const SkIRect* subset) SK_OVERRIDE; |
senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 56 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 57 | private: |
robertphillips@google.com | d881bc1 | 2012-06-28 20:02:39 +0000 | [diff] [blame] | 58 | GrSurface* fSurface; |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 59 | typedef SkROLockPixelsPixelRef INHERITED; |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 62 | #endif |