1 | /* |
---|---|
2 | * Copyright 2017 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 | #include "modules/sksg/include/SkSGInvalidationController.h" |
9 | |
10 | #include "include/core/SkRect.h" |
11 | #include "src/core/SkTLazy.h" |
12 | |
13 | namespace sksg { |
14 | |
15 | InvalidationController::InvalidationController() : fBounds(SkRect::MakeEmpty()) {} |
16 | |
17 | void InvalidationController::inval(const SkRect& r, const SkMatrix& ctm) { |
18 | if (r.isEmpty()) { |
19 | return; |
20 | } |
21 | |
22 | SkTCopyOnFirstWrite<SkRect> rect(r); |
23 | |
24 | if (!ctm.isIdentity()) { |
25 | ctm.mapRect(rect.writable()); |
26 | } |
27 | |
28 | fRects.push_back(*rect); |
29 | fBounds.join(*rect); |
30 | } |
31 | |
32 | void InvalidationController::reset() { |
33 | fRects.clear(); |
34 | fBounds.setEmpty(); |
35 | } |
36 | |
37 | } // namespace sksg |
38 |