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

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

Issue 747033005: add endRecordingAsDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: test_gatherpixelrefsandrects is failing Created 6 years 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/SkRecord.h ('k') | src/core/SkRecordDraw.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 SkRecordDraw_DEFINED 8 #ifndef SkRecordDraw_DEFINED
9 #define SkRecordDraw_DEFINED 9 #define SkRecordDraw_DEFINED
10 10
11 #include "SkBBoxHierarchy.h" 11 #include "SkBBoxHierarchy.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkDrawPictureCallback.h" 13 #include "SkDrawPictureCallback.h"
14 #include "SkMatrix.h" 14 #include "SkMatrix.h"
15 #include "SkRecord.h" 15 #include "SkRecord.h"
16 16
17 class SkCanvasDrawable;
17 class SkLayerInfo; 18 class SkLayerInfo;
18 19
19 // Fill a BBH to be used by SkRecordDraw to accelerate playback. 20 // Fill a BBH to be used by SkRecordDraw to accelerate playback.
20 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkBBoxHierarchy *); 21 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkBBoxHierarchy *);
21 22
22 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, 23 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record,
23 SkBBoxHierarchy* bbh, SkLayerInfo* data); 24 SkBBoxHierarchy* bbh, SkLayerInfo* data);
24 25
25 // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::D raw. 26 // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::D raw.
26 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic ts[], int drawableCount, 27 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic ts[],
28 SkCanvasDrawable* const drawables[], int drawableCount,
27 const SkBBoxHierarchy*, SkDrawPictureCallback*); 29 const SkBBoxHierarchy*, SkDrawPictureCallback*);
28 30
29 // Draw a portion of an SkRecord into an SkCanvas while replacing clears with dr awRects. 31 // Draw a portion of an SkRecord into an SkCanvas while replacing clears with dr awRects.
30 // When drawing a portion of an SkRecord the CTM on the passed in canvas must be 32 // When drawing a portion of an SkRecord the CTM on the passed in canvas must be
31 // the composition of the replay matrix with the record-time CTM (for the portio n 33 // the composition of the replay matrix with the record-time CTM (for the portio n
32 // of the record that is being replayed). For setMatrix calls to behave correctl y 34 // of the record that is being replayed). For setMatrix calls to behave correctl y
33 // the initialCTM parameter must set to just the replay matrix. 35 // the initialCTM parameter must set to just the replay matrix.
34 void SkRecordPartialDraw(const SkRecord&, SkCanvas*, 36 void SkRecordPartialDraw(const SkRecord&, SkCanvas*,
35 SkPicture const* const drawablePicts[], int drawableCou nt, 37 SkPicture const* const drawablePicts[], int drawableCou nt,
36 const SkRect&, unsigned start, unsigned stop, 38 const SkRect&, unsigned start, unsigned stop,
37 const SkMatrix& initialCTM); 39 const SkMatrix& initialCTM);
38 40
39 namespace SkRecords { 41 namespace SkRecords {
40 42
41 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. 43 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas.
42 class Draw : SkNoncopyable { 44 class Draw : SkNoncopyable {
43 public: 45 public:
44 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], int drawableCount, 46 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[],
47 SkCanvasDrawable* const drawables[], int drawableCount,
45 const SkMatrix* initialCTM = NULL) 48 const SkMatrix* initialCTM = NULL)
46 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) 49 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix())
47 , fCanvas(canvas) 50 , fCanvas(canvas)
48 , fDrawablePicts(drawablePicts) 51 , fDrawablePicts(drawablePicts)
52 , fDrawables(drawables)
49 , fDrawableCount(drawableCount) 53 , fDrawableCount(drawableCount)
50 {} 54 {}
51 55
52 // This operator calls methods on the |canvas|. The various draw() wrapper 56 // This operator calls methods on the |canvas|. The various draw() wrapper
53 // methods around SkCanvas are defined by the DRAW() macro in 57 // methods around SkCanvas are defined by the DRAW() macro in
54 // SkRecordDraw.cpp. 58 // SkRecordDraw.cpp.
55 template <typename T> void operator()(const T& r) { 59 template <typename T> void operator()(const T& r) {
56 this->draw(r); 60 this->draw(r);
57 } 61 }
58 62
59 protected: 63 protected:
60 SkPicture const* const* drawablePicts() const { return fDrawablePicts; } 64 SkPicture const* const* drawablePicts() const { return fDrawablePicts; }
61 int drawableCount() const { return fDrawableCount; } 65 int drawableCount() const { return fDrawableCount; }
62 66
63 private: 67 private:
64 // No base case, so we'll be compile-time checked that we implement all poss ibilities. 68 // No base case, so we'll be compile-time checked that we implement all poss ibilities.
65 template <typename T> void draw(const T&); 69 template <typename T> void draw(const T&);
66 70
67 const SkMatrix fInitialCTM; 71 const SkMatrix fInitialCTM;
68 SkCanvas* fCanvas; 72 SkCanvas* fCanvas;
69 SkPicture const* const* fDrawablePicts; 73 SkPicture const* const* fDrawablePicts;
74 SkCanvasDrawable* const* fDrawables;
70 int fDrawableCount; 75 int fDrawableCount;
71 }; 76 };
72 77
73 // Used by SkRecordPartialDraw. 78 // Used by SkRecordPartialDraw.
74 class PartialDraw : public Draw { 79 class PartialDraw : public Draw {
75 public: 80 public:
76 PartialDraw(SkCanvas* canvas, SkPicture const* const drawablePicts[], int dr awableCount, 81 PartialDraw(SkCanvas* canvas, SkPicture const* const drawablePicts[], int dr awableCount,
77 const SkRect& clearRect, const SkMatrix& initialCTM) 82 const SkRect& clearRect, const SkMatrix& initialCTM)
78 : INHERITED(canvas, drawablePicts, drawableCount, &initialCTM), fClearRe ct(clearRect) {} 83 : INHERITED(canvas, drawablePicts, NULL, drawableCount, &initialCTM), fC learRect(clearRect)
84 {}
79 85
80 // Same as Draw for all ops except Clear. 86 // Same as Draw for all ops except Clear.
81 template <typename T> void operator()(const T& r) { 87 template <typename T> void operator()(const T& r) {
82 this->INHERITED::operator()(r); 88 this->INHERITED::operator()(r);
83 } 89 }
84 void operator()(const Clear& c) { 90 void operator()(const Clear& c) {
85 SkPaint p; 91 SkPaint p;
86 p.setColor(c.color); 92 p.setColor(c.color);
87 DrawRect drawRect(p, fClearRect); 93 DrawRect drawRect(p, fClearRect);
88 this->INHERITED::operator()(drawRect); 94 this->INHERITED::operator()(drawRect);
89 } 95 }
90 96
91 private: 97 private:
92 const SkRect fClearRect; 98 const SkRect fClearRect;
93 typedef Draw INHERITED; 99 typedef Draw INHERITED;
94 }; 100 };
95 101
96 } // namespace SkRecords 102 } // namespace SkRecords
97 103
98 #endif//SkRecordDraw_DEFINED 104 #endif//SkRecordDraw_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkRecord.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698