flutter_flutter/flow/layers/texture_layer.cc
amirh 7e0bb3bbe8
Allow freezing a texture. (#5938)
This is needed to avoid jank when resizing an embedded Android view.
See
https://github.com/flutter/flutter/issues/19572#issuecomment-410400724
2018-08-07 14:43:19 -07:00

30 lines
828 B
C++

// Copyright 2017 The Chromium 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 flow {
TextureLayer::TextureLayer() = default;
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.canvas, paint_bounds(), freeze_);
}
} // namespace flow