/src/skia/src/core/SkRecordDraw.h
Line | Count | Source (jump to first uncovered line) |
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 | | |
11 | | #include "include/core/SkBBHFactory.h" |
12 | | #include "include/core/SkCanvas.h" |
13 | | #include "include/core/SkMatrix.h" |
14 | | #include "src/core/SkBigPicture.h" |
15 | | #include "src/core/SkRecord.h" |
16 | | |
17 | | class SkDrawable; |
18 | | class SkLayerInfo; |
19 | | |
20 | | // Calculate conservative identity space bounds for each op in the record. |
21 | | void SkRecordFillBounds(const SkRect& cullRect, const SkRecord&, |
22 | | SkRect bounds[], SkBBoxHierarchy::Metadata[]); |
23 | | |
24 | | // SkRecordFillBounds(), and gathers information about saveLayers and stores it for later |
25 | | // use (e.g., layer hoisting). The gathered information is sufficient to determine |
26 | | // where each saveLayer will land and which ops in the picture it represents. |
27 | | void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord&, SkRect bounds[], |
28 | | const SkBigPicture::SnapshotArray*, SkLayerInfo* data); |
29 | | |
30 | | // Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::Draw. |
31 | | void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePicts[], |
32 | | SkDrawable* const drawables[], int drawableCount, |
33 | | const SkBBoxHierarchy*, SkPicture::AbortCallback*); |
34 | | |
35 | | // Draw a portion of an SkRecord into an SkCanvas. |
36 | | // When drawing a portion of an SkRecord the CTM on the passed in canvas must be |
37 | | // the composition of the replay matrix with the record-time CTM (for the portion |
38 | | // of the record that is being replayed). For setMatrix calls to behave correctly |
39 | | // the initialCTM parameter must set to just the replay matrix. |
40 | | void SkRecordPartialDraw(const SkRecord&, SkCanvas*, |
41 | | SkPicture const* const drawablePicts[], int drawableCount, |
42 | | int start, int stop, const SkM44& initialCTM); |
43 | | |
44 | | namespace SkRecords { |
45 | | |
46 | | // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. |
47 | | class Draw : SkNoncopyable { |
48 | | public: |
49 | | explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[], |
50 | | SkDrawable* const drawables[], int drawableCount, |
51 | | const SkM44* initialCTM = nullptr) |
52 | | : fInitialCTM(initialCTM ? *initialCTM : canvas->getLocalToDevice()) |
53 | | , fCanvas(canvas) |
54 | | , fDrawablePicts(drawablePicts) |
55 | | , fDrawables(drawables) |
56 | | , fDrawableCount(drawableCount) |
57 | 18.2k | {} |
58 | | |
59 | | // This operator calls methods on the |canvas|. The various draw() wrapper |
60 | | // methods around SkCanvas are defined by the DRAW() macro in |
61 | | // SkRecordDraw.cpp. |
62 | 509k | template <typename T> void operator()(const T& r) { |
63 | 509k | this->draw(r); |
64 | 509k | } void SkRecords::Draw::operator()<SkRecords::DrawPath>(SkRecords::DrawPath const&) Line | Count | Source | 62 | 7.27k | template <typename T> void operator()(const T& r) { | 63 | 7.27k | this->draw(r); | 64 | 7.27k | } |
void SkRecords::Draw::operator()<SkRecords::DrawRect>(SkRecords::DrawRect const&) Line | Count | Source | 62 | 3.60k | template <typename T> void operator()(const T& r) { | 63 | 3.60k | this->draw(r); | 64 | 3.60k | } |
void SkRecords::Draw::operator()<SkRecords::DrawTextBlob>(SkRecords::DrawTextBlob const&) Line | Count | Source | 62 | 11.8k | template <typename T> void operator()(const T& r) { | 63 | 11.8k | this->draw(r); | 64 | 11.8k | } |
Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::NoOp>(SkRecords::NoOp const&) void SkRecords::Draw::operator()<SkRecords::Flush>(SkRecords::Flush const&) Line | Count | Source | 62 | 207k | template <typename T> void operator()(const T& r) { | 63 | 207k | this->draw(r); | 64 | 207k | } |
void SkRecords::Draw::operator()<SkRecords::Restore>(SkRecords::Restore const&) Line | Count | Source | 62 | 65.5k | template <typename T> void operator()(const T& r) { | 63 | 65.5k | this->draw(r); | 64 | 65.5k | } |
void SkRecords::Draw::operator()<SkRecords::Save>(SkRecords::Save const&) Line | Count | Source | 62 | 21.2k | template <typename T> void operator()(const T& r) { | 63 | 21.2k | this->draw(r); | 64 | 21.2k | } |
void SkRecords::Draw::operator()<SkRecords::SaveLayer>(SkRecords::SaveLayer const&) Line | Count | Source | 62 | 44.2k | template <typename T> void operator()(const T& r) { | 63 | 44.2k | this->draw(r); | 64 | 44.2k | } |
Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::SaveBehind>(SkRecords::SaveBehind const&) Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::MarkCTM>(SkRecords::MarkCTM const&) Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::SetMatrix>(SkRecords::SetMatrix const&) void SkRecords::Draw::operator()<SkRecords::SetM44>(SkRecords::SetM44 const&) Line | Count | Source | 62 | 1.73k | template <typename T> void operator()(const T& r) { | 63 | 1.73k | this->draw(r); | 64 | 1.73k | } |
void SkRecords::Draw::operator()<SkRecords::Translate>(SkRecords::Translate const&) Line | Count | Source | 62 | 836 | template <typename T> void operator()(const T& r) { | 63 | 836 | this->draw(r); | 64 | 836 | } |
void SkRecords::Draw::operator()<SkRecords::Scale>(SkRecords::Scale const&) Line | Count | Source | 62 | 1.07k | template <typename T> void operator()(const T& r) { | 63 | 1.07k | this->draw(r); | 64 | 1.07k | } |
Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::Concat>(SkRecords::Concat const&) void SkRecords::Draw::operator()<SkRecords::Concat44>(SkRecords::Concat44 const&) Line | Count | Source | 62 | 11.0k | template <typename T> void operator()(const T& r) { | 63 | 11.0k | this->draw(r); | 64 | 11.0k | } |
void SkRecords::Draw::operator()<SkRecords::ClipPath>(SkRecords::ClipPath const&) Line | Count | Source | 62 | 3.90k | template <typename T> void operator()(const T& r) { | 63 | 3.90k | this->draw(r); | 64 | 3.90k | } |
void SkRecords::Draw::operator()<SkRecords::ClipRRect>(SkRecords::ClipRRect const&) Line | Count | Source | 62 | 1.85k | template <typename T> void operator()(const T& r) { | 63 | 1.85k | this->draw(r); | 64 | 1.85k | } |
void SkRecords::Draw::operator()<SkRecords::ClipRect>(SkRecords::ClipRect const&) Line | Count | Source | 62 | 10.7k | template <typename T> void operator()(const T& r) { | 63 | 10.7k | this->draw(r); | 64 | 10.7k | } |
void SkRecords::Draw::operator()<SkRecords::ClipRegion>(SkRecords::ClipRegion const&) Line | Count | Source | 62 | 3.93k | template <typename T> void operator()(const T& r) { | 63 | 3.93k | this->draw(r); | 64 | 3.93k | } |
Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::ClipShader>(SkRecords::ClipShader const&) Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::ResetClip>(SkRecords::ResetClip const&) void SkRecords::Draw::operator()<SkRecords::DrawArc>(SkRecords::DrawArc const&) Line | Count | Source | 62 | 82 | template <typename T> void operator()(const T& r) { | 63 | 82 | this->draw(r); | 64 | 82 | } |
Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::DrawDrawable>(SkRecords::DrawDrawable const&) void SkRecords::Draw::operator()<SkRecords::DrawImage>(SkRecords::DrawImage const&) Line | Count | Source | 62 | 4.98k | template <typename T> void operator()(const T& r) { | 63 | 4.98k | this->draw(r); | 64 | 4.98k | } |
void SkRecords::Draw::operator()<SkRecords::DrawImageLattice>(SkRecords::DrawImageLattice const&) Line | Count | Source | 62 | 187 | template <typename T> void operator()(const T& r) { | 63 | 187 | this->draw(r); | 64 | 187 | } |
void SkRecords::Draw::operator()<SkRecords::DrawImageRect>(SkRecords::DrawImageRect const&) Line | Count | Source | 62 | 135 | template <typename T> void operator()(const T& r) { | 63 | 135 | this->draw(r); | 64 | 135 | } |
void SkRecords::Draw::operator()<SkRecords::DrawDRRect>(SkRecords::DrawDRRect const&) Line | Count | Source | 62 | 470 | template <typename T> void operator()(const T& r) { | 63 | 470 | this->draw(r); | 64 | 470 | } |
void SkRecords::Draw::operator()<SkRecords::DrawOval>(SkRecords::DrawOval const&) Line | Count | Source | 62 | 1.09k | template <typename T> void operator()(const T& r) { | 63 | 1.09k | this->draw(r); | 64 | 1.09k | } |
Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::DrawBehind>(SkRecords::DrawBehind const&) void SkRecords::Draw::operator()<SkRecords::DrawPaint>(SkRecords::DrawPaint const&) Line | Count | Source | 62 | 1.27k | template <typename T> void operator()(const T& r) { | 63 | 1.27k | this->draw(r); | 64 | 1.27k | } |
void SkRecords::Draw::operator()<SkRecords::DrawPatch>(SkRecords::DrawPatch const&) Line | Count | Source | 62 | 96.7k | template <typename T> void operator()(const T& r) { | 63 | 96.7k | this->draw(r); | 64 | 96.7k | } |
void SkRecords::Draw::operator()<SkRecords::DrawPicture>(SkRecords::DrawPicture const&) Line | Count | Source | 62 | 5.13k | template <typename T> void operator()(const T& r) { | 63 | 5.13k | this->draw(r); | 64 | 5.13k | } |
void SkRecords::Draw::operator()<SkRecords::DrawPoints>(SkRecords::DrawPoints const&) Line | Count | Source | 62 | 1.37k | template <typename T> void operator()(const T& r) { | 63 | 1.37k | this->draw(r); | 64 | 1.37k | } |
void SkRecords::Draw::operator()<SkRecords::DrawRRect>(SkRecords::DrawRRect const&) Line | Count | Source | 62 | 1.85k | template <typename T> void operator()(const T& r) { | 63 | 1.85k | this->draw(r); | 64 | 1.85k | } |
void SkRecords::Draw::operator()<SkRecords::DrawRegion>(SkRecords::DrawRegion const&) Line | Count | Source | 62 | 165 | template <typename T> void operator()(const T& r) { | 63 | 165 | this->draw(r); | 64 | 165 | } |
Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::DrawAtlas>(SkRecords::DrawAtlas const&) void SkRecords::Draw::operator()<SkRecords::DrawVertices>(SkRecords::DrawVertices const&) Line | Count | Source | 62 | 310 | template <typename T> void operator()(const T& r) { | 63 | 310 | this->draw(r); | 64 | 310 | } |
Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::DrawShadowRec>(SkRecords::DrawShadowRec const&) Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::DrawAnnotation>(SkRecords::DrawAnnotation const&) Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::DrawEdgeAAQuad>(SkRecords::DrawEdgeAAQuad const&) Unexecuted instantiation: void SkRecords::Draw::operator()<SkRecords::DrawEdgeAAImageSet>(SkRecords::DrawEdgeAAImageSet const&) |
65 | | |
66 | | protected: |
67 | 0 | SkPicture const* const* drawablePicts() const { return fDrawablePicts; } |
68 | 0 | int drawableCount() const { return fDrawableCount; } |
69 | | |
70 | | private: |
71 | | // No base case, so we'll be compile-time checked that we implement all possibilities. |
72 | | template <typename T> void draw(const T&); |
73 | | |
74 | | const SkM44 fInitialCTM; |
75 | | SkCanvas* fCanvas; |
76 | | SkPicture const* const* fDrawablePicts; |
77 | | SkDrawable* const* fDrawables; |
78 | | int fDrawableCount; |
79 | | }; |
80 | | |
81 | | } // namespace SkRecords |
82 | | |
83 | | #endif//SkRecordDraw_DEFINED |