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

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

Issue 1151283004: Split drawing functionality out of GrContext and into new GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review comments Created 5 years, 6 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrDawContext_DEFINED
9 #define GrDrawContext_DEFINED
10
11 #include "SkRefCnt.h"
12 #include "GrDrawTarget.h" // TODO: remove this
13
14 /*
15 * A helper object to orchestrate draws
16 */
17 class SK_API GrDrawContext : public SkRefCnt {
18 public:
19 SK_DECLARE_INST_COUNT(GrDrawContext)
20
21 void copySurface(GrRenderTarget* dst, GrSurface* src,
22 const SkIRect& srcRect, const SkIPoint& dstPoint);
23
24 // drawText and drawPaths are thanks to the GrAtlasTextContext and the
25 // GrStencilAndCoverTextContext respectively
26 // TODO: remove these two
27 void drawText(GrPipelineBuilder* pipelineBuilder, GrBatch* batch);
28
29 void drawPaths(GrPipelineBuilder* pipelineBuilder,
30 const GrPathProcessor* pathProc,
31 const GrPathRange* pathRange,
32 const void* indices,
33 GrDrawTarget::PathIndexType indexType,
34 const float transformValues[],
35 GrDrawTarget::PathTransformType transformType,
36 int count,
37 GrPathRendering::FillType fill);
38
39 /**
40 * Provides a perfomance hint that the render target's contents are allowed
41 * to become undefined.
42 */
43 void discard(GrRenderTarget*);
44
45 /**
46 * Clear the entire or rect of the render target, ignoring any clips.
47 * @param target The render target to clear.
48 * @param rect the rect to clear or the whole thing if rect is NULL.
49 * @param color the color to clear to.
50 * @param canIgnoreRect allows partial clears to be converted to whole
51 * clears on platforms for which that is cheap
52 */
53 void clear(GrRenderTarget*, const SkIRect* rect, GrColor color, bool canIgno reRect);
54
55 /**
56 * Draw everywhere (respecting the clip) with the paint.
57 */
58 void drawPaint(GrRenderTarget*, const GrClip&, const GrPaint&, const SkMatri x& viewMatrix);
59
60 /**
61 * Draw the rect using a paint.
62 * @param paint describes how to color pixels.
63 * @param viewMatrix transformation matrix
64 * @param strokeInfo the stroke information (width, join, cap), and.
65 * the dash information (intervals, count, phase).
66 * If strokeInfo == NULL, then the rect is filled.
67 * Otherwise, if stroke width == 0, then the stroke
68 * is always a single pixel thick, else the rect is
69 * mitered/beveled stroked based on stroke width.
70 * The rects coords are used to access the paint (through texture matrix)
71 */
72 void drawRect(GrRenderTarget*,
73 const GrClip&,
74 const GrPaint& paint,
75 const SkMatrix& viewMatrix,
76 const SkRect&,
77 const GrStrokeInfo* strokeInfo = NULL);
78
79 /**
80 * Maps a rectangle of shader coordinates to a rectangle and draws that rect angle
81 *
82 * @param paint describes how to color pixels.
83 * @param viewMatrix transformation matrix which applies to rectToDraw
84 * @param rectToDraw the rectangle to draw
85 * @param localRect the rectangle of shader coordinates applied to rectT oDraw
86 * @param localMatrix an optional matrix to transform the shader coordinat es before applying
87 * to rectToDraw
88 */
89 void drawNonAARectToRect(GrRenderTarget*,
90 const GrClip&,
91 const GrPaint& paint,
92 const SkMatrix& viewMatrix,
93 const SkRect& rectToDraw,
94 const SkRect& localRect,
95 const SkMatrix* localMatrix = NULL);
96
97 /**
98 * Draws a non-AA rect with paint and a localMatrix
99 */
100 void drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
101 const GrClip& clip,
102 const GrPaint& paint,
103 const SkMatrix& viewMatrix,
104 const SkRect& rect,
105 const SkMatrix& localMatrix) {
106 this->drawNonAARectToRect(rt, clip, paint, viewMatrix, rect, rect, &loca lMatrix);
107 }
108
109 /**
110 * Draw a roundrect using a paint.
111 *
112 * @param paint describes how to color pixels.
113 * @param viewMatrix transformation matrix
114 * @param rrect the roundrect to draw
115 * @param strokeInfo the stroke information (width, join, cap) and
116 * the dash information (intervals, count, phase).
117 */
118 void drawRRect(GrRenderTarget*,
119 const GrClip&,
120 const GrPaint&,
121 const SkMatrix& viewMatrix,
122 const SkRRect& rrect,
123 const GrStrokeInfo&);
124
125 /**
126 * Shortcut for drawing an SkPath consisting of nested rrects using a paint .
127 * Does not support stroking. The result is undefined if outer does not con tain
128 * inner.
129 *
130 * @param paint describes how to color pixels.
131 * @param viewMatrix transformation matrix
132 * @param outer the outer roundrect
133 * @param inner the inner roundrect
134 */
135 void drawDRRect(GrRenderTarget*,
136 const GrClip&,
137 const GrPaint&,
138 const SkMatrix& viewMatrix,
139 const SkRRect& outer,
140 const SkRRect& inner);
141
142
143 /**
144 * Draws a path.
145 *
146 * @param paint describes how to color pixels.
147 * @param viewMatrix transformation matrix
148 * @param path the path to draw
149 * @param strokeInfo the stroke information (width, join, cap) and
150 * the dash information (intervals, count, phase).
151 */
152 void drawPath(GrRenderTarget*,
153 const GrClip&,
154 const GrPaint&,
155 const SkMatrix& viewMatrix,
156 const SkPath&,
157 const GrStrokeInfo&);
158
159 /**
160 * Draws vertices with a paint.
161 *
162 * @param paint describes how to color pixels.
163 * @param viewMatrix transformation matrix
164 * @param primitiveType primitives type to draw.
165 * @param vertexCount number of vertices.
166 * @param positions array of vertex positions, required.
167 * @param texCoords optional array of texture coordinates used
168 * to access the paint.
169 * @param colors optional array of per-vertex colors, supercedes
170 * the paint's color field.
171 * @param indices optional array of indices. If NULL vertices
172 * are drawn non-indexed.
173 * @param indexCount if indices is non-null then this is the
174 * number of indices.
175 */
176 void drawVertices(GrRenderTarget*,
177 const GrClip&,
178 const GrPaint& paint,
179 const SkMatrix& viewMatrix,
180 GrPrimitiveType primitiveType,
181 int vertexCount,
182 const SkPoint positions[],
183 const SkPoint texs[],
184 const GrColor colors[],
185 const uint16_t indices[],
186 int indexCount);
187
188 /**
189 * Draws an oval.
190 *
191 * @param paint describes how to color pixels.
192 * @param viewMatrix transformation matrix
193 * @param oval the bounding rect of the oval.
194 * @param strokeInfo the stroke information (width, join, cap) and
195 * the dash information (intervals, count, phase).
196 */
197 void drawOval(GrRenderTarget*,
198 const GrClip&,
199 const GrPaint& paint,
200 const SkMatrix& viewMatrix,
201 const SkRect& oval,
202 const GrStrokeInfo& strokeInfo);
203
204
205 private:
206 friend class GrContext; // for ctor
207
208 GrDrawContext(GrContext* context, GrDrawTarget* drawTarget);
209
210 // Sets the paint. Returns true on success; false on failure.
211 bool prepareToDraw(GrPipelineBuilder*,
212 GrRenderTarget* rt,
213 const GrClip&,
214 const GrPaint* paint);
215
216 // A simpler version of the above which just returns true on success; false on failure.
217 // Clip is *NOT* set
218 bool prepareToDraw(GrRenderTarget* rt);
219
220 void internalDrawPath(GrDrawTarget*,
221 GrPipelineBuilder*,
222 const SkMatrix& viewMatrix,
223 GrColor,
224 bool useAA,
225 const SkPath&,
226 const GrStrokeInfo&);
227
228 GrContext* fContext; // owning context -> no ref
229 SkAutoTUnref<GrDrawTarget> fDrawTarget;
230 };
231
232 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698