| 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "gpu/command_buffer/service/test_helper.h" | 28 #include "gpu/command_buffer/service/test_helper.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 30 #include "ui/gl/gl_implementation.h" | 30 #include "ui/gl/gl_implementation.h" |
| 31 #include "ui/gl/gl_mock.h" | 31 #include "ui/gl/gl_mock.h" |
| 32 #include "ui/gl/gl_surface_stub.h" | 32 #include "ui/gl/gl_surface_stub.h" |
| 33 | 33 |
| 34 #if !defined(GL_DEPTH24_STENCIL8) | 34 #if !defined(GL_DEPTH24_STENCIL8) |
| 35 #define GL_DEPTH24_STENCIL8 0x88F0 | 35 #define GL_DEPTH24_STENCIL8 0x88F0 |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 using ::gfx::MockGLInterface; | 38 using ::gl::MockGLInterface; |
| 39 using ::testing::_; | 39 using ::testing::_; |
| 40 using ::testing::AnyNumber; | 40 using ::testing::AnyNumber; |
| 41 using ::testing::DoAll; | 41 using ::testing::DoAll; |
| 42 using ::testing::InSequence; | 42 using ::testing::InSequence; |
| 43 using ::testing::Invoke; | 43 using ::testing::Invoke; |
| 44 using ::testing::MatcherCast; | 44 using ::testing::MatcherCast; |
| 45 using ::testing::Mock; | 45 using ::testing::Mock; |
| 46 using ::testing::Pointee; | 46 using ::testing::Pointee; |
| 47 using ::testing::Return; | 47 using ::testing::Return; |
| 48 using ::testing::SaveArg; | 48 using ::testing::SaveArg; |
| (...skipping 2927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2976 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2976 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2977 } | 2977 } |
| 2978 | 2978 |
| 2979 TEST_P(GLES2DecoderManualInitTest, InvalidateFramebufferBinding) { | 2979 TEST_P(GLES2DecoderManualInitTest, InvalidateFramebufferBinding) { |
| 2980 InitState init; | 2980 InitState init; |
| 2981 init.gl_version = "opengl es 3.0"; | 2981 init.gl_version = "opengl es 3.0"; |
| 2982 InitDecoder(init); | 2982 InitDecoder(init); |
| 2983 | 2983 |
| 2984 // EXPECT_EQ can't be used to compare function pointers | 2984 // EXPECT_EQ can't be used to compare function pointers |
| 2985 EXPECT_TRUE( | 2985 EXPECT_TRUE( |
| 2986 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") != | 2986 gl::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") != |
| 2987 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); | 2987 gl::g_driver_gl.fn.glDiscardFramebufferEXTFn); |
| 2988 EXPECT_TRUE( | 2988 EXPECT_TRUE( |
| 2989 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") != | 2989 gl::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") != |
| 2990 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT")); | 2990 gl::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT")); |
| 2991 } | 2991 } |
| 2992 | 2992 |
| 2993 TEST_P(GLES2DecoderTest, ClearBackbufferBitsOnFlipSwap) { | 2993 TEST_P(GLES2DecoderTest, ClearBackbufferBitsOnFlipSwap) { |
| 2994 surface_->set_buffers_flipped(true); | 2994 surface_->set_buffers_flipped(true); |
| 2995 | 2995 |
| 2996 EXPECT_EQ(0u, GetAndClearBackbufferClearBitsForTest()); | 2996 EXPECT_EQ(0u, GetAndClearBackbufferClearBitsForTest()); |
| 2997 | 2997 |
| 2998 SwapBuffers& cmd = *GetImmediateAs<SwapBuffers>(); | 2998 SwapBuffers& cmd = *GetImmediateAs<SwapBuffers>(); |
| 2999 cmd.Init(); | 2999 cmd.Init(); |
| 3000 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3000 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3026 } | 3026 } |
| 3027 | 3027 |
| 3028 TEST_P(GLES2DecoderManualInitTest, DiscardFramebufferEXT) { | 3028 TEST_P(GLES2DecoderManualInitTest, DiscardFramebufferEXT) { |
| 3029 InitState init; | 3029 InitState init; |
| 3030 init.extensions = "GL_EXT_discard_framebuffer"; | 3030 init.extensions = "GL_EXT_discard_framebuffer"; |
| 3031 init.gl_version = "opengl es 2.0"; | 3031 init.gl_version = "opengl es 2.0"; |
| 3032 InitDecoder(init); | 3032 InitDecoder(init); |
| 3033 | 3033 |
| 3034 // EXPECT_EQ can't be used to compare function pointers | 3034 // EXPECT_EQ can't be used to compare function pointers |
| 3035 EXPECT_TRUE( | 3035 EXPECT_TRUE( |
| 3036 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == | 3036 gl::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == |
| 3037 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); | 3037 gl::g_driver_gl.fn.glDiscardFramebufferEXTFn); |
| 3038 | 3038 |
| 3039 const GLenum target = GL_FRAMEBUFFER; | 3039 const GLenum target = GL_FRAMEBUFFER; |
| 3040 const GLsizei count = 1; | 3040 const GLsizei count = 1; |
| 3041 const GLenum attachments[] = {GL_COLOR_ATTACHMENT0}; | 3041 const GLenum attachments[] = {GL_COLOR_ATTACHMENT0}; |
| 3042 | 3042 |
| 3043 SetupTexture(); | 3043 SetupTexture(); |
| 3044 DoBindFramebuffer( | 3044 DoBindFramebuffer( |
| 3045 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 3045 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 3046 DoFramebufferTexture2D(GL_FRAMEBUFFER, | 3046 DoFramebufferTexture2D(GL_FRAMEBUFFER, |
| 3047 GL_COLOR_ATTACHMENT0, | 3047 GL_COLOR_ATTACHMENT0, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3068 } | 3068 } |
| 3069 | 3069 |
| 3070 TEST_P(GLES2DecoderManualInitTest, ClearBackbufferBitsOnDiscardFramebufferEXT) { | 3070 TEST_P(GLES2DecoderManualInitTest, ClearBackbufferBitsOnDiscardFramebufferEXT) { |
| 3071 InitState init; | 3071 InitState init; |
| 3072 init.extensions = "GL_EXT_discard_framebuffer"; | 3072 init.extensions = "GL_EXT_discard_framebuffer"; |
| 3073 init.gl_version = "opengl es 2.0"; | 3073 init.gl_version = "opengl es 2.0"; |
| 3074 InitDecoder(init); | 3074 InitDecoder(init); |
| 3075 | 3075 |
| 3076 // EXPECT_EQ can't be used to compare function pointers. | 3076 // EXPECT_EQ can't be used to compare function pointers. |
| 3077 EXPECT_TRUE( | 3077 EXPECT_TRUE( |
| 3078 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == | 3078 gl::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == |
| 3079 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); | 3079 gl::g_driver_gl.fn.glDiscardFramebufferEXTFn); |
| 3080 | 3080 |
| 3081 const GLenum target = GL_FRAMEBUFFER; | 3081 const GLenum target = GL_FRAMEBUFFER; |
| 3082 const GLsizei count = 1; | 3082 const GLsizei count = 1; |
| 3083 GLenum attachments[] = {GL_COLOR_EXT}; | 3083 GLenum attachments[] = {GL_COLOR_EXT}; |
| 3084 | 3084 |
| 3085 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | 3085 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) |
| 3086 .Times(1) | 3086 .Times(1) |
| 3087 .RetiresOnSaturation(); | 3087 .RetiresOnSaturation(); |
| 3088 DiscardFramebufferEXTImmediate& cmd = | 3088 DiscardFramebufferEXTImmediate& cmd = |
| 3089 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 3089 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 // Check that framebuffer is cleared and complete. | 3205 // Check that framebuffer is cleared and complete. |
| 3206 FramebufferManager* framebuffer_manager = group().framebuffer_manager(); | 3206 FramebufferManager* framebuffer_manager = group().framebuffer_manager(); |
| 3207 Framebuffer* framebuffer = | 3207 Framebuffer* framebuffer = |
| 3208 framebuffer_manager->GetFramebuffer(client_framebuffer_id_); | 3208 framebuffer_manager->GetFramebuffer(client_framebuffer_id_); |
| 3209 EXPECT_TRUE(framebuffer->IsCleared()); | 3209 EXPECT_TRUE(framebuffer->IsCleared()); |
| 3210 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); | 3210 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); |
| 3211 | 3211 |
| 3212 // Check that Discard GL_COLOR_ATTACHMENT0, sets the attachment as uncleared | 3212 // Check that Discard GL_COLOR_ATTACHMENT0, sets the attachment as uncleared |
| 3213 // and the framebuffer as incomplete. | 3213 // and the framebuffer as incomplete. |
| 3214 EXPECT_TRUE( | 3214 EXPECT_TRUE( |
| 3215 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == | 3215 gl::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == |
| 3216 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); | 3216 gl::g_driver_gl.fn.glDiscardFramebufferEXTFn); |
| 3217 | 3217 |
| 3218 const GLenum target = GL_FRAMEBUFFER; | 3218 const GLenum target = GL_FRAMEBUFFER; |
| 3219 const GLsizei count = 1; | 3219 const GLsizei count = 1; |
| 3220 const GLenum attachments[] = {GL_COLOR_ATTACHMENT0}; | 3220 const GLenum attachments[] = {GL_COLOR_ATTACHMENT0}; |
| 3221 | 3221 |
| 3222 DiscardFramebufferEXTImmediate& discard_cmd = | 3222 DiscardFramebufferEXTImmediate& discard_cmd = |
| 3223 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 3223 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); |
| 3224 discard_cmd.Init(target, count, attachments); | 3224 discard_cmd.Init(target, count, attachments); |
| 3225 | 3225 |
| 3226 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | 3226 EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3325 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3325 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 3326 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 3326 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 3327 } | 3327 } |
| 3328 | 3328 |
| 3329 // TODO(gman): PixelStorei | 3329 // TODO(gman): PixelStorei |
| 3330 | 3330 |
| 3331 // TODO(gman): SwapBuffers | 3331 // TODO(gman): SwapBuffers |
| 3332 | 3332 |
| 3333 } // namespace gles2 | 3333 } // namespace gles2 |
| 3334 } // namespace gpu | 3334 } // namespace gpu |
| OLD | NEW |