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

Side by Side Diff: gpu/command_buffer/tests/gl_readback_unittest.cc

Issue 2550583002: gpu: Thread-safe command buffer state lookup. (Closed)
Patch Set: jbauman's review Created 4 years 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
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.cc ('k') | gpu/gles2_conform_support/egl/context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 namespace gpu { 25 namespace gpu {
26 26
27 class GLReadbackTest : public testing::Test { 27 class GLReadbackTest : public testing::Test {
28 protected: 28 protected:
29 void SetUp() override { gl_.Initialize(GLManager::Options()); } 29 void SetUp() override { gl_.Initialize(GLManager::Options()); }
30 30
31 void TearDown() override { gl_.Destroy(); } 31 void TearDown() override { gl_.Destroy(); }
32 32
33 static void WaitForQueryCallback(int q, base::Closure cb) { 33 void WaitForQueryCallback(int q, base::Closure cb) {
34 unsigned int done = 0; 34 unsigned int done = 0;
35 gl_.PerformIdleWork();
35 glGetQueryObjectuivEXT(q, GL_QUERY_RESULT_AVAILABLE_EXT, &done); 36 glGetQueryObjectuivEXT(q, GL_QUERY_RESULT_AVAILABLE_EXT, &done);
36 if (done) { 37 if (done) {
37 cb.Run(); 38 cb.Run();
38 } else { 39 } else {
39 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 40 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
40 FROM_HERE, base::Bind(&WaitForQueryCallback, q, cb), 41 FROM_HERE, base::Bind(&GLReadbackTest::WaitForQueryCallback,
42 base::Unretained(this), q, cb),
41 base::TimeDelta::FromMilliseconds(3)); 43 base::TimeDelta::FromMilliseconds(3));
42 } 44 }
43 } 45 }
44 46
45 void WaitForQuery(int q) { 47 void WaitForQuery(int q) {
46 base::RunLoop run_loop; 48 base::RunLoop run_loop;
47 WaitForQueryCallback(q, run_loop.QuitClosure()); 49 WaitForQueryCallback(q, run_loop.QuitClosure());
48 run_loop.Run(); 50 run_loop.Run();
49 } 51 }
50 52
51 GLManager gl_; 53 GLManager gl_;
52 }; 54 };
53 55
54
55 TEST_F(GLReadbackTest, ReadPixelsWithPBOAndQuery) { 56 TEST_F(GLReadbackTest, ReadPixelsWithPBOAndQuery) {
56 const GLint kBytesPerPixel = 4; 57 const GLint kBytesPerPixel = 4;
57 const GLint kWidth = 2; 58 const GLint kWidth = 2;
58 const GLint kHeight = 2; 59 const GLint kHeight = 2;
59 60
60 GLuint b, q; 61 GLuint b, q;
61 glClearColor(0.0, 0.0, 1.0, 1.0); 62 glClearColor(0.0, 0.0, 1.0, 1.0);
62 glClear(GL_COLOR_BUFFER_BIT); 63 glClear(GL_COLOR_BUFFER_BIT);
63 glGenBuffers(1, &b); 64 glGenBuffers(1, &b);
64 glGenQueriesEXT(1, &q); 65 glGenQueriesEXT(1, &q);
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 323
323 glDeleteFramebuffers(1, &framebuffer); 324 glDeleteFramebuffers(1, &framebuffer);
324 glDeleteTextures(1, &texture_id); 325 glDeleteTextures(1, &texture_id);
325 } 326 }
326 327
327 glDeleteBuffers(1, &vertex_buffer); 328 glDeleteBuffers(1, &vertex_buffer);
328 glDeleteProgram(program); 329 glDeleteProgram(program);
329 } 330 }
330 331
331 } // namespace gpu 332 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.cc ('k') | gpu/gles2_conform_support/egl/context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698