| 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 #ifndef GL_GLEXT_PROTOTYPES | 5 #ifndef GL_GLEXT_PROTOTYPES |
| 6 #define GL_GLEXT_PROTOTYPES | 6 #define GL_GLEXT_PROTOTYPES |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| 11 #include <GLES2/gl2extchromium.h> | 11 #include <GLES2/gl2extchromium.h> |
| 12 #include <stdint.h> |
| 12 | 13 |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "gpu/command_buffer/tests/gl_manager.h" | 18 #include "gpu/command_buffer/tests/gl_manager.h" |
| 18 #include "gpu/command_buffer/tests/gl_test_utils.h" | 19 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 19 #include "gpu/config/gpu_switches.h" | 20 #include "gpu/config/gpu_switches.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 105 |
| 105 INSTANTIATE_TEST_CASE_P(GLClearFramebufferTestWithParam, | 106 INSTANTIATE_TEST_CASE_P(GLClearFramebufferTestWithParam, |
| 106 GLClearFramebufferTest, | 107 GLClearFramebufferTest, |
| 107 ::testing::Values(true, false)); | 108 ::testing::Values(true, false)); |
| 108 | 109 |
| 109 TEST_P(GLClearFramebufferTest, ClearColor) { | 110 TEST_P(GLClearFramebufferTest, ClearColor) { |
| 110 glClearColor(1.0f, 0.5f, 0.25f, 0.5f); | 111 glClearColor(1.0f, 0.5f, 0.25f, 0.5f); |
| 111 glClear(GL_COLOR_BUFFER_BIT); | 112 glClear(GL_COLOR_BUFFER_BIT); |
| 112 | 113 |
| 113 // Verify. | 114 // Verify. |
| 114 const uint8 expected[] = {255, 128, 64, 128}; | 115 const uint8_t expected[] = {255, 128, 64, 128}; |
| 115 EXPECT_TRUE( | 116 EXPECT_TRUE( |
| 116 GLTestHelper::CheckPixels(0, 0, 1, 1, 1 /* tolerance */, expected)); | 117 GLTestHelper::CheckPixels(0, 0, 1, 1, 1 /* tolerance */, expected)); |
| 117 } | 118 } |
| 118 | 119 |
| 119 TEST_P(GLClearFramebufferTest, ClearColorWithMask) { | 120 TEST_P(GLClearFramebufferTest, ClearColorWithMask) { |
| 120 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); | 121 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); |
| 121 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); | 122 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
| 122 glClear(GL_COLOR_BUFFER_BIT); | 123 glClear(GL_COLOR_BUFFER_BIT); |
| 123 | 124 |
| 124 // Verify. | 125 // Verify. |
| 125 const uint8 expected[] = {255, 0, 0, 0}; | 126 const uint8_t expected[] = {255, 0, 0, 0}; |
| 126 EXPECT_TRUE( | 127 EXPECT_TRUE( |
| 127 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); | 128 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); |
| 128 } | 129 } |
| 129 | 130 |
| 130 // crbug.com/434094 | 131 // crbug.com/434094 |
| 131 #if !defined(OS_MACOSX) | 132 #if !defined(OS_MACOSX) |
| 132 TEST_P(GLClearFramebufferTest, ClearColorWithScissor) { | 133 TEST_P(GLClearFramebufferTest, ClearColorWithScissor) { |
| 133 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); | 134 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
| 134 glClear(GL_COLOR_BUFFER_BIT); | 135 glClear(GL_COLOR_BUFFER_BIT); |
| 135 | 136 |
| 136 // Verify. | 137 // Verify. |
| 137 const uint8 expected[] = {255, 255, 255, 255}; | 138 const uint8_t expected[] = {255, 255, 255, 255}; |
| 138 EXPECT_TRUE( | 139 EXPECT_TRUE( |
| 139 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); | 140 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); |
| 140 | 141 |
| 141 glScissor(0, 0, 0, 0); | 142 glScissor(0, 0, 0, 0); |
| 142 glEnable(GL_SCISSOR_TEST); | 143 glEnable(GL_SCISSOR_TEST); |
| 143 glClearColor(0, 0, 0, 0); | 144 glClearColor(0, 0, 0, 0); |
| 144 glClear(GL_COLOR_BUFFER_BIT); | 145 glClear(GL_COLOR_BUFFER_BIT); |
| 145 | 146 |
| 146 // Verify - no changes. | 147 // Verify - no changes. |
| 147 EXPECT_TRUE( | 148 EXPECT_TRUE( |
| 148 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); | 149 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, expected)); |
| 149 } | 150 } |
| 150 #endif | 151 #endif |
| 151 | 152 |
| 152 TEST_P(GLClearFramebufferTest, ClearDepthStencil) { | 153 TEST_P(GLClearFramebufferTest, ClearDepthStencil) { |
| 153 const GLuint kStencilRef = 1 << 2; | 154 const GLuint kStencilRef = 1 << 2; |
| 154 InitDraw(); | 155 InitDraw(); |
| 155 SetDrawColor(1.0f, 0.0f, 0.0f, 1.0f); | 156 SetDrawColor(1.0f, 0.0f, 0.0f, 1.0f); |
| 156 DrawQuad(); | 157 DrawQuad(); |
| 157 // Verify. | 158 // Verify. |
| 158 const uint8 kRed[] = {255, 0, 0, 255}; | 159 const uint8_t kRed[] = {255, 0, 0, 255}; |
| 159 const uint8 kGreen[] = {0, 255, 0, 255}; | 160 const uint8_t kGreen[] = {0, 255, 0, 255}; |
| 160 EXPECT_TRUE( | 161 EXPECT_TRUE( |
| 161 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed)); | 162 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed)); |
| 162 | 163 |
| 163 glClearStencil(kStencilRef); | 164 glClearStencil(kStencilRef); |
| 164 glClear(GL_STENCIL_BUFFER_BIT); | 165 glClear(GL_STENCIL_BUFFER_BIT); |
| 165 glEnable(GL_STENCIL_TEST); | 166 glEnable(GL_STENCIL_TEST); |
| 166 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); | 167 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); |
| 167 glStencilFunc(GL_NOTEQUAL, kStencilRef, 0xFFFFFFFF); | 168 glStencilFunc(GL_NOTEQUAL, kStencilRef, 0xFFFFFFFF); |
| 168 | 169 |
| 169 SetDrawColor(0.0f, 1.0f, 0.0f, 1.0f); | 170 SetDrawColor(0.0f, 1.0f, 0.0f, 1.0f); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 191 | 192 |
| 192 glClearDepthf(0.9f); | 193 glClearDepthf(0.9f); |
| 193 glClear(GL_DEPTH_BUFFER_BIT); | 194 glClear(GL_DEPTH_BUFFER_BIT); |
| 194 DrawQuad(); | 195 DrawQuad(); |
| 195 // Verify - depth test should have passed, so red. | 196 // Verify - depth test should have passed, so red. |
| 196 EXPECT_TRUE( | 197 EXPECT_TRUE( |
| 197 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed)); | 198 GLTestHelper::CheckPixels(0, 0, 1, 1, 0 /* tolerance */, kRed)); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace gpu | 201 } // namespace gpu |
| OLD | NEW |