| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/overlay_processor.h" | 5 #include "cc/output/overlay_processor.h" |
| 6 | 6 |
| 7 #include "cc/output/output_surface.h" | 7 #include "cc/output/output_surface.h" |
| 8 #include "cc/output/overlay_strategy_single_on_top.h" | 8 #include "cc/output/overlay_strategy_single_on_top.h" |
| 9 #include "cc/output/overlay_strategy_underlay.h" | 9 #include "cc/output/overlay_strategy_underlay.h" |
| 10 #include "cc/quads/draw_quad.h" | 10 #include "cc/quads/draw_quad.h" |
| 11 #include "cc/resources/resource_provider.h" |
| 11 #include "ui/gfx/geometry/rect_conversions.h" | 12 #include "ui/gfx/geometry/rect_conversions.h" |
| 12 #include "ui/gfx/transform.h" | 13 #include "ui/gfx/transform.h" |
| 13 | 14 |
| 15 namespace { |
| 16 |
| 17 // Utility class to make sure that we notify resource that they're promotable |
| 18 // before returning from ProcessForOverlays. |
| 19 class NotifyPromotionsBeforeReturning { |
| 20 public: |
| 21 NotifyPromotionsBeforeReturning(cc::ResourceProvider* resource_provider, |
| 22 cc::OverlayCandidateList* candidates) |
| 23 : resource_provider_(resource_provider), candidates_(candidates) {} |
| 24 ~NotifyPromotionsBeforeReturning() { |
| 25 #if defined(OS_ANDROID) |
| 26 resource_provider_->SendPromotionHints( |
| 27 candidates_->promotable_resource_hints_); |
| 28 #endif |
| 29 } |
| 30 |
| 31 private: |
| 32 cc::ResourceProvider* resource_provider_; |
| 33 cc::OverlayCandidateList* candidates_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(NotifyPromotionsBeforeReturning); |
| 36 }; |
| 37 |
| 38 } // namespace |
| 39 |
| 14 namespace cc { | 40 namespace cc { |
| 15 | 41 |
| 16 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) { | 42 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) { |
| 17 } | 43 } |
| 18 | 44 |
| 19 void OverlayProcessor::Initialize() { | 45 void OverlayProcessor::Initialize() { |
| 20 DCHECK(surface_); | 46 DCHECK(surface_); |
| 21 OverlayCandidateValidator* validator = | 47 OverlayCandidateValidator* validator = |
| 22 surface_->GetOverlayCandidateValidator(); | 48 surface_->GetOverlayCandidateValidator(); |
| 23 if (validator) | 49 if (validator) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 overlay_damage_rect_ = render_pass->output_rect; | 81 overlay_damage_rect_ = render_pass->output_rect; |
| 56 *damage_rect = gfx::Rect(); | 82 *damage_rect = gfx::Rect(); |
| 57 return true; | 83 return true; |
| 58 } | 84 } |
| 59 | 85 |
| 60 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider, | 86 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider, |
| 61 RenderPass* render_pass, | 87 RenderPass* render_pass, |
| 62 OverlayCandidateList* candidates, | 88 OverlayCandidateList* candidates, |
| 63 CALayerOverlayList* ca_layer_overlays, | 89 CALayerOverlayList* ca_layer_overlays, |
| 64 gfx::Rect* damage_rect) { | 90 gfx::Rect* damage_rect) { |
| 91 // Be sure to send out notifications, regardless of whether we get to |
| 92 // processing for overlays or not. If we don't, then we should notify that |
| 93 // they are not promotable. |
| 94 // TODO(liberato): should we only notify 'yes' instances, and make the |
| 95 // glimage infer the 'no' instances? that seems flaky, though. |
| 96 NotifyPromotionsBeforeReturning notify(resource_provider, candidates); |
| 97 |
| 65 // If we have any copy requests, we can't remove any quads for overlays or | 98 // If we have any copy requests, we can't remove any quads for overlays or |
| 66 // CALayers because the framebuffer would be missing the removed quads' | 99 // CALayers because the framebuffer would be missing the removed quads' |
| 67 // contents. | 100 // contents. |
| 68 if (!render_pass->copy_requests.empty()) { | 101 if (!render_pass->copy_requests.empty()) { |
| 69 // If overlay processing was skipped for a frame there's no way to be sure | 102 // If overlay processing was skipped for a frame there's no way to be sure |
| 70 // of the state of the previous frame, so reset. | 103 // of the state of the previous frame, so reset. |
| 71 previous_frame_underlay_rect_ = gfx::Rect(); | 104 previous_frame_underlay_rect_ = gfx::Rect(); |
| 72 return; | 105 return; |
| 73 } | 106 } |
| 74 | 107 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 148 } |
| 116 | 149 |
| 117 if (this_frame_underlay_rect == previous_frame_underlay_rect_) | 150 if (this_frame_underlay_rect == previous_frame_underlay_rect_) |
| 118 damage_rect->Subtract(this_frame_underlay_rect); | 151 damage_rect->Subtract(this_frame_underlay_rect); |
| 119 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 152 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
| 120 | 153 |
| 121 damage_rect->Union(output_surface_overlay_damage_rect); | 154 damage_rect->Union(output_surface_overlay_damage_rect); |
| 122 } | 155 } |
| 123 | 156 |
| 124 } // namespace cc | 157 } // namespace cc |
| OLD | NEW |