Skip to content

Commit

Permalink
Make Mozart draw child views
Browse files Browse the repository at this point in the history
Previously we weren't factoring in the layer's offset properly and we were
drawing the child views below the background layer.
  • Loading branch information
abarth committed Feb 8, 2016
1 parent c0e87a4 commit 4b921cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions flow/layers/child_scene_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ChildSceneLayer::~ChildSceneLayer() {

void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
transform_ = matrix;
transform_.postTranslate(offset_.x(), offset_.y());
}

void ChildSceneLayer::Paint(PaintContext::ScopedFrame& frame) {
Expand Down
20 changes: 12 additions & 8 deletions sky/shell/gpu/mojo/rasterizer_mojo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace shell {

const uint32_t kContentImageResourceId = 1;
const uint32_t kRootNodeId = mojo::gfx::composition::kSceneRootNodeId;
const uint32_t kBackgroundNodeId = 1;

std::unique_ptr<Rasterizer> Rasterizer::Create() {
return std::unique_ptr<Rasterizer>(new RasterizerMojo());
Expand Down Expand Up @@ -87,17 +88,20 @@ void RasterizerMojo::Draw(uint64_t layer_tree_ptr,
update->clear_resources = true;
update->clear_nodes = true;
update->resources.insert(kContentImageResourceId, resource.Pass());
auto root_node = mojo::gfx::composition::Node::New();
root_node->op = mojo::gfx::composition::NodeOp::New();
root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New());
root_node->op->get_image()->content_rect = mojo::Rect::New();
root_node->op->get_image()->content_rect->width = size.width;
root_node->op->get_image()->content_rect->height = size.height;
root_node->op->get_image()->image_resource_id = kContentImageResourceId;
update->nodes.insert(kRootNodeId, root_node.Pass());
auto background_node = mojo::gfx::composition::Node::New();
background_node->op = mojo::gfx::composition::NodeOp::New();
background_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New());
background_node->op->get_image()->content_rect = mojo::Rect::New();
background_node->op->get_image()->content_rect->width = size.width;
background_node->op->get_image()->content_rect->height = size.height;
background_node->op->get_image()->image_resource_id = kContentImageResourceId;
update->nodes.insert(kBackgroundNodeId, background_node.Pass());

auto root_node = mojo::gfx::composition::Node::New();
root_node->child_node_ids.push_back(kBackgroundNodeId);
layer_tree->UpdateScene(update.get(), root_node.get());

update->nodes.insert(kRootNodeId, root_node.Pass());
scene_->Update(update.Pass());
scene_->Publish(nullptr);
callback.Run();
Expand Down

0 comments on commit 4b921cb

Please sign in to comment.