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 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1993 | 1993 |
1994 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); | 1994 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); |
1995 } | 1995 } |
1996 | 1996 |
1997 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 1997 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { |
1998 current_framebuffer_lock_.reset(); | 1998 current_framebuffer_lock_.reset(); |
1999 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); | 1999 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); |
2000 | 2000 |
2001 GLC(gl_, gl_->Disable(GL_BLEND)); | 2001 GLC(gl_, gl_->Disable(GL_BLEND)); |
2002 blend_shadow_ = false; | 2002 blend_shadow_ = false; |
2003 | |
2004 ScheduleOverlays(frame); | |
2003 } | 2005 } |
2004 | 2006 |
2005 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } | 2007 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } |
2006 | 2008 |
2007 bool GLRenderer::FlippedFramebuffer() const { return true; } | 2009 bool GLRenderer::FlippedFramebuffer() const { return true; } |
2008 | 2010 |
2009 void GLRenderer::EnsureScissorTestEnabled() { | 2011 void GLRenderer::EnsureScissorTestEnabled() { |
2010 if (is_scissor_enabled_) | 2012 if (is_scissor_enabled_) |
2011 return; | 2013 return; |
2012 | 2014 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2164 gfx::Rect(swap_buffer_rect_.x(), | 2166 gfx::Rect(swap_buffer_rect_.x(), |
2165 flipped_y_pos_of_rect_bottom, | 2167 flipped_y_pos_of_rect_bottom, |
2166 swap_buffer_rect_.width(), | 2168 swap_buffer_rect_.width(), |
2167 swap_buffer_rect_.height()); | 2169 swap_buffer_rect_.height()); |
2168 } else { | 2170 } else { |
2169 compositor_frame.gl_frame_data->sub_buffer_rect = | 2171 compositor_frame.gl_frame_data->sub_buffer_rect = |
2170 gfx::Rect(output_surface_->SurfaceSize()); | 2172 gfx::Rect(output_surface_->SurfaceSize()); |
2171 } | 2173 } |
2172 output_surface_->SwapBuffers(&compositor_frame); | 2174 output_surface_->SwapBuffers(&compositor_frame); |
2173 | 2175 |
2176 // Release previously used overlay resources and hold onto the pending ones | |
2177 // until the next swap buffers. | |
2178 in_use_overlay_resources_.clear(); | |
2179 in_use_overlay_resources_.swap(pending_overlay_resources_); | |
alexst (slow to review)
2014/03/24 23:25:40
This particular section, I am not 100% certain abo
piman
2014/03/25 00:08:08
The ScopedReadLockGL is not enough to prevent the
| |
2180 | |
2174 swap_buffer_rect_ = gfx::Rect(); | 2181 swap_buffer_rect_ = gfx::Rect(); |
2175 | 2182 |
2176 // We don't have real fences, so we mark read fences as passed | 2183 // We don't have real fences, so we mark read fences as passed |
2177 // assuming a double-buffered GPU pipeline. A texture can be | 2184 // assuming a double-buffered GPU pipeline. A texture can be |
2178 // written to after one full frame has past since it was last read. | 2185 // written to after one full frame has past since it was last read. |
2179 if (last_swap_fence_.get()) | 2186 if (last_swap_fence_.get()) |
2180 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); | 2187 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); |
2181 last_swap_fence_ = resource_provider_->GetReadLockFence(); | 2188 last_swap_fence_ = resource_provider_->GetReadLockFence(); |
2182 resource_provider_->SetReadLockFence(new SimpleSwapFence()); | 2189 resource_provider_->SetReadLockFence(new SimpleSwapFence()); |
2183 } | 2190 } |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3040 // Make sure scissoring starts as disabled. | 3047 // Make sure scissoring starts as disabled. |
3041 is_scissor_enabled_ = false; | 3048 is_scissor_enabled_ = false; |
3042 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); | 3049 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); |
3043 scissor_rect_needs_reset_ = true; | 3050 scissor_rect_needs_reset_ = true; |
3044 } | 3051 } |
3045 | 3052 |
3046 bool GLRenderer::IsContextLost() { | 3053 bool GLRenderer::IsContextLost() { |
3047 return output_surface_->context_provider()->IsContextLost(); | 3054 return output_surface_->context_provider()->IsContextLost(); |
3048 } | 3055 } |
3049 | 3056 |
3057 void GLRenderer::ScheduleOverlays(DrawingFrame* frame) { | |
3058 if (!frame->overlay_passes_in_draw_order) | |
3059 return; | |
3060 | |
3061 const RenderPassList* pass_list = frame->overlay_passes_in_draw_order; | |
3062 int plane_z_order = 1; | |
3063 for (RenderPassList::const_reverse_iterator it = pass_list->rbegin(); | |
3064 it != pass_list->rend(); | |
3065 ++it) { | |
3066 RenderPass* pass = *it; | |
3067 if (pass->overlay_state != RenderPass::SIMPLE_OVERLAY) | |
3068 continue; | |
piman
2014/03/25 00:08:08
I wonder if it could make sense to construct the o
| |
3069 | |
3070 DCHECK_EQ(pass->quad_list.size(), 1U); | |
3071 const DrawQuad* candidate_quad = pass->quad_list.front(); | |
3072 DCHECK_EQ(candidate_quad->material, DrawQuad::TEXTURE_CONTENT); | |
3073 const TextureDrawQuad& quad = | |
3074 *TextureDrawQuad::MaterialCast(candidate_quad); | |
3075 | |
3076 pending_overlay_resources_.push_back( | |
3077 make_scoped_ptr(new ResourceProvider::ScopedReadLockGL( | |
3078 resource_provider(), quad.resource_id))); | |
3079 | |
3080 OverlayCandidate::OverlayTransform overlay_transform = | |
3081 OverlayCandidate::GetOverlayTransform(quad.quadTransform(), | |
3082 quad.flipped); | |
3083 gfx::Rect display_bounds = | |
3084 OverlayCandidate::GetOverlayRect(quad.quadTransform(), quad.rect); | |
3085 gfx::RectF uv_rect = BoundingRect(quad.uv_top_left, quad.uv_bottom_right); | |
piman
2014/03/25 00:08:08
Mmh, a lot of these we computed previously when tr
| |
3086 | |
3087 context_support_->ScheduleOverlayPlane( | |
3088 plane_z_order++, | |
3089 overlay_transform, | |
3090 pending_overlay_resources_.back()->texture_id(), | |
3091 display_bounds, | |
3092 uv_rect); | |
3093 } | |
3094 } | |
3095 | |
3050 } // namespace cc | 3096 } // namespace cc |
OLD | NEW |