Adapt the physical model layer for Fuchsia (#3441)

This commit is contained in:
Jason Simmons 2017-02-23 16:27:33 -08:00 committed by GitHub
parent 2868251402
commit e01d1b39ef
2 changed files with 25 additions and 2 deletions

View File

@ -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);

View File

@ -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_;