• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkSGRect.h"
9 
10 #include "SkCanvas.h"
11 #include "SkPaint.h"
12 #include "SkPath.h"
13 
14 namespace sksg {
15 
Rect(const SkRect & rect)16 Rect::Rect(const SkRect& rect) : fRect(rect) {}
17 
onClip(SkCanvas * canvas,bool antiAlias) const18 void Rect::onClip(SkCanvas* canvas, bool antiAlias) const {
19     canvas->clipRect(fRect, SkClipOp::kIntersect, antiAlias);
20 }
21 
onDraw(SkCanvas * canvas,const SkPaint & paint) const22 void Rect::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
23     canvas->drawRect(fRect, paint);
24 }
25 
onRevalidate(InvalidationController *,const SkMatrix &)26 SkRect Rect::onRevalidate(InvalidationController*, const SkMatrix&) {
27     SkASSERT(this->hasInval());
28 
29     return fRect;
30 }
31 
onAsPath() const32 SkPath Rect::onAsPath() const {
33     SkPath path;
34     path.addRect(fRect);
35     return path;
36 }
37 
RRect(const SkRRect & rr)38 RRect::RRect(const SkRRect& rr) : fRRect(rr) {}
39 
onClip(SkCanvas * canvas,bool antiAlias) const40 void RRect::onClip(SkCanvas* canvas, bool antiAlias) const {
41     canvas->clipRRect(fRRect, SkClipOp::kIntersect, antiAlias);
42 }
43 
onDraw(SkCanvas * canvas,const SkPaint & paint) const44 void RRect::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
45     canvas->drawRRect(fRRect, paint);
46 }
47 
onRevalidate(InvalidationController *,const SkMatrix &)48 SkRect RRect::onRevalidate(InvalidationController*, const SkMatrix&) {
49     SkASSERT(this->hasInval());
50 
51     return fRRect.getBounds();
52 }
53 
onAsPath() const54 SkPath RRect::onAsPath() const {
55     SkPath path;
56     path.addRRect(fRRect);
57     return path;
58 }
59 
60 } // namespace sksg
61