1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/flow/layers/texture_layer.h"
6
7#include "flutter/flow/texture.h"
8
9namespace flutter {
10
11TextureLayer::TextureLayer(const SkPoint& offset,
12 const SkSize& size,
13 int64_t texture_id,
14 bool freeze,
15 SkFilterQuality filter_quality)
16 : offset_(offset),
17 size_(size),
18 texture_id_(texture_id),
19 freeze_(freeze),
20 filter_quality_(filter_quality) {}
21
22void TextureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
23 TRACE_EVENT0("flutter", "TextureLayer::Preroll");
24
25#if defined(LEGACY_FUCHSIA_EMBEDDER)
26 CheckForChildLayerBelow(context);
27#endif
28
29 set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
30 size_.height()));
31}
32
33void TextureLayer::Paint(PaintContext& context) const {
34 TRACE_EVENT0("flutter", "TextureLayer::Paint");
35
36 std::shared_ptr<Texture> texture =
37 context.texture_registry.GetTexture(texture_id_);
38 if (!texture) {
39 TRACE_EVENT_INSTANT0("flutter", "null texture");
40 return;
41 }
42 texture->Paint(*context.leaf_nodes_canvas, paint_bounds(), freeze_,
43 context.gr_context, filter_quality_);
44}
45
46} // namespace flutter
47