• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
TextureLayer(const SkPoint & offset,const SkSize & size,int64_t texture_id,bool freeze,uint8_t opacity)11 TextureLayer::TextureLayer(const SkPoint& offset,
12                            const SkSize& size,
13                            int64_t texture_id,
14                            bool freeze,
15                            uint8_t opacity)
16     : offset_(offset), size_(size), texture_id_(texture_id), freeze_(freeze) {}
17 
18 TextureLayer::~TextureLayer() = default;
19 
Preroll(PrerollContext * context,const SkMatrix & matrix)20 void TextureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
21   set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
22                                     size_.height()));
23 }
24 
Paint(PaintContext & context) const25 void TextureLayer::Paint(PaintContext& context) const {
26   std::shared_ptr<Texture> texture =
27       context.texture_registry.GetTexture(texture_id_);
28   if (!texture) {
29     return;
30   }
31   texture->Paint(*context.leaf_nodes_canvas, paint_bounds(), freeze_,
32                  context.gr_context);
33 }
34 
35 }  // namespace flutter
36