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

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

Issue 727363003: wip for drawables (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: works, but I took a few short-cuts Created 6 years, 1 month 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 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 SkLayerInfo; 17 class SkLayerInfo;
18 18
19 // Fill a BBH to be used by SkRecordDraw to accelerate playback. 19 // Fill a BBH to be used by SkRecordDraw to accelerate playback.
20 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkBBoxHierarchy *); 20 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, SkBBoxHierarchy *);
21 21
22 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, 22 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record,
23 SkBBoxHierarchy* bbh, SkLayerInfo* data); 23 SkBBoxHierarchy* bbh, SkLayerInfo* data);
24 24
25 // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::D raw. 25 // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::D raw.
26 void SkRecordDraw(const SkRecord&, SkCanvas*, const SkBBoxHierarchy*, SkDrawPict ureCallback*); 26 void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture* const drawablePicts[], int drawableCount,
27 const SkBBoxHierarchy*, SkDrawPictureCallback*);
27 28
28 // Draw a portion of an SkRecord into an SkCanvas while replacing clears with dr awRects. 29 // Draw a portion of an SkRecord into an SkCanvas while replacing clears with dr awRects.
29 // When drawing a portion of an SkRecord the CTM on the passed in canvas must be 30 // When drawing a portion of an SkRecord the CTM on the passed in canvas must be
30 // the composition of the replay matrix with the record-time CTM (for the portio n 31 // the composition of the replay matrix with the record-time CTM (for the portio n
31 // of the record that is being replayed). For setMatrix calls to behave correctl y 32 // of the record that is being replayed). For setMatrix calls to behave correctl y
32 // the initialCTM parameter must set to just the replay matrix. 33 // the initialCTM parameter must set to just the replay matrix.
33 void SkRecordPartialDraw(const SkRecord&, SkCanvas*, const SkRect&, unsigned sta rt, unsigned stop, 34 void SkRecordPartialDraw(const SkRecord&, SkCanvas*, const SkRect&, unsigned sta rt, unsigned stop,
34 const SkMatrix& initialCTM); 35 const SkMatrix& initialCTM);
35 36
36 namespace SkRecords { 37 namespace SkRecords {
37 38
38 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. 39 // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas.
39 class Draw : SkNoncopyable { 40 class Draw : SkNoncopyable {
40 public: 41 public:
41 explicit Draw(SkCanvas* canvas, const SkMatrix* initialCTM = NULL) 42 explicit Draw(SkCanvas* canvas, SkPicture* const drawablePicts[], int drawab leCount,
43 const SkMatrix* initialCTM = NULL)
42 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix()) 44 : fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix())
43 , fCanvas(canvas) {} 45 , fCanvas(canvas)
46 , fDrawablePicts(drawablePicts)
47 , fDrawableCount(drawableCount)
48 {}
44 49
45 // This operator calls methods on the |canvas|. The various draw() wrapper 50 // This operator calls methods on the |canvas|. The various draw() wrapper
46 // methods around SkCanvas are defined by the DRAW() macro in 51 // methods around SkCanvas are defined by the DRAW() macro in
47 // SkRecordDraw.cpp. 52 // SkRecordDraw.cpp.
48 template <typename T> void operator()(const T& r) { 53 template <typename T> void operator()(const T& r) {
49 this->draw(r); 54 this->draw(r);
50 } 55 }
51 56
57 protected:
58 SkPicture* const* drawablePicts() const { return fDrawablePicts; }
59 int drawableCount() const { return fDrawableCount; }
60
52 private: 61 private:
53 // No base case, so we'll be compile-time checked that we implement all poss ibilities. 62 // No base case, so we'll be compile-time checked that we implement all poss ibilities.
54 template <typename T> void draw(const T&); 63 template <typename T> void draw(const T&);
55 64
56 const SkMatrix fInitialCTM; 65 const SkMatrix fInitialCTM;
57 SkCanvas* fCanvas; 66 SkCanvas* fCanvas;
67 SkPicture* const* fDrawablePicts;
68 int fDrawableCount;
58 }; 69 };
59 70
60 // Used by SkRecordPartialDraw. 71 // Used by SkRecordPartialDraw.
61 class PartialDraw : public Draw { 72 class PartialDraw : public Draw {
62 public: 73 public:
63 PartialDraw(SkCanvas* canvas, const SkRect& clearRect, const SkMatrix& initi alCTM) 74 PartialDraw(SkCanvas* canvas, SkPicture* const drawablePicts[], int drawable Count,
64 : INHERITED(canvas, &initialCTM), fClearRect(clearRect) {} 75 const SkRect& clearRect, const SkMatrix& initialCTM)
76 : INHERITED(canvas, drawablePicts, drawableCount, &initialCTM), fClearRe ct(clearRect) {}
65 77
66 // Same as Draw for all ops except Clear. 78 // Same as Draw for all ops except Clear.
67 template <typename T> void operator()(const T& r) { 79 template <typename T> void operator()(const T& r) {
68 this->INHERITED::operator()(r); 80 this->INHERITED::operator()(r);
69 } 81 }
70 void operator()(const Clear& c) { 82 void operator()(const Clear& c) {
71 SkPaint p; 83 SkPaint p;
72 p.setColor(c.color); 84 p.setColor(c.color);
73 DrawRect drawRect(p, fClearRect); 85 DrawRect drawRect(p, fClearRect);
74 this->INHERITED::operator()(drawRect); 86 this->INHERITED::operator()(drawRect);
75 } 87 }
76 88
77 private: 89 private:
78 const SkRect fClearRect; 90 const SkRect fClearRect;
79 typedef Draw INHERITED; 91 typedef Draw INHERITED;
80 }; 92 };
81 93
82 } // namespace SkRecords 94 } // namespace SkRecords
83 95
84 #endif//SkRecordDraw_DEFINED 96 #endif//SkRecordDraw_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698