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

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

Issue 495793002: Our SkPicture::Analysis visitors should recurse into nested pictures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« src/core/SkPicture.cpp ('K') | « src/core/SkPicture.cpp ('k') | no next file » | 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 13
14 class SkPictureBox {
15 public:
16 SkPictureBox(const SkPicture* obj) : fObj(SkRef(obj)) {}
17 ~SkPictureBox() { fObj->unref(); }
18
19 operator const SkPicture*() const { return fObj; }
20
21 private:
22 SkPictureBox(const SkPictureBox&);
23 SkPictureBox& operator=(const SkPictureBox&);
24
25 const SkPicture* fObj;
26 };
27
28 namespace SkRecords { 14 namespace SkRecords {
29 15
30 // A list of all the types of canvas calls we can record. 16 // A list of all the types of canvas calls we can record.
31 // Each of these is reified into a struct below. 17 // Each of these is reified into a struct below.
32 // 18 //
33 // (We're using the macro-of-macro trick here to do several different things wit h the same list.) 19 // (We're using the macro-of-macro trick here to do several different things wit h the same list.)
34 // 20 //
35 // We leave this SK_RECORD_TYPES macro defined for use by code that wants to ope rate on SkRecords 21 // 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. ) 22 // types polymorphically. (See SkRecord::Record::{visit,mutate} for an example. )
37 // 23 //
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 T(Z a, Y b, X c, W d, V e) : a(a), b(b), c(c), d(d), e(e) {} \ 111 T(Z a, Y b, X c, W d, V e) : a(a), b(b), c(c), d(d), e(e) {} \
126 A a; B b; C c; D d; E e; \ 112 A a; B b; C c; D d; E e; \
127 }; 113 };
128 114
129 #define ACT_AS_PTR(ptr) \ 115 #define ACT_AS_PTR(ptr) \
130 operator T*() { return ptr; } \ 116 operator T*() { return ptr; } \
131 operator const T*() const { return ptr; } \ 117 operator const T*() const { return ptr; } \
132 T* operator->() { return ptr; } \ 118 T* operator->() { return ptr; } \
133 const T* operator->() const { return ptr; } 119 const T* operator->() const { return ptr; }
134 120
121 template <typename T>
122 class SkTRefBox : SkNoncopyable {
123 public:
124 SkTRefBox(T* obj) : fObj(SkRef(obj)) {}
125 ~SkTRefBox() { fObj->unref(); }
126
127 ACT_AS_PTR(fObj);
128
129 private:
130 T* fObj;
131 };
132
135 // An Optional doesn't own the pointer's memory, but may need to destroy non-POD data. 133 // An Optional doesn't own the pointer's memory, but may need to destroy non-POD data.
136 template <typename T> 134 template <typename T>
137 class Optional : SkNoncopyable { 135 class Optional : SkNoncopyable {
138 public: 136 public:
139 Optional(T* ptr) : fPtr(ptr) {} 137 Optional(T* ptr) : fPtr(ptr) {}
140 ~Optional() { if (fPtr) fPtr->~T(); } 138 ~Optional() { if (fPtr) fPtr->~T(); }
141 139
142 ACT_AS_PTR(fPtr); 140 ACT_AS_PTR(fPtr);
143 private: 141 private:
144 T* fPtr; 142 T* fPtr;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 RECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint, 222 RECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint,
225 ImmutableBitmap, bitmap, 223 ImmutableBitmap, bitmap,
226 Optional<SkRect>, src, 224 Optional<SkRect>, src,
227 SkRect, dst, 225 SkRect, dst,
228 SkCanvas::DrawBitmapRectFlags, flags); 226 SkCanvas::DrawBitmapRectFlags, flags);
229 RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner); 227 RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
230 RECORD2(DrawOval, SkPaint, paint, SkRect, oval); 228 RECORD2(DrawOval, SkPaint, paint, SkRect, oval);
231 RECORD1(DrawPaint, SkPaint, paint); 229 RECORD1(DrawPaint, SkPaint, paint);
232 RECORD2(DrawPath, SkPaint, paint, SkPath, path); 230 RECORD2(DrawPath, SkPaint, paint, SkPath, path);
233 //RECORD2(DrawPatch, SkPaint, paint, SkPatch, patch); 231 //RECORD2(DrawPatch, SkPaint, paint, SkPatch, patch);
234 RECORD3(DrawPicture, Optional<SkPaint>, paint, SkPictureBox, picture, Optional<S kMatrix>, matrix); 232 RECORD3(DrawPicture, Optional<SkPaint>, paint,
233 SkTRefBox<const SkPicture>, picture,
234 Optional<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);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 #undef RECORD0 311 #undef RECORD0
312 #undef RECORD1 312 #undef RECORD1
313 #undef RECORD2 313 #undef RECORD2
314 #undef RECORD3 314 #undef RECORD3
315 #undef RECORD4 315 #undef RECORD4
316 #undef RECORD5 316 #undef RECORD5
317 317
318 } // namespace SkRecords 318 } // namespace SkRecords
319 319
320 #endif//SkRecords_DEFINED 320 #endif//SkRecords_DEFINED
OLDNEW
« src/core/SkPicture.cpp ('K') | « src/core/SkPicture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698