Chromium Code Reviews| Index: content/renderer/pepper/pepper_compositor_host.cc |
| diff --git a/content/renderer/pepper/pepper_compositor_host.cc b/content/renderer/pepper/pepper_compositor_host.cc |
| index 47c0fccfe6cb06198183de4377c305c91e2c0e9c..ce9e7a92bf075cafd12eae6b4c244948b7cc2c86 100644 |
| --- a/content/renderer/pepper/pepper_compositor_host.cc |
| +++ b/content/renderer/pepper/pepper_compositor_host.cc |
| @@ -119,6 +119,28 @@ int32_t VerifyCommittedLayer( |
| return PP_ERROR_BADARGUMENT; |
| } |
| +// cc::Layer::SetNeedsCommit() is a protected method, we have to use a subclass |
| +// to make it assessable. |
| +class ContainerLayer : public cc::Layer { |
|
piman
2014/06/18 00:55:24
Please don't subclass cc::Layer outside of cc.
Fo
Peng
2014/06/18 02:35:02
Done.
|
| + public: |
| + static scoped_refptr<cc::Layer> Create(); |
| + void ForceToCommit(); |
| + |
| + private: |
| + ContainerLayer() {}; |
| + virtual ~ContainerLayer() {}; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ContainerLayer); |
| +}; |
| + |
| +scoped_refptr<cc::Layer> ContainerLayer::Create() { |
| + return make_scoped_refptr(new ContainerLayer()); |
| +} |
| + |
| +void ContainerLayer::ForceToCommit() { |
| + SetNeedsCommit(); |
| +} |
| + |
| } // namespace |
| PepperCompositorHost::LayerData::LayerData( |
| @@ -134,12 +156,6 @@ PepperCompositorHost::PepperCompositorHost( |
| : ResourceHost(host->GetPpapiHost(), instance, resource), |
| bound_instance_(NULL), |
| weak_factory_(this) { |
| - layer_ = cc::Layer::Create(); |
| - // TODO(penghuang): SetMasksToBounds() can be expensive if the layer is |
| - // transformed. Possibly better could be to explicitly clip the child layers |
| - // (by modifying their bounds). |
| - layer_->SetMasksToBounds(true); |
| - layer_->SetIsDrawable(true); |
| } |
| PepperCompositorHost::~PepperCompositorHost() { |
| @@ -157,7 +173,18 @@ bool PepperCompositorHost::BindToInstance( |
| if (bound_instance_ && new_instance) |
| return false; // Can't change a bound device. |
| bound_instance_ = new_instance; |
| + layer_ = NULL; |
| + layers_.clear(); |
| + if (bound_instance_) { |
| + layer_ = ContainerLayer::Create(); |
| + // TODO(penghuang): SetMasksToBounds() can be expensive if the layer is |
| + // transformed. Possibly better could be to explicitly clip the child layers |
| + // (by modifying their bounds). |
|
piman
2014/06/18 00:55:24
Note: what's expensive is not calling SetMasksToBo
Peng
2014/06/18 02:35:02
No. Without this change, the below code will crash
|
| + layer_->SetMasksToBounds(true); |
| + layer_->SetIsDrawable(true); |
| + } |
| return true; |
| + |
| } |
| void PepperCompositorHost::ViewInitiatedPaint() { |
| @@ -366,6 +393,10 @@ int32_t PepperCompositorHost::OnHostMsgCommitLayers( |
| layers_.push_back(LayerData(cc_layer, *pp_layer)); |
| } |
| + // We need force to commit on the parent layer, so the ViewInitiatedPaint() |
| + // will be always called, even if all layers are not changed from previous |
| + // CommitLayers() call. |
| + (static_cast<ContainerLayer*>(layer_.get()))->ForceToCommit(); |
| return PP_OK_COMPLETIONPENDING; |
| } |