• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 "SkSGImage.h"
9 
10 #include "SkCanvas.h"
11 #include "SkImage.h"
12 
13 namespace sksg {
14 
Image(sk_sp<SkImage> image)15 Image::Image(sk_sp<SkImage> image) : fImage(std::move(image)) {}
16 
onRender(SkCanvas * canvas,const RenderContext * ctx) const17 void Image::onRender(SkCanvas* canvas, const RenderContext* ctx) const {
18     if (!fImage) {
19         return;
20     }
21 
22     SkPaint paint;
23     paint.setAntiAlias(fAntiAlias);
24     paint.setFilterQuality(fQuality);
25 
26     if (ctx) {
27         ctx->modulatePaint(&paint);
28     }
29 
30     canvas->drawImage(fImage, 0, 0, &paint);
31 }
32 
onRevalidate(InvalidationController *,const SkMatrix & ctm)33 SkRect Image::onRevalidate(InvalidationController*, const SkMatrix& ctm) {
34     return fImage ? SkRect::Make(fImage->bounds()) : SkRect::MakeEmpty();
35 }
36 
37 } // namespace sksg
38