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