Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Side by Side Diff: cc/output/overlay_strategy_single_on_top.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/overlay_strategy_single_on_top.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::IsInvisibleQuad(const DrawQuad* draw_quad) {
123 if (draw_quad->material == DrawQuad::SOLID_COLOR) {
124 const SolidColorDrawQuad* solid_quad =
125 SolidColorDrawQuad::MaterialCast(draw_quad);
126 SkColor color = solid_quad->color;
127 float opacity = solid_quad->opacity();
128 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
129 // Ignore transparent solid color quads.
130 return solid_quad->ShouldDrawWithBlending() &&
131 alpha < std::numeric_limits<float>::epsilon();
132 }
133 return false;
134 }
135
122 bool OverlayStrategySingleOnTop::Attempt( 136 bool OverlayStrategySingleOnTop::Attempt(
123 RenderPassList* render_passes_in_draw_order, 137 RenderPassList* render_passes_in_draw_order,
124 OverlayCandidateList* candidate_list) { 138 OverlayCandidateList* candidate_list) {
125 // Only attempt to handle very simple case for now. 139 // Only attempt to handle very simple case for now.
126 if (!capability_checker_) 140 if (!capability_checker_)
127 return false; 141 return false;
128 142
129 RenderPass* root_render_pass = render_passes_in_draw_order->back(); 143 RenderPass* root_render_pass = render_passes_in_draw_order->back();
130 DCHECK(root_render_pass); 144 DCHECK(root_render_pass);
131 145
132 OverlayCandidate candidate; 146 OverlayCandidate candidate;
133 QuadList& quad_list = root_render_pass->quad_list; 147 QuadList& quad_list = root_render_pass->quad_list;
134 auto candidate_iterator = quad_list.end(); 148 auto candidate_iterator = quad_list.end();
135 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) { 149 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) {
136 const DrawQuad* draw_quad = *it; 150 const DrawQuad* draw_quad = *it;
137 if (IsOverlayQuad(draw_quad)) { 151 if (IsOverlayQuad(draw_quad)) {
138 // Check that no prior quads overlap it. 152 // Check that no prior quads overlap it.
139 bool intersects = false; 153 bool intersects = false;
140 gfx::RectF rect = draw_quad->rect; 154 gfx::RectF rect = draw_quad->rect;
141 draw_quad->quadTransform().TransformRect(&rect); 155 draw_quad->quadTransform().TransformRect(&rect);
142 for (auto overlap_iter = quad_list.cbegin(); overlap_iter != it; 156 for (auto overlap_iter = quad_list.cbegin(); overlap_iter != it;
143 ++overlap_iter) { 157 ++overlap_iter) {
144 gfx::RectF overlap_rect = overlap_iter->rect; 158 gfx::RectF overlap_rect = overlap_iter->rect;
145 overlap_iter->quadTransform().TransformRect(&overlap_rect); 159 overlap_iter->quadTransform().TransformRect(&overlap_rect);
146 if (rect.Intersects(overlap_rect)) { 160 if (rect.Intersects(overlap_rect) && !IsInvisibleQuad(*overlap_iter)) {
147 intersects = true; 161 intersects = true;
148 break; 162 break;
149 } 163 }
150 } 164 }
151 if (intersects || !GetCandidateQuadInfo(*draw_quad, &candidate)) 165 if (intersects || !GetCandidateQuadInfo(*draw_quad, &candidate))
152 continue; 166 continue;
153 candidate_iterator = it; 167 candidate_iterator = it;
154 break; 168 break;
155 } 169 }
156 } 170 }
(...skipping 16 matching lines...) Expand all
173 // If the candidate can be handled by an overlay, create a pass for it. 187 // If the candidate can be handled by an overlay, create a pass for it.
174 if (candidates[1].overlay_handled) { 188 if (candidates[1].overlay_handled) {
175 quad_list.EraseAndInvalidateAllPointers(candidate_iterator); 189 quad_list.EraseAndInvalidateAllPointers(candidate_iterator);
176 candidate_list->swap(candidates); 190 candidate_list->swap(candidates);
177 return true; 191 return true;
178 } 192 }
179 return false; 193 return false;
180 } 194 }
181 195
182 } // namespace cc 196 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/overlay_strategy_single_on_top.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698