| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 return offscreen_target_color_texture_->size(); | 1752 return offscreen_target_color_texture_->size(); |
| 1753 } else { | 1753 } else { |
| 1754 return context_->GetSize(); | 1754 return context_->GetSize(); |
| 1755 } | 1755 } |
| 1756 } | 1756 } |
| 1757 | 1757 |
| 1758 bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() { | 1758 bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() { |
| 1759 if (offscreen_target_color_texture_->size() == pending_offscreen_size_) | 1759 if (offscreen_target_color_texture_->size() == pending_offscreen_size_) |
| 1760 return true; | 1760 return true; |
| 1761 | 1761 |
| 1762 if (parent_) { | |
| 1763 // Create the saved offscreen color texture (only accessible to parent). | |
| 1764 offscreen_saved_color_texture_->AllocateStorage(pending_offscreen_size_); | |
| 1765 | |
| 1766 // Attach the saved offscreen color texture to a frame buffer so we can | |
| 1767 // clear it with glClear. | |
| 1768 offscreen_target_frame_buffer_->AttachRenderTexture( | |
| 1769 offscreen_saved_color_texture_.get()); | |
| 1770 if (offscreen_target_frame_buffer_->CheckStatus() != | |
| 1771 GL_FRAMEBUFFER_COMPLETE) { | |
| 1772 return false; | |
| 1773 } | |
| 1774 | |
| 1775 // TODO(apatrick): Fix this once ANGLE supports shared contexts. | |
| 1776 // Clear the saved offscreen color texture. Use default GL context | |
| 1777 // to ensure clear is not affected by client set state. | |
| 1778 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | |
| 1779 ScopedDefaultGLContext scoped_context(this); | |
| 1780 glBindFramebufferEXT(GL_FRAMEBUFFER, | |
| 1781 offscreen_target_frame_buffer_->id()); | |
| 1782 glClear(GL_COLOR_BUFFER_BIT); | |
| 1783 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); | |
| 1784 | |
| 1785 if (glGetError() != GL_NO_ERROR) | |
| 1786 return false; | |
| 1787 } | |
| 1788 } | |
| 1789 | |
| 1790 // Reallocate the offscreen target buffers. | 1762 // Reallocate the offscreen target buffers. |
| 1791 if (!offscreen_target_color_texture_->AllocateStorage( | 1763 if (!offscreen_target_color_texture_->AllocateStorage( |
| 1792 pending_offscreen_size_)) { | 1764 pending_offscreen_size_)) { |
| 1793 return false; | 1765 return false; |
| 1794 } | 1766 } |
| 1795 | 1767 |
| 1796 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | 1768 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
| 1797 // ANGLE only allows 16-bit depth buffers to be requested. As it happens, | 1769 // ANGLE only allows 16-bit depth buffers to be requested. As it happens, |
| 1798 // it creates a 24-bit depth buffer behind the scenes. | 1770 // it creates a 24-bit depth buffer behind the scenes. |
| 1799 // TODO(apatrick): Attempt to use a packed 24/8 depth stencil buffer here if | 1771 // TODO(apatrick): Attempt to use a packed 24/8 depth stencil buffer here if |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 glBindFramebufferEXT(GL_FRAMEBUFFER, | 1814 glBindFramebufferEXT(GL_FRAMEBUFFER, |
| 1843 offscreen_target_frame_buffer_->id()); | 1815 offscreen_target_frame_buffer_->id()); |
| 1844 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 1816 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 1845 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); | 1817 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); |
| 1846 | 1818 |
| 1847 if (glGetError() != GL_NO_ERROR) | 1819 if (glGetError() != GL_NO_ERROR) |
| 1848 return false; | 1820 return false; |
| 1849 } | 1821 } |
| 1850 | 1822 |
| 1851 if (parent_) { | 1823 if (parent_) { |
| 1852 // Create the saved offscreen color texture (only accessible to parent). | 1824 // Adjust the saved offscreen color texture (only accessible to parent). |
| 1853 offscreen_saved_color_texture_->AllocateStorage(pending_offscreen_size_); | 1825 offscreen_saved_color_texture_->AllocateStorage(pending_offscreen_size_); |
| 1854 | 1826 |
| 1855 // Update the info about the offscreen saved color texture in the parent. | 1827 // Update the info about the offscreen saved color texture in the parent. |
| 1856 // The reference to the parent is a weak pointer and will become null if the | 1828 // The reference to the parent is a weak pointer and will become null if the |
| 1857 // parent is later destroyed. | 1829 // parent is later destroyed. |
| 1858 GLuint service_id = offscreen_saved_color_texture_->id(); | 1830 GLuint service_id = offscreen_saved_color_texture_->id(); |
| 1859 GLuint client_id; | 1831 GLuint client_id; |
| 1860 CHECK(parent_->texture_manager()->GetClientId(service_id, &client_id)); | 1832 CHECK(parent_->texture_manager()->GetClientId(service_id, &client_id)); |
| 1861 TextureManager::TextureInfo* info = parent_->GetTextureInfo(client_id); | 1833 TextureManager::TextureInfo* info = parent_->GetTextureInfo(client_id); |
| 1862 DCHECK(info); | 1834 DCHECK(info); |
| 1863 | 1835 |
| 1864 texture_manager()->SetLevelInfo( | 1836 texture_manager()->SetLevelInfo( |
| 1865 info, | 1837 info, |
| 1866 GL_TEXTURE_2D, | 1838 GL_TEXTURE_2D, |
| 1867 0, // level | 1839 0, // level |
| 1868 GL_RGBA, | 1840 GL_RGBA, |
| 1869 pending_offscreen_size_.width(), | 1841 pending_offscreen_size_.width(), |
| 1870 pending_offscreen_size_.height(), | 1842 pending_offscreen_size_.height(), |
| 1871 1, // depth | 1843 1, // depth |
| 1872 0, // border | 1844 0, // border |
| 1873 GL_RGBA, | 1845 GL_RGBA, |
| 1874 GL_UNSIGNED_BYTE); | 1846 GL_UNSIGNED_BYTE); |
| 1875 } | 1847 } |
| 1876 | 1848 |
| 1849 // Attach the saved offscreen color texture to a frame buffer so we can |
| 1850 // clear it with glClear. |
| 1851 offscreen_target_frame_buffer_->AttachRenderTexture( |
| 1852 offscreen_saved_color_texture_.get()); |
| 1853 if (offscreen_target_frame_buffer_->CheckStatus() != |
| 1854 GL_FRAMEBUFFER_COMPLETE) { |
| 1855 return false; |
| 1856 } |
| 1857 |
| 1858 // TODO(apatrick): Fix this once ANGLE supports shared contexts. |
| 1859 // Clear the saved offscreen color texture. Use default GL context |
| 1860 // to ensure clear is not affected by client set state. |
| 1861 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 1862 ScopedDefaultGLContext scoped_context(this); |
| 1863 glBindFramebufferEXT(GL_FRAMEBUFFER, |
| 1864 offscreen_target_frame_buffer_->id()); |
| 1865 glClear(GL_COLOR_BUFFER_BIT); |
| 1866 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); |
| 1867 |
| 1868 if (glGetError() != GL_NO_ERROR) |
| 1869 return false; |
| 1870 } |
| 1871 |
| 1872 // Re-attach the offscreen render texture to the target frame buffer. |
| 1873 offscreen_target_frame_buffer_->AttachRenderTexture( |
| 1874 offscreen_target_color_texture_.get()); |
| 1875 |
| 1877 return true; | 1876 return true; |
| 1878 } | 1877 } |
| 1879 | 1878 |
| 1880 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { | 1879 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { |
| 1881 swap_buffers_callback_.reset(callback); | 1880 swap_buffers_callback_.reset(callback); |
| 1882 } | 1881 } |
| 1883 | 1882 |
| 1884 void GLES2DecoderImpl::Destroy() { | 1883 void GLES2DecoderImpl::Destroy() { |
| 1885 if (context_) { | 1884 if (context_) { |
| 1886 MakeCurrent(); | 1885 MakeCurrent(); |
| (...skipping 2881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4768 return error::kNoError; | 4767 return error::kNoError; |
| 4769 } | 4768 } |
| 4770 | 4769 |
| 4771 // Include the auto-generated part of this file. We split this because it means | 4770 // Include the auto-generated part of this file. We split this because it means |
| 4772 // we can easily edit the non-auto generated parts right here in this file | 4771 // we can easily edit the non-auto generated parts right here in this file |
| 4773 // instead of having to edit some template or the code generator. | 4772 // instead of having to edit some template or the code generator. |
| 4774 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 4773 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 4775 | 4774 |
| 4776 } // namespace gles2 | 4775 } // namespace gles2 |
| 4777 } // namespace gpu | 4776 } // namespace gpu |
| OLD | NEW |