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

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

Issue 2754663003: DCLayerOverlay should damage entire frame on resize. (Closed)
Patch Set: update test Created 3 years, 9 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/dc_layer_overlay.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/dc_layer_overlay.h" 5 #include "cc/output/dc_layer_overlay.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/quads/solid_color_draw_quad.h" 8 #include "cc/quads/solid_color_draw_quad.h"
9 #include "cc/quads/yuv_video_draw_quad.h" 9 #include "cc/quads/yuv_video_draw_quad.h"
10 #include "cc/resources/resource_provider.h" 10 #include "cc/resources/resource_provider.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return result; 106 return result;
107 } 107 }
108 108
109 void DCLayerOverlayProcessor::Process(ResourceProvider* resource_provider, 109 void DCLayerOverlayProcessor::Process(ResourceProvider* resource_provider,
110 const gfx::RectF& display_rect, 110 const gfx::RectF& display_rect,
111 QuadList* quad_list, 111 QuadList* quad_list,
112 gfx::Rect* overlay_damage_rect, 112 gfx::Rect* overlay_damage_rect,
113 gfx::Rect* damage_rect, 113 gfx::Rect* damage_rect,
114 DCLayerOverlayList* ca_layer_overlays) { 114 DCLayerOverlayList* ca_layer_overlays) {
115 gfx::Rect this_frame_underlay_rect; 115 gfx::Rect this_frame_underlay_rect;
116 bool display_rect_changed = (display_rect != previous_display_rect_);
116 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) { 117 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) {
117 DCLayerOverlay ca_layer; 118 DCLayerOverlay ca_layer;
118 DCLayerResult result = FromDrawQuad(resource_provider, display_rect, 119 DCLayerResult result = FromDrawQuad(resource_provider, display_rect,
119 quad_list->begin(), it, &ca_layer); 120 quad_list->begin(), it, &ca_layer);
120 if (result != DC_LAYER_SUCCESS) 121 if (result != DC_LAYER_SUCCESS)
121 continue; 122 continue;
122 gfx::Rect quad_rectangle = MathUtil::MapEnclosingClippedRect( 123 gfx::Rect quad_rectangle = MathUtil::MapEnclosingClippedRect(
123 it->shared_quad_state->quad_to_target_transform, it->rect); 124 it->shared_quad_state->quad_to_target_transform, it->rect);
124 gfx::RectF occlusion_bounding_box = 125 gfx::RectF occlusion_bounding_box =
125 GetOcclusionBounds(gfx::RectF(quad_rectangle), quad_list->begin(), it); 126 GetOcclusionBounds(gfx::RectF(quad_rectangle), quad_list->begin(), it);
127 overlay_damage_rect->Union(quad_rectangle);
126 128
127 if (occlusion_bounding_box.IsEmpty()) { 129 if (occlusion_bounding_box.IsEmpty()) {
128 // The quad is on top, so promote it to an overlay and remove all damage 130 // The quad is on top, so promote it to an overlay and remove all damage
129 // underneath it. 131 // underneath it.
130 if (it->shared_quad_state->quad_to_target_transform 132 if (it->shared_quad_state->quad_to_target_transform
131 .Preserves2dAxisAlignment()) { 133 .Preserves2dAxisAlignment() &&
134 !display_rect_changed) {
132 damage_rect->Subtract(quad_rectangle); 135 damage_rect->Subtract(quad_rectangle);
133 overlay_damage_rect->Union(quad_rectangle);
134 } 136 }
135 quad_list->EraseAndInvalidateAllPointers(it); 137 quad_list->EraseAndInvalidateAllPointers(it);
136 } else { 138 } else {
137 // The quad is occluded, so replace it with a black solid color quad and 139 // The quad is occluded, so replace it with a black solid color quad and
138 // place the overlay itself under the quad. 140 // place the overlay itself under the quad.
139 if (it->shared_quad_state->quad_to_target_transform 141 if (it->shared_quad_state->quad_to_target_transform
140 .IsIdentityOrIntegerTranslation()) { 142 .IsIdentityOrIntegerTranslation()) {
141 this_frame_underlay_rect = quad_rectangle; 143 this_frame_underlay_rect = quad_rectangle;
142 } 144 }
143 ca_layer.shared_state->z_order = -1; 145 ca_layer.shared_state->z_order = -1;
144 const SharedQuadState* shared_quad_state = it->shared_quad_state; 146 const SharedQuadState* shared_quad_state = it->shared_quad_state;
145 gfx::Rect rect = it->visible_rect; 147 gfx::Rect rect = it->visible_rect;
146 SolidColorDrawQuad* replacement = 148 SolidColorDrawQuad* replacement =
147 quad_list->ReplaceExistingElement<SolidColorDrawQuad>(it); 149 quad_list->ReplaceExistingElement<SolidColorDrawQuad>(it);
148 replacement->SetAll(shared_quad_state, rect, rect, rect, false, 150 replacement->SetAll(shared_quad_state, rect, rect, rect, false,
149 SK_ColorTRANSPARENT, true); 151 SK_ColorTRANSPARENT, true);
150 152
151 if (this_frame_underlay_rect == previous_frame_underlay_rect_) { 153 if (this_frame_underlay_rect == previous_frame_underlay_rect_) {
152 // If this underlay rect is the same as for last frame, subtract its 154 // If this underlay rect is the same as for last frame, subtract its
153 // area from the damage of the main surface, as the cleared area was 155 // area from the damage of the main surface, as the cleared area was
154 // already cleared last frame. Add back the damage from the occluded 156 // already cleared last frame. Add back the damage from the occluded
155 // area for this and last frame, as that may have changed. 157 // area for this and last frame, as that may have changed.
156 if (it->shared_quad_state->quad_to_target_transform 158 if (it->shared_quad_state->quad_to_target_transform
157 .Preserves2dAxisAlignment()) { 159 .Preserves2dAxisAlignment() &&
160 !display_rect_changed) {
158 gfx::Rect occluding_damage_rect = *damage_rect; 161 gfx::Rect occluding_damage_rect = *damage_rect;
159 occluding_damage_rect.Intersect(quad_rectangle); 162 occluding_damage_rect.Intersect(quad_rectangle);
160 damage_rect->Subtract(quad_rectangle); 163 damage_rect->Subtract(quad_rectangle);
161 gfx::Rect new_occlusion_bounding_box = 164 gfx::Rect new_occlusion_bounding_box =
162 gfx::ToEnclosingRect(occlusion_bounding_box); 165 gfx::ToEnclosingRect(occlusion_bounding_box);
163 new_occlusion_bounding_box.Union(previous_occlusion_bounding_box_); 166 new_occlusion_bounding_box.Union(previous_occlusion_bounding_box_);
164 occluding_damage_rect.Intersect(new_occlusion_bounding_box); 167 occluding_damage_rect.Intersect(new_occlusion_bounding_box);
165 168
166 damage_rect->Union(occluding_damage_rect); 169 damage_rect->Union(occluding_damage_rect);
167 overlay_damage_rect->Union(quad_rectangle);
168 } 170 }
169 } else { 171 } else {
170 // Entire replacement quad must be redrawn. 172 // Entire replacement quad must be redrawn.
171 damage_rect->Union(quad_rectangle); 173 damage_rect->Union(quad_rectangle);
172 } 174 }
173 previous_occlusion_bounding_box_ = 175 previous_occlusion_bounding_box_ =
174 gfx::ToEnclosingRect(occlusion_bounding_box); 176 gfx::ToEnclosingRect(occlusion_bounding_box);
175 } 177 }
176 178
177 ca_layer_overlays->push_back(ca_layer); 179 ca_layer_overlays->push_back(ca_layer);
178 // Only allow one overlay for now. 180 // Only allow one overlay for now.
179 break; 181 break;
180 } 182 }
183 damage_rect->Intersect(gfx::ToEnclosingRect(display_rect));
181 previous_frame_underlay_rect_ = this_frame_underlay_rect; 184 previous_frame_underlay_rect_ = this_frame_underlay_rect;
185 previous_display_rect_ = display_rect;
182 } 186 }
183 187
184 } // namespace cc 188 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/dc_layer_overlay.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698