Flutter Engine
The Flutter Engine
third_party
skia
modules
sksg
src
SkSGImage.cpp
Go to the documentation of this file.
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 "
modules/sksg/include/SkSGImage.h
"
9
10
#include "
include/core/SkCanvas.h
"
11
#include "
include/core/SkImage.h
"
12
#include "
include/core/SkPaint.h
"
13
#include "
include/core/SkPoint.h
"
14
#include "
include/private/base/SkAssert.h
"
15
16
namespace
sksg
{
17
18
Image::Image
(
sk_sp<SkImage>
image
) : fImage(
std
::move(
image
)) {}
19
20
void
Image::onRender
(
SkCanvas
* canvas,
const
RenderContext
* ctx)
const
{
21
if
(!fImage) {
22
return
;
23
}
24
25
SkPaint
paint
;
26
paint
.setAntiAlias(fAntiAlias);
27
28
sksg::RenderNode::ScopedRenderContext
local_ctx(canvas, ctx);
29
if
(ctx) {
30
if
(ctx->
fMaskShader
) {
31
// Mask shaders cannot be applied via drawImage - we need layer isolation.
32
// TODO: remove after clipShader conversion.
33
local_ctx.
setIsolation
(this->
bounds
(), canvas->
getTotalMatrix
(),
true
);
34
}
35
local_ctx->
modulatePaint
(canvas->
getTotalMatrix
(), &
paint
);
36
}
37
38
canvas->
drawImage
(fImage, 0, 0, fSamplingOptions, &
paint
);
39
}
40
41
const
RenderNode
*
Image::onNodeAt
(
const
SkPoint
&
p
)
const
{
42
SkASSERT
(this->
bounds
().
contains
(p.
x
(),
p
.y()));
43
return
this
;
44
}
45
46
SkRect
Image::onRevalidate
(
InvalidationController
*,
const
SkMatrix
& ctm) {
47
return
fImage ?
SkRect::Make
(fImage->
bounds
()) :
SkRect::MakeEmpty
();
48
}
49
50
}
// namespace sksg
SkAssert.h
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkCanvas.h
SkImage.h
SkPaint.h
SkPoint.h
SkSGImage.h
SkCanvas
Definition:
SkCanvas.h:106
SkCanvas::getTotalMatrix
SkMatrix getTotalMatrix() const
Definition:
SkCanvas.cpp:1629
SkCanvas::drawImage
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition:
SkCanvas.h:1528
SkImage::bounds
SkIRect bounds() const
Definition:
SkImage.h:303
SkMatrix
Definition:
SkMatrix.h:54
SkPaint
Definition:
SkPaint.h:44
sk_sp< SkImage >
sksg::Image::onNodeAt
const RenderNode * onNodeAt(const SkPoint &) const override
Definition:
SkSGImage.cpp:41
sksg::Image::onRender
void onRender(SkCanvas *, const RenderContext *) const override
Definition:
SkSGImage.cpp:20
sksg::Image::onRevalidate
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Definition:
SkSGImage.cpp:46
sksg::Image::Image
Image(sk_sp< SkImage >)
Definition:
SkSGImage.cpp:18
sksg::InvalidationController
Definition:
SkSGInvalidationController.h:24
sksg::Node::bounds
const SkRect & bounds() const
Definition:
SkSGNode.h:55
sksg::RenderNode::ScopedRenderContext
Definition:
SkSGRenderNode.h:75
sksg::RenderNode::ScopedRenderContext::setIsolation
ScopedRenderContext && setIsolation(const SkRect &bounds, const SkMatrix &ctm, bool do_isolate)
Definition:
SkSGRenderNode.cpp:194
sksg::RenderNode
Definition:
SkSGRenderNode.h:34
paint
const Paint & paint
Definition:
color_source.cc:38
SkRecords::image
sk_sp< const SkImage > image
Definition:
SkRecords.h:269
dart_profiler_symbols.p
p
Definition:
dart_profiler_symbols.py:55
sksg
Definition:
Skottie.h:32
skstd::contains
constexpr bool contains(std::string_view str, std::string_view needle)
Definition:
SkStringView.h:41
std
Definition:
ref_ptr.h:256
SkPoint
Definition:
SkPoint_impl.h:163
SkPoint::x
constexpr float x() const
Definition:
SkPoint_impl.h:181
SkRect
Definition:
extension.cpp:13
SkRect::Make
static SkRect Make(const SkISize &size)
Definition:
SkRect.h:669
SkRect::MakeEmpty
static constexpr SkRect MakeEmpty()
Definition:
SkRect.h:595
sksg::RenderNode::RenderContext
Definition:
SkSGRenderNode.h:60
sksg::RenderNode::RenderContext::modulatePaint
void modulatePaint(const SkMatrix &ctm, SkPaint *, bool is_layer_paint=false) const
Definition:
SkSGRenderNode.cpp:102
sksg::RenderNode::RenderContext::fMaskShader
sk_sp< SkShader > fMaskShader
Definition:
SkSGRenderNode.h:63
Generated on Sun Jun 23 2024 21:56:07 for Flutter Engine by
1.9.4