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

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

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Build warnings fix. 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
« no previous file with comments | « src/core/SkRecorder.cpp ('k') | src/core/SkTextBlob.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 #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(DrawPatch) \ 60 M(DrawPatch) \
62 M(DrawPicture) \ 61 M(DrawPicture) \
63 M(DrawPoints) \ 62 M(DrawPoints) \
64 M(DrawPosText) \ 63 M(DrawPosText) \
65 M(DrawPosTextH) \ 64 M(DrawPosTextH) \
66 M(DrawText) \ 65 M(DrawText) \
67 M(DrawTextOnPath) \ 66 M(DrawTextOnPath) \
68 M(DrawRRect) \ 67 M(DrawRRect) \
69 M(DrawRect) \ 68 M(DrawRect) \
70 M(DrawSprite) \ 69 M(DrawSprite) \
70 M(DrawTextBlob) \
71 M(DrawVertices) 71 M(DrawVertices)
72 72
73 // Defines SkRecords::Type, an enum of all record types. 73 // Defines SkRecords::Type, an enum of all record types.
74 #define ENUM(T) T##_Type, 74 #define ENUM(T) T##_Type,
75 enum Type { SK_RECORD_TYPES(ENUM) }; 75 enum Type { SK_RECORD_TYPES(ENUM) };
76 #undef ENUM 76 #undef ENUM
77 77
78 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar gs, 2 args, etc. 78 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar gs, 2 args, etc.
79 // These should be clearer when you look at their use below. 79 // These should be clearer when you look at their use below.
80 #define RECORD0(T) \ 80 #define RECORD0(T) \
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 RECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint, 224 RECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint,
225 ImmutableBitmap, bitmap, 225 ImmutableBitmap, bitmap,
226 Optional<SkRect>, src, 226 Optional<SkRect>, src,
227 SkRect, dst, 227 SkRect, dst,
228 SkCanvas::DrawBitmapRectFlags, flags); 228 SkCanvas::DrawBitmapRectFlags, flags);
229 RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner); 229 RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
230 RECORD2(DrawOval, SkPaint, paint, SkRect, oval); 230 RECORD2(DrawOval, SkPaint, paint, SkRect, oval);
231 RECORD1(DrawPaint, SkPaint, paint); 231 RECORD1(DrawPaint, SkPaint, paint);
232 RECORD2(DrawPath, SkPaint, paint, SkPath, path); 232 RECORD2(DrawPath, SkPaint, paint, SkPath, path);
233 //RECORD2(DrawPatch, SkPaint, paint, SkPatch, patch); 233 //RECORD2(DrawPatch, SkPaint, paint, SkPatch, patch);
234 RECORD3(DrawPicture, Optional<SkPaint>, paint, SkPictureBox, picture, Optional<S kMatrix>, matrix); 234 RECORD3(DrawPicture, Optional<SkPaint>, paint, RefBox<SkPicture>, picture, Optio nal<SkMatrix>, matrix);
235 RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, size_t, count, Sk Point*, pts); 235 RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, size_t, count, Sk Point*, pts);
236 RECORD4(DrawPosText, SkPaint, paint, 236 RECORD4(DrawPosText, SkPaint, paint,
237 PODArray<char>, text, 237 PODArray<char>, text,
238 size_t, byteLength, 238 size_t, byteLength,
239 PODArray<SkPoint>, pos); 239 PODArray<SkPoint>, pos);
240 RECORD5(DrawPosTextH, SkPaint, paint, 240 RECORD5(DrawPosTextH, SkPaint, paint,
241 PODArray<char>, text, 241 PODArray<char>, text,
242 size_t, byteLength, 242 size_t, byteLength,
243 PODArray<SkScalar>, xpos, 243 PODArray<SkScalar>, xpos,
244 SkScalar, y); 244 SkScalar, y);
245 RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect); 245 RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect);
246 RECORD2(DrawRect, SkPaint, paint, SkRect, rect); 246 RECORD2(DrawRect, SkPaint, paint, SkRect, rect);
247 RECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left , int, top); 247 RECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left , int, top);
248 RECORD5(DrawText, SkPaint, paint, 248 RECORD5(DrawText, SkPaint, paint,
249 PODArray<char>, text, 249 PODArray<char>, text,
250 size_t, byteLength, 250 size_t, byteLength,
251 SkScalar, x, 251 SkScalar, x,
252 SkScalar, y); 252 SkScalar, y);
253 RECORD4(DrawTextBlob, SkPaint, paint,
254 RefBox<SkTextBlob>, blob,
255 SkScalar, x,
256 SkScalar, y);
253 RECORD5(DrawTextOnPath, SkPaint, paint, 257 RECORD5(DrawTextOnPath, SkPaint, paint,
254 PODArray<char>, text, 258 PODArray<char>, text,
255 size_t, byteLength, 259 size_t, byteLength,
256 SkPath, path, 260 SkPath, path,
257 Optional<SkMatrix>, matrix); 261 Optional<SkMatrix>, matrix);
258 262
259 // This guy is so ugly we just write it manually. 263 // This guy is so ugly we just write it manually.
260 struct DrawVertices { 264 struct DrawVertices {
261 static const Type kType = DrawVertices_Type; 265 static const Type kType = DrawVertices_Type;
262 266
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 #undef RECORD0 315 #undef RECORD0
312 #undef RECORD1 316 #undef RECORD1
313 #undef RECORD2 317 #undef RECORD2
314 #undef RECORD3 318 #undef RECORD3
315 #undef RECORD4 319 #undef RECORD4
316 #undef RECORD5 320 #undef RECORD5
317 321
318 } // namespace SkRecords 322 } // namespace SkRecords
319 323
320 #endif//SkRecords_DEFINED 324 #endif//SkRecords_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkRecorder.cpp ('k') | src/core/SkTextBlob.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698