OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
6 * | 6 * |
7 * Other contributors: | 7 * Other contributors: |
8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 return 0; | 217 return 0; |
218 return GetLayoutObject().View()->Compositor(); | 218 return GetLayoutObject().View()->Compositor(); |
219 } | 219 } |
220 | 220 |
221 void PaintLayer::ContentChanged(ContentChangeType change_type) { | 221 void PaintLayer::ContentChanged(ContentChangeType change_type) { |
222 // updateLayerCompositingState will query compositingReasons for accelerated | 222 // updateLayerCompositingState will query compositingReasons for accelerated |
223 // overflow scrolling. This is tripped by | 223 // overflow scrolling. This is tripped by |
224 // LayoutTests/compositing/content-changed-chicken-egg.html | 224 // LayoutTests/compositing/content-changed-chicken-egg.html |
225 DisableCompositingQueryAsserts disabler; | 225 DisableCompositingQueryAsserts disabler; |
226 | 226 |
227 if (change_type == kCanvasChanged) | 227 if (Compositor()) { |
228 Compositor()->SetNeedsCompositingUpdate( | 228 if (change_type == kCanvasChanged) { |
229 kCompositingUpdateAfterCompositingInputChange); | 229 Compositor()->SetNeedsCompositingUpdate( |
230 kCompositingUpdateAfterCompositingInputChange); | |
231 } | |
230 | 232 |
231 if (change_type == kCanvasContextChanged) { | 233 if (change_type == kCanvasContextChanged) { |
232 Compositor()->SetNeedsCompositingUpdate( | 234 Compositor()->SetNeedsCompositingUpdate( |
233 kCompositingUpdateAfterCompositingInputChange); | 235 kCompositingUpdateAfterCompositingInputChange); |
236 } | |
237 } | |
234 | 238 |
235 // Although we're missing test coverage, we need to call | 239 // Although we're missing test coverage, we need to call |
236 // GraphicsLayer::setContentsToPlatformLayer with the new platform | 240 // GraphicsLayer::setContentsToPlatformLayer with the new platform |
237 // layer for this canvas. | 241 // layer for this canvas. |
238 // See http://crbug.com/349195 | 242 // See http://crbug.com/349195 |
239 if (HasCompositedLayerMapping()) | 243 if (HasCompositedLayerMapping()) { |
wkorman
2017/04/26 01:04:36
It looks like we used to only do this if change_ty
chrishtr
2017/04/26 01:09:38
Oh, that was not intended. Fixed.
| |
240 GetCompositedLayerMapping()->SetNeedsGraphicsLayerUpdate( | 244 GetCompositedLayerMapping()->SetNeedsGraphicsLayerUpdate( |
241 kGraphicsLayerUpdateSubtree); | 245 kGraphicsLayerUpdateSubtree); |
242 } | 246 } |
243 | 247 |
244 if (CompositedLayerMapping* composited_layer_mapping = | 248 if (CompositedLayerMapping* composited_layer_mapping = |
245 this->GetCompositedLayerMapping()) | 249 this->GetCompositedLayerMapping()) |
246 composited_layer_mapping->ContentChanged(change_type); | 250 composited_layer_mapping->ContentChanged(change_type); |
247 } | 251 } |
248 | 252 |
249 bool PaintLayer::PaintsWithFilters() const { | 253 bool PaintLayer::PaintsWithFilters() const { |
250 if (!GetLayoutObject().HasFilterInducingProperty()) | 254 if (!GetLayoutObject().HasFilterInducingProperty()) |
251 return false; | 255 return false; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 | 382 |
379 void PaintLayer::UpdateTransformationMatrix() { | 383 void PaintLayer::UpdateTransformationMatrix() { |
380 if (TransformationMatrix* transform = this->Transform()) { | 384 if (TransformationMatrix* transform = this->Transform()) { |
381 LayoutBox* box = GetLayoutBox(); | 385 LayoutBox* box = GetLayoutBox(); |
382 DCHECK(box); | 386 DCHECK(box); |
383 transform->MakeIdentity(); | 387 transform->MakeIdentity(); |
384 box->Style()->ApplyTransform( | 388 box->Style()->ApplyTransform( |
385 *transform, box->Size(), ComputedStyle::kIncludeTransformOrigin, | 389 *transform, box->Size(), ComputedStyle::kIncludeTransformOrigin, |
386 ComputedStyle::kIncludeMotionPath, | 390 ComputedStyle::kIncludeMotionPath, |
387 ComputedStyle::kIncludeIndependentTransformProperties); | 391 ComputedStyle::kIncludeIndependentTransformProperties); |
388 MakeMatrixRenderable(*transform, Compositor()->HasAcceleratedCompositing()); | 392 MakeMatrixRenderable( |
393 *transform, | |
394 Compositor() ? Compositor()->HasAcceleratedCompositing() : false); | |
389 } | 395 } |
390 } | 396 } |
391 | 397 |
392 void PaintLayer::UpdateTransform(const ComputedStyle* old_style, | 398 void PaintLayer::UpdateTransform(const ComputedStyle* old_style, |
393 const ComputedStyle& new_style) { | 399 const ComputedStyle& new_style) { |
394 // It's possible for the old and new style transform data to be equivalent | 400 // It's possible for the old and new style transform data to be equivalent |
395 // while hasTransform() differs, as it checks a number of conditions aside | 401 // while hasTransform() differs, as it checks a number of conditions aside |
396 // from just the matrix, including but not limited to animation state. | 402 // from just the matrix, including but not limited to animation state. |
397 if (old_style && old_style->HasTransform() == new_style.HasTransform() && | 403 if (old_style && old_style->HasTransform() == new_style.HasTransform() && |
398 new_style.TransformDataEquivalent(*old_style)) { | 404 new_style.TransformDataEquivalent(*old_style)) { |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1024 } | 1030 } |
1025 | 1031 |
1026 void PaintLayer::SetNeedsCompositingInputsUpdateInternal() { | 1032 void PaintLayer::SetNeedsCompositingInputsUpdateInternal() { |
1027 needs_ancestor_dependent_compositing_inputs_update_ = true; | 1033 needs_ancestor_dependent_compositing_inputs_update_ = true; |
1028 | 1034 |
1029 for (PaintLayer* current = this; | 1035 for (PaintLayer* current = this; |
1030 current && !current->child_needs_compositing_inputs_update_; | 1036 current && !current->child_needs_compositing_inputs_update_; |
1031 current = current->Parent()) | 1037 current = current->Parent()) |
1032 current->child_needs_compositing_inputs_update_ = true; | 1038 current->child_needs_compositing_inputs_update_ = true; |
1033 | 1039 |
1034 Compositor()->SetNeedsCompositingUpdate( | 1040 if (Compositor()) { |
1035 kCompositingUpdateAfterCompositingInputChange); | 1041 Compositor()->SetNeedsCompositingUpdate( |
1042 kCompositingUpdateAfterCompositingInputChange); | |
1043 } | |
1036 } | 1044 } |
1037 | 1045 |
1038 void PaintLayer::UpdateAncestorDependentCompositingInputs( | 1046 void PaintLayer::UpdateAncestorDependentCompositingInputs( |
1039 const AncestorDependentCompositingInputs& compositing_inputs, | 1047 const AncestorDependentCompositingInputs& compositing_inputs, |
1040 bool has_ancestor_with_clip_path) { | 1048 bool has_ancestor_with_clip_path) { |
1041 ancestor_dependent_compositing_inputs_ = | 1049 ancestor_dependent_compositing_inputs_ = |
1042 WTF::MakeUnique<AncestorDependentCompositingInputs>(compositing_inputs); | 1050 WTF::MakeUnique<AncestorDependentCompositingInputs>(compositing_inputs); |
1043 has_ancestor_with_clip_path_ = has_ancestor_with_clip_path; | 1051 has_ancestor_with_clip_path_ = has_ancestor_with_clip_path; |
1044 needs_ancestor_dependent_compositing_inputs_update_ = false; | 1052 needs_ancestor_dependent_compositing_inputs_update_ = false; |
1045 } | 1053 } |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1252 } | 1260 } |
1253 | 1261 |
1254 child->parent_ = this; | 1262 child->parent_ = this; |
1255 | 1263 |
1256 // The ancestor overflow layer is calculated during compositing inputs update | 1264 // The ancestor overflow layer is calculated during compositing inputs update |
1257 // and should not be set yet. | 1265 // and should not be set yet. |
1258 CHECK(!child->AncestorOverflowLayer()); | 1266 CHECK(!child->AncestorOverflowLayer()); |
1259 | 1267 |
1260 SetNeedsCompositingInputsUpdate(); | 1268 SetNeedsCompositingInputsUpdate(); |
1261 | 1269 |
1262 if (!child->StackingNode()->IsStacked() && | 1270 if (Compositor()) { |
1263 !GetLayoutObject().DocumentBeingDestroyed()) | 1271 if (!child->StackingNode()->IsStacked() && |
1264 Compositor()->SetNeedsCompositingUpdate(kCompositingUpdateRebuildTree); | 1272 !GetLayoutObject().DocumentBeingDestroyed()) |
1273 Compositor()->SetNeedsCompositingUpdate(kCompositingUpdateRebuildTree); | |
1274 } | |
1265 | 1275 |
1266 if (child->StackingNode()->IsStacked() || child->FirstChild()) { | 1276 if (child->StackingNode()->IsStacked() || child->FirstChild()) { |
1267 // Dirty the z-order list in which we are contained. The | 1277 // Dirty the z-order list in which we are contained. The |
1268 // ancestorStackingContextNode() can be null in the case where we're | 1278 // ancestorStackingContextNode() can be null in the case where we're |
1269 // building up generated content layers. This is ok, since the lists will | 1279 // building up generated content layers. This is ok, since the lists will |
1270 // start off dirty in that case anyway. | 1280 // start off dirty in that case anyway. |
1271 child->StackingNode()->DirtyStackingContextZOrderLists(); | 1281 child->StackingNode()->DirtyStackingContextZOrderLists(); |
1272 } | 1282 } |
1273 | 1283 |
1274 // Non-self-painting children paint into this layer, so the visible contents | 1284 // Non-self-painting children paint into this layer, so the visible contents |
(...skipping 11 matching lines...) Expand all Loading... | |
1286 if (old_child->PreviousSibling()) | 1296 if (old_child->PreviousSibling()) |
1287 old_child->PreviousSibling()->SetNextSibling(old_child->NextSibling()); | 1297 old_child->PreviousSibling()->SetNextSibling(old_child->NextSibling()); |
1288 if (old_child->NextSibling()) | 1298 if (old_child->NextSibling()) |
1289 old_child->NextSibling()->SetPreviousSibling(old_child->PreviousSibling()); | 1299 old_child->NextSibling()->SetPreviousSibling(old_child->PreviousSibling()); |
1290 | 1300 |
1291 if (first_ == old_child) | 1301 if (first_ == old_child) |
1292 first_ = old_child->NextSibling(); | 1302 first_ = old_child->NextSibling(); |
1293 if (last_ == old_child) | 1303 if (last_ == old_child) |
1294 last_ = old_child->PreviousSibling(); | 1304 last_ = old_child->PreviousSibling(); |
1295 | 1305 |
1296 if (!old_child->StackingNode()->IsStacked() && | 1306 if (Compositor()) { |
1297 !GetLayoutObject().DocumentBeingDestroyed()) | 1307 if (!old_child->StackingNode()->IsStacked() && |
1298 Compositor()->SetNeedsCompositingUpdate(kCompositingUpdateRebuildTree); | 1308 !GetLayoutObject().DocumentBeingDestroyed()) |
1309 Compositor()->SetNeedsCompositingUpdate(kCompositingUpdateRebuildTree); | |
1310 } | |
1299 | 1311 |
1300 if (old_child->StackingNode()->IsStacked() || old_child->FirstChild()) { | 1312 if (old_child->StackingNode()->IsStacked() || old_child->FirstChild()) { |
1301 // Dirty the z-order list in which we are contained. When called via the | 1313 // Dirty the z-order list in which we are contained. When called via the |
1302 // reattachment process in removeOnlyThisLayer, the layer may already be | 1314 // reattachment process in removeOnlyThisLayer, the layer may already be |
1303 // disconnected from the main layer tree, so we need to null-check the | 1315 // disconnected from the main layer tree, so we need to null-check the |
1304 // |stackingContext| value. | 1316 // |stackingContext| value. |
1305 old_child->StackingNode()->DirtyStackingContextZOrderLists(); | 1317 old_child->StackingNode()->DirtyStackingContextZOrderLists(); |
1306 } | 1318 } |
1307 | 1319 |
1308 if (GetLayoutObject().Style()->Visibility() != EVisibility::kVisible) | 1320 if (GetLayoutObject().Style()->Visibility() != EVisibility::kVisible) |
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2953 ToReferenceClipPathOperation(old_clip_operation) | 2965 ToReferenceClipPathOperation(old_clip_operation) |
2954 ->RemoveClient(ResourceInfo()); | 2966 ->RemoveClient(ResourceInfo()); |
2955 } | 2967 } |
2956 } | 2968 } |
2957 | 2969 |
2958 bool PaintLayer::AttemptDirectCompositingUpdate( | 2970 bool PaintLayer::AttemptDirectCompositingUpdate( |
2959 StyleDifference diff, | 2971 StyleDifference diff, |
2960 const ComputedStyle* old_style) { | 2972 const ComputedStyle* old_style) { |
2961 CompositingReasons old_potential_compositing_reasons_from_style = | 2973 CompositingReasons old_potential_compositing_reasons_from_style = |
2962 PotentialCompositingReasonsFromStyle(); | 2974 PotentialCompositingReasonsFromStyle(); |
2963 Compositor()->UpdatePotentialCompositingReasonsFromStyle(this); | 2975 if (Compositor()) |
2976 Compositor()->UpdatePotentialCompositingReasonsFromStyle(this); | |
2964 | 2977 |
2965 // This function implements an optimization for transforms and opacity. | 2978 // This function implements an optimization for transforms and opacity. |
2966 // A common pattern is for a touchmove handler to update the transform | 2979 // A common pattern is for a touchmove handler to update the transform |
2967 // and/or an opacity of an element every frame while the user moves their | 2980 // and/or an opacity of an element every frame while the user moves their |
2968 // finger across the screen. The conditions below recognize when the | 2981 // finger across the screen. The conditions below recognize when the |
2969 // compositing state is set up to receive a direct transform or opacity | 2982 // compositing state is set up to receive a direct transform or opacity |
2970 // update. | 2983 // update. |
2971 | 2984 |
2972 if (!diff.HasAtMostPropertySpecificDifferences( | 2985 if (!diff.HasAtMostPropertySpecificDifferences( |
2973 StyleDifference::kTransformChanged | | 2986 StyleDifference::kTransformChanged | |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3007 return false; | 3020 return false; |
3008 | 3021 |
3009 UpdateTransform(old_style, GetLayoutObject().StyleRef()); | 3022 UpdateTransform(old_style, GetLayoutObject().StyleRef()); |
3010 | 3023 |
3011 // FIXME: Consider introducing a smaller graphics layer update scope | 3024 // FIXME: Consider introducing a smaller graphics layer update scope |
3012 // that just handles transforms and opacity. GraphicsLayerUpdateLocal | 3025 // that just handles transforms and opacity. GraphicsLayerUpdateLocal |
3013 // will also program bounds, clips, and many other properties that could | 3026 // will also program bounds, clips, and many other properties that could |
3014 // not possibly have changed. | 3027 // not possibly have changed. |
3015 rare_data_->composited_layer_mapping->SetNeedsGraphicsLayerUpdate( | 3028 rare_data_->composited_layer_mapping->SetNeedsGraphicsLayerUpdate( |
3016 kGraphicsLayerUpdateLocal); | 3029 kGraphicsLayerUpdateLocal); |
3017 Compositor()->SetNeedsCompositingUpdate( | 3030 if (Compositor()) { |
3018 kCompositingUpdateAfterGeometryChange); | 3031 Compositor()->SetNeedsCompositingUpdate( |
3032 kCompositingUpdateAfterGeometryChange); | |
3033 } | |
3019 | 3034 |
3020 if (scrollable_area_) | 3035 if (scrollable_area_) |
3021 scrollable_area_->UpdateAfterStyleChange(old_style); | 3036 scrollable_area_->UpdateAfterStyleChange(old_style); |
3022 | 3037 |
3023 return true; | 3038 return true; |
3024 } | 3039 } |
3025 | 3040 |
3026 void PaintLayer::StyleDidChange(StyleDifference diff, | 3041 void PaintLayer::StyleDidChange(StyleDifference diff, |
3027 const ComputedStyle* old_style) { | 3042 const ComputedStyle* old_style) { |
3028 if (AttemptDirectCompositingUpdate(diff, old_style)) | 3043 if (AttemptDirectCompositingUpdate(diff, old_style)) |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3301 } | 3316 } |
3302 | 3317 |
3303 void showLayerTree(const blink::LayoutObject* layoutObject) { | 3318 void showLayerTree(const blink::LayoutObject* layoutObject) { |
3304 if (!layoutObject) { | 3319 if (!layoutObject) { |
3305 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; | 3320 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; |
3306 return; | 3321 return; |
3307 } | 3322 } |
3308 showLayerTree(layoutObject->EnclosingLayer()); | 3323 showLayerTree(layoutObject->EnclosingLayer()); |
3309 } | 3324 } |
3310 #endif | 3325 #endif |
OLD | NEW |