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 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1668 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1669 DoBindFramebuffer( | 1669 DoBindFramebuffer( |
1670 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 1670 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
1671 DoFramebufferTexture2D(GL_FRAMEBUFFER, | 1671 DoFramebufferTexture2D(GL_FRAMEBUFFER, |
1672 GL_COLOR_ATTACHMENT0, | 1672 GL_COLOR_ATTACHMENT0, |
1673 GL_TEXTURE_2D, | 1673 GL_TEXTURE_2D, |
1674 kFBOClientTextureId, | 1674 kFBOClientTextureId, |
1675 kFBOServiceTextureId, | 1675 kFBOServiceTextureId, |
1676 0, | 1676 0, |
1677 GL_NO_ERROR); | 1677 GL_NO_ERROR); |
| 1678 // Set scissor rect and enable GL_SCISSOR_TEST to make sure we re-enable it |
| 1679 // and restore the rect again after the clear. |
| 1680 DoEnableDisable(GL_SCISSOR_TEST, true); |
| 1681 DoScissor(0, 0, 64, 64); |
1678 | 1682 |
1679 // Setup "render from" texture. | 1683 // Setup "render from" texture. |
1680 SetupTexture(); | 1684 SetupTexture(); |
1681 | 1685 |
1682 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target | 1686 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target |
1683 GL_COLOR_BUFFER_BIT, // clear bits | 1687 GL_COLOR_BUFFER_BIT, // clear bits |
1684 0, | 1688 0, 0, 0, |
1685 0, | 1689 0, // color |
1686 0, | 1690 0, // stencil |
1687 0, // color | 1691 1.0f, // depth |
1688 0, // stencil | 1692 true, // scissor test |
1689 1.0f, // depth | 1693 0, 0, 64, 64); |
1690 false); // scissor test | |
1691 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB | 1694 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB |
1692 false, // Framebuffer has depth | 1695 false, // Framebuffer has depth |
1693 false, // Framebuffer has stencil | 1696 false, // Framebuffer has stencil |
1694 0x1111, // color bits | 1697 0x1111, // color bits |
1695 false, // depth mask | 1698 false, // depth mask |
1696 false, // depth enabled | 1699 false, // depth enabled |
1697 0, // front stencil mask | 1700 0, // front stencil mask |
1698 0, // back stencil mask | 1701 0, // back stencil mask |
1699 false); // stencil enabled | 1702 false); // stencil enabled |
1700 | 1703 |
(...skipping 21 matching lines...) Expand all Loading... |
1722 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 1725 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
1723 DoBindFramebuffer( | 1726 DoBindFramebuffer( |
1724 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 1727 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
1725 DoFramebufferTexture2D(GL_FRAMEBUFFER, | 1728 DoFramebufferTexture2D(GL_FRAMEBUFFER, |
1726 GL_COLOR_ATTACHMENT0, | 1729 GL_COLOR_ATTACHMENT0, |
1727 GL_TEXTURE_2D, | 1730 GL_TEXTURE_2D, |
1728 kFBOClientTextureId, | 1731 kFBOClientTextureId, |
1729 kFBOServiceTextureId, | 1732 kFBOServiceTextureId, |
1730 0, | 1733 0, |
1731 GL_NO_ERROR); | 1734 GL_NO_ERROR); |
| 1735 DoEnableDisable(GL_SCISSOR_TEST, false); |
| 1736 DoScissor(0, 0, 1, 1); |
1732 | 1737 |
1733 // Setup "render from" texture. | 1738 // Setup "render from" texture. |
1734 SetupTexture(); | 1739 SetupTexture(); |
1735 | 1740 |
1736 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target | 1741 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target |
1737 GL_COLOR_BUFFER_BIT, // clear bits | 1742 GL_COLOR_BUFFER_BIT, // clear bits |
1738 0, | 1743 0, 0, 0, |
1739 0, | 1744 0, // color |
1740 0, | 1745 0, // stencil |
1741 0, // color | 1746 1.0f, // depth |
1742 0, // stencil | 1747 false, // scissor test |
1743 1.0f, // depth | 1748 0, 0, 1, 1); |
1744 false); // scissor test | |
1745 | 1749 |
1746 EXPECT_CALL(*gl_, GetError()) | 1750 EXPECT_CALL(*gl_, GetError()) |
1747 .WillOnce(Return(GL_NO_ERROR)) | 1751 .WillOnce(Return(GL_NO_ERROR)) |
1748 .WillOnce(Return(GL_NO_ERROR)) | 1752 .WillOnce(Return(GL_NO_ERROR)) |
1749 .RetiresOnSaturation(); | 1753 .RetiresOnSaturation(); |
1750 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) | 1754 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) |
1751 .Times(1) | 1755 .Times(1) |
1752 .RetiresOnSaturation(); | 1756 .RetiresOnSaturation(); |
1753 typedef ReadPixels::Result Result; | 1757 typedef ReadPixels::Result Result; |
1754 uint32 result_shm_id = kSharedMemoryId; | 1758 uint32 result_shm_id = kSharedMemoryId; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 DoBindFramebuffer( | 1797 DoBindFramebuffer( |
1794 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 1798 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
1795 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, | 1799 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER, |
1796 GL_COLOR_ATTACHMENT0, | 1800 GL_COLOR_ATTACHMENT0, |
1797 GL_TEXTURE_2D, | 1801 GL_TEXTURE_2D, |
1798 kFBOClientTextureId, | 1802 kFBOClientTextureId, |
1799 kFBOServiceTextureId, | 1803 kFBOServiceTextureId, |
1800 0, | 1804 0, |
1801 GL_NO_ERROR); | 1805 GL_NO_ERROR); |
1802 | 1806 |
1803 // Enable GL_SCISSOR_TEST to make sure we disable it in the clear, | 1807 // Set scissor rect and disable GL_SCISSOR_TEST to make sure we enable it in |
1804 // then re-enable after. | 1808 // the clear, then disable it and restore the rect again. |
1805 DoEnableDisable(GL_SCISSOR_TEST, true); | 1809 DoScissor(0, 0, 32, 32); |
| 1810 DoEnableDisable(GL_SCISSOR_TEST, false); |
1806 | 1811 |
1807 SetupExpectationsForFramebufferClearingMulti( | 1812 SetupExpectationsForFramebufferClearingMulti( |
1808 kServiceFramebufferId, // read framebuffer service id | 1813 kServiceFramebufferId, // read framebuffer service id |
1809 0, // backbuffer service id | 1814 0, // backbuffer service id |
1810 GL_READ_FRAMEBUFFER, // target | 1815 GL_READ_FRAMEBUFFER, // target |
1811 GL_COLOR_BUFFER_BIT, // clear bits | 1816 GL_COLOR_BUFFER_BIT, // clear bits |
1812 0, | 1817 0, 0, 0, |
1813 0, | |
1814 0, | |
1815 0, // color | 1818 0, // color |
1816 0, // stencil | 1819 0, // stencil |
1817 1.0f, // depth | 1820 1.0f, // depth |
1818 true); // scissor test | 1821 false, // scissor test |
| 1822 0, 0, 32, 32); |
1819 | 1823 |
1820 EXPECT_CALL(*gl_, GetError()) | 1824 EXPECT_CALL(*gl_, GetError()) |
1821 .WillOnce(Return(GL_NO_ERROR)) | 1825 .WillOnce(Return(GL_NO_ERROR)) |
1822 .WillOnce(Return(GL_NO_ERROR)) | 1826 .WillOnce(Return(GL_NO_ERROR)) |
1823 .RetiresOnSaturation(); | 1827 .RetiresOnSaturation(); |
1824 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) | 1828 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) |
1825 .Times(1) | 1829 .Times(1) |
1826 .RetiresOnSaturation(); | 1830 .RetiresOnSaturation(); |
1827 typedef ReadPixels::Result Result; | 1831 typedef ReadPixels::Result Result; |
1828 uint32 result_shm_id = kSharedMemoryId; | 1832 uint32 result_shm_id = kSharedMemoryId; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2194 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 2198 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
2195 DoBindFramebuffer( | 2199 DoBindFramebuffer( |
2196 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 2200 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
2197 DoFramebufferTexture2D(GL_FRAMEBUFFER, | 2201 DoFramebufferTexture2D(GL_FRAMEBUFFER, |
2198 GL_COLOR_ATTACHMENT0, | 2202 GL_COLOR_ATTACHMENT0, |
2199 GL_TEXTURE_2D, | 2203 GL_TEXTURE_2D, |
2200 kFBOClientTextureId, | 2204 kFBOClientTextureId, |
2201 kFBOServiceTextureId, | 2205 kFBOServiceTextureId, |
2202 0, | 2206 0, |
2203 GL_NO_ERROR); | 2207 GL_NO_ERROR); |
| 2208 DoEnableDisable(GL_SCISSOR_TEST, false); |
| 2209 DoScissor(0, 0, 1, 1); |
2204 | 2210 |
2205 // Setup "render from" texture. | 2211 // Setup "render from" texture. |
2206 SetupTexture(); | 2212 SetupTexture(); |
2207 | 2213 |
2208 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target | 2214 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target |
2209 GL_COLOR_BUFFER_BIT, // clear bits | 2215 GL_COLOR_BUFFER_BIT, // clear bits |
2210 0, | 2216 0, 0, 0, |
2211 0, | 2217 0, // color |
2212 0, | 2218 0, // stencil |
2213 0, // color | 2219 1.0f, // depth |
2214 0, // stencil | 2220 false, // scissor test |
2215 1.0f, // depth | 2221 0, 0, 1, 1); |
2216 false); // scissor test | |
2217 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB | 2222 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB |
2218 false, // Framebuffer has depth | 2223 false, // Framebuffer has depth |
2219 false, // Framebuffer has stencil | 2224 false, // Framebuffer has stencil |
2220 0x1111, // color bits | 2225 0x1111, // color bits |
2221 false, // depth mask | 2226 false, // depth mask |
2222 false, // depth enabled | 2227 false, // depth enabled |
2223 0, // front stencil mask | 2228 0, // front stencil mask |
2224 0, // back stencil mask | 2229 0, // back stencil mask |
2225 false); // stencil enabled | 2230 false); // stencil enabled |
2226 | 2231 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 EXPECT_EQ(1, result->GetNumResults()); | 2382 EXPECT_EQ(1, result->GetNumResults()); |
2378 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2383 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2379 } | 2384 } |
2380 | 2385 |
2381 // TODO(gman): PixelStorei | 2386 // TODO(gman): PixelStorei |
2382 | 2387 |
2383 // TODO(gman): SwapBuffers | 2388 // TODO(gman): SwapBuffers |
2384 | 2389 |
2385 } // namespace gles2 | 2390 } // namespace gles2 |
2386 } // namespace gpu | 2391 } // namespace gpu |
OLD | NEW |