Flutter Engine
The Flutter Engine
SkRecordDraw.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkRecordDraw_DEFINED
9#define SkRecordDraw_DEFINED
10
13#include "include/core/SkM44.h"
16
17class SkDrawable;
18class SkRecord;
19struct SkRect;
20
21// Calculate conservative identity space bounds for each op in the record.
22void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&,
24
25// Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::Draw.
26void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePicts[],
27 SkDrawable* const drawables[], int drawableCount,
29
30namespace SkRecords {
31
32// This is an SkRecord visitor that will draw that SkRecord to an SkCanvas.
34public:
35 explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[],
36 SkDrawable* const drawables[], int drawableCount,
37 const SkM44* initialCTM = nullptr)
38 : fInitialCTM(initialCTM ? *initialCTM : canvas->getLocalToDevice())
39 , fCanvas(canvas)
40 , fDrawablePicts(drawablePicts)
41 , fDrawables(drawables)
42 , fDrawableCount(drawableCount)
43 {}
44
45 // This operator calls methods on the |canvas|. The various draw() wrapper
46 // methods around SkCanvas are defined by the DRAW() macro in
47 // SkRecordDraw.cpp.
48 template <typename T> void operator()(const T& r) {
49 this->draw(r);
50 }
51
52protected:
53 SkPicture const* const* drawablePicts() const { return fDrawablePicts; }
54 int drawableCount() const { return fDrawableCount; }
55
56private:
57 // No base case, so we'll be compile-time checked that we implement all possibilities.
58 template <typename T> void draw(const T&);
59
60 const SkM44 fInitialCTM;
61 SkCanvas* fCanvas;
62 SkPicture const* const* fDrawablePicts;
63 SkDrawable* const* fDrawables;
64 int fDrawableCount;
65};
66
67} // namespace SkRecords
68
69#endif//SkRecordDraw_DEFINED
void SkRecordDraw(const SkRecord &, SkCanvas *, SkPicture const *const drawablePicts[], SkDrawable *const drawables[], int drawableCount, const SkBBoxHierarchy *, SkPicture::AbortCallback *)
void SkRecordFillBounds(const SkRect &cullRect, const SkRecord &, SkRect bounds[], SkBBoxHierarchy::Metadata[])
Definition: SkM44.h:150
SkPicture const *const * drawablePicts() const
Definition: SkRecordDraw.h:53
Draw(SkCanvas *canvas, SkPicture const *const drawablePicts[], SkDrawable *const drawables[], int drawableCount, const SkM44 *initialCTM=nullptr)
Definition: SkRecordDraw.h:35
int drawableCount() const
Definition: SkRecordDraw.h:54
void operator()(const T &r)
Definition: SkRecordDraw.h:48
Optional< SkRect > bounds
Definition: SkRecords.h:189
#define T
Definition: precompiler.cc:65