epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef SkGrTexturePixelRef_DEFINED |
| 12 | #define SkGrTexturePixelRef_DEFINED |
| 13 | |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 14 | #include "SkBitmap.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | #include "SkPixelRef.h" |
bsalomon@google.com | bbfa100 | 2011-08-16 15:13:54 +0000 | [diff] [blame] | 16 | #include "GrTexture.h" |
| 17 | #include "GrRenderTarget.h" |
| 18 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 19 | |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 20 | /** |
| 21 | * Common baseclass that implements onLockPixels() by calling onReadPixels(). |
| 22 | * Since it has a copy, it always returns false for onLockPixelsAreWritable(). |
| 23 | */ |
senorblanco@chromium.org | 2976765 | 2012-02-08 20:27:16 +0000 | [diff] [blame^] | 24 | class SK_API SkROLockPixelsPixelRef : public SkPixelRef { |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 25 | public: |
| 26 | SkROLockPixelsPixelRef(); |
| 27 | virtual ~SkROLockPixelsPixelRef(); |
| 28 | |
| 29 | protected: |
| 30 | // override from SkPixelRef |
| 31 | virtual void* onLockPixels(SkColorTable** ptr); |
| 32 | virtual void onUnlockPixels(); |
| 33 | virtual bool onLockPixelsAreWritable() const; // return false; |
| 34 | |
| 35 | private: |
| 36 | SkBitmap fBitmap; |
| 37 | typedef SkPixelRef INHERITED; |
| 38 | }; |
| 39 | |
| 40 | /** |
| 41 | * PixelRef that wraps a GrTexture |
| 42 | */ |
senorblanco@chromium.org | 2976765 | 2012-02-08 20:27:16 +0000 | [diff] [blame^] | 43 | class SK_API SkGrTexturePixelRef : public SkROLockPixelsPixelRef { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 44 | public: |
| 45 | SkGrTexturePixelRef(GrTexture*); |
| 46 | virtual ~SkGrTexturePixelRef(); |
| 47 | |
| 48 | // override from SkPixelRef |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 49 | virtual SkGpuTexture* getTexture(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 50 | |
| 51 | protected: |
| 52 | // override from SkPixelRef |
reed@google.com | 50dfa01 | 2011-04-01 19:05:36 +0000 | [diff] [blame] | 53 | virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 54 | |
senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 55 | // override from SkPixelRef |
| 56 | virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE; |
| 57 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 58 | private: |
| 59 | GrTexture* fTexture; |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 60 | typedef SkROLockPixelsPixelRef INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 63 | /** |
| 64 | * PixelRef that wraps a GrRenderTarget |
| 65 | */ |
senorblanco@chromium.org | 2976765 | 2012-02-08 20:27:16 +0000 | [diff] [blame^] | 66 | class SK_API SkGrRenderTargetPixelRef : public SkROLockPixelsPixelRef { |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 67 | public: |
| 68 | SkGrRenderTargetPixelRef(GrRenderTarget* rt); |
| 69 | virtual ~SkGrRenderTargetPixelRef(); |
| 70 | |
| 71 | // override from SkPixelRef |
| 72 | virtual SkGpuTexture* getTexture(); |
| 73 | |
| 74 | protected: |
| 75 | // override from SkPixelRef |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 76 | virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset); |
| 77 | |
senorblanco@chromium.org | ef843cd | 2011-12-02 19:11:17 +0000 | [diff] [blame] | 78 | // override from SkPixelRef |
| 79 | virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE; |
| 80 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 81 | private: |
| 82 | GrRenderTarget* fRenderTarget; |
reed@google.com | 9c49bc3 | 2011-07-07 13:42:37 +0000 | [diff] [blame] | 83 | typedef SkROLockPixelsPixelRef INHERITED; |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 86 | #endif |
| 87 | |