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

Side by Side Diff: content/common/gpu/client/command_buffer_proxy_impl.cc

Issue 896723008: Add OrderingBarrierCHROMIUM API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update unit test classes. Created 5 years, 10 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/common/gpu/client/command_buffer_proxy_impl.h" 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "content/common/child_process_messages.h" 12 #include "content/common/child_process_messages.h"
13 #include "content/common/gpu/client/gpu_channel_host.h" 13 #include "content/common/gpu/client/gpu_channel_host.h"
14 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" 14 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h"
15 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" 15 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h"
16 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
17 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
18 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 18 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
19 #include "gpu/command_buffer/common/cmd_buffer_common.h" 19 #include "gpu/command_buffer/common/cmd_buffer_common.h"
20 #include "gpu/command_buffer/common/command_buffer_shared.h" 20 #include "gpu/command_buffer/common/command_buffer_shared.h"
21 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 21 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
22 #include "gpu/command_buffer/service/image_factory.h" 22 #include "gpu/command_buffer/service/image_factory.h"
23 #include "ui/gfx/geometry/size.h" 23 #include "ui/gfx/geometry/size.h"
24 #include "ui/gl/gl_bindings.h" 24 #include "ui/gl/gl_bindings.h"
25 25
26 namespace content { 26 namespace content {
27 27
28 CommandBufferProxyImpl::CommandBufferProxyImpl( 28 CommandBufferProxyImpl::CommandBufferProxyImpl(GpuChannelHost* channel,
29 GpuChannelHost* channel, 29 int route_id)
30 int route_id)
31 : channel_(channel), 30 : channel_(channel),
32 route_id_(route_id), 31 route_id_(route_id),
33 flush_count_(0), 32 flush_count_(0),
34 last_put_offset_(-1), 33 last_put_offset_(-1),
34 last_shallow_put_offset_(-1),
35 next_signal_id_(0) { 35 next_signal_id_(0) {
36 } 36 }
37 37
38 CommandBufferProxyImpl::~CommandBufferProxyImpl() { 38 CommandBufferProxyImpl::~CommandBufferProxyImpl() {
39 FOR_EACH_OBSERVER(DeletionObserver, 39 FOR_EACH_OBSERVER(DeletionObserver,
40 deletion_observers_, 40 deletion_observers_,
41 OnWillDeleteImpl()); 41 OnWillDeleteImpl());
42 } 42 }
43 43
44 bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) { 44 bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 TRACE_EVENT1("gpu", 177 TRACE_EVENT1("gpu",
178 "CommandBufferProxyImpl::Flush", 178 "CommandBufferProxyImpl::Flush",
179 "put_offset", 179 "put_offset",
180 put_offset); 180 put_offset);
181 181
182 if (last_put_offset_ == put_offset) 182 if (last_put_offset_ == put_offset)
183 return; 183 return;
184 184
185 last_put_offset_ = put_offset; 185 last_put_offset_ = put_offset;
186 last_shallow_put_offset_ = put_offset;
186 187
187 Send(new GpuCommandBufferMsg_AsyncFlush(route_id_, 188 if (channel_)
188 put_offset, 189 channel_->Flush(route_id_, put_offset, ++flush_count_, latency_info_,
189 ++flush_count_, 190 false);
190 latency_info_)); 191
191 latency_info_.clear(); 192 latency_info_.clear();
192 } 193 }
193 194
195 void CommandBufferProxyImpl::ShallowFlush(int32 put_offset) {
196 if (last_state_.error != gpu::error::kNoError)
197 return;
198
199 TRACE_EVENT1("gpu", "CommandBufferProxyImpl::ShallowFlush", "put_offset",
200 put_offset);
201
202 if (last_shallow_put_offset_ == put_offset)
203 return;
204
205 last_shallow_put_offset_ = put_offset;
206
207 if (channel_)
208 channel_->Flush(route_id_, put_offset, ++flush_count_, latency_info_, true);
209
210 latency_info_.clear();
211 }
212
194 void CommandBufferProxyImpl::SetLatencyInfo( 213 void CommandBufferProxyImpl::SetLatencyInfo(
195 const std::vector<ui::LatencyInfo>& latency_info) { 214 const std::vector<ui::LatencyInfo>& latency_info) {
196 for (size_t i = 0; i < latency_info.size(); i++) 215 for (size_t i = 0; i < latency_info.size(); i++)
197 latency_info_.push_back(latency_info[i]); 216 latency_info_.push_back(latency_info[i]);
198 } 217 }
199 218
200 void CommandBufferProxyImpl::SetSwapBuffersCompletionCallback( 219 void CommandBufferProxyImpl::SetSwapBuffersCompletionCallback(
201 const SwapBuffersCompletionCallback& callback) { 220 const SwapBuffersCompletionCallback& callback) {
202 swap_buffers_completion_callback_ = callback; 221 swap_buffers_completion_callback_ = callback;
203 } 222 }
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (!ui::LatencyInfo::Verify( 551 if (!ui::LatencyInfo::Verify(
533 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) { 552 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) {
534 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>()); 553 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>());
535 return; 554 return;
536 } 555 }
537 swap_buffers_completion_callback_.Run(latency_info); 556 swap_buffers_completion_callback_.Run(latency_info);
538 } 557 }
539 } 558 }
540 559
541 } // namespace content 560 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698