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" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 cc::OverlayCandidateList* candidates_; | 32 cc::OverlayCandidateList* candidates_; |
33 | 33 |
34 DISALLOW_COPY_AND_ASSIGN(SendPromotionHintsBeforeReturning); | 34 DISALLOW_COPY_AND_ASSIGN(SendPromotionHintsBeforeReturning); |
35 }; | 35 }; |
36 #endif | 36 #endif |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 namespace cc { | 40 namespace cc { |
41 | 41 |
42 void OverlayProcessor::Strategy::GetContentBounds( | |
43 std::vector<gfx::Rect>* bounds) {} | |
44 | |
42 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) { | 45 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) { |
43 } | 46 } |
44 | 47 |
45 void OverlayProcessor::Initialize() { | 48 void OverlayProcessor::Initialize() { |
46 DCHECK(surface_); | 49 DCHECK(surface_); |
47 OverlayCandidateValidator* validator = | 50 OverlayCandidateValidator* validator = |
48 surface_->GetOverlayCandidateValidator(); | 51 surface_->GetOverlayCandidateValidator(); |
49 if (validator) | 52 if (validator) |
50 validator->GetStrategies(&strategies_); | 53 validator->GetStrategies(&strategies_); |
51 } | 54 } |
52 | 55 |
53 OverlayProcessor::~OverlayProcessor() {} | 56 OverlayProcessor::~OverlayProcessor() {} |
54 | 57 |
55 gfx::Rect OverlayProcessor::GetAndResetOverlayDamage() { | 58 gfx::Rect OverlayProcessor::GetAndResetOverlayDamage() { |
56 gfx::Rect result = overlay_damage_rect_; | 59 gfx::Rect result = overlay_damage_rect_; |
57 overlay_damage_rect_ = gfx::Rect(); | 60 overlay_damage_rect_ = gfx::Rect(); |
58 return result; | 61 return result; |
59 } | 62 } |
60 | 63 |
64 void OverlayProcessor::GetContentBounds( | |
65 std::vector<gfx::Rect>* content_bounds) { | |
66 DCHECK(content_bounds); | |
67 content_bounds->insert(content_bounds->end(), content_bounds_.begin(), | |
danakj
2017/02/14 17:28:58
why append and not replace the contents?
halliwell
2017/02/15 22:29:04
This function removed now.
| |
68 content_bounds_.end()); | |
69 } | |
70 | |
61 bool OverlayProcessor::ProcessForCALayers( | 71 bool OverlayProcessor::ProcessForCALayers( |
62 ResourceProvider* resource_provider, | 72 ResourceProvider* resource_provider, |
63 RenderPass* render_pass, | 73 RenderPass* render_pass, |
64 const RenderPassFilterList& render_pass_filters, | 74 const RenderPassFilterList& render_pass_filters, |
65 const RenderPassFilterList& render_pass_background_filters, | 75 const RenderPassFilterList& render_pass_background_filters, |
66 OverlayCandidateList* overlay_candidates, | 76 OverlayCandidateList* overlay_candidates, |
67 CALayerOverlayList* ca_layer_overlays, | 77 CALayerOverlayList* ca_layer_overlays, |
68 gfx::Rect* damage_rect) { | 78 gfx::Rect* damage_rect) { |
69 OverlayCandidateValidator* overlay_validator = | 79 OverlayCandidateValidator* overlay_validator = |
70 surface_->GetOverlayCandidateValidator(); | 80 surface_->GetOverlayCandidateValidator(); |
(...skipping 15 matching lines...) Expand all Loading... | |
86 return true; | 96 return true; |
87 } | 97 } |
88 | 98 |
89 void OverlayProcessor::ProcessForOverlays( | 99 void OverlayProcessor::ProcessForOverlays( |
90 ResourceProvider* resource_provider, | 100 ResourceProvider* resource_provider, |
91 RenderPass* render_pass, | 101 RenderPass* render_pass, |
92 const RenderPassFilterList& render_pass_filters, | 102 const RenderPassFilterList& render_pass_filters, |
93 const RenderPassFilterList& render_pass_background_filters, | 103 const RenderPassFilterList& render_pass_background_filters, |
94 OverlayCandidateList* candidates, | 104 OverlayCandidateList* candidates, |
95 CALayerOverlayList* ca_layer_overlays, | 105 CALayerOverlayList* ca_layer_overlays, |
96 gfx::Rect* damage_rect) { | 106 gfx::Rect* damage_rect) { |
danakj
2017/02/14 17:28:58
Shall we just add the bounds here so we don't need
halliwell
2017/02/15 22:29:04
Done.
| |
97 #if defined(OS_ANDROID) | 107 #if defined(OS_ANDROID) |
98 // Be sure to send out notifications, regardless of whether we get to | 108 // Be sure to send out notifications, regardless of whether we get to |
99 // processing for overlays or not. If we don't, then we should notify that | 109 // processing for overlays or not. If we don't, then we should notify that |
100 // they are not promotable. | 110 // they are not promotable. |
101 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); | 111 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); |
102 #endif | 112 #endif |
113 content_bounds_.clear(); | |
103 | 114 |
104 // If we have any copy requests, we can't remove any quads for overlays or | 115 // If we have any copy requests, we can't remove any quads for overlays or |
105 // CALayers because the framebuffer would be missing the removed quads' | 116 // CALayers because the framebuffer would be missing the removed quads' |
106 // contents. | 117 // contents. |
107 if (!render_pass->copy_requests.empty()) { | 118 if (!render_pass->copy_requests.empty()) { |
108 // If overlay processing was skipped for a frame there's no way to be sure | 119 // If overlay processing was skipped for a frame there's no way to be sure |
109 // of the state of the previous frame, so reset. | 120 // of the state of the previous frame, so reset. |
110 previous_frame_underlay_rect_ = gfx::Rect(); | 121 previous_frame_underlay_rect_ = gfx::Rect(); |
111 return; | 122 return; |
112 } | 123 } |
113 | 124 |
114 // First attempt to process for CALayers. | 125 // First attempt to process for CALayers. |
115 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, | 126 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, |
116 render_pass_background_filters, candidates, | 127 render_pass_background_filters, candidates, |
117 ca_layer_overlays, damage_rect)) { | 128 ca_layer_overlays, damage_rect)) { |
118 return; | 129 return; |
119 } | 130 } |
120 | 131 |
121 // Only if that fails, attempt hardware overlay strategies. | 132 // Only if that fails, attempt hardware overlay strategies. |
122 for (const auto& strategy : strategies_) { | 133 for (const auto& strategy : strategies_) { |
123 if (!strategy->Attempt(resource_provider, render_pass, candidates)) | 134 if (!strategy->Attempt(resource_provider, render_pass, candidates)) |
124 continue; | 135 continue; |
125 | 136 |
126 UpdateDamageRect(candidates, damage_rect); | 137 UpdateDamageRect(candidates, damage_rect); |
138 strategy->GetContentBounds(&content_bounds_); | |
127 return; | 139 return; |
128 } | 140 } |
129 } | 141 } |
130 | 142 |
131 // Subtract on-top overlays from the damage rect, unless the overlays use | 143 // Subtract on-top overlays from the damage rect, unless the overlays use |
132 // the backbuffer as their content (in which case, add their combined rect | 144 // the backbuffer as their content (in which case, add their combined rect |
133 // back to the damage at the end). | 145 // back to the damage at the end). |
134 // Also subtract unoccluded underlays from the damage rect if we know that the | 146 // Also subtract unoccluded underlays from the damage rect if we know that the |
135 // same underlay was scheduled on the previous frame. If the renderer decides | 147 // same underlay was scheduled on the previous frame. If the renderer decides |
136 // not to swap the framebuffer there will still be a transparent hole in the | 148 // not to swap the framebuffer there will still be a transparent hole in the |
(...skipping 18 matching lines...) Expand all Loading... | |
155 } | 167 } |
156 | 168 |
157 if (this_frame_underlay_rect == previous_frame_underlay_rect_) | 169 if (this_frame_underlay_rect == previous_frame_underlay_rect_) |
158 damage_rect->Subtract(this_frame_underlay_rect); | 170 damage_rect->Subtract(this_frame_underlay_rect); |
159 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 171 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
160 | 172 |
161 damage_rect->Union(output_surface_overlay_damage_rect); | 173 damage_rect->Union(output_surface_overlay_damage_rect); |
162 } | 174 } |
163 | 175 |
164 } // namespace cc | 176 } // namespace cc |
OLD | NEW |