From e01d1b39efd5d83de53adeb6413a8dcfd2470dc7 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 23 Feb 2017 16:27:33 -0800 Subject: [PATCH] Adapt the physical model layer for Fuchsia (#3441) --- flow/layers/physical_model_layer.cc | 22 ++++++++++++++++++++-- flow/layers/physical_model_layer.h | 5 +++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/flow/layers/physical_model_layer.cc b/flow/layers/physical_model_layer.cc index 0392677b5f0..18a6d21fafc 100644 --- a/flow/layers/physical_model_layer.cc +++ b/flow/layers/physical_model_layer.cc @@ -6,6 +6,11 @@ #include "third_party/skia/include/utils/SkShadowUtils.h" +#if defined(OS_FUCHSIA) +#include "apps/mozart/lib/skia/type_converters.h" +#include "apps/mozart/services/composition/nodes.fidl.h" +#endif // defined(OS_FUCHSIA) + namespace flow { PhysicalModelLayer::PhysicalModelLayer() @@ -26,10 +31,20 @@ void PhysicalModelLayer::Preroll(PrerollContext* context, const SkMatrix& matrix set_paint_bounds(bounds); } +#if defined(OS_FUCHSIA) + +void PhysicalModelLayer::UpdateScene(SceneUpdateContext& context, + mozart::Node* container) { + context.AddLayerToCurrentPaintTask(this); + auto node = mozart::Node::New(); + node->content_clip = mozart::RectF::From(rrect_.getBounds()); + UpdateSceneChildrenInsideNode(context, container, std::move(node)); +} + +#endif // defined(OS_FUCHSIA) + void PhysicalModelLayer::Paint(PaintContext& context) { TRACE_EVENT0("flutter", "PhysicalModelLayer::Paint"); - // TODO: need to support this layer on Fuchsia - FTL_DCHECK(!needs_system_composite()); SkPath path; path.addRRect(rrect_); @@ -43,6 +58,9 @@ void PhysicalModelLayer::Paint(PaintContext& context) { SK_ColorBLACK); } + if (needs_system_composite()) + return; + SkPaint paint; paint.setColor(SkColorSetA(color_, 0xFF)); context.canvas.drawPath(path, paint); diff --git a/flow/layers/physical_model_layer.h b/flow/layers/physical_model_layer.h index 64b4915818b..3271f79081f 100644 --- a/flow/layers/physical_model_layer.h +++ b/flow/layers/physical_model_layer.h @@ -22,6 +22,11 @@ class PhysicalModelLayer : public ContainerLayer { void Preroll(PrerollContext* context, const SkMatrix& matrix) override; void Paint(PaintContext& context) override; +#if defined(OS_FUCHSIA) + void UpdateScene(SceneUpdateContext& context, + mozart::Node* container) override; +#endif // defined(OS_FUCHSIA) + private: SkRRect rrect_; int elevation_;