| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 InitializeSharedObjects(); | 251 InitializeSharedObjects(); |
| 252 } | 252 } |
| 253 | 253 |
| 254 GLRenderer::~GLRenderer() { | 254 GLRenderer::~GLRenderer() { |
| 255 while (!pending_async_read_pixels_.empty()) { | 255 while (!pending_async_read_pixels_.empty()) { |
| 256 PendingAsyncReadPixels* pending_read = pending_async_read_pixels_.back(); | 256 PendingAsyncReadPixels* pending_read = pending_async_read_pixels_.back(); |
| 257 pending_read->finished_read_pixels_callback.Cancel(); | 257 pending_read->finished_read_pixels_callback.Cancel(); |
| 258 pending_async_read_pixels_.pop_back(); | 258 pending_async_read_pixels_.pop_back(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 in_use_overlay_resources_.clear(); |
| 262 |
| 261 CleanupSharedObjects(); | 263 CleanupSharedObjects(); |
| 262 } | 264 } |
| 263 | 265 |
| 264 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { | 266 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { |
| 265 return capabilities_; | 267 return capabilities_; |
| 266 } | 268 } |
| 267 | 269 |
| 268 void GLRenderer::DebugGLCall(GLES2Interface* gl, | 270 void GLRenderer::DebugGLCall(GLES2Interface* gl, |
| 269 const char* command, | 271 const char* command, |
| 270 const char* file, | 272 const char* file, |
| (...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1998 | 2000 |
| 1999 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); | 2001 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); |
| 2000 } | 2002 } |
| 2001 | 2003 |
| 2002 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 2004 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { |
| 2003 current_framebuffer_lock_.reset(); | 2005 current_framebuffer_lock_.reset(); |
| 2004 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); | 2006 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); |
| 2005 | 2007 |
| 2006 GLC(gl_, gl_->Disable(GL_BLEND)); | 2008 GLC(gl_, gl_->Disable(GL_BLEND)); |
| 2007 blend_shadow_ = false; | 2009 blend_shadow_ = false; |
| 2010 |
| 2011 ScheduleOverlays(frame); |
| 2008 } | 2012 } |
| 2009 | 2013 |
| 2010 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } | 2014 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } |
| 2011 | 2015 |
| 2012 bool GLRenderer::FlippedFramebuffer() const { return true; } | 2016 bool GLRenderer::FlippedFramebuffer() const { return true; } |
| 2013 | 2017 |
| 2014 void GLRenderer::EnsureScissorTestEnabled() { | 2018 void GLRenderer::EnsureScissorTestEnabled() { |
| 2015 if (is_scissor_enabled_) | 2019 if (is_scissor_enabled_) |
| 2016 return; | 2020 return; |
| 2017 | 2021 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2169 gfx::Rect(swap_buffer_rect_.x(), | 2173 gfx::Rect(swap_buffer_rect_.x(), |
| 2170 flipped_y_pos_of_rect_bottom, | 2174 flipped_y_pos_of_rect_bottom, |
| 2171 swap_buffer_rect_.width(), | 2175 swap_buffer_rect_.width(), |
| 2172 swap_buffer_rect_.height()); | 2176 swap_buffer_rect_.height()); |
| 2173 } else { | 2177 } else { |
| 2174 compositor_frame.gl_frame_data->sub_buffer_rect = | 2178 compositor_frame.gl_frame_data->sub_buffer_rect = |
| 2175 gfx::Rect(output_surface_->SurfaceSize()); | 2179 gfx::Rect(output_surface_->SurfaceSize()); |
| 2176 } | 2180 } |
| 2177 output_surface_->SwapBuffers(&compositor_frame); | 2181 output_surface_->SwapBuffers(&compositor_frame); |
| 2178 | 2182 |
| 2183 // Release previously used overlay resources and hold onto the pending ones |
| 2184 // until the next swap buffers. |
| 2185 in_use_overlay_resources_.clear(); |
| 2186 in_use_overlay_resources_.swap(pending_overlay_resources_); |
| 2187 |
| 2179 swap_buffer_rect_ = gfx::Rect(); | 2188 swap_buffer_rect_ = gfx::Rect(); |
| 2180 | 2189 |
| 2181 // We don't have real fences, so we mark read fences as passed | 2190 // We don't have real fences, so we mark read fences as passed |
| 2182 // assuming a double-buffered GPU pipeline. A texture can be | 2191 // assuming a double-buffered GPU pipeline. A texture can be |
| 2183 // written to after one full frame has past since it was last read. | 2192 // written to after one full frame has past since it was last read. |
| 2184 if (last_swap_fence_.get()) | 2193 if (last_swap_fence_.get()) |
| 2185 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); | 2194 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); |
| 2186 last_swap_fence_ = resource_provider_->GetReadLockFence(); | 2195 last_swap_fence_ = resource_provider_->GetReadLockFence(); |
| 2187 resource_provider_->SetReadLockFence(new SimpleSwapFence()); | 2196 resource_provider_->SetReadLockFence(new SimpleSwapFence()); |
| 2188 } | 2197 } |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3043 // Make sure scissoring starts as disabled. | 3052 // Make sure scissoring starts as disabled. |
| 3044 is_scissor_enabled_ = false; | 3053 is_scissor_enabled_ = false; |
| 3045 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); | 3054 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); |
| 3046 scissor_rect_needs_reset_ = true; | 3055 scissor_rect_needs_reset_ = true; |
| 3047 } | 3056 } |
| 3048 | 3057 |
| 3049 bool GLRenderer::IsContextLost() { | 3058 bool GLRenderer::IsContextLost() { |
| 3050 return output_surface_->context_provider()->IsContextLost(); | 3059 return output_surface_->context_provider()->IsContextLost(); |
| 3051 } | 3060 } |
| 3052 | 3061 |
| 3062 void GLRenderer::ScheduleOverlays(DrawingFrame* frame) { |
| 3063 if (!frame->overlay_list.size()) |
| 3064 return; |
| 3065 |
| 3066 ResourceProvider::ResourceIdArray resources; |
| 3067 OverlayCandidateList& overlays = frame->overlay_list; |
| 3068 OverlayCandidateList::iterator it; |
| 3069 for (it = overlays.begin(); it != overlays.end(); ++it) { |
| 3070 const OverlayCandidate& overlay = *it; |
| 3071 // Skip primary plane. |
| 3072 if (overlay.plane_z_order == 0) |
| 3073 continue; |
| 3074 |
| 3075 pending_overlay_resources_.push_back( |
| 3076 make_scoped_ptr(new ResourceProvider::ScopedReadLockGL( |
| 3077 resource_provider(), overlay.resource_id))); |
| 3078 |
| 3079 context_support_->ScheduleOverlayPlane( |
| 3080 overlay.plane_z_order, |
| 3081 overlay.transform, |
| 3082 pending_overlay_resources_.back()->texture_id(), |
| 3083 overlay.display_rect, |
| 3084 overlay.uv_rect); |
| 3085 } |
| 3086 } |
| 3087 |
| 3053 } // namespace cc | 3088 } // namespace cc |
| OLD | NEW |