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

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

Issue 2380683003: add range check to service-side MapBufferRange (Closed)
Patch Set: rebase over reformat Created 4 years, 2 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 16818 matching lines...) Expand 10 before | Expand all | Expand 10 after
16829 if ((access & mask) == mask) { 16829 if ((access & mask) == mask) {
16830 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "MapBufferRange", 16830 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "MapBufferRange",
16831 "incompatible access bits"); 16831 "incompatible access bits");
16832 return error::kNoError; 16832 return error::kNoError;
16833 } 16833 }
16834 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT); 16834 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT);
16835 if ((access & GL_MAP_WRITE_BIT) == GL_MAP_WRITE_BIT && 16835 if ((access & GL_MAP_WRITE_BIT) == GL_MAP_WRITE_BIT &&
16836 (access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { 16836 (access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) {
16837 access = (access | GL_MAP_READ_BIT); 16837 access = (access | GL_MAP_READ_BIT);
16838 } 16838 }
16839 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target);
16840 if (!buffer) {
16841 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "MapBufferRange",
16842 "no buffer bound to target");
16843 return error::kNoError;
16844 }
16845 if (!buffer->CheckRange(offset, size)) {
16846 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "MapBufferRange",
16847 "invalid range");
16848 return error::kNoError;
16849 }
16839 void* ptr = glMapBufferRange(target, offset, size, access); 16850 void* ptr = glMapBufferRange(target, offset, size, access);
16840 if (ptr == nullptr) { 16851 if (ptr == nullptr) {
16841 return error::kNoError; 16852 return error::kNoError;
16842 } 16853 }
16843 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target);
16844 DCHECK(buffer);
16845 buffer->SetMappedRange(offset, size, access, ptr, 16854 buffer->SetMappedRange(offset, size, access, ptr,
16846 GetSharedMemoryBuffer(data_shm_id)); 16855 GetSharedMemoryBuffer(data_shm_id));
16847 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { 16856 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) {
16848 memcpy(mem, ptr, size); 16857 memcpy(mem, ptr, size);
16849 } 16858 }
16850 *result = 1; 16859 *result = 1;
16851 return error::kNoError; 16860 return error::kNoError;
16852 } 16861 }
16853 16862
16854 error::Error GLES2DecoderImpl::HandleUnmapBuffer( 16863 error::Error GLES2DecoderImpl::HandleUnmapBuffer(
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
18100 } 18109 }
18101 18110
18102 // Include the auto-generated part of this file. We split this because it means 18111 // Include the auto-generated part of this file. We split this because it means
18103 // we can easily edit the non-auto generated parts right here in this file 18112 // we can easily edit the non-auto generated parts right here in this file
18104 // instead of having to edit some template or the code generator. 18113 // instead of having to edit some template or the code generator.
18105 #include "base/macros.h" 18114 #include "base/macros.h"
18106 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18115 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18107 18116
18108 } // namespace gles2 18117 } // namespace gles2
18109 } // namespace gpu 18118 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/buffer_manager.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_buffers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698