Add prune to child scene layers (flutter/engine#3272)
Also, change the hit testing geometry so that we get our hits at the root.
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
|
||||
namespace flow {
|
||||
|
||||
ChildSceneLayer::ChildSceneLayer() : device_pixel_ratio_(1.0f) {}
|
||||
ChildSceneLayer::ChildSceneLayer() = default;
|
||||
|
||||
ChildSceneLayer::~ChildSceneLayer() {}
|
||||
ChildSceneLayer::~ChildSceneLayer() = default;
|
||||
|
||||
void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
||||
set_needs_system_composite(true);
|
||||
@@ -20,10 +20,10 @@ void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
|
||||
float inverse_device_pixel_ratio = 1.f / device_pixel_ratio_;
|
||||
transform_.preScale(inverse_device_pixel_ratio, inverse_device_pixel_ratio);
|
||||
|
||||
SkRect bounds = SkRect::MakeXYWH(
|
||||
offset_.x(), offset_.y(),
|
||||
physical_size_.width() * inverse_device_pixel_ratio,
|
||||
physical_size_.height() * inverse_device_pixel_ratio);
|
||||
SkRect bounds =
|
||||
SkRect::MakeXYWH(offset_.x(), offset_.y(),
|
||||
physical_size_.width() * inverse_device_pixel_ratio,
|
||||
physical_size_.height() * inverse_device_pixel_ratio);
|
||||
set_paint_bounds(bounds);
|
||||
context->child_paint_bounds = bounds;
|
||||
}
|
||||
@@ -42,6 +42,10 @@ void ChildSceneLayer::UpdateScene(SceneUpdateContext& context,
|
||||
resource->get_scene()->scene_token->value = scene_token_;
|
||||
|
||||
auto node = mozart::Node::New();
|
||||
if (!hittable_) {
|
||||
node->hit_test_behavior = mozart::HitTestBehavior::New();
|
||||
node->hit_test_behavior->prune = true;
|
||||
}
|
||||
node->op = mozart::NodeOp::New();
|
||||
node->op->set_scene(mozart::SceneNodeOp::New());
|
||||
node->op->get_scene()->scene_resource_id =
|
||||
|
||||
@@ -27,6 +27,8 @@ class ChildSceneLayer : public Layer {
|
||||
|
||||
void set_scene_token(uint32_t scene_token) { scene_token_ = scene_token; }
|
||||
|
||||
void set_hittable(bool hittable) { hittable_ = hittable; }
|
||||
|
||||
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
|
||||
void Paint(PaintContext& context) override;
|
||||
void UpdateScene(SceneUpdateContext& context,
|
||||
@@ -34,9 +36,10 @@ class ChildSceneLayer : public Layer {
|
||||
|
||||
private:
|
||||
SkPoint offset_;
|
||||
float device_pixel_ratio_;
|
||||
float device_pixel_ratio_ = 1.0;
|
||||
SkISize physical_size_;
|
||||
uint32_t scene_token_;
|
||||
uint32_t scene_token_ = 0;
|
||||
bool hittable_ = true;
|
||||
SkMatrix transform_;
|
||||
|
||||
FTL_DISALLOW_COPY_AND_ASSIGN(ChildSceneLayer);
|
||||
|
||||
@@ -78,7 +78,6 @@ mozart::NodePtr SceneUpdateContext::FinalizeCurrentPaintTask(
|
||||
resource->get_image()->image = std::move(image);
|
||||
|
||||
auto node = mozart::Node::New();
|
||||
node->hit_test_behavior = mozart::HitTestBehavior::New();
|
||||
node->op = mozart::NodeOp::New();
|
||||
node->op->set_image(mozart::ImageNodeOp::New());
|
||||
node->op->get_image()->content_rect = mozart::RectF::From(bounds);
|
||||
|
||||
@@ -191,24 +191,29 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
|
||||
/// Applications typically obtain scene tokens when embedding other views via
|
||||
/// the Fuchsia view manager, but this function is agnostic as to the source
|
||||
/// of scene token.
|
||||
void addChildScene(Offset offset,
|
||||
double devicePixelRatio,
|
||||
int physicalWidth,
|
||||
int physicalHeight,
|
||||
int sceneToken) {
|
||||
void addChildScene({
|
||||
Offset offset: Offset.zero,
|
||||
double devicePixelRatio: 1.0,
|
||||
int physicalWidth: 0,
|
||||
int physicalHeight: 0,
|
||||
int sceneToken,
|
||||
bool hittable: true,
|
||||
}) {
|
||||
_addChildScene(offset.dx,
|
||||
offset.dy,
|
||||
devicePixelRatio,
|
||||
physicalWidth,
|
||||
physicalHeight,
|
||||
sceneToken);
|
||||
sceneToken,
|
||||
hittable);
|
||||
}
|
||||
void _addChildScene(double dx,
|
||||
double dy,
|
||||
double devicePixelRatio,
|
||||
int physicalWidth,
|
||||
int physicalHeight,
|
||||
int sceneToken) native "SceneBuilder_addChildScene";
|
||||
int sceneToken,
|
||||
bool hittable) native "SceneBuilder_addChildScene";
|
||||
|
||||
/// Sets a threshold after which additional debugging information should be recorded.
|
||||
///
|
||||
|
||||
@@ -203,7 +203,8 @@ void SceneBuilder::addChildScene(double dx,
|
||||
double devicePixelRatio,
|
||||
int physicalWidth,
|
||||
int physicalHeight,
|
||||
uint32_t sceneToken) {
|
||||
uint32_t sceneToken,
|
||||
bool hittable) {
|
||||
#if defined(OS_FUCHSIA)
|
||||
if (!m_currentLayer)
|
||||
return;
|
||||
@@ -218,6 +219,7 @@ void SceneBuilder::addChildScene(double dx,
|
||||
layer->set_device_pixel_ratio(devicePixelRatio);
|
||||
layer->set_physical_size(SkISize::Make(physicalWidth, physicalHeight));
|
||||
layer->set_scene_token(sceneToken);
|
||||
layer->set_hittable(hittable);
|
||||
m_currentLayer->Add(std::move(layer));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ class SceneBuilder : public ftl::RefCountedThreadSafe<SceneBuilder>,
|
||||
double devicePixelRatio,
|
||||
int physicalWidth,
|
||||
int physicalHeight,
|
||||
uint32_t sceneToken);
|
||||
uint32_t sceneToken,
|
||||
bool hittable);
|
||||
|
||||
void setRasterizerTracingThreshold(uint32_t frameInterval);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user