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_strategy_single_on_top.h" | 5 #include "cc/output/overlay_strategy_single_on_top.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "cc/quads/draw_quad.h" | 9 #include "cc/quads/draw_quad.h" |
10 #include "cc/quads/solid_color_draw_quad.h" | 10 #include "cc/quads/solid_color_draw_quad.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 if (!GetVideoQuadInfo(quad, quad_info)) | 112 if (!GetVideoQuadInfo(quad, quad_info)) |
113 return false; | 113 return false; |
114 } | 114 } |
115 | 115 |
116 quad_info->format = RGBA_8888; | 116 quad_info->format = RGBA_8888; |
117 quad_info->display_rect = OverlayCandidate::GetOverlayRect( | 117 quad_info->display_rect = OverlayCandidate::GetOverlayRect( |
118 draw_quad.quadTransform(), draw_quad.rect); | 118 draw_quad.quadTransform(), draw_quad.rect); |
119 return true; | 119 return true; |
120 } | 120 } |
121 | 121 |
122 bool OverlayStrategySingleOnTop::DoesQuadBlockOverlay( | |
123 const DrawQuad* draw_quad) { | |
124 if (draw_quad->material == DrawQuad::SOLID_COLOR) { | |
125 const SolidColorDrawQuad* solid_quad = | |
126 SolidColorDrawQuad::MaterialCast(draw_quad); | |
127 SkColor color = solid_quad->color; | |
128 float opacity = solid_quad->opacity(); | |
129 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; | |
130 // Ignore transparent solid color quads. | |
131 return !solid_quad->ShouldDrawWithBlending() || | |
danakj
2015/02/04 18:42:32
!ShouldDrawWithBlending does not mean transparent
achaulk
2015/02/04 22:20:30
Done.
| |
132 alpha >= std::numeric_limits<float>::epsilon(); | |
133 } | |
134 return true; | |
135 } | |
136 | |
122 bool OverlayStrategySingleOnTop::Attempt( | 137 bool OverlayStrategySingleOnTop::Attempt( |
123 RenderPassList* render_passes_in_draw_order, | 138 RenderPassList* render_passes_in_draw_order, |
124 OverlayCandidateList* candidate_list) { | 139 OverlayCandidateList* candidate_list) { |
125 // Only attempt to handle very simple case for now. | 140 // Only attempt to handle very simple case for now. |
126 if (!capability_checker_) | 141 if (!capability_checker_) |
127 return false; | 142 return false; |
128 | 143 |
129 RenderPass* root_render_pass = render_passes_in_draw_order->back(); | 144 RenderPass* root_render_pass = render_passes_in_draw_order->back(); |
130 DCHECK(root_render_pass); | 145 DCHECK(root_render_pass); |
131 | 146 |
132 OverlayCandidate candidate; | 147 OverlayCandidate candidate; |
133 QuadList& quad_list = root_render_pass->quad_list; | 148 QuadList& quad_list = root_render_pass->quad_list; |
134 auto candidate_iterator = quad_list.end(); | 149 auto candidate_iterator = quad_list.end(); |
135 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) { | 150 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) { |
136 const DrawQuad* draw_quad = *it; | 151 const DrawQuad* draw_quad = *it; |
137 if (IsOverlayQuad(draw_quad)) { | 152 if (IsOverlayQuad(draw_quad)) { |
138 // Check that no prior quads overlap it. | 153 // Check that no prior quads overlap it. |
139 bool intersects = false; | 154 bool intersects = false; |
140 gfx::RectF rect = draw_quad->rect; | 155 gfx::RectF rect = draw_quad->rect; |
141 draw_quad->quadTransform().TransformRect(&rect); | 156 draw_quad->quadTransform().TransformRect(&rect); |
142 for (auto overlap_iter = quad_list.cbegin(); overlap_iter != it; | 157 for (auto overlap_iter = quad_list.cbegin(); overlap_iter != it; |
143 ++overlap_iter) { | 158 ++overlap_iter) { |
144 gfx::RectF overlap_rect = overlap_iter->rect; | 159 gfx::RectF overlap_rect = overlap_iter->rect; |
145 overlap_iter->quadTransform().TransformRect(&overlap_rect); | 160 overlap_iter->quadTransform().TransformRect(&overlap_rect); |
146 if (rect.Intersects(overlap_rect)) { | 161 if (rect.Intersects(overlap_rect) && |
162 DoesQuadBlockOverlay(*overlap_iter)) { | |
147 intersects = true; | 163 intersects = true; |
148 break; | 164 break; |
149 } | 165 } |
150 } | 166 } |
151 if (intersects || !GetCandidateQuadInfo(*draw_quad, &candidate)) | 167 if (intersects || !GetCandidateQuadInfo(*draw_quad, &candidate)) |
152 continue; | 168 continue; |
153 candidate_iterator = it; | 169 candidate_iterator = it; |
154 break; | 170 break; |
155 } | 171 } |
156 } | 172 } |
(...skipping 16 matching lines...) Expand all Loading... | |
173 // If the candidate can be handled by an overlay, create a pass for it. | 189 // If the candidate can be handled by an overlay, create a pass for it. |
174 if (candidates[1].overlay_handled) { | 190 if (candidates[1].overlay_handled) { |
175 quad_list.EraseAndInvalidateAllPointers(candidate_iterator); | 191 quad_list.EraseAndInvalidateAllPointers(candidate_iterator); |
176 candidate_list->swap(candidates); | 192 candidate_list->swap(candidates); |
177 return true; | 193 return true; |
178 } | 194 } |
179 return false; | 195 return false; |
180 } | 196 } |
181 | 197 |
182 } // namespace cc | 198 } // namespace cc |
OLD | NEW |