blob: 5bc64f532a230823163605a81705246672bcfdf3 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
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
24class SkGrTexturePixelRef : public SkPixelRef {
25public:
26 SkGrTexturePixelRef(GrTexture*);
27 virtual ~SkGrTexturePixelRef();
28
29 // override from SkPixelRef
30 virtual SkGpuTexture* getTexture() { return (SkGpuTexture*)fTexture; }
31
32protected:
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.com50dfa012011-04-01 19:05:36 +000043 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset);
reed@google.comac10a2d2010-12-22 21:39:39 +000044
45private:
46 GrTexture* fTexture;
47 typedef SkPixelRef INHERITED;
48};
49
bsalomon@google.com669fdc42011-04-05 17:08:27 +000050class SkGrRenderTargetPixelRef : public SkPixelRef {
51public:
52 SkGrRenderTargetPixelRef(GrRenderTarget* rt);
53 virtual ~SkGrRenderTargetPixelRef();
54
55 // override from SkPixelRef
56 virtual SkGpuTexture* getTexture();
57
58protected:
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
71private:
72 GrRenderTarget* fRenderTarget;
73 typedef SkPixelRef INHERITED;
74};
75
reed@google.comac10a2d2010-12-22 21:39:39 +000076#endif
77