Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: include/gpu/GrDrawContext.h

Issue 1404823005: GrDrawContext now holds GrRenderTarget pointer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix overlength line Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 struct SkRSXform; 37 struct SkRSXform;
38 class SkTextBlob; 38 class SkTextBlob;
39 39
40 /* 40 /*
41 * A helper object to orchestrate draws 41 * A helper object to orchestrate draws
42 */ 42 */
43 class SK_API GrDrawContext : public SkRefCnt { 43 class SK_API GrDrawContext : public SkRefCnt {
44 public: 44 public:
45 ~GrDrawContext() override; 45 ~GrDrawContext() override;
46 46
47 void copySurface(GrRenderTarget* dst, GrSurface* src, 47 void copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dst Point);
48 const SkIRect& srcRect, const SkIPoint& dstPoint);
49 48
50 // TODO: it is odd that we need both the SkPaint in the following 3 methods. 49 // TODO: it is odd that we need both the SkPaint in the following 3 methods.
51 // We should extract the text parameters from SkPaint and pass them separate ly 50 // We should extract the text parameters from SkPaint and pass them separate ly
52 // akin to GrStrokeInfo (GrTextInfo?) 51 // akin to GrStrokeInfo (GrTextInfo?)
53 void drawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint &, 52 void drawText(const GrClip&, const GrPaint&, const SkPaint&,
54 const SkMatrix& viewMatrix, const char text[], size_t byteLeng th, 53 const SkMatrix& viewMatrix, const char text[], size_t byteLeng th,
55 SkScalar x, SkScalar y, const SkIRect& clipBounds); 54 SkScalar x, SkScalar y, const SkIRect& clipBounds);
56 void drawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPai nt&, 55 void drawPosText(const GrClip&, const GrPaint&, const SkPaint&,
57 const SkMatrix& viewMatrix, const char text[], size_t byteL ength, 56 const SkMatrix& viewMatrix, const char text[], size_t byteL ength,
58 const SkScalar pos[], int scalarsPerPosition, 57 const SkScalar pos[], int scalarsPerPosition,
59 const SkPoint& offset, const SkIRect& clipBounds); 58 const SkPoint& offset, const SkIRect& clipBounds);
60 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, 59 void drawTextBlob(const GrClip&, const SkPaint&,
61 const SkMatrix& viewMatrix, const SkTextBlob*, 60 const SkMatrix& viewMatrix, const SkTextBlob*,
62 SkScalar x, SkScalar y, 61 SkScalar x, SkScalar y,
63 SkDrawFilter*, const SkIRect& clipBounds); 62 SkDrawFilter*, const SkIRect& clipBounds);
64 63
65 // drawPathsFromRange is thanks to GrStencilAndCoverTextContext 64 // drawPathsFromRange is thanks to GrStencilAndCoverTextContext
66 // TODO: remove once path batches can be created external to GrDrawTarget. 65 // TODO: remove once path batches can be created external to GrDrawTarget.
67 void drawPathsFromRange(const GrPipelineBuilder*, 66 void drawPathsFromRange(const GrPipelineBuilder*,
68 const SkMatrix& viewMatrix, 67 const SkMatrix& viewMatrix,
69 const SkMatrix& localMatrix, 68 const SkMatrix& localMatrix,
70 GrColor color, 69 GrColor color,
71 GrPathRange* range, 70 GrPathRange* range,
72 GrPathRangeDraw* draw, 71 GrPathRangeDraw* draw,
73 int /*GrPathRendering::FillType*/ fill); 72 int /*GrPathRendering::FillType*/ fill);
74 73
75 /** 74 /**
76 * Provides a perfomance hint that the render target's contents are allowed 75 * Provides a perfomance hint that the render target's contents are allowed
77 * to become undefined. 76 * to become undefined.
78 */ 77 */
79 void discard(GrRenderTarget*); 78 void discard();
80 79
81 /** 80 /**
82 * Clear the entire or rect of the render target, ignoring any clips. 81 * Clear the entire or rect of the render target, ignoring any clips.
83 * @param target The render target to clear.
84 * @param rect the rect to clear or the whole thing if rect is NULL. 82 * @param rect the rect to clear or the whole thing if rect is NULL.
85 * @param color the color to clear to. 83 * @param color the color to clear to.
86 * @param canIgnoreRect allows partial clears to be converted to whole 84 * @param canIgnoreRect allows partial clears to be converted to whole
87 * clears on platforms for which that is cheap 85 * clears on platforms for which that is cheap
88 */ 86 */
89 void clear(GrRenderTarget*, const SkIRect* rect, GrColor color, bool canIgno reRect); 87 void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect);
90 88
91 /** 89 /**
92 * Draw everywhere (respecting the clip) with the paint. 90 * Draw everywhere (respecting the clip) with the paint.
93 */ 91 */
94 void drawPaint(GrRenderTarget*, const GrClip&, const GrPaint&, const SkMatri x& viewMatrix); 92 void drawPaint(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix);
95 93
96 /** 94 /**
97 * Draw the rect using a paint. 95 * Draw the rect using a paint.
98 * @param paint describes how to color pixels. 96 * @param paint describes how to color pixels.
99 * @param viewMatrix transformation matrix 97 * @param viewMatrix transformation matrix
100 * @param strokeInfo the stroke information (width, join, cap), and. 98 * @param strokeInfo the stroke information (width, join, cap), and.
101 * the dash information (intervals, count, phase). 99 * the dash information (intervals, count, phase).
102 * If strokeInfo == NULL, then the rect is filled. 100 * If strokeInfo == NULL, then the rect is filled.
103 * Otherwise, if stroke width == 0, then the stroke 101 * Otherwise, if stroke width == 0, then the stroke
104 * is always a single pixel thick, else the rect is 102 * is always a single pixel thick, else the rect is
105 * mitered/beveled stroked based on stroke width. 103 * mitered/beveled stroked based on stroke width.
106 * The rects coords are used to access the paint (through texture matrix) 104 * The rects coords are used to access the paint (through texture matrix)
107 */ 105 */
108 void drawRect(GrRenderTarget*, 106 void drawRect(const GrClip&,
109 const GrClip&,
110 const GrPaint& paint, 107 const GrPaint& paint,
111 const SkMatrix& viewMatrix, 108 const SkMatrix& viewMatrix,
112 const SkRect&, 109 const SkRect&,
113 const GrStrokeInfo* strokeInfo = NULL); 110 const GrStrokeInfo* strokeInfo = NULL);
114 111
115 /** 112 /**
116 * Maps a rectangle of shader coordinates to a rectangle and draws that rect angle 113 * Maps a rectangle of shader coordinates to a rectangle and draws that rect angle
117 * 114 *
118 * @param paint describes how to color pixels. 115 * @param paint describes how to color pixels.
119 * @param viewMatrix transformation matrix which applies to rectToDraw 116 * @param viewMatrix transformation matrix which applies to rectToDraw
120 * @param rectToDraw the rectangle to draw 117 * @param rectToDraw the rectangle to draw
121 * @param localRect the rectangle of shader coordinates applied to rectT oDraw 118 * @param localRect the rectangle of shader coordinates applied to rectT oDraw
122 */ 119 */
123 void drawNonAARectToRect(GrRenderTarget*, 120 void drawNonAARectToRect(const GrClip&,
124 const GrClip&,
125 const GrPaint& paint, 121 const GrPaint& paint,
126 const SkMatrix& viewMatrix, 122 const SkMatrix& viewMatrix,
127 const SkRect& rectToDraw, 123 const SkRect& rectToDraw,
128 const SkRect& localRect); 124 const SkRect& localRect);
129 125
130 /** 126 /**
131 * Draws a non-AA rect with paint and a localMatrix 127 * Draws a non-AA rect with paint and a localMatrix
132 */ 128 */
133 void drawNonAARectWithLocalMatrix(GrRenderTarget* rt, 129 void drawNonAARectWithLocalMatrix(const GrClip& clip,
134 const GrClip& clip,
135 const GrPaint& paint, 130 const GrPaint& paint,
136 const SkMatrix& viewMatrix, 131 const SkMatrix& viewMatrix,
137 const SkRect& rect, 132 const SkRect& rect,
138 const SkMatrix& localMatrix); 133 const SkMatrix& localMatrix);
139 134
140 /** 135 /**
141 * Draw a roundrect using a paint. 136 * Draw a roundrect using a paint.
142 * 137 *
143 * @param paint describes how to color pixels. 138 * @param paint describes how to color pixels.
144 * @param viewMatrix transformation matrix 139 * @param viewMatrix transformation matrix
145 * @param rrect the roundrect to draw 140 * @param rrect the roundrect to draw
146 * @param strokeInfo the stroke information (width, join, cap) and 141 * @param strokeInfo the stroke information (width, join, cap) and
147 * the dash information (intervals, count, phase). 142 * the dash information (intervals, count, phase).
148 */ 143 */
149 void drawRRect(GrRenderTarget*, 144 void drawRRect(const GrClip&,
150 const GrClip&,
151 const GrPaint&, 145 const GrPaint&,
152 const SkMatrix& viewMatrix, 146 const SkMatrix& viewMatrix,
153 const SkRRect& rrect, 147 const SkRRect& rrect,
154 const GrStrokeInfo&); 148 const GrStrokeInfo&);
155 149
156 /** 150 /**
157 * Shortcut for drawing an SkPath consisting of nested rrects using a paint . 151 * Shortcut for drawing an SkPath consisting of nested rrects using a paint .
158 * Does not support stroking. The result is undefined if outer does not con tain 152 * Does not support stroking. The result is undefined if outer does not con tain
159 * inner. 153 * inner.
160 * 154 *
161 * @param paint describes how to color pixels. 155 * @param paint describes how to color pixels.
162 * @param viewMatrix transformation matrix 156 * @param viewMatrix transformation matrix
163 * @param outer the outer roundrect 157 * @param outer the outer roundrect
164 * @param inner the inner roundrect 158 * @param inner the inner roundrect
165 */ 159 */
166 void drawDRRect(GrRenderTarget*, 160 void drawDRRect(const GrClip&,
167 const GrClip&,
168 const GrPaint&, 161 const GrPaint&,
169 const SkMatrix& viewMatrix, 162 const SkMatrix& viewMatrix,
170 const SkRRect& outer, 163 const SkRRect& outer,
171 const SkRRect& inner); 164 const SkRRect& inner);
172 165
173 166
174 /** 167 /**
175 * Draws a path. 168 * Draws a path.
176 * 169 *
177 * @param paint describes how to color pixels. 170 * @param paint describes how to color pixels.
178 * @param viewMatrix transformation matrix 171 * @param viewMatrix transformation matrix
179 * @param path the path to draw 172 * @param path the path to draw
180 * @param strokeInfo the stroke information (width, join, cap) and 173 * @param strokeInfo the stroke information (width, join, cap) and
181 * the dash information (intervals, count, phase). 174 * the dash information (intervals, count, phase).
182 */ 175 */
183 void drawPath(GrRenderTarget*, 176 void drawPath(const GrClip&,
184 const GrClip&,
185 const GrPaint&, 177 const GrPaint&,
186 const SkMatrix& viewMatrix, 178 const SkMatrix& viewMatrix,
187 const SkPath&, 179 const SkPath&,
188 const GrStrokeInfo&); 180 const GrStrokeInfo&);
189 181
190 /** 182 /**
191 * Draws vertices with a paint. 183 * Draws vertices with a paint.
192 * 184 *
193 * @param paint describes how to color pixels. 185 * @param paint describes how to color pixels.
194 * @param viewMatrix transformation matrix 186 * @param viewMatrix transformation matrix
195 * @param primitiveType primitives type to draw. 187 * @param primitiveType primitives type to draw.
196 * @param vertexCount number of vertices. 188 * @param vertexCount number of vertices.
197 * @param positions array of vertex positions, required. 189 * @param positions array of vertex positions, required.
198 * @param texCoords optional array of texture coordinates used 190 * @param texCoords optional array of texture coordinates used
199 * to access the paint. 191 * to access the paint.
200 * @param colors optional array of per-vertex colors, supercedes 192 * @param colors optional array of per-vertex colors, supercedes
201 * the paint's color field. 193 * the paint's color field.
202 * @param indices optional array of indices. If NULL vertices 194 * @param indices optional array of indices. If NULL vertices
203 * are drawn non-indexed. 195 * are drawn non-indexed.
204 * @param indexCount if indices is non-null then this is the 196 * @param indexCount if indices is non-null then this is the
205 * number of indices. 197 * number of indices.
206 */ 198 */
207 void drawVertices(GrRenderTarget*, 199 void drawVertices(const GrClip&,
208 const GrClip&,
209 const GrPaint& paint, 200 const GrPaint& paint,
210 const SkMatrix& viewMatrix, 201 const SkMatrix& viewMatrix,
211 GrPrimitiveType primitiveType, 202 GrPrimitiveType primitiveType,
212 int vertexCount, 203 int vertexCount,
213 const SkPoint positions[], 204 const SkPoint positions[],
214 const SkPoint texs[], 205 const SkPoint texs[],
215 const GrColor colors[], 206 const GrColor colors[],
216 const uint16_t indices[], 207 const uint16_t indices[],
217 int indexCount); 208 int indexCount);
218 209
219 /** 210 /**
220 * Draws textured sprites from an atlas with a paint. 211 * Draws textured sprites from an atlas with a paint.
221 * 212 *
222 * @param paint describes how to color pixels. 213 * @param paint describes how to color pixels.
223 * @param viewMatrix transformation matrix 214 * @param viewMatrix transformation matrix
224 * @param spriteCount number of sprites. 215 * @param spriteCount number of sprites.
225 * @param xform array of compressed transformation data, require d. 216 * @param xform array of compressed transformation data, require d.
226 * @param texRect array of texture rectangles used to access the p aint. 217 * @param texRect array of texture rectangles used to access the p aint.
227 * @param colors optional array of per-sprite colors, supercedes 218 * @param colors optional array of per-sprite colors, supercedes
228 * the paint's color field. 219 * the paint's color field.
229 */ 220 */
230 void drawAtlas(GrRenderTarget*, 221 void drawAtlas(const GrClip&,
231 const GrClip&,
232 const GrPaint& paint, 222 const GrPaint& paint,
233 const SkMatrix& viewMatrix, 223 const SkMatrix& viewMatrix,
234 int spriteCount, 224 int spriteCount,
235 const SkRSXform xform[], 225 const SkRSXform xform[],
236 const SkRect texRect[], 226 const SkRect texRect[],
237 const SkColor colors[]); 227 const SkColor colors[]);
238 228
239 /** 229 /**
240 * Draws an oval. 230 * Draws an oval.
241 * 231 *
242 * @param paint describes how to color pixels. 232 * @param paint describes how to color pixels.
243 * @param viewMatrix transformation matrix 233 * @param viewMatrix transformation matrix
244 * @param oval the bounding rect of the oval. 234 * @param oval the bounding rect of the oval.
245 * @param strokeInfo the stroke information (width, join, cap) and 235 * @param strokeInfo the stroke information (width, join, cap) and
246 * the dash information (intervals, count, phase). 236 * the dash information (intervals, count, phase).
247 */ 237 */
248 void drawOval(GrRenderTarget*, 238 void drawOval(const GrClip&,
249 const GrClip&,
250 const GrPaint& paint, 239 const GrPaint& paint,
251 const SkMatrix& viewMatrix, 240 const SkMatrix& viewMatrix,
252 const SkRect& oval, 241 const SkRect& oval,
253 const GrStrokeInfo& strokeInfo); 242 const GrStrokeInfo& strokeInfo);
254 243
255 244
256 /** 245 /**
257 * Draws a batch 246 * Draws a batch
258 * 247 *
259 * @param paint describes how to color pixels. 248 * @param paint describes how to color pixels.
260 * @param batch the batch to draw 249 * @param batch the batch to draw
261 */ 250 */
262 void drawBatch(GrRenderTarget*, const GrClip&, const GrPaint&, GrDrawBatch*) ; 251 void drawBatch(const GrClip&, const GrPaint&, GrDrawBatch*);
263 252
264 private: 253 private:
265 friend class GrAtlasTextContext; // for access to drawBatch 254 friend class GrAtlasTextContext; // for access to drawBatch
266 friend class GrContext; // for ctor 255 friend class GrContext; // for ctor
267 256
268 GrDrawContext(GrContext*, GrDrawTarget*, const SkSurfaceProps* surfaceProps) ; 257 SkDEBUGCODE(void validate() const;)
269 258
270 // Checks if the context has been abandoned and if the rendertarget is owned by this context 259 GrDrawContext(GrContext*, GrRenderTarget*, GrDrawTarget*, const SkSurfacePro ps* surfaceProps);
271 bool prepareToDraw(GrRenderTarget* rt);
272 260
273 void internalDrawPath(GrDrawTarget*, 261 void internalDrawPath(GrDrawTarget*,
274 GrPipelineBuilder*, 262 GrPipelineBuilder*,
275 const SkMatrix& viewMatrix, 263 const SkMatrix& viewMatrix,
276 GrColor, 264 GrColor,
277 bool useAA, 265 bool useAA,
278 const SkPath&, 266 const SkPath&,
279 const GrStrokeInfo&); 267 const GrStrokeInfo&);
280 268
281 // This entry point allows the GrTextContext-derived classes to add their ba tches to 269 // This entry point allows the GrTextContext-derived classes to add their ba tches to
282 // the drawTarget. 270 // the drawTarget.
283 void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch); 271 void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch);
284 272
285 GrContext* fContext; // owning context -> no ref 273 GrContext* fContext; // owning context -> no ref
274 GrRenderTarget* fRenderTarget;
286 GrDrawTarget* fDrawTarget; 275 GrDrawTarget* fDrawTarget;
287 GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMg r 276 GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMg r
288 277
289 SkSurfaceProps fSurfaceProps; 278 SkSurfaceProps fSurfaceProps;
290 }; 279 };
291 280
292 #endif 281 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698