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

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 1175113010: cc: Rename visible_content_rect and content stuff on quads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename-visible-content-rect: comment Created 5 years, 6 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 render_pass->CreateAndAppendSharedQuadState(); 154 render_pass->CreateAndAppendSharedQuadState();
155 155
156 if (raster_source_->IsSolidColor()) { 156 if (raster_source_->IsSolidColor()) {
157 PopulateSharedQuadState(shared_quad_state); 157 PopulateSharedQuadState(shared_quad_state);
158 158
159 AppendDebugBorderQuad( 159 AppendDebugBorderQuad(
160 render_pass, bounds(), shared_quad_state, append_quads_data); 160 render_pass, bounds(), shared_quad_state, append_quads_data);
161 161
162 SolidColorLayerImpl::AppendSolidQuads( 162 SolidColorLayerImpl::AppendSolidQuads(
163 render_pass, draw_properties().occlusion_in_content_space, 163 render_pass, draw_properties().occlusion_in_content_space,
164 shared_quad_state, visible_content_rect(), 164 shared_quad_state, visible_layer_rect(),
165 raster_source_->GetSolidColor(), append_quads_data); 165 raster_source_->GetSolidColor(), append_quads_data);
166 return; 166 return;
167 } 167 }
168 168
169 float max_contents_scale = MaximumTilingContentsScale(); 169 float max_contents_scale = MaximumTilingContentsScale();
170 PopulateScaledSharedQuadState(shared_quad_state, max_contents_scale); 170 PopulateScaledSharedQuadState(shared_quad_state, max_contents_scale);
171 Occlusion scaled_occlusion = 171 Occlusion scaled_occlusion =
172 draw_properties() 172 draw_properties()
173 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( 173 .occlusion_in_content_space.GetOcclusionWithGivenDrawTransform(
174 shared_quad_state->content_to_target_transform); 174 shared_quad_state->quad_to_target_transform);
175 175
176 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { 176 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) {
177 AppendDebugBorderQuad( 177 AppendDebugBorderQuad(
178 render_pass, shared_quad_state->content_bounds, shared_quad_state, 178 render_pass, shared_quad_state->quad_layer_bounds, shared_quad_state,
179 append_quads_data, DebugColors::DirectPictureBorderColor(), 179 append_quads_data, DebugColors::DirectPictureBorderColor(),
180 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); 180 DebugColors::DirectPictureBorderWidth(layer_tree_impl()));
181 181
182 gfx::Rect geometry_rect = shared_quad_state->visible_content_rect; 182 gfx::Rect geometry_rect = shared_quad_state->visible_quad_layer_rect;
183 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); 183 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect();
184 gfx::Rect visible_geometry_rect = 184 gfx::Rect visible_geometry_rect =
185 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); 185 scaled_occlusion.GetUnoccludedContentRect(geometry_rect);
186 if (visible_geometry_rect.IsEmpty()) 186 if (visible_geometry_rect.IsEmpty())
187 return; 187 return;
188 188
189 gfx::Rect quad_content_rect = shared_quad_state->visible_content_rect; 189 gfx::Rect quad_content_rect = shared_quad_state->visible_quad_layer_rect;
190 gfx::Size texture_size = quad_content_rect.size(); 190 gfx::Size texture_size = quad_content_rect.size();
191 gfx::RectF texture_rect = gfx::RectF(texture_size); 191 gfx::RectF texture_rect = gfx::RectF(texture_size);
192 192
193 PictureDrawQuad* quad = 193 PictureDrawQuad* quad =
194 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 194 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>();
195 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, 195 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect,
196 visible_geometry_rect, texture_rect, texture_size, 196 visible_geometry_rect, texture_rect, texture_size,
197 nearest_neighbor_, RGBA_8888, quad_content_rect, 197 nearest_neighbor_, RGBA_8888, quad_content_rect,
198 max_contents_scale, raster_source_); 198 max_contents_scale, raster_source_);
199 ValidateQuadResources(quad); 199 ValidateQuadResources(quad);
200 return; 200 return;
201 } 201 }
202 202
203 AppendDebugBorderQuad(render_pass, shared_quad_state->content_bounds, 203 AppendDebugBorderQuad(render_pass, shared_quad_state->quad_layer_bounds,
204 shared_quad_state, append_quads_data); 204 shared_quad_state, append_quads_data);
205 205
206 if (ShowDebugBorders()) { 206 if (ShowDebugBorders()) {
207 for (PictureLayerTilingSet::CoverageIterator iter( 207 for (PictureLayerTilingSet::CoverageIterator iter(
208 tilings_.get(), max_contents_scale, 208 tilings_.get(), max_contents_scale,
209 shared_quad_state->visible_content_rect, ideal_contents_scale_); 209 shared_quad_state->visible_quad_layer_rect, ideal_contents_scale_);
210 iter; ++iter) { 210 iter; ++iter) {
211 SkColor color; 211 SkColor color;
212 float width; 212 float width;
213 if (*iter && iter->draw_info().IsReadyToDraw()) { 213 if (*iter && iter->draw_info().IsReadyToDraw()) {
214 TileDrawInfo::Mode mode = iter->draw_info().mode(); 214 TileDrawInfo::Mode mode = iter->draw_info().mode();
215 if (mode == TileDrawInfo::SOLID_COLOR_MODE) { 215 if (mode == TileDrawInfo::SOLID_COLOR_MODE) {
216 color = DebugColors::SolidColorTileBorderColor(); 216 color = DebugColors::SolidColorTileBorderColor();
217 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); 217 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
218 } else if (mode == TileDrawInfo::OOM_MODE) { 218 } else if (mode == TileDrawInfo::OOM_MODE) {
219 color = DebugColors::OOMTileBorderColor(); 219 color = DebugColors::OOMTileBorderColor();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // normally the same as draw viewport but can be independently overridden by 256 // normally the same as draw viewport but can be independently overridden by
257 // embedders like Android WebView with SetExternalDrawConstraints. 257 // embedders like Android WebView with SetExternalDrawConstraints.
258 gfx::Rect scaled_viewport_for_tile_priority = gfx::ScaleToEnclosingRect( 258 gfx::Rect scaled_viewport_for_tile_priority = gfx::ScaleToEnclosingRect(
259 viewport_rect_for_tile_priority_in_content_space_, max_contents_scale); 259 viewport_rect_for_tile_priority_in_content_space_, max_contents_scale);
260 260
261 size_t missing_tile_count = 0u; 261 size_t missing_tile_count = 0u;
262 size_t on_demand_missing_tile_count = 0u; 262 size_t on_demand_missing_tile_count = 0u;
263 only_used_low_res_last_append_quads_ = true; 263 only_used_low_res_last_append_quads_ = true;
264 for (PictureLayerTilingSet::CoverageIterator iter( 264 for (PictureLayerTilingSet::CoverageIterator iter(
265 tilings_.get(), max_contents_scale, 265 tilings_.get(), max_contents_scale,
266 shared_quad_state->visible_content_rect, ideal_contents_scale_); 266 shared_quad_state->visible_quad_layer_rect, ideal_contents_scale_);
267 iter; ++iter) { 267 iter; ++iter) {
268 gfx::Rect geometry_rect = iter.geometry_rect(); 268 gfx::Rect geometry_rect = iter.geometry_rect();
269 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); 269 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect();
270 gfx::Rect visible_geometry_rect = 270 gfx::Rect visible_geometry_rect =
271 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); 271 scaled_occlusion.GetUnoccludedContentRect(geometry_rect);
272 if (visible_geometry_rect.IsEmpty()) 272 if (visible_geometry_rect.IsEmpty())
273 continue; 273 continue;
274 274
275 append_quads_data->visible_content_area += 275 append_quads_data->visible_layer_area +=
276 visible_geometry_rect.width() * visible_geometry_rect.height(); 276 visible_geometry_rect.width() * visible_geometry_rect.height();
277 277
278 bool has_draw_quad = false; 278 bool has_draw_quad = false;
279 if (*iter && iter->draw_info().IsReadyToDraw()) { 279 if (*iter && iter->draw_info().IsReadyToDraw()) {
280 const TileDrawInfo& draw_info = iter->draw_info(); 280 const TileDrawInfo& draw_info = iter->draw_info();
281 switch (draw_info.mode()) { 281 switch (draw_info.mode()) {
282 case TileDrawInfo::RESOURCE_MODE: { 282 case TileDrawInfo::RESOURCE_MODE: {
283 gfx::RectF texture_rect = iter.texture_rect(); 283 gfx::RectF texture_rect = iter.texture_rect();
284 284
285 // The raster_contents_scale_ is the best scale that the layer is 285 // The raster_contents_scale_ is the best scale that the layer is
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 visible_geometry_rect, 334 visible_geometry_rect,
335 color, 335 color,
336 false); 336 false);
337 ValidateQuadResources(quad); 337 ValidateQuadResources(quad);
338 } 338 }
339 339
340 if (geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { 340 if (geometry_rect.Intersects(scaled_viewport_for_tile_priority)) {
341 append_quads_data->num_missing_tiles++; 341 append_quads_data->num_missing_tiles++;
342 ++missing_tile_count; 342 ++missing_tile_count;
343 } 343 }
344 append_quads_data->approximated_visible_content_area += 344 append_quads_data->approximated_visible_layer_area +=
345 visible_geometry_rect.width() * visible_geometry_rect.height(); 345 visible_geometry_rect.width() * visible_geometry_rect.height();
346 append_quads_data->checkerboarded_visible_content_area += 346 append_quads_data->checkerboarded_visible_layer_area +=
enne (OOO) 2015/06/18 21:02:15 This is not true. I think this in the space of ma
danakj 2015/06/18 21:06:34 I reverted this name and will file a bug.
347 visible_geometry_rect.width() * visible_geometry_rect.height(); 347 visible_geometry_rect.width() * visible_geometry_rect.height();
348 continue; 348 continue;
349 } 349 }
350 350
351 if (iter.resolution() != HIGH_RESOLUTION) { 351 if (iter.resolution() != HIGH_RESOLUTION) {
352 append_quads_data->approximated_visible_content_area += 352 append_quads_data->approximated_visible_layer_area +=
353 visible_geometry_rect.width() * visible_geometry_rect.height(); 353 visible_geometry_rect.width() * visible_geometry_rect.height();
354 } 354 }
355 355
356 // If we have a draw quad, but it's not low resolution, then 356 // If we have a draw quad, but it's not low resolution, then
357 // mark that we've used something other than low res to draw. 357 // mark that we've used something other than low res to draw.
358 if (iter.resolution() != LOW_RESOLUTION) 358 if (iter.resolution() != LOW_RESOLUTION)
359 only_used_low_res_last_append_quads_ = false; 359 only_used_low_res_last_append_quads_ = false;
360 360
361 if (last_append_quads_tilings_.empty() || 361 if (last_append_quads_tilings_.empty() ||
362 last_append_quads_tilings_.back() != iter.CurrentTiling()) { 362 last_append_quads_tilings_.back() != iter.CurrentTiling()) {
363 last_append_quads_tilings_.push_back(iter.CurrentTiling()); 363 last_append_quads_tilings_.push_back(iter.CurrentTiling());
364 } 364 }
365 } 365 }
366 366
367 if (missing_tile_count) { 367 if (missing_tile_count) {
368 TRACE_EVENT_INSTANT2("cc", 368 TRACE_EVENT_INSTANT2("cc",
369 "PictureLayerImpl::AppendQuads checkerboard", 369 "PictureLayerImpl::AppendQuads checkerboard",
370 TRACE_EVENT_SCOPE_THREAD, 370 TRACE_EVENT_SCOPE_THREAD,
371 "missing_tile_count", 371 "missing_tile_count",
372 missing_tile_count, 372 missing_tile_count,
373 "on_demand_missing_tile_count", 373 "on_demand_missing_tile_count",
374 on_demand_missing_tile_count); 374 on_demand_missing_tile_count);
375 } 375 }
376 376
377 // Aggressively remove any tilings that are not seen to save memory. Note 377 // Aggressively remove any tilings that are not seen to save memory. Note
378 // that this is at the expense of doing cause more frequent re-painting. A 378 // that this is at the expense of doing cause more frequent re-painting. A
379 // better scheme would be to maintain a tighter visible_content_rect for the 379 // better scheme would be to maintain a tighter visible_layer_rect for the
380 // finer tilings. 380 // finer tilings.
381 CleanUpTilingsOnActiveLayer(last_append_quads_tilings_); 381 CleanUpTilingsOnActiveLayer(last_append_quads_tilings_);
382 } 382 }
383 383
384 bool PictureLayerImpl::UpdateTiles(bool resourceless_software_draw) { 384 bool PictureLayerImpl::UpdateTiles(bool resourceless_software_draw) {
385 if (!resourceless_software_draw) { 385 if (!resourceless_software_draw) {
386 visible_rect_for_tile_priority_ = visible_content_rect(); 386 visible_rect_for_tile_priority_ = visible_layer_rect();
387 } 387 }
388 388
389 if (!CanHaveTilings()) { 389 if (!CanHaveTilings()) {
390 ideal_page_scale_ = 0.f; 390 ideal_page_scale_ = 0.f;
391 ideal_device_scale_ = 0.f; 391 ideal_device_scale_ = 0.f;
392 ideal_contents_scale_ = 0.f; 392 ideal_contents_scale_ = 0.f;
393 ideal_source_scale_ = 0.f; 393 ideal_source_scale_ = 0.f;
394 SanityCheckTilingState(); 394 SanityCheckTilingState();
395 return false; 395 return false;
396 } 396 }
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 LayerImpl::AsValueInto(state); 1185 LayerImpl::AsValueInto(state);
1186 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 1186 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
1187 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); 1187 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale());
1188 state->BeginArray("tilings"); 1188 state->BeginArray("tilings");
1189 tilings_->AsValueInto(state); 1189 tilings_->AsValueInto(state);
1190 state->EndArray(); 1190 state->EndArray();
1191 1191
1192 MathUtil::AddToTracedValue("tile_priority_rect", 1192 MathUtil::AddToTracedValue("tile_priority_rect",
1193 viewport_rect_for_tile_priority_in_content_space_, 1193 viewport_rect_for_tile_priority_in_content_space_,
1194 state); 1194 state);
1195 MathUtil::AddToTracedValue("visible_rect", visible_content_rect(), state); 1195 MathUtil::AddToTracedValue("visible_rect", visible_layer_rect(), state);
1196 1196
1197 state->BeginArray("pictures"); 1197 state->BeginArray("pictures");
1198 raster_source_->AsValueInto(state); 1198 raster_source_->AsValueInto(state);
1199 state->EndArray(); 1199 state->EndArray();
1200 1200
1201 state->BeginArray("invalidation"); 1201 state->BeginArray("invalidation");
1202 invalidation_.AsValueInto(state); 1202 invalidation_.AsValueInto(state);
1203 state->EndArray(); 1203 state->EndArray();
1204 1204
1205 state->BeginArray("coverage_tiles"); 1205 state->BeginArray("coverage_tiles");
(...skipping 27 matching lines...) Expand all
1233 1233
1234 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1234 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1235 return !layer_tree_impl()->IsRecycleTree(); 1235 return !layer_tree_impl()->IsRecycleTree();
1236 } 1236 }
1237 1237
1238 bool PictureLayerImpl::HasValidTilePriorities() const { 1238 bool PictureLayerImpl::HasValidTilePriorities() const {
1239 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); 1239 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember();
1240 } 1240 }
1241 1241
1242 } // namespace cc 1242 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698