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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 on_demand_tile_raster_resource_id_(0), | 341 on_demand_tile_raster_resource_id_(0), |
342 bound_geometry_(NO_BINDING) { | 342 bound_geometry_(NO_BINDING) { |
343 DCHECK(gl_); | 343 DCHECK(gl_); |
344 DCHECK(context_support_); | 344 DCHECK(context_support_); |
345 | 345 |
346 ContextProvider::Capabilities context_caps = | 346 ContextProvider::Capabilities context_caps = |
347 output_surface_->context_provider()->ContextCapabilities(); | 347 output_surface_->context_provider()->ContextCapabilities(); |
348 | 348 |
349 capabilities_.using_partial_swap = | 349 capabilities_.using_partial_swap = |
350 settings_->partial_swap_enabled && context_caps.gpu.post_sub_buffer; | 350 settings_->partial_swap_enabled && context_caps.gpu.post_sub_buffer; |
| 351 capabilities_.allow_empty_swap = capabilities_.using_partial_swap || |
| 352 context_caps.gpu.commit_overlay_planes; |
351 | 353 |
352 DCHECK(!context_caps.gpu.iosurface || context_caps.gpu.texture_rectangle); | 354 DCHECK(!context_caps.gpu.iosurface || context_caps.gpu.texture_rectangle); |
353 | 355 |
354 capabilities_.using_egl_image = context_caps.gpu.egl_image_external; | 356 capabilities_.using_egl_image = context_caps.gpu.egl_image_external; |
355 | 357 |
356 capabilities_.max_texture_size = resource_provider_->max_texture_size(); | 358 capabilities_.max_texture_size = resource_provider_->max_texture_size(); |
357 capabilities_.best_texture_format = resource_provider_->best_texture_format(); | 359 capabilities_.best_texture_format = resource_provider_->best_texture_format(); |
358 | 360 |
359 // The updater can access textures while the GLRenderer is using them. | 361 // The updater can access textures while the GLRenderer is using them. |
360 capabilities_.allow_partial_texture_updates = true; | 362 capabilities_.allow_partial_texture_updates = true; |
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2611 // If supported, we can save significant bandwidth by only swapping the | 2613 // If supported, we can save significant bandwidth by only swapping the |
2612 // damaged/scissored region (clamped to the viewport). | 2614 // damaged/scissored region (clamped to the viewport). |
2613 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); | 2615 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); |
2614 int flipped_y_pos_of_rect_bottom = surface_size.height() - | 2616 int flipped_y_pos_of_rect_bottom = surface_size.height() - |
2615 swap_buffer_rect_.y() - | 2617 swap_buffer_rect_.y() - |
2616 swap_buffer_rect_.height(); | 2618 swap_buffer_rect_.height(); |
2617 compositor_frame.gl_frame_data->sub_buffer_rect = | 2619 compositor_frame.gl_frame_data->sub_buffer_rect = |
2618 gfx::Rect(swap_buffer_rect_.x(), | 2620 gfx::Rect(swap_buffer_rect_.x(), |
2619 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom | 2621 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom |
2620 : swap_buffer_rect_.y(), | 2622 : swap_buffer_rect_.y(), |
2621 swap_buffer_rect_.width(), | 2623 swap_buffer_rect_.width(), swap_buffer_rect_.height()); |
2622 swap_buffer_rect_.height()); | |
2623 } else { | 2624 } else { |
2624 compositor_frame.gl_frame_data->sub_buffer_rect = | 2625 // Expand the swap rect to the full surface unless it's empty, and empty |
2625 gfx::Rect(output_surface_->SurfaceSize()); | 2626 // swap is allowed. |
| 2627 if (!swap_buffer_rect_.IsEmpty() || !capabilities_.allow_empty_swap) { |
| 2628 swap_buffer_rect_ = gfx::Rect(surface_size); |
| 2629 } |
| 2630 compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_; |
2626 } | 2631 } |
2627 output_surface_->SwapBuffers(&compositor_frame); | 2632 output_surface_->SwapBuffers(&compositor_frame); |
2628 | 2633 |
2629 // We always hold onto resources for an extra frame, to make sure we don't | 2634 // We always hold onto resources for an extra frame, to make sure we don't |
2630 // update the buffer while it's being scanned out. On some platforms, hold | 2635 // update the buffer while it's being scanned out. On some platforms, hold |
2631 // on to resources for an extra frame. | 2636 // on to resources for an extra frame. |
2632 if (settings_->delay_releasing_overlay_resources) { | 2637 if (settings_->delay_releasing_overlay_resources) { |
2633 previous_swap_overlay_resources_[1].clear(); | 2638 previous_swap_overlay_resources_[1].clear(); |
2634 previous_swap_overlay_resources_[1].swap( | 2639 previous_swap_overlay_resources_[1].swap( |
2635 previous_swap_overlay_resources_[0]); | 2640 previous_swap_overlay_resources_[0]); |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 texture_id = pending_overlay_resources_.back()->texture_id(); | 3582 texture_id = pending_overlay_resources_.back()->texture_id(); |
3578 } | 3583 } |
3579 | 3584 |
3580 context_support_->ScheduleOverlayPlane( | 3585 context_support_->ScheduleOverlayPlane( |
3581 overlay.plane_z_order, overlay.transform, texture_id, | 3586 overlay.plane_z_order, overlay.transform, texture_id, |
3582 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3587 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
3583 } | 3588 } |
3584 } | 3589 } |
3585 | 3590 |
3586 } // namespace cc | 3591 } // namespace cc |
OLD | NEW |