reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2010 Google Inc. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | |
| 18 | #ifndef SkGrTexturePixelRef_DEFINED |
| 19 | #define SkGrTexturePixelRef_DEFINED |
| 20 | |
| 21 | #include "SkPixelRef.h" |
| 22 | #include "GrGpu.h" |
| 23 | |
| 24 | class SkGrTexturePixelRef : public SkPixelRef { |
| 25 | public: |
| 26 | SkGrTexturePixelRef(GrTexture*); |
| 27 | virtual ~SkGrTexturePixelRef(); |
| 28 | |
| 29 | // override from SkPixelRef |
| 30 | virtual SkGpuTexture* getTexture() { return (SkGpuTexture*)fTexture; } |
| 31 | |
| 32 | protected: |
| 33 | // override from SkPixelRef |
| 34 | virtual void* onLockPixels(SkColorTable** ptr) { |
| 35 | if (ptr) { |
| 36 | *ptr = NULL; |
| 37 | } |
| 38 | return NULL; |
| 39 | } |
| 40 | |
| 41 | // override from SkPixelRef |
| 42 | virtual void onUnlockPixels() {} |
reed@google.com | 50dfa01 | 2011-04-01 19:05:36 +0000 | [diff] [blame] | 43 | virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 44 | |
| 45 | private: |
| 46 | GrTexture* fTexture; |
| 47 | typedef SkPixelRef INHERITED; |
| 48 | }; |
| 49 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame^] | 50 | class SkGrRenderTargetPixelRef : public SkPixelRef { |
| 51 | public: |
| 52 | SkGrRenderTargetPixelRef(GrRenderTarget* rt); |
| 53 | virtual ~SkGrRenderTargetPixelRef(); |
| 54 | |
| 55 | // override from SkPixelRef |
| 56 | virtual SkGpuTexture* getTexture(); |
| 57 | |
| 58 | protected: |
| 59 | // override from SkPixelRef |
| 60 | virtual void* onLockPixels(SkColorTable** ptr) { |
| 61 | if (ptr) { |
| 62 | *ptr = NULL; |
| 63 | } |
| 64 | return NULL; |
| 65 | } |
| 66 | |
| 67 | // override from SkPixelRef |
| 68 | virtual void onUnlockPixels() {} |
| 69 | virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset); |
| 70 | |
| 71 | private: |
| 72 | GrRenderTarget* fRenderTarget; |
| 73 | typedef SkPixelRef INHERITED; |
| 74 | }; |
| 75 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 76 | #endif |
| 77 | |