Flutter Engine
texture_layer.cc
Go to the documentation of this file.
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 
9 namespace flutter {
10 
11 TextureLayer::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 
22 void 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 
33 void 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
TextureRegistry & texture_registry
Definition: layer.h:121
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
#define TRACE_EVENT_INSTANT0(category_group, name)
Definition: trace_event.h:104
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
GrDirectContext * gr_context
Definition: layer.h:117
TextureLayer(const SkPoint &offset, const SkSize &size, int64_t texture_id, bool freeze, SkFilterQuality filter_quality)
const SkRect & paint_bounds() const
Definition: layer.h:166
void Paint(PaintContext &context) const override
SkCanvas * leaf_nodes_canvas
Definition: layer.h:116
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:170
void Preroll(PrerollContext *context, const SkMatrix &matrix) override
std::shared_ptr< Texture > GetTexture(int64_t id)
Definition: texture.cc:43