flutter_flutter/flow/export_node.cc
Jeff Brown 8ee1910ca9 Use metrics provided by scene events. (#3922)
Compute the necessary texture resolution using more accurate scaling
information provided by Mozart scene node metrics events instead of the
device pixel ratio provided by the Mozart view properties (which we
might remove in the future).

This allows us to allocate smaller textures when a Flutter view is
being scaled down.
2017-07-24 19:17:55 -07:00

38 lines
1.2 KiB
C++

// Copyright 2016 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/export_node.h"
namespace flow {
ExportNode::ExportNode(uint32_t export_token_handle)
: export_token_(export_token_handle) {}
ExportNode::~ExportNode() {
// TODO(MZ-190): Ensure the node is properly unregistered on the rasterizer
// thread by attaching it to the update context in some way.
}
void ExportNode::Bind(SceneUpdateContext& context,
mozart::client::ContainerNode& container,
const SkPoint& offset,
bool hit_testable) {
ftl::MutexLocker lock(&mutex_);
if (export_token_) {
node_.reset(new mozart::client::EntityNode(container.session()));
node_->Export(std::move(export_token_));
}
if (node_) {
container.AddChild(*node_);
node_->SetTranslation(offset.x(), offset.y(), 0.f);
node_->SetHitTestBehavior(hit_testable
? mozart2::HitTestBehavior::kDefault
: mozart2::HitTestBehavior::kSuppress);
}
}
} // namespace flow