OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 UTF16ToASCII(context_->getString(GL_EXTENSIONS)); | 150 UTF16ToASCII(context_->getString(GL_EXTENSIONS)); |
151 std::vector<std::string> extensions_list; | 151 std::vector<std::string> extensions_list; |
152 base::SplitString(extensions_string, ' ', &extensions_list); | 152 base::SplitString(extensions_string, ' ', &extensions_list); |
153 std::set<std::string> extensions(extensions_list.begin(), | 153 std::set<std::string> extensions(extensions_list.begin(), |
154 extensions_list.end()); | 154 extensions_list.end()); |
155 | 155 |
156 capabilities_.using_partial_swap = | 156 capabilities_.using_partial_swap = |
157 Settings().partial_swap_enabled && | 157 Settings().partial_swap_enabled && |
158 extensions.count("GL_CHROMIUM_post_sub_buffer"); | 158 extensions.count("GL_CHROMIUM_post_sub_buffer"); |
159 | 159 |
160 // Use the SwapBuffers callback only with the threaded proxy. | |
161 if (client_->HasImplThread()) | |
162 capabilities_.using_swap_complete_callback = | |
163 extensions.count("GL_CHROMIUM_swapbuffers_complete_callback") > 0; | |
164 | |
165 capabilities_.using_set_visibility = | 160 capabilities_.using_set_visibility = |
166 extensions.count("GL_CHROMIUM_set_visibility") > 0; | 161 extensions.count("GL_CHROMIUM_set_visibility") > 0; |
167 | 162 |
168 if (extensions.count("GL_CHROMIUM_iosurface") > 0) | 163 if (extensions.count("GL_CHROMIUM_iosurface") > 0) |
169 DCHECK_GT(extensions.count("GL_ARB_texture_rectangle"), 0u); | 164 DCHECK_GT(extensions.count("GL_ARB_texture_rectangle"), 0u); |
170 | 165 |
171 capabilities_.using_gpu_memory_manager = | 166 capabilities_.using_gpu_memory_manager = |
172 extensions.count("GL_CHROMIUM_gpu_memory_manager") > 0 && | 167 extensions.count("GL_CHROMIUM_gpu_memory_manager") > 0 && |
173 Settings().use_memory_management; | 168 Settings().use_memory_management; |
174 if (capabilities_.using_gpu_memory_manager) | 169 if (capabilities_.using_gpu_memory_manager) |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1852 | 1847 |
1853 GLC(Context(), Context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); | 1848 GLC(Context(), Context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); |
1854 } | 1849 } |
1855 | 1850 |
1856 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 1851 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { |
1857 current_framebuffer_lock_.reset(); | 1852 current_framebuffer_lock_.reset(); |
1858 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); | 1853 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); |
1859 | 1854 |
1860 GLC(context_, context_->disable(GL_BLEND)); | 1855 GLC(context_, context_->disable(GL_BLEND)); |
1861 blend_shadow_ = false; | 1856 blend_shadow_ = false; |
1862 | |
1863 if (Settings().compositor_frame_message) { | |
1864 CompositorFrame compositor_frame; | |
1865 compositor_frame.metadata = client_->MakeCompositorFrameMetadata(); | |
1866 output_surface_->SendFrameToParentCompositor(&compositor_frame); | |
1867 } | |
1868 } | 1857 } |
1869 | 1858 |
1870 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } | 1859 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } |
1871 | 1860 |
1872 bool GLRenderer::FlippedFramebuffer() const { return true; } | 1861 bool GLRenderer::FlippedFramebuffer() const { return true; } |
1873 | 1862 |
1874 void GLRenderer::EnsureScissorTestEnabled() { | 1863 void GLRenderer::EnsureScissorTestEnabled() { |
1875 if (is_scissor_enabled_) | 1864 if (is_scissor_enabled_) |
1876 return; | 1865 return; |
1877 | 1866 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1977 SetShaderOpacity(1, program->fragment_shader().alpha_location()); | 1966 SetShaderOpacity(1, program->fragment_shader().alpha_location()); |
1978 DrawQuadGeometry( | 1967 DrawQuadGeometry( |
1979 frame, draw_matrix, rect, program->vertex_shader().matrix_location()); | 1968 frame, draw_matrix, rect, program->vertex_shader().matrix_location()); |
1980 } | 1969 } |
1981 | 1970 |
1982 void GLRenderer::Finish() { | 1971 void GLRenderer::Finish() { |
1983 TRACE_EVENT0("cc", "GLRenderer::finish"); | 1972 TRACE_EVENT0("cc", "GLRenderer::finish"); |
1984 context_->finish(); | 1973 context_->finish(); |
1985 } | 1974 } |
1986 | 1975 |
1987 void GLRenderer::SwapBuffers(const ui::LatencyInfo& latency_info) { | 1976 void GLRenderer::SwapBuffers() { |
1988 DCHECK(visible_); | 1977 DCHECK(visible_); |
1989 DCHECK(!is_backbuffer_discarded_); | 1978 DCHECK(!is_backbuffer_discarded_); |
1990 | 1979 |
1991 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); | 1980 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); |
1992 // We're done! Time to swapbuffers! | 1981 // We're done! Time to swapbuffers! |
1993 | 1982 |
1983 CompositorFrame compositor_frame; | |
1984 compositor_frame.metadata = client_->MakeCompositorFrameMetadata(); | |
1985 compositor_frame.gl_frame_data = make_scoped_ptr(new GLFrameData); | |
1986 compositor_frame.gl_frame_data->size = output_surface_->SurfaceSize(); | |
1994 if (capabilities_.using_partial_swap && client_->AllowPartialSwap()) { | 1987 if (capabilities_.using_partial_swap && client_->AllowPartialSwap()) { |
1995 // If supported, we can save significant bandwidth by only swapping the | 1988 // If supported, we can save significant bandwidth by only swapping the |
1996 // damaged/scissored region (clamped to the viewport) | 1989 // damaged/scissored region (clamped to the viewport) |
1997 swap_buffer_rect_.Intersect(client_->DeviceViewport()); | 1990 swap_buffer_rect_.Intersect(client_->DeviceViewport()); |
1998 int flipped_y_pos_of_rect_bottom = | 1991 int flipped_y_pos_of_rect_bottom = |
1999 client_->DeviceViewport().height() - swap_buffer_rect_.y() - | 1992 client_->DeviceViewport().height() - swap_buffer_rect_.y() - |
2000 swap_buffer_rect_.height(); | 1993 swap_buffer_rect_.height(); |
2001 output_surface_->PostSubBuffer(gfx::Rect(swap_buffer_rect_.x(), | 1994 compositor_frame.gl_frame_data->sub_buffer_rect = |
2002 flipped_y_pos_of_rect_bottom, | 1995 gfx::Rect(swap_buffer_rect_.x(), |
2003 swap_buffer_rect_.width(), | 1996 flipped_y_pos_of_rect_bottom, |
2004 swap_buffer_rect_.height()), | 1997 swap_buffer_rect_.width(), |
2005 latency_info); | 1998 swap_buffer_rect_.height()); |
piman
2013/06/10 19:52:25
Is it at all possible that the rect here would be
aelias_OOO_until_Jul13
2013/06/10 23:18:07
OK, switched to full rect. And I introduced anoth
| |
2006 } else { | |
2007 output_surface_->SwapBuffers(latency_info); | |
2008 } | 1999 } |
2000 output_surface_->SwapBuffers(&compositor_frame); | |
2009 | 2001 |
2010 swap_buffer_rect_ = gfx::Rect(); | 2002 swap_buffer_rect_ = gfx::Rect(); |
2011 | 2003 |
2012 // We don't have real fences, so we mark read fences as passed | 2004 // We don't have real fences, so we mark read fences as passed |
2013 // assuming a double-buffered GPU pipeline. A texture can be | 2005 // assuming a double-buffered GPU pipeline. A texture can be |
2014 // written to after one full frame has past since it was last read. | 2006 // written to after one full frame has past since it was last read. |
2015 if (last_swap_fence_.get()) | 2007 if (last_swap_fence_.get()) |
2016 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); | 2008 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); |
2017 last_swap_fence_ = resource_provider_->GetReadLockFence(); | 2009 last_swap_fence_ = resource_provider_->GetReadLockFence(); |
2018 resource_provider_->SetReadLockFence(new SimpleSwapFence()); | 2010 resource_provider_->SetReadLockFence(new SimpleSwapFence()); |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2951 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 2943 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
2952 // implementation. | 2944 // implementation. |
2953 return gr_context_ && context_->getContextAttributes().stencil; | 2945 return gr_context_ && context_->getContextAttributes().stencil; |
2954 } | 2946 } |
2955 | 2947 |
2956 bool GLRenderer::IsContextLost() { | 2948 bool GLRenderer::IsContextLost() { |
2957 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2949 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
2958 } | 2950 } |
2959 | 2951 |
2960 } // namespace cc | 2952 } // namespace cc |
OLD | NEW |