| 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 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 1821 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { |
| 1822 current_framebuffer_lock_.reset(); | 1822 current_framebuffer_lock_.reset(); |
| 1823 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); | 1823 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); |
| 1824 | 1824 |
| 1825 GLC(context_, context_->disable(GL_BLEND)); | 1825 GLC(context_, context_->disable(GL_BLEND)); |
| 1826 blend_shadow_ = false; | 1826 blend_shadow_ = false; |
| 1827 | 1827 |
| 1828 if (Settings().compositor_frame_message) { | 1828 if (Settings().compositor_frame_message) { |
| 1829 CompositorFrame compositor_frame; | 1829 CompositorFrame compositor_frame; |
| 1830 compositor_frame.metadata = client_->MakeCompositorFrameMetadata(); | 1830 compositor_frame.metadata = client_->MakeCompositorFrameMetadata(); |
| 1831 compositor_frame.gl_frame_data.reset(new GLFrameData()); |
| 1832 compositor_frame.gl_frame_data->damage_rect = GetFrameDamage(); |
| 1831 output_surface_->SendFrameToParentCompositor(&compositor_frame); | 1833 output_surface_->SendFrameToParentCompositor(&compositor_frame); |
| 1832 } | 1834 } |
| 1833 } | 1835 } |
| 1834 | 1836 |
| 1835 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } | 1837 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } |
| 1836 | 1838 |
| 1837 bool GLRenderer::FlippedFramebuffer() const { return true; } | 1839 bool GLRenderer::FlippedFramebuffer() const { return true; } |
| 1838 | 1840 |
| 1839 void GLRenderer::EnsureScissorTestEnabled() { | 1841 void GLRenderer::EnsureScissorTestEnabled() { |
| 1840 if (is_scissor_enabled_) | 1842 if (is_scissor_enabled_) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 void GLRenderer::SwapBuffers(const ui::LatencyInfo& latency_info) { | 1954 void GLRenderer::SwapBuffers(const ui::LatencyInfo& latency_info) { |
| 1953 DCHECK(visible_); | 1955 DCHECK(visible_); |
| 1954 DCHECK(!is_backbuffer_discarded_); | 1956 DCHECK(!is_backbuffer_discarded_); |
| 1955 | 1957 |
| 1956 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); | 1958 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); |
| 1957 // We're done! Time to swapbuffers! | 1959 // We're done! Time to swapbuffers! |
| 1958 | 1960 |
| 1959 if (capabilities_.using_partial_swap && client_->AllowPartialSwap()) { | 1961 if (capabilities_.using_partial_swap && client_->AllowPartialSwap()) { |
| 1960 // If supported, we can save significant bandwidth by only swapping the | 1962 // If supported, we can save significant bandwidth by only swapping the |
| 1961 // damaged/scissored region (clamped to the viewport) | 1963 // damaged/scissored region (clamped to the viewport) |
| 1962 swap_buffer_rect_.Intersect(client_->DeviceViewport()); | 1964 output_surface_->PostSubBuffer(GetFrameDamage(), latency_info); |
| 1963 int flipped_y_pos_of_rect_bottom = | |
| 1964 client_->DeviceViewport().height() - swap_buffer_rect_.y() - | |
| 1965 swap_buffer_rect_.height(); | |
| 1966 output_surface_->PostSubBuffer(gfx::Rect(swap_buffer_rect_.x(), | |
| 1967 flipped_y_pos_of_rect_bottom, | |
| 1968 swap_buffer_rect_.width(), | |
| 1969 swap_buffer_rect_.height()), | |
| 1970 latency_info); | |
| 1971 } else { | 1965 } else { |
| 1972 output_surface_->SwapBuffers(latency_info); | 1966 output_surface_->SwapBuffers(latency_info); |
| 1973 } | 1967 } |
| 1974 | 1968 |
| 1975 swap_buffer_rect_ = gfx::Rect(); | 1969 swap_buffer_rect_ = gfx::Rect(); |
| 1976 | 1970 |
| 1977 // We don't have real fences, so we mark read fences as passed | 1971 // We don't have real fences, so we mark read fences as passed |
| 1978 // assuming a double-buffered GPU pipeline. A texture can be | 1972 // assuming a double-buffered GPU pipeline. A texture can be |
| 1979 // written to after one full frame has past since it was last read. | 1973 // written to after one full frame has past since it was last read. |
| 1980 if (last_swap_fence_.get()) | 1974 if (last_swap_fence_.get()) |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2897 bool GLRenderer::CanUseSkiaGPUBackend() const { | 2891 bool GLRenderer::CanUseSkiaGPUBackend() const { |
| 2898 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 2892 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
| 2899 // implementation. | 2893 // implementation. |
| 2900 return gr_context_ && context_->getContextAttributes().stencil; | 2894 return gr_context_ && context_->getContextAttributes().stencil; |
| 2901 } | 2895 } |
| 2902 | 2896 |
| 2903 bool GLRenderer::IsContextLost() { | 2897 bool GLRenderer::IsContextLost() { |
| 2904 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2898 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2905 } | 2899 } |
| 2906 | 2900 |
| 2901 gfx::Rect GLRenderer::GetFrameDamage() { |
| 2902 gfx::Rect frame_damage = swap_buffer_rect_; |
| 2903 frame_damage.Intersect(client_->DeviceViewport()); |
| 2904 int flipped_y_pos_of_rect_bottom = client_->DeviceViewport().height() - |
| 2905 frame_damage.y() - frame_damage.height(); |
| 2906 frame_damage.set_y(flipped_y_pos_of_rect_bottom); |
| 2907 return frame_damage; |
| 2908 } |
| 2909 |
| 2907 } // namespace cc | 2910 } // namespace cc |
| OLD | NEW |