Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / layers / delegated_renderer_layer.cc
blob99f089fee7e096bee1037bdb3ec75e4b31f88a96
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/layers/delegated_renderer_layer.h"
7 #include "cc/layers/delegated_renderer_layer_impl.h"
8 #include "cc/output/delegated_frame_data.h"
9 #include "cc/quads/render_pass_draw_quad.h"
10 #include "cc/trees/layer_tree_host.h"
12 namespace cc {
14 scoped_refptr<DelegatedRendererLayer> DelegatedRendererLayer::Create(
15 const LayerSettings& settings,
16 const scoped_refptr<DelegatedFrameProvider>& frame_provider) {
17 return scoped_refptr<DelegatedRendererLayer>(
18 new DelegatedRendererLayer(settings, frame_provider));
21 DelegatedRendererLayer::DelegatedRendererLayer(
22 const LayerSettings& settings,
23 const scoped_refptr<DelegatedFrameProvider>& frame_provider)
24 : Layer(settings),
25 frame_provider_(frame_provider),
26 should_collect_new_frame_(true),
27 frame_data_(nullptr),
28 weak_ptrs_(this) {
29 frame_provider_->AddObserver(this);
32 DelegatedRendererLayer::~DelegatedRendererLayer() {
33 frame_provider_->RemoveObserver(this);
36 scoped_ptr<LayerImpl> DelegatedRendererLayer::CreateLayerImpl(
37 LayerTreeImpl* tree_impl) {
38 return DelegatedRendererLayerImpl::Create(tree_impl, layer_id_);
41 void DelegatedRendererLayer::SetLayerTreeHost(LayerTreeHost* host) {
42 if (layer_tree_host() == host) {
43 Layer::SetLayerTreeHost(host);
44 return;
47 if (!host) {
48 // The active frame needs to be removed from the active tree and resources
49 // returned before the commit is called complete.
50 // TODO(danakj): Don't need to do this if the last frame commited was empty
51 // or we never commited a frame with resources.
52 SetNextCommitWaitsForActivation();
53 } else {
54 // There is no active frame in the new layer tree host to wait for so no
55 // need to call SetNextCommitWaitsForActivation().
56 should_collect_new_frame_ = true;
57 SetNeedsUpdate();
60 Layer::SetLayerTreeHost(host);
63 void DelegatedRendererLayer::PushPropertiesTo(LayerImpl* impl) {
64 Layer::PushPropertiesTo(impl);
66 DelegatedRendererLayerImpl* delegated_impl =
67 static_cast<DelegatedRendererLayerImpl*>(impl);
69 delegated_impl->CreateChildIdIfNeeded(
70 frame_provider_->GetReturnResourcesCallbackForImplThread());
72 if (frame_data_)
73 delegated_impl->SetFrameData(frame_data_, frame_damage_);
74 frame_data_ = nullptr;
75 frame_damage_ = gfx::RectF();
78 void DelegatedRendererLayer::ProviderHasNewFrame() {
79 should_collect_new_frame_ = true;
80 SetNeedsUpdate();
81 // The active frame needs to be replaced and resources returned before the
82 // commit is called complete.
83 SetNextCommitWaitsForActivation();
86 bool DelegatedRendererLayer::Update(ResourceUpdateQueue* queue,
87 const OcclusionTracker<Layer>* occlusion) {
88 bool updated = Layer::Update(queue, occlusion);
89 if (!should_collect_new_frame_)
90 return updated;
92 frame_data_ =
93 frame_provider_->GetFrameDataAndRefResources(this, &frame_damage_);
94 should_collect_new_frame_ = false;
96 SetNeedsPushProperties();
97 return true;
100 bool DelegatedRendererLayer::HasDelegatedContent() const {
101 return true;
104 } // namespace cc