blob: df711abbf4fe2ded817c7e2a056a0e75805acec4 [file] [log] [blame]
Florin Malita4aa44412017-12-19 12:21:02 -05001/*
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 "SkSGInvalidationController.h"
9
10#include "SkRect.h"
Florin Malita2a2dfcb2017-12-28 19:24:07 -050011#include "SkTLazy.h"
Florin Malita4aa44412017-12-19 12:21:02 -050012
13namespace sksg {
14
Florin Malitac75e2402018-01-03 16:17:29 -050015InvalidationController::InvalidationController() : fBounds(SkRect::MakeEmpty()) {}
Florin Malita4aa44412017-12-19 12:21:02 -050016
Florin Malita2a2dfcb2017-12-28 19:24:07 -050017void InvalidationController::inval(const SkRect& r, const SkMatrix& ctm) {
Florin Malitac75e2402018-01-03 16:17:29 -050018 if (r.isEmpty()) {
19 return;
20 }
21
Florin Malita2a2dfcb2017-12-28 19:24:07 -050022 SkTCopyOnFirstWrite<SkRect> rect(r);
23
Florin Malita80746c22017-12-30 12:39:11 -050024 if (!ctm.isIdentity()) {
25 ctm.mapRect(rect.writable());
Florin Malita2a2dfcb2017-12-28 19:24:07 -050026 }
27
Mike Reed5edcd312018-08-08 11:23:41 -040028 fRects.push_back(*rect);
Florin Malitac75e2402018-01-03 16:17:29 -050029 fBounds.join(*rect);
Florin Malita4aa44412017-12-19 12:21:02 -050030}
31
32} // namespace sksg