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

Side by Side Diff: src/record/SkRecords.h

Issue 272673002: Move paints to the front of draw structs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 7 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 | « src/record/SkRecorder.cpp ('k') | tests/RecordTest.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 2014 Google Inc. 2 * Copyright 2014 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 SkRecords_DEFINED 8 #ifndef SkRecords_DEFINED
9 #define SkRecords_DEFINED 9 #define SkRecords_DEFINED
10 10
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 12
13 namespace SkRecords { 13 namespace SkRecords {
14 14
15 // A list of all the types of canvas calls we can record. 15 // A list of all the types of canvas calls we can record.
16 // Each of these is reified into a struct below. 16 // Each of these is reified into a struct below.
17 // 17 //
18 // (We're using the macro-of-macro trick here to do several different things wit h the same list.) 18 // (We're using the macro-of-macro trick here to do several different things wit h the same list.)
19 // 19 //
20 // We leave this SK_RECORD_TYPES macro defined for use by code that wants to ope rate on SkRecords 20 // We leave this SK_RECORD_TYPES macro defined for use by code that wants to ope rate on SkRecords
21 // types polymorphically. (See SkRecord::Record::{visit,mutate} for an example. ) 21 // types polymorphically. (See SkRecord::Record::{visit,mutate} for an example. )
22 //
23 // Order doesn't technically matter here, but the compiler can generally generat e better code if
24 // you keep them semantically grouped, especially the Draws. It's also nice to leave NoOp at 0.
22 #define SK_RECORD_TYPES(M) \ 25 #define SK_RECORD_TYPES(M) \
23 M(NoOp) \ 26 M(NoOp) \
24 M(Restore) \ 27 M(Restore) \
25 M(Save) \ 28 M(Save) \
26 M(SaveLayer) \ 29 M(SaveLayer) \
30 M(PushCull) \
31 M(PopCull) \
32 M(PairedPushCull) /*From SkRecordAnnotateCullingPairs*/ \
27 M(Concat) \ 33 M(Concat) \
28 M(SetMatrix) \ 34 M(SetMatrix) \
29 M(ClipPath) \ 35 M(ClipPath) \
30 M(ClipRRect) \ 36 M(ClipRRect) \
31 M(ClipRect) \ 37 M(ClipRect) \
32 M(ClipRegion) \ 38 M(ClipRegion) \
33 M(Clear) \ 39 M(Clear) \
34 M(DrawBitmap) \ 40 M(DrawBitmap) \
35 M(DrawBitmapMatrix) \ 41 M(DrawBitmapMatrix) \
36 M(DrawBitmapNine) \ 42 M(DrawBitmapNine) \
37 M(DrawBitmapRectToRect) \ 43 M(DrawBitmapRectToRect) \
38 M(DrawDRRect) \ 44 M(DrawDRRect) \
39 M(DrawOval) \ 45 M(DrawOval) \
40 M(DrawPaint) \ 46 M(DrawPaint) \
41 M(DrawPath) \ 47 M(DrawPath) \
42 M(DrawPoints) \ 48 M(DrawPoints) \
43 M(DrawPosText) \ 49 M(DrawPosText) \
44 M(DrawPosTextH) \ 50 M(DrawPosTextH) \
45 M(DrawRRect) \ 51 M(DrawRRect) \
46 M(DrawRect) \ 52 M(DrawRect) \
47 M(DrawSprite) \ 53 M(DrawSprite) \
48 M(DrawText) \ 54 M(DrawText) \
49 M(DrawTextOnPath) \ 55 M(DrawTextOnPath) \
50 M(DrawVertices) \ 56 M(DrawVertices) \
51 M(PushCull) \
52 M(PopCull) \
53 M(PairedPushCull) /*From SkRecordAnnotateCullingPairs*/ \
54 M(BoundedDrawPosTextH) /*From SkRecordBoundDrawPosTextH*/ 57 M(BoundedDrawPosTextH) /*From SkRecordBoundDrawPosTextH*/
55 58
56 // Defines SkRecords::Type, an enum of all record types. 59 // Defines SkRecords::Type, an enum of all record types.
57 #define ENUM(T) T##_Type, 60 #define ENUM(T) T##_Type,
58 enum Type { SK_RECORD_TYPES(ENUM) }; 61 enum Type { SK_RECORD_TYPES(ENUM) };
59 #undef ENUM 62 #undef ENUM
60 63
61 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar gs, 2 args, etc. 64 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar gs, 2 args, etc.
62 // These should be clearer when you look at their use below. 65 // These should be clearer when you look at their use below.
63 #define RECORD0(T) \ 66 #define RECORD0(T) \
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 191
189 RECORD1(Concat, SkMatrix, matrix); 192 RECORD1(Concat, SkMatrix, matrix);
190 RECORD1(SetMatrix, SkMatrix, matrix); 193 RECORD1(SetMatrix, SkMatrix, matrix);
191 194
192 RECORD3(ClipPath, SkPath, path, SkRegion::Op, op, bool, doAA); 195 RECORD3(ClipPath, SkPath, path, SkRegion::Op, op, bool, doAA);
193 RECORD3(ClipRRect, SkRRect, rrect, SkRegion::Op, op, bool, doAA); 196 RECORD3(ClipRRect, SkRRect, rrect, SkRegion::Op, op, bool, doAA);
194 RECORD3(ClipRect, SkRect, rect, SkRegion::Op, op, bool, doAA); 197 RECORD3(ClipRect, SkRect, rect, SkRegion::Op, op, bool, doAA);
195 RECORD2(ClipRegion, SkRegion, region, SkRegion::Op, op); 198 RECORD2(ClipRegion, SkRegion, region, SkRegion::Op, op);
196 199
197 RECORD1(Clear, SkColor, color); 200 RECORD1(Clear, SkColor, color);
198 RECORD4(DrawBitmap, ImmutableBitmap, bitmap, 201 // While not strictly required, if you have an SkPaint, it's fastest to put it f irst.
202 RECORD4(DrawBitmap, Optional<SkPaint>, paint,
203 ImmutableBitmap, bitmap,
199 SkScalar, left, 204 SkScalar, left,
200 SkScalar, top, 205 SkScalar, top);
201 Optional<SkPaint>, paint); 206 RECORD3(DrawBitmapMatrix, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, SkM atrix, matrix);
202 RECORD3(DrawBitmapMatrix, ImmutableBitmap, bitmap, SkMatrix, matrix, Optional<Sk Paint>, paint); 207 RECORD4(DrawBitmapNine, Optional<SkPaint>, paint,
203 RECORD4(DrawBitmapNine, ImmutableBitmap, bitmap, 208 ImmutableBitmap, bitmap,
204 SkIRect, center, 209 SkIRect, center,
205 SkRect, dst, 210 SkRect, dst);
206 Optional<SkPaint>, paint); 211 RECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint,
207 RECORD5(DrawBitmapRectToRect, ImmutableBitmap, bitmap, 212 ImmutableBitmap, bitmap,
208 Optional<SkRect>, src, 213 Optional<SkRect>, src,
209 SkRect, dst, 214 SkRect, dst,
210 Optional<SkPaint>, paint,
211 SkCanvas::DrawBitmapRectFlags, flags); 215 SkCanvas::DrawBitmapRectFlags, flags);
212 RECORD3(DrawDRRect, SkRRect, outer, SkRRect, inner, SkPaint, paint); 216 RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
213 RECORD2(DrawOval, SkRect, oval, SkPaint, paint); 217 RECORD2(DrawOval, SkPaint, paint, SkRect, oval);
214 RECORD1(DrawPaint, SkPaint, paint); 218 RECORD1(DrawPaint, SkPaint, paint);
215 RECORD2(DrawPath, SkPath, path, SkPaint, paint); 219 RECORD2(DrawPath, SkPaint, paint, SkPath, path);
216 RECORD4(DrawPoints, SkCanvas::PointMode, mode, size_t, count, SkPoint*, pts, SkP aint, paint); 220 RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, size_t, count, Sk Point*, pts);
217 RECORD4(DrawPosText, PODArray<char>, text, 221 RECORD4(DrawPosText, SkPaint, paint,
222 PODArray<char>, text,
218 size_t, byteLength, 223 size_t, byteLength,
219 PODArray<SkPoint>, pos, 224 PODArray<SkPoint>, pos);
220 SkPaint, paint); 225 RECORD5(DrawPosTextH, SkPaint, paint,
221 RECORD5(DrawPosTextH, PODArray<char>, text, 226 PODArray<char>, text,
222 size_t, byteLength, 227 size_t, byteLength,
223 PODArray<SkScalar>, xpos, 228 PODArray<SkScalar>, xpos,
224 SkScalar, y, 229 SkScalar, y);
225 SkPaint, paint); 230 RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect);
226 RECORD2(DrawRRect, SkRRect, rrect, SkPaint, paint); 231 RECORD2(DrawRect, SkPaint, paint, SkRect, rect);
227 RECORD2(DrawRect, SkRect, rect, SkPaint, paint); 232 RECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left , int, top);
228 RECORD4(DrawSprite, ImmutableBitmap, bitmap, int, left, int, top, Optional<SkPai nt>, paint); 233 RECORD5(DrawText, SkPaint, paint,
229 RECORD5(DrawText, PODArray<char>, text, 234 PODArray<char>, text,
230 size_t, byteLength, 235 size_t, byteLength,
231 SkScalar, x, 236 SkScalar, x,
232 SkScalar, y, 237 SkScalar, y);
233 SkPaint, paint); 238 RECORD5(DrawTextOnPath, SkPaint, paint,
234 RECORD5(DrawTextOnPath, PODArray<char>, text, 239 PODArray<char>, text,
235 size_t, byteLength, 240 size_t, byteLength,
236 SkPath, path, 241 SkPath, path,
237 Optional<SkMatrix>, matrix, 242 Optional<SkMatrix>, matrix);
238 SkPaint, paint);
239 243
240 // This guy is so ugly we just write it manually. 244 // This guy is so ugly we just write it manually.
241 struct DrawVertices { 245 struct DrawVertices {
242 static const Type kType = DrawVertices_Type; 246 static const Type kType = DrawVertices_Type;
243 247
244 DrawVertices(SkCanvas::VertexMode vmode, 248 DrawVertices(const SkPaint& paint,
249 SkCanvas::VertexMode vmode,
245 int vertexCount, 250 int vertexCount,
246 SkPoint* vertices, 251 SkPoint* vertices,
247 SkPoint* texs, 252 SkPoint* texs,
248 SkColor* colors, 253 SkColor* colors,
249 SkXfermode* xmode, 254 SkXfermode* xmode,
250 uint16_t* indices, 255 uint16_t* indices,
251 int indexCount, 256 int indexCount)
252 const SkPaint& paint) 257 : paint(paint)
253 : vmode(vmode) 258 , vmode(vmode)
254 , vertexCount(vertexCount) 259 , vertexCount(vertexCount)
255 , vertices(vertices) 260 , vertices(vertices)
256 , texs(texs) 261 , texs(texs)
257 , colors(colors) 262 , colors(colors)
258 , xmode(SkSafeRef(xmode)) 263 , xmode(SkSafeRef(xmode))
259 , indices(indices) 264 , indices(indices)
260 , indexCount(indexCount) 265 , indexCount(indexCount) {}
261 , paint(paint) {}
262 266
267 SkPaint paint;
263 SkCanvas::VertexMode vmode; 268 SkCanvas::VertexMode vmode;
264 int vertexCount; 269 int vertexCount;
265 PODArray<SkPoint> vertices; 270 PODArray<SkPoint> vertices;
266 PODArray<SkPoint> texs; 271 PODArray<SkPoint> texs;
267 PODArray<SkColor> colors; 272 PODArray<SkColor> colors;
268 SkAutoTUnref<SkXfermode> xmode; 273 SkAutoTUnref<SkXfermode> xmode;
269 PODArray<uint16_t> indices; 274 PODArray<uint16_t> indices;
270 int indexCount; 275 int indexCount;
271 SkPaint paint;
272 }; 276 };
273 277
274 // Records added by optimizations. 278 // Records added by optimizations.
275 RECORD2(PairedPushCull, Adopted<PushCull>, base, unsigned, skip); 279 RECORD2(PairedPushCull, Adopted<PushCull>, base, unsigned, skip);
276 RECORD3(BoundedDrawPosTextH, Adopted<DrawPosTextH>, base, SkScalar, minY, SkScal ar, maxY); 280 RECORD3(BoundedDrawPosTextH, Adopted<DrawPosTextH>, base, SkScalar, minY, SkScal ar, maxY);
277 281
278 #undef RECORD0 282 #undef RECORD0
279 #undef RECORD1 283 #undef RECORD1
280 #undef RECORD2 284 #undef RECORD2
281 #undef RECORD3 285 #undef RECORD3
282 #undef RECORD4 286 #undef RECORD4
283 #undef RECORD5 287 #undef RECORD5
284 288
285 } // namespace SkRecords 289 } // namespace SkRecords
286 290
287 #endif//SkRecords_DEFINED 291 #endif//SkRecords_DEFINED
OLDNEW
« no previous file with comments | « src/record/SkRecorder.cpp ('k') | tests/RecordTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698