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

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

Issue 128263006: Remove all traces of compositing reasons from cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/layer_impl.h ('k') | webkit/renderer/compositor_bindings/compositor_bindings.gyp » ('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 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/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "cc/animation/animation_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 use_parent_backface_visibility_(false), 56 use_parent_backface_visibility_(false),
57 draw_checkerboard_for_missing_tiles_(false), 57 draw_checkerboard_for_missing_tiles_(false),
58 draws_content_(false), 58 draws_content_(false),
59 hide_layer_and_subtree_(false), 59 hide_layer_and_subtree_(false),
60 force_render_surface_(false), 60 force_render_surface_(false),
61 is_container_for_fixed_position_layers_(false), 61 is_container_for_fixed_position_layers_(false),
62 background_color_(0), 62 background_color_(0),
63 opacity_(1.0), 63 opacity_(1.0),
64 blend_mode_(SkXfermode::kSrcOver_Mode), 64 blend_mode_(SkXfermode::kSrcOver_Mode),
65 draw_depth_(0.f), 65 draw_depth_(0.f),
66 compositing_reasons_(kCompositingReasonUnknown),
67 current_draw_mode_(DRAW_MODE_NONE), 66 current_draw_mode_(DRAW_MODE_NONE),
68 horizontal_scrollbar_layer_(NULL), 67 horizontal_scrollbar_layer_(NULL),
69 vertical_scrollbar_layer_(NULL) { 68 vertical_scrollbar_layer_(NULL) {
70 DCHECK_GT(layer_id_, 0); 69 DCHECK_GT(layer_id_, 0);
71 DCHECK(layer_tree_impl_); 70 DCHECK(layer_tree_impl_);
72 layer_tree_impl_->RegisterLayer(this); 71 layer_tree_impl_->RegisterLayer(this);
73 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); 72 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar();
74 layer_animation_controller_ = 73 layer_animation_controller_ =
75 registrar->GetAnimationControllerForId(layer_id_); 74 registrar->GetAnimationControllerForId(layer_id_);
76 layer_animation_controller_->AddValueObserver(this); 75 layer_animation_controller_->AddValueObserver(this);
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 497 }
499 498
500 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { 499 void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
501 layer->SetAnchorPoint(anchor_point_); 500 layer->SetAnchorPoint(anchor_point_);
502 layer->SetAnchorPointZ(anchor_point_z_); 501 layer->SetAnchorPointZ(anchor_point_z_);
503 layer->SetBackgroundColor(background_color_); 502 layer->SetBackgroundColor(background_color_);
504 layer->SetBounds(bounds_); 503 layer->SetBounds(bounds_);
505 layer->SetContentBounds(content_bounds()); 504 layer->SetContentBounds(content_bounds());
506 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); 505 layer->SetContentsScale(contents_scale_x(), contents_scale_y());
507 layer->SetDebugName(debug_name_); 506 layer->SetDebugName(debug_name_);
508 layer->SetCompositingReasons(compositing_reasons_);
509 layer->SetDoubleSided(double_sided_); 507 layer->SetDoubleSided(double_sided_);
510 layer->SetDrawCheckerboardForMissingTiles( 508 layer->SetDrawCheckerboardForMissingTiles(
511 draw_checkerboard_for_missing_tiles_); 509 draw_checkerboard_for_missing_tiles_);
512 layer->SetForceRenderSurface(force_render_surface_); 510 layer->SetForceRenderSurface(force_render_surface_);
513 layer->SetDrawsContent(DrawsContent()); 511 layer->SetDrawsContent(DrawsContent());
514 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 512 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
515 layer->SetFilters(filters()); 513 layer->SetFilters(filters());
516 layer->SetBackgroundFilters(background_filters()); 514 layer->SetBackgroundFilters(background_filters());
517 layer->SetMasksToBounds(masks_to_bounds_); 515 layer->SetMasksToBounds(masks_to_bounds_);
518 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); 516 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_);
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 horizontal_scrollbar_layer_->set_scroll_layer_id(id()); 1184 horizontal_scrollbar_layer_->set_scroll_layer_id(id());
1187 } 1185 }
1188 1186
1189 void LayerImpl::SetVerticalScrollbarLayer( 1187 void LayerImpl::SetVerticalScrollbarLayer(
1190 ScrollbarLayerImplBase* scrollbar_layer) { 1188 ScrollbarLayerImplBase* scrollbar_layer) {
1191 vertical_scrollbar_layer_ = scrollbar_layer; 1189 vertical_scrollbar_layer_ = scrollbar_layer;
1192 if (vertical_scrollbar_layer_) 1190 if (vertical_scrollbar_layer_)
1193 vertical_scrollbar_layer_->set_scroll_layer_id(id()); 1191 vertical_scrollbar_layer_->set_scroll_layer_id(id());
1194 } 1192 }
1195 1193
1196 static scoped_ptr<base::Value>
1197 CompositingReasonsAsValue(CompositingReasons reasons) {
1198 scoped_ptr<base::ListValue> reason_list(new base::ListValue());
1199
1200 if (reasons == kCompositingReasonUnknown) {
1201 reason_list->AppendString("No reasons given");
1202 return reason_list.PassAs<base::Value>();
1203 }
1204
1205 if (reasons & kCompositingReason3DTransform)
1206 reason_list->AppendString("Has a 3d Transform");
1207
1208 if (reasons & kCompositingReasonVideo)
1209 reason_list->AppendString("Is accelerated video");
1210
1211 if (reasons & kCompositingReasonCanvas)
1212 reason_list->AppendString("Is accelerated canvas");
1213
1214 if (reasons & kCompositingReasonPlugin)
1215 reason_list->AppendString("Is accelerated plugin");
1216
1217 if (reasons & kCompositingReasonIFrame)
1218 reason_list->AppendString("Is accelerated iframe");
1219
1220 if (reasons & kCompositingReasonBackfaceVisibilityHidden)
1221 reason_list->AppendString("Has backface-visibility: hidden");
1222
1223 if (reasons & kCompositingReasonAnimation)
1224 reason_list->AppendString("Has accelerated animation or transition");
1225
1226 if (reasons & kCompositingReasonFilters)
1227 reason_list->AppendString("Has accelerated filters");
1228
1229 if (reasons & kCompositingReasonPositionFixed)
1230 reason_list->AppendString("Is fixed position");
1231
1232 if (reasons & kCompositingReasonPositionSticky)
1233 reason_list->AppendString("Is sticky position");
1234
1235 if (reasons & kCompositingReasonOverflowScrollingTouch)
1236 reason_list->AppendString("Is a scrollable overflow element");
1237
1238 if (reasons & kCompositingReasonAssumedOverlap)
1239 reason_list->AppendString("Might overlap a composited animation");
1240
1241 if (reasons & kCompositingReasonOverlap)
1242 reason_list->AppendString("Overlaps other composited content");
1243
1244 if (reasons & kCompositingReasonNegativeZIndexChildren) {
1245 reason_list->AppendString("Might overlap negative z-index "
1246 "composited content");
1247 }
1248
1249 if (reasons & kCompositingReasonTransformWithCompositedDescendants) {
1250 reason_list->AppendString("Has transform needed by a "
1251 "composited descendant");
1252 }
1253
1254 if (reasons & kCompositingReasonOpacityWithCompositedDescendants)
1255 reason_list->AppendString("Has opacity needed by a composited descendant");
1256
1257 if (reasons & kCompositingReasonMaskWithCompositedDescendants)
1258 reason_list->AppendString("Has a mask needed by a composited descendant");
1259
1260 if (reasons & kCompositingReasonReflectionWithCompositedDescendants)
1261 reason_list->AppendString("Has a reflection with a composited descendant");
1262
1263 if (reasons & kCompositingReasonFilterWithCompositedDescendants)
1264 reason_list->AppendString("Has filter effect with a composited descendant");
1265
1266 if (reasons & kCompositingReasonBlendingWithCompositedDescendants)
1267 reason_list->AppendString("Has a blend mode with a composited descendant");
1268
1269 if (reasons & kCompositingReasonClipsCompositingDescendants)
1270 reason_list->AppendString("Clips a composited descendant");
1271
1272 if (reasons & kCompositingReasonPerspective) {
1273 reason_list->AppendString("Has a perspective transform needed by a "
1274 "composited 3d descendant");
1275 }
1276
1277 if (reasons & kCompositingReasonPreserve3D) {
1278 reason_list->AppendString("Has preserves-3d style with composited "
1279 "3d descendant");
1280 }
1281
1282 if (reasons & kCompositingReasonReflectionOfCompositedParent)
1283 reason_list->AppendString("Is the reflection of a composited layer");
1284
1285 if (reasons & kCompositingReasonRoot)
1286 reason_list->AppendString("Is the root");
1287
1288 if (reasons & kCompositingReasonLayerForClip)
1289 reason_list->AppendString("Convenience layer, to clip subtree");
1290
1291 if (reasons & kCompositingReasonLayerForScrollbar)
1292 reason_list->AppendString("Convenience layer for rendering scrollbar");
1293
1294 if (reasons & kCompositingReasonLayerForScrollingContainer)
1295 reason_list->AppendString("Convenience layer, the scrolling container");
1296
1297 if (reasons & kCompositingReasonLayerForForeground) {
1298 reason_list->AppendString("Convenience layer, foreground when main layer "
1299 "has negative z-index composited content");
1300 }
1301
1302 if (reasons & kCompositingReasonLayerForBackground) {
1303 reason_list->AppendString("Convenience layer, background when main layer "
1304 "has a composited background");
1305 }
1306
1307 if (reasons & kCompositingReasonLayerForMask)
1308 reason_list->AppendString("Is a mask layer");
1309
1310 if (reasons & kCompositingReasonOverflowScrollingParent)
1311 reason_list->AppendString("Scroll parent is not an ancestor");
1312
1313 if (reasons & kCompositingReasonOutOfFlowClipping)
1314 reason_list->AppendString("Has clipping ancestor");
1315
1316 if (reasons & kCompositingReasonIsolateCompositedDescendants)
1317 reason_list->AppendString("Should isolate composited descendants");
1318
1319 return reason_list.PassAs<base::Value>();
1320 }
1321
1322 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { 1194 void LayerImpl::AsValueInto(base::DictionaryValue* state) const {
1323 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this); 1195 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this);
1324 state->SetInteger("layer_id", id()); 1196 state->SetInteger("layer_id", id());
1325 state->SetString("layer_name", debug_name()); 1197 state->SetString("layer_name", debug_name());
1326 state->Set("bounds", MathUtil::AsValue(bounds()).release()); 1198 state->Set("bounds", MathUtil::AsValue(bounds()).release());
1327 state->SetInteger("draws_content", DrawsContent()); 1199 state->SetInteger("draws_content", DrawsContent());
1328 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); 1200 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
1329 state->Set("compositing_reasons",
1330 CompositingReasonsAsValue(compositing_reasons_).release());
1331 1201
1332 bool clipped; 1202 bool clipped;
1333 gfx::QuadF layer_quad = MathUtil::MapQuad( 1203 gfx::QuadF layer_quad = MathUtil::MapQuad(
1334 screen_space_transform(), 1204 screen_space_transform(),
1335 gfx::QuadF(gfx::Rect(content_bounds())), 1205 gfx::QuadF(gfx::Rect(content_bounds())),
1336 &clipped); 1206 &clipped);
1337 state->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); 1207 state->Set("layer_quad", MathUtil::AsValue(layer_quad).release());
1338 1208
1339 if (!touch_event_handler_region_.IsEmpty()) { 1209 if (!touch_event_handler_region_.IsEmpty()) {
1340 state->Set("touch_event_handler_region", 1210 state->Set("touch_event_handler_region",
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 if (layer_animation_controller_->AnimatedBoundsForBox(box, &inflated)) 1246 if (layer_animation_controller_->AnimatedBoundsForBox(box, &inflated))
1377 state->Set("animated_bounds", MathUtil::AsValue(inflated).release()); 1247 state->Set("animated_bounds", MathUtil::AsValue(inflated).release());
1378 } 1248 }
1379 1249
1380 if (debug_info_.get()) { 1250 if (debug_info_.get()) {
1381 std::string str; 1251 std::string str;
1382 debug_info_->AppendAsTraceFormat(&str); 1252 debug_info_->AppendAsTraceFormat(&str);
1383 base::JSONReader json_reader; 1253 base::JSONReader json_reader;
1384 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); 1254 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
1385 1255
1386 // TODO(vollick): The TYPE_LIST code below is brittle; it assumes the only 1256 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) {
1387 // debug info is the layout rects. In future, this will be generalized, and
1388 // debug info will return a dictionary to be merged into state. Until then,
1389 // we unfortunately have to support both situations. Once we've migrated,
1390 // the TYPE_LIST branch will be deleted.
1391 if (debug_info_value->IsType(base::Value::TYPE_LIST)) {
1392 // Parsing the JSON and re-encoding it is not very efficient,
1393 // but it's the simplest way to achieve the desired effect, which
1394 // is to output:
1395 // {..., layout_rects: [{geometry_rect: ...}, ...], ...}
1396 // rather than:
1397 // {layout_rects: "[{geometry_rect: ...}, ...]", ...}
1398 state->Set("layout_rects", debug_info_value.release());
1399 } else if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) {
1400 base::DictionaryValue* dictionary_value = NULL; 1257 base::DictionaryValue* dictionary_value = NULL;
1401 bool converted_to_dictionary = 1258 bool converted_to_dictionary =
1402 debug_info_value->GetAsDictionary(&dictionary_value); 1259 debug_info_value->GetAsDictionary(&dictionary_value);
1403 DCHECK(converted_to_dictionary); 1260 DCHECK(converted_to_dictionary);
1404 state->MergeDictionary(dictionary_value); 1261 state->MergeDictionary(dictionary_value);
1405 } else { 1262 } else {
1406 NOTREACHED(); 1263 NOTREACHED();
1407 } 1264 }
1408 } 1265 }
1409 } 1266 }
1410 1267
1411 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1268 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1412 1269
1413 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1270 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1414 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1271 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1415 AsValueInto(state.get()); 1272 AsValueInto(state.get());
1416 return state.PassAs<base::Value>(); 1273 return state.PassAs<base::Value>();
1417 } 1274 }
1418 1275
1419 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { 1276 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
1420 benchmark->RunOnLayer(this); 1277 benchmark->RunOnLayer(this);
1421 } 1278 }
1422 1279
1423 } // namespace cc 1280 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | webkit/renderer/compositor_bindings/compositor_bindings.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698