robertphillips@google.com | ecf1f32 | 2012-06-28 21:59:38 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 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. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | |
| 11 | #ifndef SkGrTexturePixelRef_DEFINED |
| 12 | #define SkGrTexturePixelRef_DEFINED |
| 13 | |
| 14 | #include "SkBitmap.h" |
| 15 | #include "SkPixelRef.h" |
| 16 | #include "GrTexture.h" |
| 17 | #include "GrRenderTarget.h" |
| 18 | |
| 19 | |
| 20 | /** |
| 21 | * Common baseclass that implements onLockPixels() by calling onReadPixels(). |
| 22 | * Since it has a copy, it always returns false for onLockPixelsAreWritable(). |
| 23 | */ |
| 24 | class SK_API SkROLockPixelsPixelRef_Deprecated : public SkPixelRef { |
| 25 | public: |
| 26 | SkROLockPixelsPixelRef_Deprecated(); |
| 27 | virtual ~SkROLockPixelsPixelRef_Deprecated(); |
| 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 | */ |
| 43 | class SK_API SkGrTexturePixelRef : public SkROLockPixelsPixelRef_Deprecated { |
| 44 | public: |
| 45 | SkGrTexturePixelRef(GrTexture*); |
| 46 | virtual ~SkGrTexturePixelRef(); |
| 47 | |
| 48 | // override from SkPixelRef |
| 49 | virtual SkGpuTexture* getTexture(); |
| 50 | |
| 51 | SK_DECLARE_UNFLATTENABLE_OBJECT() |
| 52 | |
| 53 | protected: |
| 54 | // override from SkPixelRef |
| 55 | virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset); |
| 56 | |
| 57 | // override from SkPixelRef |
| 58 | virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE; |
| 59 | |
| 60 | private: |
| 61 | GrTexture* fTexture; |
| 62 | typedef SkROLockPixelsPixelRef_Deprecated INHERITED; |
| 63 | }; |
| 64 | |
| 65 | /** |
| 66 | * PixelRef that wraps a GrRenderTarget |
| 67 | */ |
| 68 | class SK_API SkGrRenderTargetPixelRef : public SkROLockPixelsPixelRef_Deprecated { |
| 69 | public: |
| 70 | SkGrRenderTargetPixelRef(GrRenderTarget* rt); |
| 71 | virtual ~SkGrRenderTargetPixelRef(); |
| 72 | |
| 73 | // override from SkPixelRef |
| 74 | virtual SkGpuTexture* getTexture(); |
| 75 | |
| 76 | SK_DECLARE_UNFLATTENABLE_OBJECT() |
| 77 | |
| 78 | protected: |
| 79 | // override from SkPixelRef |
| 80 | virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset); |
| 81 | |
| 82 | // override from SkPixelRef |
| 83 | virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig) SK_OVERRIDE; |
| 84 | |
| 85 | private: |
| 86 | GrRenderTarget* fRenderTarget; |
| 87 | typedef SkROLockPixelsPixelRef_Deprecated INHERITED; |
| 88 | }; |
| 89 | |
| 90 | #endif |
| 91 | |