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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2511893002: Paint solid color background into both scrolling contents layer and graphics layer. (Closed)
Patch Set: Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return (!page) ? nullptr : page->scrollingCoordinator(); 169 return (!page) ? nullptr : page->scrollingCoordinator();
170 } 170 }
171 171
172 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) 172 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer)
173 : m_owningLayer(layer), 173 : m_owningLayer(layer),
174 m_contentOffsetInCompositingLayerDirty(false), 174 m_contentOffsetInCompositingLayerDirty(false),
175 m_pendingUpdateScope(GraphicsLayerUpdateNone), 175 m_pendingUpdateScope(GraphicsLayerUpdateNone),
176 m_isMainFrameLayoutViewLayer(false), 176 m_isMainFrameLayoutViewLayer(false),
177 m_backgroundLayerPaintsFixedRootBackground(false), 177 m_backgroundLayerPaintsFixedRootBackground(false),
178 m_scrollingContentsAreEmpty(false), 178 m_scrollingContentsAreEmpty(false),
179 m_backgroundPaintsOntoScrollingContentsLayer(false) { 179 m_backgroundPaintsOntoScrollingContentsLayer(false),
180 m_backgroundPaintsOntoGraphicsLayer(true) {
chrishtr 2016/11/17 20:55:39 false
flackr 2016/11/17 23:38:00 Done.
180 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame()) 181 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame())
181 m_isMainFrameLayoutViewLayer = true; 182 m_isMainFrameLayoutViewLayer = true;
182 183
183 createPrimaryGraphicsLayer(); 184 createPrimaryGraphicsLayer();
184 } 185 }
185 186
186 CompositedLayerMapping::~CompositedLayerMapping() { 187 CompositedLayerMapping::~CompositedLayerMapping() {
187 // Hits in compositing/squashing/squash-onto-nephew.html. 188 // Hits in compositing/squashing/squash-onto-nephew.html.
188 DisableCompositingQueryAsserts disabler; 189 DisableCompositingQueryAsserts disabler;
189 190
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 ASSERT(m_owningLayer.stackingNode()->isStackingContext() || !isolate); 355 ASSERT(m_owningLayer.stackingNode()->isStackingContext() || !isolate);
355 356
356 m_graphicsLayer->setIsRootForIsolatedGroup(isolate); 357 m_graphicsLayer->setIsRootForIsolatedGroup(isolate);
357 } 358 }
358 359
359 void CompositedLayerMapping:: 360 void CompositedLayerMapping::
360 updateBackgroundPaintsOntoScrollingContentsLayer() { 361 updateBackgroundPaintsOntoScrollingContentsLayer() {
361 // We can only paint the background onto the scrolling contents layer if 362 // We can only paint the background onto the scrolling contents layer if
362 // it would be visually correct and we are using composited scrolling meaning 363 // it would be visually correct and we are using composited scrolling meaning
363 // we have a scrolling contents layer to paint it into. 364 // we have a scrolling contents layer to paint it into.
365 BackgroundPaintLocation paintLocation =
366 m_owningLayer.backgroundPaintLocation();
364 bool shouldPaintOntoScrollingContentsLayer = 367 bool shouldPaintOntoScrollingContentsLayer =
365 m_owningLayer.canPaintBackgroundOntoScrollingContentsLayer() && 368 paintLocation & BackgroundPaintInScrollingContents &&
366 m_owningLayer.getScrollableArea()->usesCompositedScrolling(); 369 m_owningLayer.getScrollableArea()->usesCompositedScrolling();
367 if (shouldPaintOntoScrollingContentsLayer != 370 if (shouldPaintOntoScrollingContentsLayer !=
368 backgroundPaintsOntoScrollingContentsLayer()) { 371 backgroundPaintsOntoScrollingContentsLayer()) {
369 m_backgroundPaintsOntoScrollingContentsLayer = 372 m_backgroundPaintsOntoScrollingContentsLayer =
370 shouldPaintOntoScrollingContentsLayer; 373 shouldPaintOntoScrollingContentsLayer;
371 // If the background is no longer painted onto the scrolling contents layer 374 // If the background is no longer painted onto the scrolling contents layer
372 // the scrolling contents layer needs to be updated. If it is going to be 375 // the scrolling contents layer needs to be updated. If it is going to be
373 // painted onto the scrolling contents layer this update will be triggered 376 // painted onto the scrolling contents layer this update will be triggered
374 // by LayoutBoxModelObject::setBackingNeedsPaintInvalidationInRect 377 // by LayoutBoxModelObject::setBackingNeedsPaintInvalidationInRect
375 if (hasScrollingLayer() && !shouldPaintOntoScrollingContentsLayer) 378 if (hasScrollingLayer() && !shouldPaintOntoScrollingContentsLayer)
376 m_scrollingContentsLayer->setNeedsDisplay(); 379 m_scrollingContentsLayer->setNeedsDisplay();
377 } 380 }
381 m_backgroundPaintsOntoGraphicsLayer =
382 !m_backgroundPaintsOntoScrollingContentsLayer ||
383 paintLocation & BackgroundPaintInGraphicsLayer;
378 } 384 }
379 385
380 void CompositedLayerMapping::updateContentsOpaque() { 386 void CompositedLayerMapping::updateContentsOpaque() {
381 if (isAcceleratedCanvas(layoutObject())) { 387 if (isAcceleratedCanvas(layoutObject())) {
382 // Determine whether the rendering context's external texture layer is 388 // Determine whether the rendering context's external texture layer is
383 // opaque. 389 // opaque.
384 CanvasRenderingContext* context = 390 CanvasRenderingContext* context =
385 toHTMLCanvasElement(layoutObject()->node())->renderingContext(); 391 toHTMLCanvasElement(layoutObject()->node())->renderingContext();
386 if (!context->creationAttributes().alpha()) 392 if (!context->creationAttributes().alpha())
387 m_graphicsLayer->setContentsOpaque(true); 393 m_graphicsLayer->setContentsOpaque(true);
(...skipping 13 matching lines...) Expand all
401 if (hasScrollingLayer() && m_backgroundPaintsOntoScrollingContentsLayer) { 407 if (hasScrollingLayer() && m_backgroundPaintsOntoScrollingContentsLayer) {
402 // Backgrounds painted onto the foreground are clipped by the padding box 408 // Backgrounds painted onto the foreground are clipped by the padding box
403 // rect. 409 // rect.
404 // TODO(flackr): This should actually check the entire overflow rect 410 // TODO(flackr): This should actually check the entire overflow rect
405 // within the scrolling contents layer but since we currently only trigger 411 // within the scrolling contents layer but since we currently only trigger
406 // this for solid color backgrounds the answer will be the same. 412 // this for solid color backgrounds the answer will be the same.
407 m_scrollingContentsLayer->setContentsOpaque( 413 m_scrollingContentsLayer->setContentsOpaque(
408 m_owningLayer.backgroundIsKnownToBeOpaqueInRect( 414 m_owningLayer.backgroundIsKnownToBeOpaqueInRect(
409 toLayoutBox(layoutObject())->paddingBoxRect())); 415 toLayoutBox(layoutObject())->paddingBoxRect()));
410 416
411 // When we paint the background onto the scrolling contents layer we are 417 if (m_owningLayer.backgroundPaintLocation() &
412 // going to leave a hole in the m_graphicsLayer where the background is so 418 BackgroundPaintInGraphicsLayer) {
413 // it is not opaque. 419 m_graphicsLayer->setContentsOpaque(
414 m_graphicsLayer->setContentsOpaque(false); 420 m_owningLayer.backgroundIsKnownToBeOpaqueInRect(
421 compositedBounds()));
422 } else {
423 // If we only paint the background onto the scrolling contents layer we
424 // are going to leave a hole in the m_graphicsLayer where the background
425 // is so it is not opaque.
426 m_graphicsLayer->setContentsOpaque(false);
427 }
415 } else { 428 } else {
416 if (hasScrollingLayer()) 429 if (hasScrollingLayer())
417 m_scrollingContentsLayer->setContentsOpaque(false); 430 m_scrollingContentsLayer->setContentsOpaque(false);
418 m_graphicsLayer->setContentsOpaque( 431 m_graphicsLayer->setContentsOpaque(
419 m_owningLayer.backgroundIsKnownToBeOpaqueInRect(compositedBounds())); 432 m_owningLayer.backgroundIsKnownToBeOpaqueInRect(compositedBounds()));
420 } 433 }
421 } 434 }
422 } 435 }
423 436
424 void CompositedLayerMapping::updateCompositedBounds() { 437 void CompositedLayerMapping::updateCompositedBounds() {
(...skipping 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 graphicsLayer == m_maskLayer.get() || 2983 graphicsLayer == m_maskLayer.get() ||
2971 graphicsLayer == m_childClippingMaskLayer.get() || 2984 graphicsLayer == m_childClippingMaskLayer.get() ||
2972 graphicsLayer == m_scrollingContentsLayer.get()) { 2985 graphicsLayer == m_scrollingContentsLayer.get()) {
2973 bool paintRootBackgroundOntoScrollingContentsLayer = 2986 bool paintRootBackgroundOntoScrollingContentsLayer =
2974 m_backgroundPaintsOntoScrollingContentsLayer; 2987 m_backgroundPaintsOntoScrollingContentsLayer;
2975 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || 2988 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer ||
2976 (!m_backgroundLayer && !m_foregroundLayer)); 2989 (!m_backgroundLayer && !m_foregroundLayer));
2977 if (paintRootBackgroundOntoScrollingContentsLayer) { 2990 if (paintRootBackgroundOntoScrollingContentsLayer) {
2978 if (graphicsLayer == m_scrollingContentsLayer.get()) 2991 if (graphicsLayer == m_scrollingContentsLayer.get())
2979 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground; 2992 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground;
2980 else 2993 else if (!m_backgroundPaintsOntoGraphicsLayer)
2981 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 2994 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
2982 } 2995 }
2983 GraphicsLayerPaintInfo paintInfo; 2996 GraphicsLayerPaintInfo paintInfo;
2984 paintInfo.paintLayer = &m_owningLayer; 2997 paintInfo.paintLayer = &m_owningLayer;
2985 paintInfo.compositedBounds = compositedBounds(); 2998 paintInfo.compositedBounds = compositedBounds();
2986 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject(); 2999 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject();
2987 adjustForCompositedScrolling(graphicsLayer, 3000 adjustForCompositedScrolling(graphicsLayer,
2988 paintInfo.offsetFromLayoutObject); 3001 paintInfo.offsetFromLayoutObject);
2989 3002
2990 // We have to use the same root as for hit testing, because both methods can 3003 // We have to use the same root as for hit testing, because both methods can
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 3264 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
3252 name = "Scrolling Contents Layer"; 3265 name = "Scrolling Contents Layer";
3253 } else { 3266 } else {
3254 ASSERT_NOT_REACHED(); 3267 ASSERT_NOT_REACHED();
3255 } 3268 }
3256 3269
3257 return name; 3270 return name;
3258 } 3271 }
3259 3272
3260 } // namespace blink 3273 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698