OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrDrawContext_DEFINED | 8 #ifndef GrDrawContext_DEFINED |
9 #define GrDrawContext_DEFINED | 9 #define GrDrawContext_DEFINED |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 class GrContext; | 21 class GrContext; |
22 class GrDrawBatch; | 22 class GrDrawBatch; |
23 class GrDrawContextPriv; | 23 class GrDrawContextPriv; |
24 class GrDrawPathBatchBase; | 24 class GrDrawPathBatchBase; |
25 class GrDrawingManager; | 25 class GrDrawingManager; |
26 class GrDrawTarget; | 26 class GrDrawTarget; |
27 class GrPaint; | 27 class GrPaint; |
28 class GrPathProcessor; | 28 class GrPathProcessor; |
29 class GrPipelineBuilder; | 29 class GrPipelineBuilder; |
30 class GrRenderTarget; | 30 class GrRenderTarget; |
31 class GrStyle; | 31 class GrStrokeInfo; |
32 class GrSurface; | 32 class GrSurface; |
33 class SkDrawFilter; | 33 class SkDrawFilter; |
34 struct SkIPoint; | 34 struct SkIPoint; |
35 struct SkIRect; | 35 struct SkIRect; |
36 class SkMatrix; | 36 class SkMatrix; |
37 class SkPaint; | 37 class SkPaint; |
38 class SkPath; | 38 class SkPath; |
39 struct SkPoint; | 39 struct SkPoint; |
40 struct SkRect; | 40 struct SkRect; |
41 class SkRRect; | 41 class SkRRect; |
42 struct SkRSXform; | 42 struct SkRSXform; |
43 class SkTextBlob; | 43 class SkTextBlob; |
44 | 44 |
45 /* | 45 /* |
46 * A helper object to orchestrate draws | 46 * A helper object to orchestrate draws |
47 */ | 47 */ |
48 class SK_API GrDrawContext : public SkRefCnt { | 48 class SK_API GrDrawContext : public SkRefCnt { |
49 public: | 49 public: |
50 ~GrDrawContext() override; | 50 ~GrDrawContext() override; |
51 | 51 |
52 bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dst
Point); | 52 bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dst
Point); |
53 | 53 |
54 // TODO: it is odd that we need both the SkPaint in the following 3 methods. | 54 // TODO: it is odd that we need both the SkPaint in the following 3 methods. |
55 // We should extract the text parameters from SkPaint and pass them separate
ly | 55 // We should extract the text parameters from SkPaint and pass them separate
ly |
56 // akin to GrStyle (GrTextInfo?) | 56 // akin to GrStrokeInfo (GrTextInfo?) |
57 virtual void drawText(const GrClip&, const GrPaint&, const SkPaint&, | 57 virtual void drawText(const GrClip&, const GrPaint&, const SkPaint&, |
58 const SkMatrix& viewMatrix, const char text[], size_t
byteLength, | 58 const SkMatrix& viewMatrix, const char text[], size_t
byteLength, |
59 SkScalar x, SkScalar y, const SkIRect& clipBounds); | 59 SkScalar x, SkScalar y, const SkIRect& clipBounds); |
60 virtual void drawPosText(const GrClip&, const GrPaint&, const SkPaint&, | 60 virtual void drawPosText(const GrClip&, const GrPaint&, const SkPaint&, |
61 const SkMatrix& viewMatrix, const char text[], size
_t byteLength, | 61 const SkMatrix& viewMatrix, const char text[], size
_t byteLength, |
62 const SkScalar pos[], int scalarsPerPosition, | 62 const SkScalar pos[], int scalarsPerPosition, |
63 const SkPoint& offset, const SkIRect& clipBounds); | 63 const SkPoint& offset, const SkIRect& clipBounds); |
64 virtual void drawTextBlob(const GrClip&, const SkPaint&, | 64 virtual void drawTextBlob(const GrClip&, const SkPaint&, |
65 const SkMatrix& viewMatrix, const SkTextBlob*, | 65 const SkMatrix& viewMatrix, const SkTextBlob*, |
66 SkScalar x, SkScalar y, | 66 SkScalar x, SkScalar y, |
(...skipping 16 matching lines...) Expand all Loading... |
83 | 83 |
84 /** | 84 /** |
85 * Draw everywhere (respecting the clip) with the paint. | 85 * Draw everywhere (respecting the clip) with the paint. |
86 */ | 86 */ |
87 void drawPaint(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix); | 87 void drawPaint(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix); |
88 | 88 |
89 /** | 89 /** |
90 * Draw the rect using a paint. | 90 * Draw the rect using a paint. |
91 * @param paint describes how to color pixels. | 91 * @param paint describes how to color pixels. |
92 * @param viewMatrix transformation matrix | 92 * @param viewMatrix transformation matrix |
93 * @param style The style to apply. Null means fill. Currently path
effects are not | 93 * @param strokeInfo the stroke information (width, join, cap), and. |
94 * allowed. | 94 * the dash information (intervals, count, phase). |
| 95 * If strokeInfo == NULL, then the rect is filled. |
| 96 * Otherwise, if stroke width == 0, then the stroke |
| 97 * is always a single pixel thick, else the rect is |
| 98 * mitered/beveled stroked based on stroke width. |
95 * The rects coords are used to access the paint (through texture matrix) | 99 * The rects coords are used to access the paint (through texture matrix) |
96 */ | 100 */ |
97 void drawRect(const GrClip&, | 101 void drawRect(const GrClip&, |
98 const GrPaint& paint, | 102 const GrPaint& paint, |
99 const SkMatrix& viewMatrix, | 103 const SkMatrix& viewMatrix, |
100 const SkRect&, | 104 const SkRect&, |
101 const GrStyle* style = nullptr); | 105 const GrStrokeInfo* strokeInfo = nullptr); |
102 | 106 |
103 /** | 107 /** |
104 * Maps a rectangle of shader coordinates to a rectangle and fills that rect
angle. | 108 * Maps a rectangle of shader coordinates to a rectangle and fills that rect
angle. |
105 * | 109 * |
106 * @param paint describes how to color pixels. | 110 * @param paint describes how to color pixels. |
107 * @param viewMatrix transformation matrix which applies to rectToDraw | 111 * @param viewMatrix transformation matrix which applies to rectToDraw |
108 * @param rectToDraw the rectangle to draw | 112 * @param rectToDraw the rectangle to draw |
109 * @param localRect the rectangle of shader coordinates applied to rectT
oDraw | 113 * @param localRect the rectangle of shader coordinates applied to rectT
oDraw |
110 */ | 114 */ |
111 void fillRectToRect(const GrClip&, | 115 void fillRectToRect(const GrClip&, |
(...skipping 10 matching lines...) Expand all Loading... |
122 const SkMatrix& viewMatrix, | 126 const SkMatrix& viewMatrix, |
123 const SkRect& rect, | 127 const SkRect& rect, |
124 const SkMatrix& localMatrix); | 128 const SkMatrix& localMatrix); |
125 | 129 |
126 /** | 130 /** |
127 * Draw a roundrect using a paint. | 131 * Draw a roundrect using a paint. |
128 * | 132 * |
129 * @param paint describes how to color pixels. | 133 * @param paint describes how to color pixels. |
130 * @param viewMatrix transformation matrix | 134 * @param viewMatrix transformation matrix |
131 * @param rrect the roundrect to draw | 135 * @param rrect the roundrect to draw |
132 * @param style style to apply to the rrect. Currently path effects
are not allowed. | 136 * @param strokeInfo the stroke information (width, join, cap) and |
| 137 * the dash information (intervals, count, phase). |
133 */ | 138 */ |
134 void drawRRect(const GrClip&, | 139 void drawRRect(const GrClip&, |
135 const GrPaint&, | 140 const GrPaint&, |
136 const SkMatrix& viewMatrix, | 141 const SkMatrix& viewMatrix, |
137 const SkRRect& rrect, | 142 const SkRRect& rrect, |
138 const GrStyle& style); | 143 const GrStrokeInfo&); |
139 | 144 |
140 /** | 145 /** |
141 * Shortcut for drawing an SkPath consisting of nested rrects using a paint
. | 146 * Shortcut for drawing an SkPath consisting of nested rrects using a paint
. |
142 * Does not support stroking. The result is undefined if outer does not con
tain | 147 * Does not support stroking. The result is undefined if outer does not con
tain |
143 * inner. | 148 * inner. |
144 * | 149 * |
145 * @param paint describes how to color pixels. | 150 * @param paint describes how to color pixels. |
146 * @param viewMatrix transformation matrix | 151 * @param viewMatrix transformation matrix |
147 * @param outer the outer roundrect | 152 * @param outer the outer roundrect |
148 * @param inner the inner roundrect | 153 * @param inner the inner roundrect |
149 */ | 154 */ |
150 void drawDRRect(const GrClip&, | 155 void drawDRRect(const GrClip&, |
151 const GrPaint&, | 156 const GrPaint&, |
152 const SkMatrix& viewMatrix, | 157 const SkMatrix& viewMatrix, |
153 const SkRRect& outer, | 158 const SkRRect& outer, |
154 const SkRRect& inner); | 159 const SkRRect& inner); |
155 | 160 |
156 /** | 161 /** |
157 * Draws a path. | 162 * Draws a path. |
158 * | 163 * |
159 * @param paint describes how to color pixels. | 164 * @param paint describes how to color pixels. |
160 * @param viewMatrix transformation matrix | 165 * @param viewMatrix transformation matrix |
161 * @param path the path to draw | 166 * @param path the path to draw |
162 * @param style style to apply to the path. | 167 * @param strokeInfo the stroke information (width, join, cap) and |
| 168 * the dash information (intervals, count, phase). |
163 */ | 169 */ |
164 void drawPath(const GrClip&, | 170 void drawPath(const GrClip&, |
165 const GrPaint&, | 171 const GrPaint&, |
166 const SkMatrix& viewMatrix, | 172 const SkMatrix& viewMatrix, |
167 const SkPath&, | 173 const SkPath&, |
168 const GrStyle& style); | 174 const GrStrokeInfo&); |
169 | 175 |
170 /** | 176 /** |
171 * Draws vertices with a paint. | 177 * Draws vertices with a paint. |
172 * | 178 * |
173 * @param paint describes how to color pixels. | 179 * @param paint describes how to color pixels. |
174 * @param viewMatrix transformation matrix | 180 * @param viewMatrix transformation matrix |
175 * @param primitiveType primitives type to draw. | 181 * @param primitiveType primitives type to draw. |
176 * @param vertexCount number of vertices. | 182 * @param vertexCount number of vertices. |
177 * @param positions array of vertex positions, required. | 183 * @param positions array of vertex positions, required. |
178 * @param texCoords optional array of texture coordinates used | 184 * @param texCoords optional array of texture coordinates used |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const SkRSXform xform[], | 219 const SkRSXform xform[], |
214 const SkRect texRect[], | 220 const SkRect texRect[], |
215 const SkColor colors[]); | 221 const SkColor colors[]); |
216 | 222 |
217 /** | 223 /** |
218 * Draws an oval. | 224 * Draws an oval. |
219 * | 225 * |
220 * @param paint describes how to color pixels. | 226 * @param paint describes how to color pixels. |
221 * @param viewMatrix transformation matrix | 227 * @param viewMatrix transformation matrix |
222 * @param oval the bounding rect of the oval. | 228 * @param oval the bounding rect of the oval. |
223 * @param style style to apply to the oval. Currently path effects a
re not allowed. | 229 * @param strokeInfo the stroke information (width, join, cap) and |
| 230 * the dash information (intervals, count, phase). |
224 */ | 231 */ |
225 void drawOval(const GrClip&, | 232 void drawOval(const GrClip&, |
226 const GrPaint& paint, | 233 const GrPaint& paint, |
227 const SkMatrix& viewMatrix, | 234 const SkMatrix& viewMatrix, |
228 const SkRect& oval, | 235 const SkRect& oval, |
229 const GrStyle& style); | 236 const GrStrokeInfo& strokeInfo); |
230 | 237 |
231 /** | 238 /** |
232 * Draw the image stretched differentially to fit into dst. | 239 * Draw the image stretched differentially to fit into dst. |
233 * center is a rect within the image, and logically divides the image | 240 * center is a rect within the image, and logically divides the image |
234 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 241 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
235 * image is the "center", then the center-rect should be [2, 2, 3, 3]. | 242 * image is the "center", then the center-rect should be [2, 2, 3, 3]. |
236 * | 243 * |
237 * If the dst is >= the image size, then... | 244 * If the dst is >= the image size, then... |
238 * - The 4 corners are not stretched at all. | 245 * - The 4 corners are not stretched at all. |
239 * - The sides are stretched in only one axis. | 246 * - The sides are stretched in only one axis. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 const SkRRect& origInner); | 311 const SkRRect& origInner); |
305 | 312 |
306 GrDrawBatch* getFillRectBatch(const GrPaint& paint, | 313 GrDrawBatch* getFillRectBatch(const GrPaint& paint, |
307 const SkMatrix& viewMatrix, | 314 const SkMatrix& viewMatrix, |
308 const SkRect& rect); | 315 const SkRect& rect); |
309 | 316 |
310 void internalDrawPath(const GrClip& clip, | 317 void internalDrawPath(const GrClip& clip, |
311 const GrPaint& paint, | 318 const GrPaint& paint, |
312 const SkMatrix& viewMatrix, | 319 const SkMatrix& viewMatrix, |
313 const SkPath& path, | 320 const SkPath& path, |
314 const GrStyle& style); | 321 const GrStrokeInfo& strokeInfo); |
315 | 322 |
316 // This entry point allows the GrTextContext-derived classes to add their ba
tches to | 323 // This entry point allows the GrTextContext-derived classes to add their ba
tches to |
317 // the drawTarget. | 324 // the drawTarget. |
318 void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch); | 325 void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch); |
319 | 326 |
320 GrDrawTarget* getDrawTarget(); | 327 GrDrawTarget* getDrawTarget(); |
321 | 328 |
322 GrDrawingManager* fDrawingManager; | 329 GrDrawingManager* fDrawingManager; |
323 sk_sp<GrRenderTarget> fRenderTarget; | 330 sk_sp<GrRenderTarget> fRenderTarget; |
324 | 331 |
325 // In MDB-mode the drawTarget can be closed by some other drawContext that h
as picked | 332 // In MDB-mode the drawTarget can be closed by some other drawContext that h
as picked |
326 // it up. For this reason, the drawTarget should only ever be accessed via '
getDrawTarget'. | 333 // it up. For this reason, the drawTarget should only ever be accessed via '
getDrawTarget'. |
327 GrDrawTarget* fDrawTarget; | 334 GrDrawTarget* fDrawTarget; |
328 SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext; | 335 SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext; |
329 GrContext* fContext; | 336 GrContext* fContext; |
330 | 337 |
331 SkSurfaceProps fSurfaceProps; | 338 SkSurfaceProps fSurfaceProps; |
332 GrAuditTrail* fAuditTrail; | 339 GrAuditTrail* fAuditTrail; |
333 | 340 |
334 // In debug builds we guard against improper thread handling | 341 // In debug builds we guard against improper thread handling |
335 SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) | 342 SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) |
336 }; | 343 }; |
337 | 344 |
338 #endif | 345 #endif |
OLD | NEW |