blob: 532a604af425b02de7c35bbfee017586b90d9653 [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 "SkSGRect.h"
9
10#include "SkCanvas.h"
11#include "SkPaint.h"
Florin Malitae6345d92018-01-03 23:37:54 -050012#include "SkPath.h"
Florin Malita4aa44412017-12-19 12:21:02 -050013
14namespace sksg {
15
16Rect::Rect(const SkRect& rect) : fRect(rect) {}
17
18void Rect::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
19 canvas->drawRect(fRect, paint);
20}
21
Florin Malitac14f1442018-01-05 11:32:31 -050022SkRect Rect::onRevalidate(InvalidationController*, const SkMatrix&) {
23 SkASSERT(this->hasInval());
Florin Malitac75e2402018-01-03 16:17:29 -050024
Florin Malitac14f1442018-01-05 11:32:31 -050025 return fRect;
Florin Malita4aa44412017-12-19 12:21:02 -050026}
27
Florin Malitae6345d92018-01-03 23:37:54 -050028SkPath Rect::onAsPath() const {
29 SkPath path;
30 path.addRect(fRect);
31 return path;
32}
33
Florin Malita2e1d7e22018-01-02 10:40:00 -050034RRect::RRect(const SkRRect& rr) : fRRect(rr) {}
35
36void RRect::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
37 canvas->drawRRect(fRRect, paint);
38}
39
Florin Malitac14f1442018-01-05 11:32:31 -050040SkRect RRect::onRevalidate(InvalidationController*, const SkMatrix&) {
41 SkASSERT(this->hasInval());
Florin Malitac75e2402018-01-03 16:17:29 -050042
Florin Malitac14f1442018-01-05 11:32:31 -050043 return fRRect.getBounds();
Florin Malita2e1d7e22018-01-02 10:40:00 -050044}
45
Florin Malitae6345d92018-01-03 23:37:54 -050046SkPath RRect::onAsPath() const {
47 SkPath path;
48 path.addRRect(fRRect);
49 return path;
50}
51
Florin Malita4aa44412017-12-19 12:21:02 -050052} // namespace sksg