OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
11 #ifndef SkGpuDevice_DEFINED | 11 #ifndef SkGpuDevice_DEFINED |
12 #define SkGpuDevice_DEFINED | 12 #define SkGpuDevice_DEFINED |
13 | 13 |
14 #include "SkGr.h" | 14 #include "SkGr.h" |
15 #include "SkBitmap.h" | 15 #include "SkBitmap.h" |
16 #include "SkDevice.h" | 16 #include "SkBitmapDevice.h" |
17 #include "SkRegion.h" | 17 #include "SkRegion.h" |
18 #include "GrContext.h" | 18 #include "GrContext.h" |
19 | 19 |
20 struct SkDrawProcs; | 20 struct SkDrawProcs; |
21 struct GrSkDrawProcs; | 21 struct GrSkDrawProcs; |
22 class GrTextContext; | 22 class GrTextContext; |
23 | 23 |
24 /** | 24 /** |
25 * Subclass of SkDevice, which directs all drawing to the GrGpu owned by the | 25 * Subclass of SkBitmapDevice, which directs all drawing to the GrGpu owned by
the |
26 * canvas. | 26 * canvas. |
27 */ | 27 */ |
28 class SK_API SkGpuDevice : public SkDevice { | 28 class SK_API SkGpuDevice : public SkBitmapDevice { |
29 public: | 29 public: |
30 | 30 |
31 /** | 31 /** |
32 * Creates an SkGpuDevice from a GrSurface. This will fail if the surface is
not a render | 32 * Creates an SkGpuDevice from a GrSurface. This will fail if the surface is
not a render |
33 * target. The caller owns a ref on the returned device. | 33 * target. The caller owns a ref on the returned device. |
34 */ | 34 */ |
35 static SkGpuDevice* Create(GrSurface* surface); | 35 static SkGpuDevice* Create(GrSurface* surface); |
36 | 36 |
37 /** | 37 /** |
38 * New device that will create an offscreen renderTarget based on the | 38 * New device that will create an offscreen renderTarget based on the |
(...skipping 16 matching lines...) Expand all Loading... |
55 * DEPRECATED: Use Create(surface) | 55 * DEPRECATED: Use Create(surface) |
56 */ | 56 */ |
57 SkGpuDevice(GrContext*, GrTexture*); | 57 SkGpuDevice(GrContext*, GrTexture*); |
58 | 58 |
59 virtual ~SkGpuDevice(); | 59 virtual ~SkGpuDevice(); |
60 | 60 |
61 GrContext* context() const { return fContext; } | 61 GrContext* context() const { return fContext; } |
62 | 62 |
63 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 63 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
64 | 64 |
65 // overrides from SkDevice | 65 // overrides from SkBaseDevice |
66 | 66 |
67 virtual void clear(SkColor color) SK_OVERRIDE; | 67 virtual void clear(SkColor color) SK_OVERRIDE; |
68 virtual void writePixels(const SkBitmap& bitmap, int x, int y, | 68 virtual void writePixels(const SkBitmap& bitmap, int x, int y, |
69 SkCanvas::Config8888 config8888) SK_OVERRIDE; | 69 SkCanvas::Config8888 config8888) SK_OVERRIDE; |
70 | 70 |
71 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; | 71 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; |
72 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | 72 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, |
73 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; | 73 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; |
74 virtual void drawRect(const SkDraw&, const SkRect& r, | 74 virtual void drawRect(const SkDraw&, const SkRect& r, |
75 const SkPaint& paint) SK_OVERRIDE; | 75 const SkPaint& paint) SK_OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
94 const SkScalar pos[], SkScalar constY, | 94 const SkScalar pos[], SkScalar constY, |
95 int scalarsPerPos, const SkPaint&) SK_OVERRIDE; | 95 int scalarsPerPos, const SkPaint&) SK_OVERRIDE; |
96 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, | 96 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, |
97 const SkPath& path, const SkMatrix* matrix, | 97 const SkPath& path, const SkMatrix* matrix, |
98 const SkPaint&) SK_OVERRIDE; | 98 const SkPaint&) SK_OVERRIDE; |
99 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou
nt, | 99 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCou
nt, |
100 const SkPoint verts[], const SkPoint texs[], | 100 const SkPoint verts[], const SkPoint texs[], |
101 const SkColor colors[], SkXfermode* xmode, | 101 const SkColor colors[], SkXfermode* xmode, |
102 const uint16_t indices[], int indexCount, | 102 const uint16_t indices[], int indexCount, |
103 const SkPaint&) SK_OVERRIDE; | 103 const SkPaint&) SK_OVERRIDE; |
104 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, | 104 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
105 const SkPaint&) SK_OVERRIDE; | 105 const SkPaint&) SK_OVERRIDE; |
106 virtual bool filterTextFlags(const SkPaint&, TextFlags*) SK_OVERRIDE; | 106 virtual bool filterTextFlags(const SkPaint&, TextFlags*) SK_OVERRIDE; |
107 | 107 |
108 virtual void flush(); | 108 virtual void flush() SK_OVERRIDE; |
109 | 109 |
110 virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE; | 110 virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE; |
111 virtual void onDetachFromCanvas() SK_OVERRIDE; | 111 virtual void onDetachFromCanvas() SK_OVERRIDE; |
112 | 112 |
113 /** | 113 /** |
114 * Make's this device's rendertarget current in the underlying 3D API. | 114 * Make's this device's rendertarget current in the underlying 3D API. |
115 * Also implicitly flushes. | 115 * Also implicitly flushes. |
116 */ | 116 */ |
117 virtual void makeRenderTargetCurrent(); | 117 virtual void makeRenderTargetCurrent(); |
118 | 118 |
119 virtual bool canHandleImageFilter(SkImageFilter*) SK_OVERRIDE; | 119 virtual bool canHandleImageFilter(SkImageFilter*) SK_OVERRIDE; |
120 virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&, | 120 virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&, |
121 SkBitmap*, SkIPoint*) SK_OVERRIDE; | 121 SkBitmap*, SkIPoint*) SK_OVERRIDE; |
122 | 122 |
123 class SkAutoCachedTexture; // used internally | 123 class SkAutoCachedTexture; // used internally |
124 | 124 |
125 protected: | 125 protected: |
126 // overrides from SkDevice | 126 // overrides from SkBaseDevice |
127 virtual bool onReadPixels(const SkBitmap& bitmap, | 127 virtual bool onReadPixels(const SkBitmap& bitmap, |
128 int x, int y, | 128 int x, int y, |
129 SkCanvas::Config8888 config8888) SK_OVERRIDE; | 129 SkCanvas::Config8888 config8888) SK_OVERRIDE; |
130 | 130 |
131 private: | 131 private: |
132 GrContext* fContext; | 132 GrContext* fContext; |
133 | 133 |
134 GrSkDrawProcs* fDrawProcs; | 134 GrSkDrawProcs* fDrawProcs; |
135 | 135 |
136 GrClipData fClipData; | 136 GrClipData fClipData; |
137 | 137 |
138 // state for our render-target | 138 // state for our render-target |
139 GrRenderTarget* fRenderTarget; | 139 GrRenderTarget* fRenderTarget; |
140 bool fNeedClear; | 140 bool fNeedClear; |
141 | 141 |
142 // called from rt and tex cons | 142 // called from rt and tex cons |
143 void initFromRenderTarget(GrContext*, GrRenderTarget*, bool cached); | 143 void initFromRenderTarget(GrContext*, GrRenderTarget*, bool cached); |
144 | 144 |
145 // used by createCompatibleDevice | 145 // used by createCompatibleDevice |
146 SkGpuDevice(GrContext*, GrTexture* texture, bool needClear); | 146 SkGpuDevice(GrContext*, GrTexture* texture, bool needClear); |
147 | 147 |
148 // override from SkDevice | 148 // override from SkBaseDevice |
149 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config, | 149 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, |
150 int width, int height, | 150 int width, int height, |
151 bool isOpaque, | 151 bool isOpaque, |
152 Usage usage) SK_OVERRIDE; | 152 Usage usage) SK_OVERRIDE; |
153 | 153 |
154 SkDrawProcs* initDrawForText(GrTextContext*); | 154 SkDrawProcs* initDrawForText(GrTextContext*); |
155 | 155 |
156 // sets the render target, clip, and matrix on GrContext. Use forceIdenity t
o override | 156 // sets the render target, clip, and matrix on GrContext. Use forceIdenity t
o override |
157 // SkDraw's matrix and draw in device coords. | 157 // SkDraw's matrix and draw in device coords. |
158 void prepareDraw(const SkDraw&, bool forceIdentity); | 158 void prepareDraw(const SkDraw&, bool forceIdentity); |
159 | 159 |
160 /** | 160 /** |
161 * Implementation for both drawBitmap and drawBitmapRect. | 161 * Implementation for both drawBitmap and drawBitmapRect. |
162 */ | 162 */ |
(...skipping 22 matching lines...) Expand all Loading... |
185 const SkMatrix& m, | 185 const SkMatrix& m, |
186 const GrTextureParams& params, | 186 const GrTextureParams& params, |
187 const SkPaint& paint, | 187 const SkPaint& paint, |
188 SkCanvas::DrawBitmapRectFlags flags); | 188 SkCanvas::DrawBitmapRectFlags flags); |
189 | 189 |
190 /** | 190 /** |
191 * Returns non-initialized instance. | 191 * Returns non-initialized instance. |
192 */ | 192 */ |
193 GrTextContext* getTextContext(); | 193 GrTextContext* getTextContext(); |
194 | 194 |
195 typedef SkDevice INHERITED; | 195 typedef SkBitmapDevice INHERITED; |
196 }; | 196 }; |
197 | 197 |
198 #endif | 198 #endif |
OLD | NEW |