Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: content/renderer/gpu/renderer_compositor_frame_sink.cc

Issue 2404993002: cc: Stop calling DetachFromClient if bind failed. (Closed)
Patch Set: detachinternal: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/gpu/renderer_compositor_frame_sink.h" 5 #include "content/renderer/gpu/renderer_compositor_frame_sink.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 compositor_frame_sink_proxy_ = new RendererCompositorFrameSinkProxy(this); 81 compositor_frame_sink_proxy_ = new RendererCompositorFrameSinkProxy(this);
82 compositor_frame_sink_filter_handler_ = 82 compositor_frame_sink_filter_handler_ =
83 base::Bind(&RendererCompositorFrameSinkProxy::OnMessageReceived, 83 base::Bind(&RendererCompositorFrameSinkProxy::OnMessageReceived,
84 compositor_frame_sink_proxy_); 84 compositor_frame_sink_proxy_);
85 compositor_frame_sink_filter_->AddHandlerOnCompositorThread( 85 compositor_frame_sink_filter_->AddHandlerOnCompositorThread(
86 routing_id_, compositor_frame_sink_filter_handler_); 86 routing_id_, compositor_frame_sink_filter_handler_);
87 return true; 87 return true;
88 } 88 }
89 89
90 void RendererCompositorFrameSink::DetachFromClient() { 90 void RendererCompositorFrameSink::DetachFromClient() {
91 if (!HasClient())
92 return;
93 client_->SetBeginFrameSource(nullptr); 91 client_->SetBeginFrameSource(nullptr);
94 // Destroy the begin frame source on the same thread it was bound on. 92 // Destroy the begin frame source on the same thread it was bound on.
95 // The CompositorFrameSink itself is destroyed on the main thread. 93 // The CompositorFrameSink itself is destroyed on the main thread.
96 begin_frame_source_ = nullptr; 94 begin_frame_source_ = nullptr;
95 compositor_frame_sink_proxy_->ClearCompositorFrameSink();
96 compositor_frame_sink_filter_->RemoveHandlerOnCompositorThread(
97 routing_id_, compositor_frame_sink_filter_handler_);
97 98
98 if (compositor_frame_sink_proxy_) {
99 compositor_frame_sink_proxy_->ClearCompositorFrameSink();
100 compositor_frame_sink_filter_->RemoveHandlerOnCompositorThread(
101 routing_id_, compositor_frame_sink_filter_handler_);
102 }
103 cc::CompositorFrameSink::DetachFromClient(); 99 cc::CompositorFrameSink::DetachFromClient();
104 } 100 }
105 101
106 void RendererCompositorFrameSink::SwapBuffers(cc::CompositorFrame frame) { 102 void RendererCompositorFrameSink::SwapBuffers(cc::CompositorFrame frame) {
107 { 103 {
108 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> 104 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope>
109 send_message_scope = 105 send_message_scope =
110 frame_swap_message_queue_->AcquireSendMessageScope(); 106 frame_swap_message_queue_->AcquireSendMessageScope();
111 std::vector<std::unique_ptr<IPC::Message>> messages; 107 std::vector<std::unique_ptr<IPC::Message>> messages;
112 std::vector<IPC::Message> messages_to_deliver_with_frame; 108 std::vector<IPC::Message> messages_to_deliver_with_frame;
113 frame_swap_message_queue_->DrainMessages(&messages); 109 frame_swap_message_queue_->DrainMessages(&messages);
114 FrameSwapMessageQueue::TransferMessages(&messages, 110 FrameSwapMessageQueue::TransferMessages(&messages,
115 &messages_to_deliver_with_frame); 111 &messages_to_deliver_with_frame);
116 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, 112 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_,
117 compositor_frame_sink_id_, frame, 113 compositor_frame_sink_id_, frame,
118 messages_to_deliver_with_frame)); 114 messages_to_deliver_with_frame));
119 // ~send_message_scope. 115 // ~send_message_scope.
120 } 116 }
121 } 117 }
122 118
123 void RendererCompositorFrameSink::OnMessageReceived( 119 void RendererCompositorFrameSink::OnMessageReceived(
124 const IPC::Message& message) { 120 const IPC::Message& message) {
125 DCHECK(client_thread_checker_.CalledOnValidThread()); 121 DCHECK(client_thread_checker_.CalledOnValidThread());
126 if (!HasClient())
127 return;
128 IPC_BEGIN_MESSAGE_MAP(RendererCompositorFrameSink, message) 122 IPC_BEGIN_MESSAGE_MAP(RendererCompositorFrameSink, message)
129 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, 123 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources,
130 OnReclaimCompositorResources); 124 OnReclaimCompositorResources);
131 IPC_END_MESSAGE_MAP() 125 IPC_END_MESSAGE_MAP()
132 } 126 }
133 127
134 void RendererCompositorFrameSink::OnReclaimCompositorResources( 128 void RendererCompositorFrameSink::OnReclaimCompositorResources(
135 uint32_t compositor_frame_sink_id, 129 uint32_t compositor_frame_sink_id,
136 bool is_swap_ack, 130 bool is_swap_ack,
137 const cc::ReturnedResourceArray& resources) { 131 const cc::ReturnedResourceArray& resources) {
138 // Ignore message if it's a stale one coming from a different output surface 132 // Ignore message if it's a stale one coming from a different output surface
139 // (e.g. after a lost context). 133 // (e.g. after a lost context).
140 if (compositor_frame_sink_id != compositor_frame_sink_id_) 134 if (compositor_frame_sink_id != compositor_frame_sink_id_)
141 return; 135 return;
142 client_->ReclaimResources(resources); 136 client_->ReclaimResources(resources);
143 if (is_swap_ack) 137 if (is_swap_ack)
144 client_->DidSwapBuffersComplete(); 138 client_->DidSwapBuffersComplete();
145 } 139 }
146 140
147 bool RendererCompositorFrameSink::Send(IPC::Message* message) { 141 bool RendererCompositorFrameSink::Send(IPC::Message* message) {
148 return message_sender_->Send(message); 142 return message_sender_->Send(message);
149 } 143 }
150 144
151 } // namespace content 145 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_frame_sink.cc ('k') | services/ui/public/cpp/compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698