| OLD | NEW |
| 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/vertex_attrib_manager.h" | 5 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "gpu/command_buffer/service/buffer_manager.h" | 8 #include "gpu/command_buffer/service/buffer_manager.h" |
| 9 #include "gpu/command_buffer/service/error_state_mock.h" |
| 9 #include "gpu/command_buffer/service/feature_info.h" | 10 #include "gpu/command_buffer/service/feature_info.h" |
| 10 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | |
| 11 #include "gpu/command_buffer/service/test_helper.h" | 11 #include "gpu/command_buffer/service/test_helper.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/gl/gl_mock.h" | 13 #include "ui/gl/gl_mock.h" |
| 14 | 14 |
| 15 using ::testing::Pointee; | 15 using ::testing::Pointee; |
| 16 using ::testing::_; | 16 using ::testing::_; |
| 17 | 17 |
| 18 namespace gpu { | 18 namespace gpu { |
| 19 namespace gles2 { | 19 namespace gles2 { |
| 20 | 20 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 EXPECT_TRUE(manager_->HaveFixedAttribs()); | 135 EXPECT_TRUE(manager_->HaveFixedAttribs()); |
| 136 manager_->SetAttribInfo(3, NULL, 4, GL_FIXED, GL_FALSE, 0, 16, 0); | 136 manager_->SetAttribInfo(3, NULL, 4, GL_FIXED, GL_FALSE, 0, 16, 0); |
| 137 EXPECT_TRUE(manager_->HaveFixedAttribs()); | 137 EXPECT_TRUE(manager_->HaveFixedAttribs()); |
| 138 manager_->SetAttribInfo(1, NULL, 4, GL_FLOAT, GL_FALSE, 0, 16, 0); | 138 manager_->SetAttribInfo(1, NULL, 4, GL_FLOAT, GL_FALSE, 0, 16, 0); |
| 139 EXPECT_TRUE(manager_->HaveFixedAttribs()); | 139 EXPECT_TRUE(manager_->HaveFixedAttribs()); |
| 140 manager_->SetAttribInfo(3, NULL, 4, GL_FLOAT, GL_FALSE, 0, 16, 0); | 140 manager_->SetAttribInfo(3, NULL, 4, GL_FLOAT, GL_FALSE, 0, 16, 0); |
| 141 EXPECT_FALSE(manager_->HaveFixedAttribs()); | 141 EXPECT_FALSE(manager_->HaveFixedAttribs()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 TEST_F(VertexAttribManagerTest, CanAccess) { | 144 TEST_F(VertexAttribManagerTest, CanAccess) { |
| 145 MockGLES2Decoder decoder; | 145 MockErrorState error_state; |
| 146 BufferManager buffer_manager(NULL, NULL); | 146 BufferManager buffer_manager(NULL, NULL); |
| 147 buffer_manager.CreateBuffer(1, 2); | 147 buffer_manager.CreateBuffer(1, 2); |
| 148 Buffer* buffer = buffer_manager.GetBuffer(1); | 148 Buffer* buffer = buffer_manager.GetBuffer(1); |
| 149 ASSERT_TRUE(buffer != NULL); | 149 ASSERT_TRUE(buffer != NULL); |
| 150 | 150 |
| 151 VertexAttrib* attrib = manager_->GetVertexAttrib(1); | 151 VertexAttrib* attrib = manager_->GetVertexAttrib(1); |
| 152 | 152 |
| 153 EXPECT_TRUE(attrib->CanAccess(0)); | 153 EXPECT_TRUE(attrib->CanAccess(0)); |
| 154 manager_->Enable(1, true); | 154 manager_->Enable(1, true); |
| 155 EXPECT_FALSE(attrib->CanAccess(0)); | 155 EXPECT_FALSE(attrib->CanAccess(0)); |
| 156 | 156 |
| 157 manager_->SetAttribInfo(1, buffer, 4, GL_FLOAT, GL_FALSE, 0, 16, 0); | 157 manager_->SetAttribInfo(1, buffer, 4, GL_FLOAT, GL_FALSE, 0, 16, 0); |
| 158 EXPECT_FALSE(attrib->CanAccess(0)); | 158 EXPECT_FALSE(attrib->CanAccess(0)); |
| 159 | 159 |
| 160 EXPECT_TRUE(buffer_manager.SetTarget(buffer, GL_ARRAY_BUFFER)); | 160 EXPECT_TRUE(buffer_manager.SetTarget(buffer, GL_ARRAY_BUFFER)); |
| 161 TestHelper::DoBufferData( | 161 TestHelper::DoBufferData( |
| 162 gl_.get(), &decoder, &buffer_manager, buffer, 15, GL_STATIC_DRAW, NULL, | 162 gl_.get(), &error_state, &buffer_manager, buffer, 15, GL_STATIC_DRAW, |
| 163 GL_NO_ERROR); | 163 NULL, GL_NO_ERROR); |
| 164 | 164 |
| 165 EXPECT_FALSE(attrib->CanAccess(0)); | 165 EXPECT_FALSE(attrib->CanAccess(0)); |
| 166 TestHelper::DoBufferData( | 166 TestHelper::DoBufferData( |
| 167 gl_.get(), &decoder, &buffer_manager, buffer, 16, GL_STATIC_DRAW, NULL, | 167 gl_.get(), &error_state, &buffer_manager, buffer, 16, GL_STATIC_DRAW, |
| 168 GL_NO_ERROR); | 168 NULL, GL_NO_ERROR); |
| 169 EXPECT_TRUE(attrib->CanAccess(0)); | 169 EXPECT_TRUE(attrib->CanAccess(0)); |
| 170 EXPECT_FALSE(attrib->CanAccess(1)); | 170 EXPECT_FALSE(attrib->CanAccess(1)); |
| 171 | 171 |
| 172 manager_->SetAttribInfo(1, buffer, 4, GL_FLOAT, GL_FALSE, 0, 16, 1); | 172 manager_->SetAttribInfo(1, buffer, 4, GL_FLOAT, GL_FALSE, 0, 16, 1); |
| 173 EXPECT_FALSE(attrib->CanAccess(0)); | 173 EXPECT_FALSE(attrib->CanAccess(0)); |
| 174 | 174 |
| 175 TestHelper::DoBufferData( | 175 TestHelper::DoBufferData( |
| 176 gl_.get(), &decoder, &buffer_manager, buffer, 32, GL_STATIC_DRAW, NULL, | 176 gl_.get(), &error_state, &buffer_manager, buffer, 32, GL_STATIC_DRAW, |
| 177 GL_NO_ERROR); | 177 NULL, GL_NO_ERROR); |
| 178 EXPECT_TRUE(attrib->CanAccess(0)); | 178 EXPECT_TRUE(attrib->CanAccess(0)); |
| 179 EXPECT_FALSE(attrib->CanAccess(1)); | 179 EXPECT_FALSE(attrib->CanAccess(1)); |
| 180 manager_->SetAttribInfo(1, buffer, 4, GL_FLOAT, GL_FALSE, 0, 16, 0); | 180 manager_->SetAttribInfo(1, buffer, 4, GL_FLOAT, GL_FALSE, 0, 16, 0); |
| 181 EXPECT_TRUE(attrib->CanAccess(1)); | 181 EXPECT_TRUE(attrib->CanAccess(1)); |
| 182 manager_->SetAttribInfo(1, buffer, 4, GL_FLOAT, GL_FALSE, 0, 20, 0); | 182 manager_->SetAttribInfo(1, buffer, 4, GL_FLOAT, GL_FALSE, 0, 20, 0); |
| 183 EXPECT_TRUE(attrib->CanAccess(0)); | 183 EXPECT_TRUE(attrib->CanAccess(0)); |
| 184 EXPECT_FALSE(attrib->CanAccess(1)); | 184 EXPECT_FALSE(attrib->CanAccess(1)); |
| 185 | 185 |
| 186 // The VertexAttribManager must be destroyed before the BufferManager | 186 // The VertexAttribManager must be destroyed before the BufferManager |
| 187 // so it releases its buffers. | 187 // so it releases its buffers. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 buffer_manager.Destroy(false); | 224 buffer_manager.Destroy(false); |
| 225 } | 225 } |
| 226 | 226 |
| 227 // TODO(gman): Test ValidateBindings | 227 // TODO(gman): Test ValidateBindings |
| 228 // TODO(gman): Test ValidateBindings with client side arrays. | 228 // TODO(gman): Test ValidateBindings with client side arrays. |
| 229 | 229 |
| 230 } // namespace gles2 | 230 } // namespace gles2 |
| 231 } // namespace gpu | 231 } // namespace gpu |
| 232 | 232 |
| 233 | 233 |
| OLD | NEW |