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 "ppapi/tests/test_graphics_3d.h" | 5 #include "ppapi/tests/test_graphics_3d.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 glSetCurrentContextPPAPI(kInvalidContext); | 130 glSetCurrentContextPPAPI(kInvalidContext); |
131 | 131 |
132 int32_t rv = SwapBuffersSync(&context); | 132 int32_t rv = SwapBuffersSync(&context); |
133 ASSERT_EQ(rv, PP_OK); | 133 ASSERT_EQ(rv, PP_OK); |
134 | 134 |
135 PASS(); | 135 PASS(); |
136 } | 136 } |
137 | 137 |
138 int32_t TestGraphics3D::SwapBuffersSync(pp::Graphics3D* context) { | 138 int32_t TestGraphics3D::SwapBuffersSync(pp::Graphics3D* context) { |
139 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); | 139 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
140 int32_t rv = context->SwapBuffers(callback.GetCallback()); | 140 callback.WaitForResult(context->SwapBuffers(callback.GetCallback())); |
141 if (rv != PP_OK_COMPLETIONPENDING) | 141 return callback.result(); |
142 return rv; | |
143 | |
144 return callback.WaitForResult(); | |
145 } | 142 } |
146 | 143 |
147 std::string TestGraphics3D::CheckPixelPPAPI( | 144 std::string TestGraphics3D::CheckPixelPPAPI( |
148 pp::Graphics3D* context, | 145 pp::Graphics3D* context, |
149 int x, int y, const uint8_t expected_color[4]) { | 146 int x, int y, const uint8_t expected_color[4]) { |
150 GLubyte pixel_color[4]; | 147 GLubyte pixel_color[4]; |
151 opengl_es2_->ReadPixels(context->pp_resource(), | 148 opengl_es2_->ReadPixels(context->pp_resource(), |
152 x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); | 149 x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); |
153 | 150 |
154 ASSERT_EQ(pixel_color[0], expected_color[0]); | 151 ASSERT_EQ(pixel_color[0], expected_color[0]); |
155 ASSERT_EQ(pixel_color[1], expected_color[1]); | 152 ASSERT_EQ(pixel_color[1], expected_color[1]); |
156 ASSERT_EQ(pixel_color[2], expected_color[2]); | 153 ASSERT_EQ(pixel_color[2], expected_color[2]); |
157 ASSERT_EQ(pixel_color[3], expected_color[3]); | 154 ASSERT_EQ(pixel_color[3], expected_color[3]); |
158 PASS(); | 155 PASS(); |
159 } | 156 } |
160 | 157 |
161 std::string TestGraphics3D::CheckPixelGL( | 158 std::string TestGraphics3D::CheckPixelGL( |
162 int x, int y, const uint8_t expected_color[4]) { | 159 int x, int y, const uint8_t expected_color[4]) { |
163 GLubyte pixel_color[4]; | 160 GLubyte pixel_color[4]; |
164 glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); | 161 glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); |
165 | 162 |
166 ASSERT_EQ(pixel_color[0], expected_color[0]); | 163 ASSERT_EQ(pixel_color[0], expected_color[0]); |
167 ASSERT_EQ(pixel_color[1], expected_color[1]); | 164 ASSERT_EQ(pixel_color[1], expected_color[1]); |
168 ASSERT_EQ(pixel_color[2], expected_color[2]); | 165 ASSERT_EQ(pixel_color[2], expected_color[2]); |
169 ASSERT_EQ(pixel_color[3], expected_color[3]); | 166 ASSERT_EQ(pixel_color[3], expected_color[3]); |
170 PASS(); | 167 PASS(); |
171 } | 168 } |
172 | 169 |
OLD | NEW |