| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
| 6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
| 7 #include <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/location.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/thread_task_runner_handle.h" |
| 15 #include "gpu/command_buffer/tests/gl_manager.h" | 17 #include "gpu/command_buffer/tests/gl_manager.h" |
| 16 #include "gpu/command_buffer/tests/gl_test_utils.h" | 18 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 21 |
| 20 namespace gpu { | 22 namespace gpu { |
| 21 | 23 |
| 22 class GLReadbackTest : public testing::Test { | 24 class GLReadbackTest : public testing::Test { |
| 23 protected: | 25 protected: |
| 24 void SetUp() override { gl_.Initialize(GLManager::Options()); } | 26 void SetUp() override { gl_.Initialize(GLManager::Options()); } |
| 25 | 27 |
| 26 void TearDown() override { gl_.Destroy(); } | 28 void TearDown() override { gl_.Destroy(); } |
| 27 | 29 |
| 28 static void WaitForQueryCallback(int q, base::Closure cb) { | 30 static void WaitForQueryCallback(int q, base::Closure cb) { |
| 29 unsigned int done = 0; | 31 unsigned int done = 0; |
| 30 glGetQueryObjectuivEXT(q, GL_QUERY_RESULT_AVAILABLE_EXT, &done); | 32 glGetQueryObjectuivEXT(q, GL_QUERY_RESULT_AVAILABLE_EXT, &done); |
| 31 if (done) { | 33 if (done) { |
| 32 cb.Run(); | 34 cb.Run(); |
| 33 } else { | 35 } else { |
| 34 base::MessageLoop::current()->PostDelayedTask( | 36 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 35 FROM_HERE, | 37 FROM_HERE, base::Bind(&WaitForQueryCallback, q, cb), |
| 36 base::Bind(&WaitForQueryCallback, q, cb), | |
| 37 base::TimeDelta::FromMilliseconds(3)); | 38 base::TimeDelta::FromMilliseconds(3)); |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| 41 void WaitForQuery(int q) { | 42 void WaitForQuery(int q) { |
| 42 base::RunLoop run_loop; | 43 base::RunLoop run_loop; |
| 43 WaitForQueryCallback(q, run_loop.QuitClosure()); | 44 WaitForQueryCallback(q, run_loop.QuitClosure()); |
| 44 run_loop.Run(); | 45 run_loop.Run(); |
| 45 } | 46 } |
| 46 | 47 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 310 |
| 310 glDeleteFramebuffers(1, &framebuffer); | 311 glDeleteFramebuffers(1, &framebuffer); |
| 311 glDeleteTextures(1, &texture_id); | 312 glDeleteTextures(1, &texture_id); |
| 312 } | 313 } |
| 313 | 314 |
| 314 glDeleteBuffers(1, &vertex_buffer); | 315 glDeleteBuffers(1, &vertex_buffer); |
| 315 glDeleteProgram(program); | 316 glDeleteProgram(program); |
| 316 } | 317 } |
| 317 | 318 |
| 318 } // namespace gpu | 319 } // namespace gpu |
| OLD | NEW |