mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
For https://github.com/flutter/flutter/issues/33807 We still need to make layers' children immutable for full immutability. That will require us to change the SceneBuilder API to build the layer bottom up instead of top down (post-order traversal instead of pre-order traversal).
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/flow/layers/texture_layer.h"
|
|
|
|
#include "flutter/flow/texture.h"
|
|
|
|
namespace flutter {
|
|
|
|
TextureLayer::TextureLayer(const SkPoint& offset,
|
|
const SkSize& size,
|
|
int64_t texture_id,
|
|
bool freeze)
|
|
: offset_(offset), size_(size), texture_id_(texture_id), freeze_(freeze) {}
|
|
|
|
TextureLayer::~TextureLayer() = default;
|
|
|
|
void TextureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
|
set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
|
|
size_.height()));
|
|
}
|
|
|
|
void TextureLayer::Paint(PaintContext& context) const {
|
|
std::shared_ptr<Texture> texture =
|
|
context.texture_registry.GetTexture(texture_id_);
|
|
if (!texture) {
|
|
return;
|
|
}
|
|
texture->Paint(*context.leaf_nodes_canvas, paint_bounds(), freeze_,
|
|
context.gr_context);
|
|
}
|
|
|
|
} // namespace flutter
|