Home | History | Annotate | Download | only in src
      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 
     16 Rect::Rect(const SkRect& rect) : fRect(rect) {}
     17 
     18 void Rect::onClip(SkCanvas* canvas, bool antiAlias) const {
     19     canvas->clipRect(fRect, SkClipOp::kIntersect, antiAlias);
     20 }
     21 
     22 void Rect::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
     23     canvas->drawRect(fRect, paint);
     24 }
     25 
     26 SkRect Rect::onRevalidate(InvalidationController*, const SkMatrix&) {
     27     SkASSERT(this->hasInval());
     28 
     29     return fRect;
     30 }
     31 
     32 SkPath Rect::onAsPath() const {
     33     SkPath path;
     34     path.addRect(fRect, this->getDirection(), this->getInitialPointIndex());
     35     return path;
     36 }
     37 
     38 RRect::RRect(const SkRRect& rr) : fRRect(rr) {}
     39 
     40 void RRect::onClip(SkCanvas* canvas, bool antiAlias) const {
     41     canvas->clipRRect(fRRect, SkClipOp::kIntersect, antiAlias);
     42 }
     43 
     44 void RRect::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
     45     canvas->drawRRect(fRRect, paint);
     46 }
     47 
     48 SkRect RRect::onRevalidate(InvalidationController*, const SkMatrix&) {
     49     SkASSERT(this->hasInval());
     50 
     51     return fRRect.getBounds();
     52 }
     53 
     54 SkPath RRect::onAsPath() const {
     55     SkPath path;
     56     path.addRRect(fRRect, this->getDirection(), this->getInitialPointIndex());
     57     return path;
     58 }
     59 
     60 } // namespace sksg
     61