| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 }; | 360 }; |
| 361 | 361 |
| 362 gpu::gles2::GLES2Interface* gl_; | 362 gpu::gles2::GLES2Interface* gl_; |
| 363 unsigned query_id_; | 363 unsigned query_id_; |
| 364 bool is_pending_; | 364 bool is_pending_; |
| 365 base::WeakPtrFactory<SyncQuery> weak_ptr_factory_; | 365 base::WeakPtrFactory<SyncQuery> weak_ptr_factory_; |
| 366 | 366 |
| 367 DISALLOW_COPY_AND_ASSIGN(SyncQuery); | 367 DISALLOW_COPY_AND_ASSIGN(SyncQuery); |
| 368 }; | 368 }; |
| 369 | 369 |
| 370 GLRenderer::GLRenderer(RendererClient* client, | 370 GLRenderer::GLRenderer(const RendererSettings* settings, |
| 371 const RendererSettings* settings, | |
| 372 OutputSurface* output_surface, | 371 OutputSurface* output_surface, |
| 373 ResourceProvider* resource_provider, | 372 ResourceProvider* resource_provider, |
| 374 TextureMailboxDeleter* texture_mailbox_deleter, | 373 TextureMailboxDeleter* texture_mailbox_deleter, |
| 375 int highp_threshold_min) | 374 int highp_threshold_min) |
| 376 : DirectRenderer(client, settings, output_surface, resource_provider), | 375 : DirectRenderer(settings, output_surface, resource_provider), |
| 377 offscreen_framebuffer_id_(0), | 376 offscreen_framebuffer_id_(0), |
| 378 shared_geometry_quad_(QuadVertexRect()), | 377 shared_geometry_quad_(QuadVertexRect()), |
| 379 gl_(output_surface->context_provider()->ContextGL()), | 378 gl_(output_surface->context_provider()->ContextGL()), |
| 380 context_support_(output_surface->context_provider()->ContextSupport()), | 379 context_support_(output_surface->context_provider()->ContextSupport()), |
| 381 texture_mailbox_deleter_(texture_mailbox_deleter), | 380 texture_mailbox_deleter_(texture_mailbox_deleter), |
| 382 is_backbuffer_discarded_(false), | |
| 383 is_scissor_enabled_(false), | 381 is_scissor_enabled_(false), |
| 384 scissor_rect_needs_reset_(true), | 382 scissor_rect_needs_reset_(true), |
| 385 stencil_shadow_(false), | 383 stencil_shadow_(false), |
| 386 blend_shadow_(false), | 384 blend_shadow_(false), |
| 387 highp_threshold_min_(highp_threshold_min), | 385 highp_threshold_min_(highp_threshold_min), |
| 388 highp_threshold_cache_(0), | 386 highp_threshold_cache_(0), |
| 389 use_sync_query_(false), | 387 use_sync_query_(false), |
| 390 gl_composited_texture_quad_border_( | 388 gl_composited_texture_quad_border_( |
| 391 settings->gl_composited_texture_quad_border), | 389 settings->gl_composited_texture_quad_border), |
| 392 bound_geometry_(NO_BINDING), | 390 bound_geometry_(NO_BINDING), |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 } | 440 } |
| 443 | 441 |
| 444 CleanupSharedObjects(); | 442 CleanupSharedObjects(); |
| 445 } | 443 } |
| 446 | 444 |
| 447 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { | 445 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { |
| 448 return capabilities_; | 446 return capabilities_; |
| 449 } | 447 } |
| 450 | 448 |
| 451 void GLRenderer::DidChangeVisibility() { | 449 void GLRenderer::DidChangeVisibility() { |
| 452 if (!visible()) { | 450 if (visible()) { |
| 451 output_surface_->EnsureBackbuffer(); |
| 452 } else { |
| 453 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); | 453 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); |
| 454 ReleaseRenderPassTextures(); | 454 ReleaseRenderPassTextures(); |
| 455 DiscardBackbuffer(); | 455 output_surface_->DiscardBackbuffer(); |
| 456 } | 456 } |
| 457 | 457 |
| 458 PrepareGeometry(NO_BINDING); | 458 PrepareGeometry(NO_BINDING); |
| 459 | 459 |
| 460 // Handle cleanup of resources on the ContextProvider. The compositor | 460 // Handle cleanup of resources on the ContextProvider. The compositor |
| 461 // ContextProvider is not shared, so always pass 0 for the client_id. | 461 // ContextProvider is not shared, so always pass 0 for the client_id. |
| 462 // TODO(crbug.com/487471): Update this when we share compositor | 462 // TODO(crbug.com/487471): Update this when we share compositor |
| 463 // ContextProviders. | 463 // ContextProviders. |
| 464 context_support_->SetClientVisible(0 /* client_id */, visible()); | 464 context_support_->SetClientVisible(0 /* client_id */, visible()); |
| 465 bool aggressively_free_resources = !context_support_->AnyClientsVisible(); | 465 bool aggressively_free_resources = !context_support_->AnyClientsVisible(); |
| (...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 gfx::Transform quad_rect_matrix; | 2891 gfx::Transform quad_rect_matrix; |
| 2892 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); | 2892 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); |
| 2893 static float gl_matrix[16]; | 2893 static float gl_matrix[16]; |
| 2894 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix); | 2894 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix); |
| 2895 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); | 2895 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); |
| 2896 | 2896 |
| 2897 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); | 2897 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); |
| 2898 } | 2898 } |
| 2899 | 2899 |
| 2900 void GLRenderer::SwapBuffers(CompositorFrameMetadata metadata) { | 2900 void GLRenderer::SwapBuffers(CompositorFrameMetadata metadata) { |
| 2901 DCHECK(!is_backbuffer_discarded_); | 2901 DCHECK(visible()); |
| 2902 | 2902 |
| 2903 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); | 2903 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); |
| 2904 // We're done! Time to swapbuffers! | 2904 // We're done! Time to swapbuffers! |
| 2905 | 2905 |
| 2906 gfx::Size surface_size = output_surface_->SurfaceSize(); | 2906 gfx::Size surface_size = output_surface_->SurfaceSize(); |
| 2907 | 2907 |
| 2908 CompositorFrame compositor_frame; | 2908 CompositorFrame compositor_frame; |
| 2909 compositor_frame.metadata = std::move(metadata); | 2909 compositor_frame.metadata = std::move(metadata); |
| 2910 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); | 2910 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); |
| 2911 compositor_frame.gl_frame_data->size = surface_size; | 2911 compositor_frame.gl_frame_data->size = surface_size; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2982 const gpu::TextureInUseResponses& responses) { | 2982 const gpu::TextureInUseResponses& responses) { |
| 2983 DCHECK(settings_->release_overlay_resources_after_gpu_query); | 2983 DCHECK(settings_->release_overlay_resources_after_gpu_query); |
| 2984 for (const gpu::TextureInUseResponse& response : responses) { | 2984 for (const gpu::TextureInUseResponse& response : responses) { |
| 2985 if (!response.in_use) { | 2985 if (!response.in_use) { |
| 2986 swapped_and_acked_overlay_resources_.erase(response.texture); | 2986 swapped_and_acked_overlay_resources_.erase(response.texture); |
| 2987 } | 2987 } |
| 2988 } | 2988 } |
| 2989 color_lut_cache_.Swap(); | 2989 color_lut_cache_.Swap(); |
| 2990 } | 2990 } |
| 2991 | 2991 |
| 2992 void GLRenderer::DiscardBackbuffer() { | |
| 2993 if (is_backbuffer_discarded_) | |
| 2994 return; | |
| 2995 | |
| 2996 output_surface_->DiscardBackbuffer(); | |
| 2997 | |
| 2998 is_backbuffer_discarded_ = true; | |
| 2999 | |
| 3000 // Damage tracker needs a full reset every time framebuffer is discarded. | |
| 3001 client_->SetFullRootLayerDamage(); | |
| 3002 } | |
| 3003 | |
| 3004 void GLRenderer::EnsureBackbuffer() { | |
| 3005 if (!is_backbuffer_discarded_) | |
| 3006 return; | |
| 3007 | |
| 3008 output_surface_->EnsureBackbuffer(); | |
| 3009 is_backbuffer_discarded_ = false; | |
| 3010 } | |
| 3011 | |
| 3012 void GLRenderer::GetFramebufferPixelsAsync( | 2992 void GLRenderer::GetFramebufferPixelsAsync( |
| 3013 const DrawingFrame* frame, | 2993 const DrawingFrame* frame, |
| 3014 const gfx::Rect& rect, | 2994 const gfx::Rect& rect, |
| 3015 std::unique_ptr<CopyOutputRequest> request) { | 2995 std::unique_ptr<CopyOutputRequest> request) { |
| 3016 DCHECK(!request->IsEmpty()); | 2996 DCHECK(!request->IsEmpty()); |
| 3017 if (request->IsEmpty()) | 2997 if (request->IsEmpty()) |
| 3018 return; | 2998 return; |
| 3019 if (rect.IsEmpty()) | 2999 if (rect.IsEmpty()) |
| 3020 return; | 3000 return; |
| 3021 | 3001 |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4073 | 4053 |
| 4074 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4054 gl_->ScheduleCALayerSharedStateCHROMIUM( |
| 4075 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4055 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
| 4076 sorting_context_id, gl_transform); | 4056 sorting_context_id, gl_transform); |
| 4077 gl_->ScheduleCALayerCHROMIUM( | 4057 gl_->ScheduleCALayerCHROMIUM( |
| 4078 texture_id, contents_rect, ca_layer_overlay->background_color, | 4058 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4079 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4059 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4080 } | 4060 } |
| 4081 | 4061 |
| 4082 } // namespace cc | 4062 } // namespace cc |
| OLD | NEW |