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

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

Issue 802323005: Revert of Validate Bucket data in ShaderSourceBucket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/service/common_decoder.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 "gpu/command_buffer/service/common_decoder.h" 5 #include "gpu/command_buffer/service/common_decoder.h"
6 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 6 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
7 7
8 namespace gpu { 8 namespace gpu {
9 9
10 CommonDecoder::Bucket::Bucket() : size_(0) {} 10 CommonDecoder::Bucket::Bucket() : size_(0) {}
11 11
12 CommonDecoder::Bucket::~Bucket() {} 12 CommonDecoder::Bucket::~Bucket() {}
13 13
14 void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const { 14 void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const {
15 if (OffsetSizeValid(offset, size)) { 15 if (OffsetSizeValid(offset, size)) {
16 return data_.get() + offset; 16 return data_.get() + offset;
17 } 17 }
18 return NULL; 18 return NULL;
19 } 19 }
20 20
21 bool CommonDecoder::Bucket::SetSize(size_t size) { 21 void CommonDecoder::Bucket::SetSize(size_t size) {
22 if (size != size_) { 22 if (size != size_) {
23 data_.reset(size ? new int8[size] : NULL); 23 data_.reset(size ? new int8[size] : NULL);
24 if (!data_.get() && (size != 0)) {
25 size_ = 0;
26 return false;
27 }
28 size_ = size; 24 size_ = size;
29 memset(data_.get(), 0, size); 25 memset(data_.get(), 0, size);
30 } 26 }
31 return true;
32 } 27 }
33 28
34 bool CommonDecoder::Bucket::SetData( 29 bool CommonDecoder::Bucket::SetData(
35 const void* src, size_t offset, size_t size) { 30 const void* src, size_t offset, size_t size) {
36 if (OffsetSizeValid(offset, size)) { 31 if (OffsetSizeValid(offset, size)) {
37 memcpy(data_.get() + offset, src, size); 32 memcpy(data_.get() + offset, src, size);
38 return true; 33 return true;
39 } 34 }
40 return false; 35 return false;
41 } 36 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return error::kNoError; 179 return error::kNoError;
185 } 180 }
186 181
187 error::Error CommonDecoder::HandleSetBucketSize( 182 error::Error CommonDecoder::HandleSetBucketSize(
188 uint32 immediate_data_size, 183 uint32 immediate_data_size,
189 const cmd::SetBucketSize& args) { 184 const cmd::SetBucketSize& args) {
190 uint32 bucket_id = args.bucket_id; 185 uint32 bucket_id = args.bucket_id;
191 uint32 size = args.size; 186 uint32 size = args.size;
192 187
193 Bucket* bucket = CreateBucket(bucket_id); 188 Bucket* bucket = CreateBucket(bucket_id);
194 if (!bucket->SetSize(size)) { 189 bucket->SetSize(size);
195 return error::kOutOfBounds;
196 }
197 return error::kNoError; 190 return error::kNoError;
198 } 191 }
199 192
200 error::Error CommonDecoder::HandleSetBucketData( 193 error::Error CommonDecoder::HandleSetBucketData(
201 uint32 immediate_data_size, 194 uint32 immediate_data_size,
202 const cmd::SetBucketData& args) { 195 const cmd::SetBucketData& args) {
203 uint32 bucket_id = args.bucket_id; 196 uint32 bucket_id = args.bucket_id;
204 uint32 offset = args.offset; 197 uint32 offset = args.offset;
205 uint32 size = args.size; 198 uint32 size = args.size;
206 const void* data = GetSharedMemoryAs<const void*>( 199 const void* data = GetSharedMemoryAs<const void*>(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 286 }
294 const void* src = bucket->GetData(offset, size); 287 const void* src = bucket->GetData(offset, size);
295 if (!src) { 288 if (!src) {
296 return error::kInvalidArguments; 289 return error::kInvalidArguments;
297 } 290 }
298 memcpy(data, src, size); 291 memcpy(data, src, size);
299 return error::kNoError; 292 return error::kNoError;
300 } 293 }
301 294
302 } // namespace gpu 295 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/common_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698