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/program_manager.h" | 5 #include "gpu/command_buffer/service/program_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace { | 37 namespace { |
38 const uint32 kMaxVaryingVectors = 8; | 38 const uint32 kMaxVaryingVectors = 8; |
39 | 39 |
40 void ShaderCacheCb(const std::string& key, const std::string& shader) {} | 40 void ShaderCacheCb(const std::string& key, const std::string& shader) {} |
41 } // namespace anonymous | 41 } // namespace anonymous |
42 | 42 |
43 class ProgramManagerTest : public GpuServiceTest { | 43 class ProgramManagerTest : public GpuServiceTest { |
44 public: | 44 public: |
45 ProgramManagerTest() : manager_(NULL, kMaxVaryingVectors) { } | 45 ProgramManagerTest() : manager_(NULL, kMaxVaryingVectors) { } |
46 virtual ~ProgramManagerTest() { | 46 ~ProgramManagerTest() override { manager_.Destroy(false); } |
47 manager_.Destroy(false); | |
48 } | |
49 | 47 |
50 protected: | 48 protected: |
51 ProgramManager manager_; | 49 ProgramManager manager_; |
52 }; | 50 }; |
53 | 51 |
54 TEST_F(ProgramManagerTest, Basic) { | 52 TEST_F(ProgramManagerTest, Basic) { |
55 const GLuint kClient1Id = 1; | 53 const GLuint kClient1Id = 1; |
56 const GLuint kService1Id = 11; | 54 const GLuint kService1Id = 11; |
57 const GLuint kClient2Id = 2; | 55 const GLuint kClient2Id = 2; |
58 // Check we can create program. | 56 // Check we can create program. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 EXPECT_FALSE(program1->CanLink()); | 122 EXPECT_FALSE(program1->CanLink()); |
125 EXPECT_TRUE(program1->log_info() == NULL); | 123 EXPECT_TRUE(program1->log_info() == NULL); |
126 } | 124 } |
127 | 125 |
128 class ProgramManagerWithShaderTest : public GpuServiceTest { | 126 class ProgramManagerWithShaderTest : public GpuServiceTest { |
129 public: | 127 public: |
130 ProgramManagerWithShaderTest() | 128 ProgramManagerWithShaderTest() |
131 : manager_(NULL, kMaxVaryingVectors), program_(NULL) { | 129 : manager_(NULL, kMaxVaryingVectors), program_(NULL) { |
132 } | 130 } |
133 | 131 |
134 virtual ~ProgramManagerWithShaderTest() { | 132 ~ProgramManagerWithShaderTest() override { |
135 manager_.Destroy(false); | 133 manager_.Destroy(false); |
136 shader_manager_.Destroy(false); | 134 shader_manager_.Destroy(false); |
137 } | 135 } |
138 | 136 |
139 static const GLint kNumVertexAttribs = 16; | 137 static const GLint kNumVertexAttribs = 16; |
140 | 138 |
141 static const GLuint kClientProgramId = 123; | 139 static const GLuint kClientProgramId = 123; |
142 static const GLuint kServiceProgramId = 456; | 140 static const GLuint kServiceProgramId = 456; |
143 static const GLuint kVertexShaderClientId = 201; | 141 static const GLuint kVertexShaderClientId = 201; |
144 static const GLuint kFragmentShaderClientId = 202; | 142 static const GLuint kFragmentShaderClientId = 202; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 206 |
209 typedef struct { | 207 typedef struct { |
210 GLenum type; | 208 GLenum type; |
211 GLint size; | 209 GLint size; |
212 GLenum precision; | 210 GLenum precision; |
213 bool static_use; | 211 bool static_use; |
214 std::string name; | 212 std::string name; |
215 VarCategory category; | 213 VarCategory category; |
216 } VarInfo; | 214 } VarInfo; |
217 | 215 |
218 virtual void SetUp() { | 216 void SetUp() override { |
219 GpuServiceTest::SetUp(); | 217 GpuServiceTest::SetUp(); |
220 | 218 |
221 SetupDefaultShaderExpectations(); | 219 SetupDefaultShaderExpectations(); |
222 | 220 |
223 Shader* vertex_shader = shader_manager_.CreateShader( | 221 Shader* vertex_shader = shader_manager_.CreateShader( |
224 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); | 222 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); |
225 Shader* fragment_shader = | 223 Shader* fragment_shader = |
226 shader_manager_.CreateShader( | 224 shader_manager_.CreateShader( |
227 kFragmentShaderClientId, kFragmentShaderServiceId, | 225 kFragmentShaderClientId, kFragmentShaderServiceId, |
228 GL_FRAGMENT_SHADER); | 226 GL_FRAGMENT_SHADER); |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 static const GLuint kVertexShaderServiceId = 3; | 1570 static const GLuint kVertexShaderServiceId = 3; |
1573 static const GLuint kFragmentShaderServiceId = 30; | 1571 static const GLuint kFragmentShaderServiceId = 30; |
1574 | 1572 |
1575 ProgramManagerWithCacheTest() | 1573 ProgramManagerWithCacheTest() |
1576 : cache_(new MockProgramCache()), | 1574 : cache_(new MockProgramCache()), |
1577 manager_(cache_.get(), kMaxVaryingVectors), | 1575 manager_(cache_.get(), kMaxVaryingVectors), |
1578 vertex_shader_(NULL), | 1576 vertex_shader_(NULL), |
1579 fragment_shader_(NULL), | 1577 fragment_shader_(NULL), |
1580 program_(NULL) { | 1578 program_(NULL) { |
1581 } | 1579 } |
1582 virtual ~ProgramManagerWithCacheTest() { | 1580 ~ProgramManagerWithCacheTest() override { |
1583 manager_.Destroy(false); | 1581 manager_.Destroy(false); |
1584 shader_manager_.Destroy(false); | 1582 shader_manager_.Destroy(false); |
1585 } | 1583 } |
1586 | 1584 |
1587 protected: | 1585 protected: |
1588 virtual void SetUp() { | 1586 void SetUp() override { |
1589 GpuServiceTest::SetUp(); | 1587 GpuServiceTest::SetUp(); |
1590 | 1588 |
1591 vertex_shader_ = shader_manager_.CreateShader( | 1589 vertex_shader_ = shader_manager_.CreateShader( |
1592 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); | 1590 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); |
1593 fragment_shader_ = shader_manager_.CreateShader( | 1591 fragment_shader_ = shader_manager_.CreateShader( |
1594 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); | 1592 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); |
1595 ASSERT_TRUE(vertex_shader_ != NULL); | 1593 ASSERT_TRUE(vertex_shader_ != NULL); |
1596 ASSERT_TRUE(fragment_shader_ != NULL); | 1594 ASSERT_TRUE(fragment_shader_ != NULL); |
1597 vertex_shader_->set_source("lka asjf bjajsdfj"); | 1595 vertex_shader_->set_source("lka asjf bjajsdfj"); |
1598 fragment_shader_->set_source("lka asjf a fasgag 3rdsf3 bjajsdfj"); | 1596 fragment_shader_->set_source("lka asjf a fasgag 3rdsf3 bjajsdfj"); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 SetExpectationsForProgramLoad(ProgramCache::PROGRAM_LOAD_SUCCESS); | 1780 SetExpectationsForProgramLoad(ProgramCache::PROGRAM_LOAD_SUCCESS); |
1783 SetExpectationsForNotCachingProgram(); | 1781 SetExpectationsForNotCachingProgram(); |
1784 SetExpectationsForProgramLoadSuccess(); | 1782 SetExpectationsForProgramLoadSuccess(); |
1785 | 1783 |
1786 EXPECT_TRUE(program_->Link(NULL, NULL, NULL, | 1784 EXPECT_TRUE(program_->Link(NULL, NULL, NULL, |
1787 Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb))); | 1785 Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb))); |
1788 } | 1786 } |
1789 | 1787 |
1790 } // namespace gles2 | 1788 } // namespace gles2 |
1791 } // namespace gpu | 1789 } // namespace gpu |
OLD | NEW |