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

Side by Side Diff: ppapi/tests/test_graphics_3d.cc

Issue 7737013: Move PPAPI graphics3d and opengles interfaces out of Dev. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_graphics_3d.h ('k') | ppapi/thunk/ppb_graphics_3d_api.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 8
9 #include "ppapi/c/dev/ppb_opengles_dev.h"
10 #include "ppapi/c/dev/ppb_testing_dev.h" 9 #include "ppapi/c/dev/ppb_testing_dev.h"
11 #include "ppapi/cpp/dev/graphics_3d_dev.h" 10 #include "ppapi/c/ppb_opengles.h"
11 #include "ppapi/cpp/graphics_3d.h"
12 #include "ppapi/cpp/module.h" 12 #include "ppapi/cpp/module.h"
13 #include "ppapi/tests/test_utils.h" 13 #include "ppapi/tests/test_utils.h"
14 #include "ppapi/tests/testing_instance.h" 14 #include "ppapi/tests/testing_instance.h"
15 15
16 REGISTER_TEST_CASE(Graphics3D); 16 REGISTER_TEST_CASE(Graphics3D);
17 17
18 bool TestGraphics3D::Init() { 18 bool TestGraphics3D::Init() {
19 opengl_es2_ = reinterpret_cast<const PPB_OpenGLES2_Dev*>( 19 opengl_es2_ = reinterpret_cast<const PPB_OpenGLES2*>(
20 pp::Module::Get()->GetBrowserInterface(PPB_OPENGLES2_DEV_INTERFACE)); 20 pp::Module::Get()->GetBrowserInterface(PPB_OPENGLES2_INTERFACE));
21 return opengl_es2_ && InitTestingInterface(); 21 return opengl_es2_ && InitTestingInterface();
22 } 22 }
23 23
24 void TestGraphics3D::RunTest() { 24 void TestGraphics3D::RunTest() {
25 RUN_TEST(Frame); 25 RUN_TEST(Frame);
26 } 26 }
27 27
28 std::string TestGraphics3D::TestFrame() { 28 std::string TestGraphics3D::TestFrame() {
29 const int width = 16; 29 const int width = 16;
30 const int height = 16; 30 const int height = 16;
31 const int32_t attribs[] = { 31 const int32_t attribs[] = {
32 PP_GRAPHICS3DATTRIB_WIDTH, width, 32 PP_GRAPHICS3DATTRIB_WIDTH, width,
33 PP_GRAPHICS3DATTRIB_HEIGHT, height, 33 PP_GRAPHICS3DATTRIB_HEIGHT, height,
34 PP_GRAPHICS3DATTRIB_NONE 34 PP_GRAPHICS3DATTRIB_NONE
35 }; 35 };
36 pp::Graphics3D_Dev context(*instance_, pp::Graphics3D_Dev(), attribs); 36 pp::Graphics3D context(*instance_, pp::Graphics3D(), attribs);
37 ASSERT_FALSE(context.is_null()); 37 ASSERT_FALSE(context.is_null());
38 38
39 // Clear color buffer to opaque red. 39 // Clear color buffer to opaque red.
40 opengl_es2_->ClearColor(context.pp_resource(), 1.0f, 0.0f, 0.0f, 1.0f); 40 opengl_es2_->ClearColor(context.pp_resource(), 1.0f, 0.0f, 0.0f, 1.0f);
41 opengl_es2_->Clear(context.pp_resource(), GL_COLOR_BUFFER_BIT); 41 opengl_es2_->Clear(context.pp_resource(), GL_COLOR_BUFFER_BIT);
42 // Check if the color buffer has opaque red. 42 // Check if the color buffer has opaque red.
43 const uint8_t red_color[4] = {255, 0, 0, 255}; 43 const uint8_t red_color[4] = {255, 0, 0, 255};
44 std::string error = TestPixel(&context, width/2, height/2, red_color); 44 std::string error = TestPixel(&context, width/2, height/2, red_color);
45 if (!error.empty()) 45 if (!error.empty())
46 return error; 46 return error;
47 47
48 int32_t rv = SwapBuffersSync(&context); 48 int32_t rv = SwapBuffersSync(&context);
49 ASSERT_EQ(rv, PP_OK); 49 ASSERT_EQ(rv, PP_OK);
50 PASS(); 50 PASS();
51 } 51 }
52 52
53 int32_t TestGraphics3D::SwapBuffersSync(pp::Graphics3D_Dev* context) { 53 int32_t TestGraphics3D::SwapBuffersSync(pp::Graphics3D* context) {
54 TestCompletionCallback callback(instance_->pp_instance(), true); 54 TestCompletionCallback callback(instance_->pp_instance(), true);
55 int32_t rv = context->SwapBuffers(callback); 55 int32_t rv = context->SwapBuffers(callback);
56 if (rv != PP_OK_COMPLETIONPENDING) 56 if (rv != PP_OK_COMPLETIONPENDING)
57 return rv; 57 return rv;
58 58
59 return callback.WaitForResult(); 59 return callback.WaitForResult();
60 } 60 }
61 61
62 std::string TestGraphics3D::TestPixel( 62 std::string TestGraphics3D::TestPixel(
63 pp::Graphics3D_Dev* context, 63 pp::Graphics3D* context,
64 int x, int y, const uint8_t expected_color[4]) { 64 int x, int y, const uint8_t expected_color[4]) {
65 GLubyte pixel_color[4]; 65 GLubyte pixel_color[4];
66 opengl_es2_->ReadPixels(context->pp_resource(), 66 opengl_es2_->ReadPixels(context->pp_resource(),
67 x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); 67 x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color);
68 68
69 ASSERT_EQ(pixel_color[0], expected_color[0]); 69 ASSERT_EQ(pixel_color[0], expected_color[0]);
70 ASSERT_EQ(pixel_color[1], expected_color[1]); 70 ASSERT_EQ(pixel_color[1], expected_color[1]);
71 ASSERT_EQ(pixel_color[2], expected_color[2]); 71 ASSERT_EQ(pixel_color[2], expected_color[2]);
72 ASSERT_EQ(pixel_color[3], expected_color[3]); 72 ASSERT_EQ(pixel_color[3], expected_color[3]);
73 PASS(); 73 PASS();
74 } 74 }
75 75
OLDNEW
« no previous file with comments | « ppapi/tests/test_graphics_3d.h ('k') | ppapi/thunk/ppb_graphics_3d_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698