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

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

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: More const API, minimal docs. Created 6 years, 4 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
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 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkTextBlob.h"
13 14
14 class SkPictureBox { 15 namespace SkRecords {
16
17 template <typename T>
18 class RefBox: SkNoncopyable {
15 public: 19 public:
16 SkPictureBox(const SkPicture* obj) : fObj(SkRef(obj)) {} 20 RefBox(const T* obj) : fObj(SkRef(obj)) {}
17 ~SkPictureBox() { fObj->unref(); } 21 ~RefBox() { fObj->unref(); }
18 22
19 operator const SkPicture*() const { return fObj; } 23 operator const T*() const { return fObj; }
20 24
21 private: 25 private:
22 SkPictureBox(const SkPictureBox&); 26 const T* fObj;
23 SkPictureBox& operator=(const SkPictureBox&);
24
25 const SkPicture* fObj;
26 }; 27 };
27 28
28 namespace SkRecords {
29
30 // A list of all the types of canvas calls we can record. 29 // A list of all the types of canvas calls we can record.
31 // Each of these is reified into a struct below. 30 // Each of these is reified into a struct below.
32 // 31 //
33 // (We're using the macro-of-macro trick here to do several different things wit h the same list.) 32 // (We're using the macro-of-macro trick here to do several different things wit h the same list.)
34 // 33 //
35 // We leave this SK_RECORD_TYPES macro defined for use by code that wants to ope rate on SkRecords 34 // We leave this SK_RECORD_TYPES macro defined for use by code that wants to ope rate on SkRecords
36 // types polymorphically. (See SkRecord::Record::{visit,mutate} for an example. ) 35 // types polymorphically. (See SkRecord::Record::{visit,mutate} for an example. )
37 // 36 //
38 // Order doesn't technically matter here, but the compiler can generally generat e better code if 37 // Order doesn't technically matter here, but the compiler can generally generat e better code if
39 // you keep them semantically grouped, especially the Draws. It's also nice to leave NoOp at 0. 38 // you keep them semantically grouped, especially the Draws. It's also nice to leave NoOp at 0.
(...skipping 21 matching lines...) Expand all
61 M(DrawPath) \ 60 M(DrawPath) \
62 M(DrawPatch) \ 61 M(DrawPatch) \
63 M(DrawPicture) \ 62 M(DrawPicture) \
64 M(DrawPoints) \ 63 M(DrawPoints) \
65 M(DrawPosText) \ 64 M(DrawPosText) \
66 M(DrawPosTextH) \ 65 M(DrawPosTextH) \
67 M(DrawRRect) \ 66 M(DrawRRect) \
68 M(DrawRect) \ 67 M(DrawRect) \
69 M(DrawSprite) \ 68 M(DrawSprite) \
70 M(DrawText) \ 69 M(DrawText) \
70 M(DrawTextBlob) \
71 M(DrawTextOnPath) \ 71 M(DrawTextOnPath) \
72 M(DrawVertices) 72 M(DrawVertices)
73 73
74 // Defines SkRecords::Type, an enum of all record types. 74 // Defines SkRecords::Type, an enum of all record types.
75 #define ENUM(T) T##_Type, 75 #define ENUM(T) T##_Type,
76 enum Type { SK_RECORD_TYPES(ENUM) }; 76 enum Type { SK_RECORD_TYPES(ENUM) };
77 #undef ENUM 77 #undef ENUM
78 78
79 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar gs, 2 args, etc. 79 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar gs, 2 args, etc.
80 // These should be clearer when you look at their use below. 80 // These should be clearer when you look at their use below.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 RECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint, 226 RECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint,
227 ImmutableBitmap, bitmap, 227 ImmutableBitmap, bitmap,
228 Optional<SkRect>, src, 228 Optional<SkRect>, src,
229 SkRect, dst, 229 SkRect, dst,
230 SkCanvas::DrawBitmapRectFlags, flags); 230 SkCanvas::DrawBitmapRectFlags, flags);
231 RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner); 231 RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
232 RECORD2(DrawOval, SkPaint, paint, SkRect, oval); 232 RECORD2(DrawOval, SkPaint, paint, SkRect, oval);
233 RECORD1(DrawPaint, SkPaint, paint); 233 RECORD1(DrawPaint, SkPaint, paint);
234 RECORD2(DrawPath, SkPaint, paint, SkPath, path); 234 RECORD2(DrawPath, SkPaint, paint, SkPath, path);
235 //RECORD2(DrawPatch, SkPaint, paint, SkPatch, patch); 235 //RECORD2(DrawPatch, SkPaint, paint, SkPatch, patch);
236 RECORD3(DrawPicture, Optional<SkPaint>, paint, SkPictureBox, picture, Optional<S kMatrix>, matrix); 236 RECORD3(DrawPicture, Optional<SkPaint>, paint, RefBox<SkPicture>, picture, Optio nal<SkMatrix>, matrix);
237 RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, size_t, count, Sk Point*, pts); 237 RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, size_t, count, Sk Point*, pts);
238 RECORD4(DrawPosText, SkPaint, paint, 238 RECORD4(DrawPosText, SkPaint, paint,
239 PODArray<char>, text, 239 PODArray<char>, text,
240 size_t, byteLength, 240 size_t, byteLength,
241 PODArray<SkPoint>, pos); 241 PODArray<SkPoint>, pos);
242 RECORD5(DrawPosTextH, SkPaint, paint, 242 RECORD5(DrawPosTextH, SkPaint, paint,
243 PODArray<char>, text, 243 PODArray<char>, text,
244 size_t, byteLength, 244 size_t, byteLength,
245 PODArray<SkScalar>, xpos, 245 PODArray<SkScalar>, xpos,
246 SkScalar, y); 246 SkScalar, y);
247 RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect); 247 RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect);
248 RECORD2(DrawRect, SkPaint, paint, SkRect, rect); 248 RECORD2(DrawRect, SkPaint, paint, SkRect, rect);
249 RECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left , int, top); 249 RECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left , int, top);
250 RECORD5(DrawText, SkPaint, paint, 250 RECORD5(DrawText, SkPaint, paint,
251 PODArray<char>, text, 251 PODArray<char>, text,
252 size_t, byteLength, 252 size_t, byteLength,
253 SkScalar, x, 253 SkScalar, x,
254 SkScalar, y); 254 SkScalar, y);
255 RECORD5(DrawTextOnPath, SkPaint, paint, 255 RECORD5(DrawTextOnPath, SkPaint, paint,
256 PODArray<char>, text, 256 PODArray<char>, text,
257 size_t, byteLength, 257 size_t, byteLength,
258 SkPath, path, 258 SkPath, path,
259 Optional<SkMatrix>, matrix); 259 Optional<SkMatrix>, matrix);
260 RECORD3(DrawTextBlob, SkPaint, paint,
261 SkPoint, offset,
262 RefBox<SkTextBlob>, blob);
260 263
261 // This guy is so ugly we just write it manually. 264 // This guy is so ugly we just write it manually.
262 struct DrawVertices { 265 struct DrawVertices {
263 static const Type kType = DrawVertices_Type; 266 static const Type kType = DrawVertices_Type;
264 267
265 DrawVertices(const SkPaint& paint, 268 DrawVertices(const SkPaint& paint,
266 SkCanvas::VertexMode vmode, 269 SkCanvas::VertexMode vmode,
267 int vertexCount, 270 int vertexCount,
268 SkPoint* vertices, 271 SkPoint* vertices,
269 SkPoint* texs, 272 SkPoint* texs,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 #undef RECORD0 316 #undef RECORD0
314 #undef RECORD1 317 #undef RECORD1
315 #undef RECORD2 318 #undef RECORD2
316 #undef RECORD3 319 #undef RECORD3
317 #undef RECORD4 320 #undef RECORD4
318 #undef RECORD5 321 #undef RECORD5
319 322
320 } // namespace SkRecords 323 } // namespace SkRecords
321 324
322 #endif//SkRecords_DEFINED 325 #endif//SkRecords_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698