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

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

Issue 2435803004: Initialize buffers before allowing access to them. (Closed)
Patch Set: win failure Created 4 years, 1 month 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "gpu/command_buffer/service/buffer_manager.h" 10 #include "gpu/command_buffer/service/buffer_manager.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 Buffer* buffer, GLenum target, GLsizeiptr size, GLenum usage, 54 Buffer* buffer, GLenum target, GLsizeiptr size, GLenum usage,
55 const GLvoid* data, GLenum error) { 55 const GLvoid* data, GLenum error) {
56 TestHelper::DoBufferData( 56 TestHelper::DoBufferData(
57 gl_.get(), error_state_.get(), manager_.get(), 57 gl_.get(), error_state_.get(), manager_.get(),
58 buffer, target, size, usage, data, error); 58 buffer, target, size, usage, data, error);
59 } 59 }
60 60
61 bool DoBufferSubData( 61 bool DoBufferSubData(
62 Buffer* buffer, GLenum target, GLintptr offset, GLsizeiptr size, 62 Buffer* buffer, GLenum target, GLintptr offset, GLsizeiptr size,
63 const GLvoid* data) { 63 const GLvoid* data) {
64 bool success = true;
65 if (!buffer->CheckRange(offset, size)) { 64 if (!buffer->CheckRange(offset, size)) {
66 EXPECT_CALL(*error_state_, SetGLError(_, _, GL_INVALID_VALUE, _, _)) 65 return false;
67 .Times(1) 66 }
68 .RetiresOnSaturation(); 67 if (!buffer->IsClientSideArray()) {
69 success = false;
70 } else if (!buffer->IsClientSideArray()) {
71 EXPECT_CALL(*gl_, BufferSubData(target, offset, size, _)) 68 EXPECT_CALL(*gl_, BufferSubData(target, offset, size, _))
72 .Times(1) 69 .Times(1)
73 .RetiresOnSaturation(); 70 .RetiresOnSaturation();
74 } 71 }
75 manager_->DoBufferSubData( 72 manager_->DoBufferSubData(buffer, target, offset, size, data);
76 error_state_.get(), buffer, target, offset, size, data); 73 return true;
77 return success;
78 } 74 }
79 75
80 void RunGetMaxValueForRangeUint8Test(bool enable_primitive_restart) 76 void RunGetMaxValueForRangeUint8Test(bool enable_primitive_restart)
81 { 77 {
82 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; 78 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER;
83 const GLuint kClientBufferId = 1; 79 const GLuint kClientBufferId = 1;
84 const GLuint kServiceBufferId = 11; 80 const GLuint kServiceBufferId = 11;
85 const uint8_t data[] = {10, 9, 8, 7, 6, 0xFFu, 4, 3, 2, 1}; 81 const uint8_t data[] = {10, 9, 8, 7, 6, 0xFFu, 4, 3, 2, 1};
86 const uint8_t new_data[] = {100, 120, 110}; 82 const uint8_t new_data[] = {100, 120, 110};
87 manager_->CreateBuffer(kClientBufferId, kServiceBufferId); 83 manager_->CreateBuffer(kClientBufferId, kServiceBufferId);
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // Removing buffers after MarkContextLost cause no GL calls. 578 // Removing buffers after MarkContextLost cause no GL calls.
583 manager_->RemoveBuffer(kClient1Id); 579 manager_->RemoveBuffer(kClient1Id);
584 manager_->Destroy(); 580 manager_->Destroy();
585 // Check the resources were released. 581 // Check the resources were released.
586 buffer1 = manager_->GetBuffer(kClient1Id); 582 buffer1 = manager_->GetBuffer(kClient1Id);
587 ASSERT_TRUE(buffer1 == nullptr); 583 ASSERT_TRUE(buffer1 == nullptr);
588 } 584 }
589 585
590 } // namespace gles2 586 } // namespace gles2
591 } // namespace gpu 587 } // namespace gpu
592
593
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698