| 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 "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" | 
| 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 
| 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 
| (...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2508       .RetiresOnSaturation(); | 2508       .RetiresOnSaturation(); | 
| 2509   DiscardFramebufferEXTImmediate& cmd = | 2509   DiscardFramebufferEXTImmediate& cmd = | 
| 2510       *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 2510       *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 
| 2511   cmd.Init(target, count, attachments); | 2511   cmd.Init(target, count, attachments); | 
| 2512 | 2512 | 
| 2513   EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | 2513   EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | 
| 2514   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2514   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
| 2515   EXPECT_FALSE(framebuffer->IsCleared()); | 2515   EXPECT_FALSE(framebuffer->IsCleared()); | 
| 2516 } | 2516 } | 
| 2517 | 2517 | 
|  | 2518 TEST_P(GLES2DecoderManualInitTest, ClearBackbufferBitsOnDiscardFramebufferEXT) { | 
|  | 2519   InitState init; | 
|  | 2520   init.extensions = "GL_EXT_discard_framebuffer"; | 
|  | 2521   init.gl_version = "opengl es 2.0"; | 
|  | 2522   InitDecoder(init); | 
|  | 2523 | 
|  | 2524   // EXPECT_EQ can't be used to compare function pointers. | 
|  | 2525   EXPECT_TRUE( | 
|  | 2526       gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == | 
|  | 2527       gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); | 
|  | 2528 | 
|  | 2529   const GLenum target = GL_FRAMEBUFFER; | 
|  | 2530   const GLsizei count = 1; | 
|  | 2531   GLenum attachments[] = {GL_COLOR_EXT}; | 
|  | 2532 | 
|  | 2533   EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | 
|  | 2534       .Times(1) | 
|  | 2535       .RetiresOnSaturation(); | 
|  | 2536   DiscardFramebufferEXTImmediate& cmd = | 
|  | 2537       *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 
|  | 2538   cmd.Init(target, count, attachments); | 
|  | 2539   EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | 
|  | 2540   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
|  | 2541   EXPECT_EQ(static_cast<uint32_t>(GL_COLOR_BUFFER_BIT), | 
|  | 2542             GetAndClearBackbufferClearBitsForTest()); | 
|  | 2543 | 
|  | 2544   attachments[0] = GL_DEPTH_EXT; | 
|  | 2545   EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | 
|  | 2546       .Times(1) | 
|  | 2547       .RetiresOnSaturation(); | 
|  | 2548   cmd.Init(target, count, attachments); | 
|  | 2549   EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | 
|  | 2550   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
|  | 2551   EXPECT_EQ(static_cast<uint32_t>(GL_DEPTH_BUFFER_BIT), | 
|  | 2552             GetAndClearBackbufferClearBitsForTest()); | 
|  | 2553 | 
|  | 2554   attachments[0] = GL_STENCIL_EXT; | 
|  | 2555   EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count, _)) | 
|  | 2556       .Times(1) | 
|  | 2557       .RetiresOnSaturation(); | 
|  | 2558   cmd.Init(target, count, attachments); | 
|  | 2559   EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments))); | 
|  | 2560   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
|  | 2561   EXPECT_EQ(static_cast<uint32_t>(GL_STENCIL_BUFFER_BIT), | 
|  | 2562             GetAndClearBackbufferClearBitsForTest()); | 
|  | 2563 | 
|  | 2564   const GLsizei count0 = 3; | 
|  | 2565   const GLenum attachments0[] = {GL_COLOR_EXT, GL_DEPTH_EXT, GL_STENCIL_EXT}; | 
|  | 2566   EXPECT_CALL(*gl_, DiscardFramebufferEXT(target, count0, _)) | 
|  | 2567       .Times(1) | 
|  | 2568       .RetiresOnSaturation(); | 
|  | 2569   cmd.Init(target, count0, attachments0); | 
|  | 2570   EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(attachments0))); | 
|  | 2571   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
|  | 2572   EXPECT_EQ(static_cast<uint32_t>(GL_COLOR_BUFFER_BIT | | 
|  | 2573                                   GL_DEPTH_BUFFER_BIT | | 
|  | 2574                                   GL_STENCIL_BUFFER_BIT), | 
|  | 2575             GetAndClearBackbufferClearBitsForTest()); | 
|  | 2576 } | 
|  | 2577 | 
| 2518 TEST_P(GLES2DecoderTest, DiscardFramebufferEXTUnsupported) { | 2578 TEST_P(GLES2DecoderTest, DiscardFramebufferEXTUnsupported) { | 
| 2519   const GLenum target = GL_FRAMEBUFFER; | 2579   const GLenum target = GL_FRAMEBUFFER; | 
| 2520   const GLsizei count = 1; | 2580   const GLsizei count = 1; | 
| 2521   const GLenum attachments[] = {GL_COLOR_EXT}; | 2581   const GLenum attachments[] = {GL_COLOR_EXT}; | 
| 2522   DiscardFramebufferEXTImmediate& cmd = | 2582   DiscardFramebufferEXTImmediate& cmd = | 
| 2523       *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 2583       *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 
| 2524   cmd.Init(target, count, attachments); | 2584   cmd.Init(target, count, attachments); | 
| 2525 | 2585 | 
| 2526   // Should not result into a call into GL. | 2586   // Should not result into a call into GL. | 
| 2527   EXPECT_EQ(error::kUnknownCommand, | 2587   EXPECT_EQ(error::kUnknownCommand, | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2736   EXPECT_EQ(1, result->GetNumResults()); | 2796   EXPECT_EQ(1, result->GetNumResults()); | 
| 2737   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2797   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
| 2738 } | 2798 } | 
| 2739 | 2799 | 
| 2740 // TODO(gman): PixelStorei | 2800 // TODO(gman): PixelStorei | 
| 2741 | 2801 | 
| 2742 // TODO(gman): SwapBuffers | 2802 // TODO(gman): SwapBuffers | 
| 2743 | 2803 | 
| 2744 }  // namespace gles2 | 2804 }  // namespace gles2 | 
| 2745 }  // namespace gpu | 2805 }  // namespace gpu | 
| OLD | NEW | 
|---|