| 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 17 matching lines...) Expand all Loading... |
| 28 #include "cc/base/math_util.h" | 28 #include "cc/base/math_util.h" |
| 29 #include "cc/output/compositor_frame.h" | 29 #include "cc/output/compositor_frame.h" |
| 30 #include "cc/output/compositor_frame_metadata.h" | 30 #include "cc/output/compositor_frame_metadata.h" |
| 31 #include "cc/output/context_provider.h" | 31 #include "cc/output/context_provider.h" |
| 32 #include "cc/output/copy_output_request.h" | 32 #include "cc/output/copy_output_request.h" |
| 33 #include "cc/output/dynamic_geometry_binding.h" | 33 #include "cc/output/dynamic_geometry_binding.h" |
| 34 #include "cc/output/gl_frame_data.h" | 34 #include "cc/output/gl_frame_data.h" |
| 35 #include "cc/output/layer_quad.h" | 35 #include "cc/output/layer_quad.h" |
| 36 #include "cc/output/output_surface.h" | 36 #include "cc/output/output_surface.h" |
| 37 #include "cc/output/render_surface_filters.h" | 37 #include "cc/output/render_surface_filters.h" |
| 38 #include "cc/output/renderer_settings.h" |
| 38 #include "cc/output/static_geometry_binding.h" | 39 #include "cc/output/static_geometry_binding.h" |
| 39 #include "cc/output/texture_mailbox_deleter.h" | 40 #include "cc/output/texture_mailbox_deleter.h" |
| 40 #include "cc/quads/draw_polygon.h" | 41 #include "cc/quads/draw_polygon.h" |
| 41 #include "cc/quads/picture_draw_quad.h" | 42 #include "cc/quads/picture_draw_quad.h" |
| 42 #include "cc/quads/render_pass.h" | 43 #include "cc/quads/render_pass.h" |
| 43 #include "cc/quads/stream_video_draw_quad.h" | 44 #include "cc/quads/stream_video_draw_quad.h" |
| 44 #include "cc/quads/texture_draw_quad.h" | 45 #include "cc/quads/texture_draw_quad.h" |
| 45 #include "cc/raster/scoped_gpu_raster.h" | 46 #include "cc/raster/scoped_gpu_raster.h" |
| 46 #include "cc/resources/resource_pool.h" | 47 #include "cc/resources/resource_pool.h" |
| 47 #include "cc/resources/scoped_resource.h" | 48 #include "cc/resources/scoped_resource.h" |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 } | 441 } |
| 441 | 442 |
| 442 CleanupSharedObjects(); | 443 CleanupSharedObjects(); |
| 443 } | 444 } |
| 444 | 445 |
| 445 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { | 446 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { |
| 446 return capabilities_; | 447 return capabilities_; |
| 447 } | 448 } |
| 448 | 449 |
| 449 void GLRenderer::DidChangeVisibility() { | 450 void GLRenderer::DidChangeVisibility() { |
| 450 if (visible()) { | 451 if (visible_) { |
| 451 output_surface_->EnsureBackbuffer(); | 452 output_surface_->EnsureBackbuffer(); |
| 452 } else { | 453 } else { |
| 453 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); | 454 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); |
| 454 ReleaseRenderPassTextures(); | 455 ReleaseRenderPassTextures(); |
| 455 output_surface_->DiscardBackbuffer(); | 456 output_surface_->DiscardBackbuffer(); |
| 456 } | 457 } |
| 457 | 458 |
| 458 PrepareGeometry(NO_BINDING); | 459 PrepareGeometry(NO_BINDING); |
| 459 | 460 |
| 460 // Handle cleanup of resources on the ContextProvider. The compositor | 461 // Handle cleanup of resources on the ContextProvider. The compositor |
| 461 // ContextProvider is not shared, so always pass 0 for the client_id. | 462 // ContextProvider is not shared, so always pass 0 for the client_id. |
| 462 // TODO(crbug.com/487471): Update this when we share compositor | 463 // TODO(crbug.com/487471): Update this when we share compositor |
| 463 // ContextProviders. | 464 // ContextProviders. |
| 464 context_support_->SetClientVisible(0 /* client_id */, visible()); | 465 context_support_->SetClientVisible(0 /* client_id */, visible_); |
| 465 bool aggressively_free_resources = !context_support_->AnyClientsVisible(); | 466 bool aggressively_free_resources = !context_support_->AnyClientsVisible(); |
| 466 if (aggressively_free_resources) | 467 if (aggressively_free_resources) |
| 467 output_surface_->context_provider()->DeleteCachedResources(); | 468 output_surface_->context_provider()->DeleteCachedResources(); |
| 468 context_support_->SetAggressivelyFreeResources(aggressively_free_resources); | 469 context_support_->SetAggressivelyFreeResources(aggressively_free_resources); |
| 469 } | 470 } |
| 470 | 471 |
| 471 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } | 472 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } |
| 472 | 473 |
| 473 void GLRenderer::DiscardPixels() { | 474 void GLRenderer::DiscardPixels() { |
| 474 if (!capabilities_.using_discard_framebuffer) | 475 if (!capabilities_.using_discard_framebuffer) |
| (...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 gfx::Transform quad_rect_matrix; | 2892 gfx::Transform quad_rect_matrix; |
| 2892 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); | 2893 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); |
| 2893 static float gl_matrix[16]; | 2894 static float gl_matrix[16]; |
| 2894 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix); | 2895 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix); |
| 2895 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); | 2896 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); |
| 2896 | 2897 |
| 2897 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); | 2898 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); |
| 2898 } | 2899 } |
| 2899 | 2900 |
| 2900 void GLRenderer::SwapBuffers(CompositorFrameMetadata metadata) { | 2901 void GLRenderer::SwapBuffers(CompositorFrameMetadata metadata) { |
| 2901 DCHECK(visible()); | 2902 DCHECK(visible_); |
| 2902 | 2903 |
| 2903 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); | 2904 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); |
| 2904 // We're done! Time to swapbuffers! | 2905 // We're done! Time to swapbuffers! |
| 2905 | 2906 |
| 2906 gfx::Size surface_size = output_surface_->SurfaceSize(); | 2907 gfx::Size surface_size = output_surface_->SurfaceSize(); |
| 2907 | 2908 |
| 2908 CompositorFrame compositor_frame; | 2909 CompositorFrame compositor_frame; |
| 2909 compositor_frame.metadata = std::move(metadata); | 2910 compositor_frame.metadata = std::move(metadata); |
| 2910 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); | 2911 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); |
| 2911 compositor_frame.gl_frame_data->size = surface_size; | 2912 compositor_frame.gl_frame_data->size = surface_size; |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4053 | 4054 |
| 4054 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4055 gl_->ScheduleCALayerSharedStateCHROMIUM( |
| 4055 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4056 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
| 4056 sorting_context_id, gl_transform); | 4057 sorting_context_id, gl_transform); |
| 4057 gl_->ScheduleCALayerCHROMIUM( | 4058 gl_->ScheduleCALayerCHROMIUM( |
| 4058 texture_id, contents_rect, ca_layer_overlay->background_color, | 4059 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4059 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4060 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4060 } | 4061 } |
| 4061 | 4062 |
| 4062 } // namespace cc | 4063 } // namespace cc |
| OLD | NEW |