Skip to content

Commit

Permalink
Adapt the physical model layer for Fuchsia (flutter#3441)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Feb 24, 2017
1 parent 2868251 commit e01d1b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
22 changes: 20 additions & 2 deletions flow/layers/physical_model_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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_);
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions flow/layers/physical_model_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down

0 comments on commit e01d1b3

Please sign in to comment.