blob: e4f521c157851966c3c083ce7d7e7a156d87615c [file] [log] [blame]
robertphillips@google.comecf1f322012-06-28 21:59:38 +00001
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 */
24class SK_API SkROLockPixelsPixelRef_Deprecated : public SkPixelRef {
25public:
26 SkROLockPixelsPixelRef_Deprecated();
27 virtual ~SkROLockPixelsPixelRef_Deprecated();
28
29protected:
30 // override from SkPixelRef
31 virtual void* onLockPixels(SkColorTable** ptr);
32 virtual void onUnlockPixels();
33 virtual bool onLockPixelsAreWritable() const; // return false;
34
35private:
36 SkBitmap fBitmap;
37 typedef SkPixelRef INHERITED;
38};
39
40/**
41 * PixelRef that wraps a GrTexture
42 */
43class SK_API SkGrTexturePixelRef : public SkROLockPixelsPixelRef_Deprecated {
44public:
45 SkGrTexturePixelRef(GrTexture*);
46 virtual ~SkGrTexturePixelRef();
47
48 // override from SkPixelRef
49 virtual SkGpuTexture* getTexture();
50
51 SK_DECLARE_UNFLATTENABLE_OBJECT()
52
53protected:
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
60private:
61 GrTexture* fTexture;
62 typedef SkROLockPixelsPixelRef_Deprecated INHERITED;
63};
64
65/**
66 * PixelRef that wraps a GrRenderTarget
67 */
68class SK_API SkGrRenderTargetPixelRef : public SkROLockPixelsPixelRef_Deprecated {
69public:
70 SkGrRenderTargetPixelRef(GrRenderTarget* rt);
71 virtual ~SkGrRenderTargetPixelRef();
72
73 // override from SkPixelRef
74 virtual SkGpuTexture* getTexture();
75
76 SK_DECLARE_UNFLATTENABLE_OBJECT()
77
78protected:
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
85private:
86 GrRenderTarget* fRenderTarget;
87 typedef SkROLockPixelsPixelRef_Deprecated INHERITED;
88};
89
90#endif
91