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

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: Fixed nits. 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_barrier_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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 void CommandBufferProxyImpl::Flush(int32 put_offset) { 173 void CommandBufferProxyImpl::Flush(int32 put_offset) {
174 if (last_state_.error != gpu::error::kNoError) 174 if (last_state_.error != gpu::error::kNoError)
175 return; 175 return;
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 bool put_offset_changed = last_put_offset_ != put_offset;
183 last_put_offset_ = put_offset;
184 last_barrier_put_offset_ = put_offset;
185
186 if (channel_) {
187 channel_->OrderingBarrier(route_id_, put_offset, ++flush_count_,
188 latency_info_, put_offset_changed, true);
189 }
190
191 if (put_offset_changed)
192 latency_info_.clear();
193 }
194
195 void CommandBufferProxyImpl::OrderingBarrier(int32 put_offset) {
196 if (last_state_.error != gpu::error::kNoError)
183 return; 197 return;
184 198
185 last_put_offset_ = put_offset; 199 TRACE_EVENT1("gpu", "CommandBufferProxyImpl::OrderingBarrier", "put_offset",
200 put_offset);
186 201
187 Send(new GpuCommandBufferMsg_AsyncFlush(route_id_, 202 bool put_offset_changed = last_barrier_put_offset_ != put_offset;
188 put_offset, 203 last_barrier_put_offset_ = put_offset;
189 ++flush_count_, 204
190 latency_info_)); 205 if (channel_) {
191 latency_info_.clear(); 206 channel_->OrderingBarrier(route_id_, put_offset, ++flush_count_,
207 latency_info_, put_offset_changed, false);
208 }
209
210 if (put_offset_changed)
211 latency_info_.clear();
192 } 212 }
193 213
194 void CommandBufferProxyImpl::SetLatencyInfo( 214 void CommandBufferProxyImpl::SetLatencyInfo(
195 const std::vector<ui::LatencyInfo>& latency_info) { 215 const std::vector<ui::LatencyInfo>& latency_info) {
196 for (size_t i = 0; i < latency_info.size(); i++) 216 for (size_t i = 0; i < latency_info.size(); i++)
197 latency_info_.push_back(latency_info[i]); 217 latency_info_.push_back(latency_info[i]);
198 } 218 }
199 219
200 void CommandBufferProxyImpl::SetSwapBuffersCompletionCallback( 220 void CommandBufferProxyImpl::SetSwapBuffersCompletionCallback(
201 const SwapBuffersCompletionCallback& callback) { 221 const SwapBuffersCompletionCallback& callback) {
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (!ui::LatencyInfo::Verify( 552 if (!ui::LatencyInfo::Verify(
533 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) { 553 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) {
534 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>()); 554 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>());
535 return; 555 return;
536 } 556 }
537 swap_buffers_completion_callback_.Run(latency_info); 557 swap_buffers_completion_callback_.Run(latency_info);
538 } 558 }
539 } 559 }
540 560
541 } // namespace content 561 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.h ('k') | content/common/gpu/client/gpu_channel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698