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

Unified Diff: gpu/command_buffer/service/test_helper.cc

Issue 10635011: Add glBindUniformLocationCHROMIUM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/test_helper.cc
diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc
index 33a17036ab434e88ed2c220f060cea6ba1bff858..bd95c4f7e5fbe51540ef5df2c503cd62ccde4624 100644
--- a/gpu/command_buffer/service/test_helper.cc
+++ b/gpu/command_buffer/service/test_helper.cc
@@ -12,7 +12,6 @@
#include "gpu/command_buffer/service/program_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <algorithm>
#include <string.h>
using ::testing::_;
@@ -369,17 +368,6 @@ void TestHelper::SetupExpectationsForClearingUniforms(
}
}
-namespace {
-
-struct UniformInfoComparer {
- bool operator()(const TestHelper::UniformInfo& lhs,
- const TestHelper::UniformInfo& rhs) const {
- return strcmp(lhs.name, rhs.name) < 0;
- }
-};
-
-} // anonymous namespace.
-
void TestHelper::SetupShader(
::gfx::MockGLInterface* gl,
AttribInfo* attribs, size_t num_attribs,
@@ -436,9 +424,6 @@ void TestHelper::SetupShader(
.WillOnce(SetArgumentPointee<2>(num_uniforms))
.RetiresOnSaturation();
- scoped_array<UniformInfo> sorted_uniforms(new UniformInfo[num_uniforms]);
- size_t num_valid_uniforms = 0;
-
size_t max_uniform_len = 0;
for (size_t ii = 0; ii < num_uniforms; ++ii) {
size_t len = strlen(uniforms[ii].name) + 1;
@@ -460,33 +445,37 @@ void TestHelper::SetupShader(
SetArrayArgument<6>(info.name,
info.name + strlen(info.name) + 1)))
.RetiresOnSaturation();
- if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) {
- sorted_uniforms[num_valid_uniforms++] = uniforms[ii];
- }
}
- std::sort(
- &sorted_uniforms[0], &sorted_uniforms[num_valid_uniforms],
- UniformInfoComparer());
-
- for (size_t ii = 0; ii < num_valid_uniforms; ++ii) {
- const UniformInfo& info = sorted_uniforms[ii];
- EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(info.name)))
- .WillOnce(Return(info.real_location))
- .RetiresOnSaturation();
- if (info.size > 1) {
- std::string base_name = info.name;
- size_t array_pos = base_name.rfind("[0]");
- if (base_name.size() > 3 && array_pos == base_name.size() - 3) {
- base_name = base_name.substr(0, base_name.size() - 3);
+ for (int pass = 0; pass < 2; ++pass) {
+ for (size_t ii = 0; ii < num_uniforms; ++ii) {
+ const UniformInfo& info = uniforms[ii];
+ if (ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) {
+ continue;
}
- for (GLsizei jj = 1; jj < info.size; ++jj) {
- std::string element_name(
- std::string(base_name) + "[" + base::IntToString(jj) + "]");
- EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(element_name)))
- .WillOnce(Return(info.real_location + jj * 2))
+ if (pass == 0) {
+ EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(info.name)))
+ .WillOnce(Return(info.real_location))
.RetiresOnSaturation();
}
+ if ((pass == 0 && info.desired_location >= 0) ||
+ (pass == 1 && info.desired_location < 0)) {
+ if (info.size > 1) {
+ std::string base_name = info.name;
+ size_t array_pos = base_name.rfind("[0]");
+ if (base_name.size() > 3 && array_pos == base_name.size() - 3) {
+ base_name = base_name.substr(0, base_name.size() - 3);
+ }
+ for (GLsizei jj = 1; jj < info.size; ++jj) {
+ std::string element_name(
+ std::string(base_name) + "[" + base::IntToString(jj) + "]");
+ EXPECT_CALL(*gl, GetUniformLocation(
+ service_id, StrEq(element_name)))
+ .WillOnce(Return(info.real_location + jj * 2))
+ .RetiresOnSaturation();
+ }
+ }
+ }
}
}
}
« no previous file with comments | « gpu/command_buffer/service/test_helper.h ('k') | gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698