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

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

Issue 9567026: Avoid sending duplicate flushes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "content/common/gpu/client/command_buffer_proxy.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 10 matching lines...) Expand all
21 #include "gpu/command_buffer/common/command_buffer_shared.h" 21 #include "gpu/command_buffer/common/command_buffer_shared.h"
22 #include "ui/gfx/size.h" 22 #include "ui/gfx/size.h"
23 23
24 using gpu::Buffer; 24 using gpu::Buffer;
25 25
26 CommandBufferProxy::CommandBufferProxy( 26 CommandBufferProxy::CommandBufferProxy(
27 GpuChannelHost* channel, 27 GpuChannelHost* channel,
28 int route_id) 28 int route_id)
29 : channel_(channel), 29 : channel_(channel),
30 route_id_(route_id), 30 route_id_(route_id),
31 flush_count_(0) { 31 flush_count_(0),
32 last_put_offset_(-1) {
32 } 33 }
33 34
34 CommandBufferProxy::~CommandBufferProxy() { 35 CommandBufferProxy::~CommandBufferProxy() {
35 // Delete all the locally cached shared memory objects, closing the handle 36 // Delete all the locally cached shared memory objects, closing the handle
36 // in this process. 37 // in this process.
37 for (TransferBufferMap::iterator it = transfer_buffers_.begin(); 38 for (TransferBufferMap::iterator it = transfer_buffers_.begin();
38 it != transfer_buffers_.end(); 39 it != transfer_buffers_.end();
39 ++it) { 40 ++it) {
40 delete it->second.shared_memory; 41 delete it->second.shared_memory;
41 it->second.shared_memory = NULL; 42 it->second.shared_memory = NULL;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 gpu::CommandBuffer::State CommandBufferProxy::GetLastState() { 166 gpu::CommandBuffer::State CommandBufferProxy::GetLastState() {
166 return last_state_; 167 return last_state_;
167 } 168 }
168 169
169 void CommandBufferProxy::Flush(int32 put_offset) { 170 void CommandBufferProxy::Flush(int32 put_offset) {
170 if (last_state_.error != gpu::error::kNoError) 171 if (last_state_.error != gpu::error::kNoError)
171 return; 172 return;
172 173
173 TRACE_EVENT1("gpu", "CommandBufferProxy::Flush", "put_offset", put_offset); 174 TRACE_EVENT1("gpu", "CommandBufferProxy::Flush", "put_offset", put_offset);
174 175
176 if (last_put_offset_ == put_offset)
177 return;
178
179 last_put_offset_ = put_offset;
180
175 Send(new GpuCommandBufferMsg_AsyncFlush(route_id_, 181 Send(new GpuCommandBufferMsg_AsyncFlush(route_id_,
176 put_offset, 182 put_offset,
177 ++flush_count_)); 183 ++flush_count_));
178 } 184 }
179 185
180 gpu::CommandBuffer::State CommandBufferProxy::FlushSync(int32 put_offset, 186 gpu::CommandBuffer::State CommandBufferProxy::FlushSync(int32 put_offset,
181 int32 last_known_get) { 187 int32 last_known_get) {
182 TRACE_EVENT1("gpu", "CommandBufferProxy::FlushSync", "put_offset", 188 TRACE_EVENT1("gpu", "CommandBufferProxy::FlushSync", "put_offset",
183 put_offset); 189 put_offset);
184 Flush(put_offset); 190 Flush(put_offset);
(...skipping 10 matching lines...) Expand all
195 } 201 }
196 202
197 return last_state_; 203 return last_state_;
198 } 204 }
199 205
200 void CommandBufferProxy::SetGetBuffer(int32 shm_id) { 206 void CommandBufferProxy::SetGetBuffer(int32 shm_id) {
201 if (last_state_.error != gpu::error::kNoError) 207 if (last_state_.error != gpu::error::kNoError)
202 return; 208 return;
203 209
204 Send(new GpuCommandBufferMsg_SetGetBuffer(route_id_, shm_id)); 210 Send(new GpuCommandBufferMsg_SetGetBuffer(route_id_, shm_id));
211 last_put_offset_ = -1;
205 } 212 }
206 213
207 void CommandBufferProxy::SetGetOffset(int32 get_offset) { 214 void CommandBufferProxy::SetGetOffset(int32 get_offset) {
208 // Not implemented in proxy. 215 // Not implemented in proxy.
209 NOTREACHED(); 216 NOTREACHED();
210 } 217 }
211 218
212 int32 CommandBufferProxy::CreateTransferBuffer(size_t size, int32 id_request) { 219 int32 CommandBufferProxy::CreateTransferBuffer(size_t size, int32 id_request) {
213 if (last_state_.error != gpu::error::kNoError) 220 if (last_state_.error != gpu::error::kNoError)
214 return -1; 221 return -1;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 454
448 void CommandBufferProxy::SetOnConsoleMessageCallback( 455 void CommandBufferProxy::SetOnConsoleMessageCallback(
449 const GpuConsoleMessageCallback& callback) { 456 const GpuConsoleMessageCallback& callback) {
450 console_message_callback_ = callback; 457 console_message_callback_ = callback;
451 } 458 }
452 459
453 void CommandBufferProxy::TryUpdateState() { 460 void CommandBufferProxy::TryUpdateState() {
454 if (last_state_.error == gpu::error::kNoError) 461 if (last_state_.error == gpu::error::kNoError)
455 shared_state_->Read(&last_state_); 462 shared_state_->Read(&last_state_);
456 } 463 }
OLDNEW
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698