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

Side by Side Diff: gpu/command_buffer/service/command_buffer_service.cc

Issue 217593004: GPU: Fix NULL gpu::Buffer dereference. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 8 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
« no previous file with comments | « gpu/command_buffer/client/transfer_buffer.cc ('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 "gpu/command_buffer/service/command_buffer_service.h" 5 #include "gpu/command_buffer/service/command_buffer_service.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 put_offset_ = put_offset; 82 put_offset_ = put_offset;
83 83
84 if (!put_offset_change_callback_.is_null()) 84 if (!put_offset_change_callback_.is_null())
85 put_offset_change_callback_.Run(); 85 put_offset_change_callback_.Run();
86 } 86 }
87 87
88 void CommandBufferService::SetGetBuffer(int32 transfer_buffer_id) { 88 void CommandBufferService::SetGetBuffer(int32 transfer_buffer_id) {
89 DCHECK_EQ(-1, ring_buffer_id_); 89 DCHECK_EQ(-1, ring_buffer_id_);
90 DCHECK_EQ(put_offset_, get_offset_); // Only if it's empty. 90 DCHECK_EQ(put_offset_, get_offset_); // Only if it's empty.
91 // If the buffer is invalid we handle it gracefully.
92 // This means ring_buffer_ can be NULL.
91 ring_buffer_ = GetTransferBuffer(transfer_buffer_id); 93 ring_buffer_ = GetTransferBuffer(transfer_buffer_id);
92 DCHECK(ring_buffer_);
93 ring_buffer_id_ = transfer_buffer_id; 94 ring_buffer_id_ = transfer_buffer_id;
94 num_entries_ = ring_buffer_->size() / sizeof(CommandBufferEntry); 95 int32 size = ring_buffer_ ? ring_buffer_->size() : 0;
96 num_entries_ = size / sizeof(CommandBufferEntry);
95 put_offset_ = 0; 97 put_offset_ = 0;
96 SetGetOffset(0); 98 SetGetOffset(0);
97 if (!get_buffer_change_callback_.is_null()) { 99 if (!get_buffer_change_callback_.is_null()) {
98 get_buffer_change_callback_.Run(ring_buffer_id_); 100 get_buffer_change_callback_.Run(ring_buffer_id_);
99 } 101 }
100 102
101 UpdateState(); 103 UpdateState();
102 } 104 }
103 105
104 bool CommandBufferService::SetSharedStateBuffer( 106 bool CommandBufferService::SetSharedStateBuffer(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 const GetBufferChangedCallback& callback) { 190 const GetBufferChangedCallback& callback) {
189 get_buffer_change_callback_ = callback; 191 get_buffer_change_callback_ = callback;
190 } 192 }
191 193
192 void CommandBufferService::SetParseErrorCallback( 194 void CommandBufferService::SetParseErrorCallback(
193 const base::Closure& callback) { 195 const base::Closure& callback) {
194 parse_error_callback_ = callback; 196 parse_error_callback_ = callback;
195 } 197 }
196 198
197 } // namespace gpu 199 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/transfer_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698