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

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

Issue 2738573002: Streamline the presentation of ImageBitmapRenderingContext (Closed)
Patch Set: Fix crash in gpu 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
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 static IntRect backgroundRect(const LayoutObject& layoutObject) { 104 static IntRect backgroundRect(const LayoutObject& layoutObject) {
105 if (!layoutObject.isBox()) 105 if (!layoutObject.isBox())
106 return IntRect(); 106 return IntRect();
107 107
108 LayoutRect rect; 108 LayoutRect rect;
109 const LayoutBox& box = toLayoutBox(layoutObject); 109 const LayoutBox& box = toLayoutBox(layoutObject);
110 return pixelSnappedIntRect(box.backgroundRect(BackgroundClipRect)); 110 return pixelSnappedIntRect(box.backgroundRect(BackgroundClipRect));
111 } 111 }
112 112
113 static inline bool isAcceleratedCanvas(const LayoutObject& layoutObject) { 113 static inline bool isCompositedCanvas(const LayoutObject& layoutObject) {
114 if (layoutObject.isCanvas()) { 114 if (layoutObject.isCanvas()) {
115 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); 115 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node());
116 if (CanvasRenderingContext* context = canvas->renderingContext()) 116 if (CanvasRenderingContext* context = canvas->renderingContext())
117 return context->isAccelerated(); 117 return context->isComposited();
118 } 118 }
119 return false; 119 return false;
120 } 120 }
121 121
122 static inline bool isCanvasControlledByOffscreen( 122 static inline bool isCanvasControlledByOffscreen(
123 const LayoutObject& layoutObject) { 123 const LayoutObject& layoutObject) {
124 if (layoutObject.isCanvas()) { 124 if (layoutObject.isCanvas()) {
125 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); 125 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node());
126 if (canvas->surfaceLayerBridge()) 126 if (canvas->surfaceLayerBridge())
127 return true; 127 return true;
(...skipping 24 matching lines...) Expand all
152 if (!layoutObject.isEmbeddedObject()) 152 if (!layoutObject.isEmbeddedObject())
153 return nullptr; 153 return nullptr;
154 FrameViewBase* frameViewBase = 154 FrameViewBase* frameViewBase =
155 toLayoutEmbeddedObject(layoutObject).frameViewBase(); 155 toLayoutEmbeddedObject(layoutObject).frameViewBase();
156 if (!frameViewBase || !frameViewBase->isPluginView()) 156 if (!frameViewBase || !frameViewBase->isPluginView())
157 return nullptr; 157 return nullptr;
158 return toPluginView(frameViewBase)->platformLayer(); 158 return toPluginView(frameViewBase)->platformLayer();
159 } 159 }
160 160
161 static inline bool isAcceleratedContents(LayoutObject& layoutObject) { 161 static inline bool isAcceleratedContents(LayoutObject& layoutObject) {
162 return isAcceleratedCanvas(layoutObject) || 162 return isCompositedCanvas(layoutObject) ||
163 (layoutObject.isEmbeddedObject() && 163 (layoutObject.isEmbeddedObject() &&
164 toLayoutEmbeddedObject(layoutObject) 164 toLayoutEmbeddedObject(layoutObject)
165 .requiresAcceleratedCompositing()) || 165 .requiresAcceleratedCompositing()) ||
166 layoutObject.isVideo(); 166 layoutObject.isVideo();
167 } 167 }
168 168
169 // Get the scrolling coordinator in a way that works inside 169 // Get the scrolling coordinator in a way that works inside
170 // CompositedLayerMapping's destructor. 170 // CompositedLayerMapping's destructor.
171 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { 171 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) {
172 Page* page = layer.layoutObject().frame()->page(); 172 Page* page = layer.layoutObject().frame()->page();
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 paintLocation & BackgroundPaintInGraphicsLayer; 396 paintLocation & BackgroundPaintInGraphicsLayer;
397 if (shouldPaintOntoGraphicsLayer != !!m_backgroundPaintsOntoGraphicsLayer) { 397 if (shouldPaintOntoGraphicsLayer != !!m_backgroundPaintsOntoGraphicsLayer) {
398 m_backgroundPaintsOntoGraphicsLayer = shouldPaintOntoGraphicsLayer; 398 m_backgroundPaintsOntoGraphicsLayer = shouldPaintOntoGraphicsLayer;
399 // The graphics layer needs to be updated for changed 399 // The graphics layer needs to be updated for changed
400 // m_backgroundPaintsOntoGraphicsLayer. 400 // m_backgroundPaintsOntoGraphicsLayer.
401 m_graphicsLayer->setNeedsDisplay(); 401 m_graphicsLayer->setNeedsDisplay();
402 } 402 }
403 } 403 }
404 404
405 void CompositedLayerMapping::updateContentsOpaque() { 405 void CompositedLayerMapping::updateContentsOpaque() {
406 if (isAcceleratedCanvas(layoutObject())) { 406 if (isCompositedCanvas(layoutObject())) {
407 CanvasRenderingContext* context = 407 CanvasRenderingContext* context =
408 toHTMLCanvasElement(layoutObject().node())->renderingContext(); 408 toHTMLCanvasElement(layoutObject().node())->renderingContext();
409 WebLayer* layer = context ? context->platformLayer() : nullptr; 409 WebLayer* layer = context ? context->platformLayer() : nullptr;
410 // Determine whether the external texture layer covers the whole graphics 410 // Determine whether the external texture layer covers the whole graphics
411 // layer. This may not be the case if there are box decorations or 411 // layer. This may not be the case if there are box decorations or
412 // shadows. 412 // shadows.
413 if (layer && 413 if (layer &&
414 layer->bounds() == m_graphicsLayer->platformLayer()->bounds()) { 414 layer->bounds() == m_graphicsLayer->platformLayer()->bounds()) {
415 // Determine whether the rendering context's external texture layer is 415 // Determine whether the rendering context's external texture layer is
416 // opaque. 416 // opaque.
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 m_graphicsLayer->setContentsToPlatformLayer(layer); 752 m_graphicsLayer->setContentsToPlatformLayer(layer);
753 } 753 }
754 } else if (layoutObject.isVideo()) { 754 } else if (layoutObject.isVideo()) {
755 HTMLMediaElement* mediaElement = toHTMLMediaElement(layoutObject.node()); 755 HTMLMediaElement* mediaElement = toHTMLMediaElement(layoutObject.node());
756 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer()); 756 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer());
757 } else if (isCanvasControlledByOffscreen(layoutObject)) { 757 } else if (isCanvasControlledByOffscreen(layoutObject)) {
758 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); 758 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node());
759 m_graphicsLayer->setContentsToPlatformLayer( 759 m_graphicsLayer->setContentsToPlatformLayer(
760 canvas->surfaceLayerBridge()->getWebLayer()); 760 canvas->surfaceLayerBridge()->getWebLayer());
761 layerConfigChanged = true; 761 layerConfigChanged = true;
762 } else if (isAcceleratedCanvas(layoutObject)) { 762 } else if (isCompositedCanvas(layoutObject)) {
763 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); 763 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node());
764 if (CanvasRenderingContext* context = canvas->renderingContext()) 764 if (CanvasRenderingContext* context = canvas->renderingContext())
765 m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer()); 765 m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer());
766 layerConfigChanged = true; 766 layerConfigChanged = true;
767 } 767 }
768 if (layoutObject.isLayoutPart()) { 768 if (layoutObject.isLayoutPart()) {
769 if (PaintLayerCompositor::attachFrameContentLayersToIframeLayer( 769 if (PaintLayerCompositor::attachFrameContentLayersToIframeLayer(
770 toLayoutPart(layoutObject))) 770 toLayoutPart(layoutObject)))
771 layerConfigChanged = true; 771 layerConfigChanged = true;
772 } 772 }
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 // contents need to paint. 1705 // contents need to paint.
1706 m_scrollingContentsAreEmpty = 1706 m_scrollingContentsAreEmpty =
1707 !m_owningLayer.hasVisibleContent() || 1707 !m_owningLayer.hasVisibleContent() ||
1708 !(layoutObject().styleRef().hasBackground() || 1708 !(layoutObject().styleRef().hasBackground() ||
1709 layoutObject().hasBackdropFilter() || paintsChildren()); 1709 layoutObject().hasBackdropFilter() || paintsChildren());
1710 m_scrollingContentsLayer->setDrawsContent(!m_scrollingContentsAreEmpty); 1710 m_scrollingContentsLayer->setDrawsContent(!m_scrollingContentsAreEmpty);
1711 } 1711 }
1712 1712
1713 m_drawsBackgroundOntoContentLayer = false; 1713 m_drawsBackgroundOntoContentLayer = false;
1714 1714
1715 if (hasPaintedContent && isAcceleratedCanvas(layoutObject())) { 1715 if (hasPaintedContent && isCompositedCanvas(layoutObject())) {
1716 CanvasRenderingContext* context = 1716 CanvasRenderingContext* context =
1717 toHTMLCanvasElement(layoutObject().node())->renderingContext(); 1717 toHTMLCanvasElement(layoutObject().node())->renderingContext();
1718 // Content layer may be null if context is lost. 1718 // Content layer may be null if context is lost.
1719 if (WebLayer* contentLayer = context->platformLayer()) { 1719 if (WebLayer* contentLayer = context->platformLayer()) {
1720 Color bgColor(Color::transparent); 1720 Color bgColor(Color::transparent);
1721 if (contentLayerSupportsDirectBackgroundComposition(layoutObject())) { 1721 if (contentLayerSupportsDirectBackgroundComposition(layoutObject())) {
1722 bgColor = layoutObjectBackgroundColor(); 1722 bgColor = layoutObjectBackgroundColor();
1723 hasPaintedContent = false; 1723 hasPaintedContent = false;
1724 m_drawsBackgroundOntoContentLayer = true; 1724 m_drawsBackgroundOntoContentLayer = true;
1725 } 1725 }
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 return false; 2619 return false;
2620 } 2620 }
2621 2621
2622 void CompositedLayerMapping::contentChanged(ContentChangeType changeType) { 2622 void CompositedLayerMapping::contentChanged(ContentChangeType changeType) {
2623 if ((changeType == ImageChanged) && layoutObject().isImage() && 2623 if ((changeType == ImageChanged) && layoutObject().isImage() &&
2624 isDirectlyCompositedImage()) { 2624 isDirectlyCompositedImage()) {
2625 updateImageContents(); 2625 updateImageContents();
2626 return; 2626 return;
2627 } 2627 }
2628 2628
2629 if (changeType == CanvasChanged && isAcceleratedCanvas(layoutObject())) { 2629 if (changeType == CanvasChanged && isCompositedCanvas(layoutObject())) {
2630 m_graphicsLayer->setContentsNeedsDisplay(); 2630 m_graphicsLayer->setContentsNeedsDisplay();
2631 return; 2631 return;
2632 } 2632 }
2633 } 2633 }
2634 2634
2635 void CompositedLayerMapping::updateImageContents() { 2635 void CompositedLayerMapping::updateImageContents() {
2636 DCHECK(layoutObject().isImage()); 2636 DCHECK(layoutObject().isImage());
2637 LayoutImage& imageLayoutObject = toLayoutImage(layoutObject()); 2637 LayoutImage& imageLayoutObject = toLayoutImage(layoutObject());
2638 2638
2639 ImageResourceContent* cachedImage = imageLayoutObject.cachedImage(); 2639 ImageResourceContent* cachedImage = imageLayoutObject.cachedImage();
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
3498 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { 3498 } else if (graphicsLayer == m_decorationOutlineLayer.get()) {
3499 name = "Decoration Layer"; 3499 name = "Decoration Layer";
3500 } else { 3500 } else {
3501 ASSERT_NOT_REACHED(); 3501 ASSERT_NOT_REACHED();
3502 } 3502 }
3503 3503
3504 return name; 3504 return name;
3505 } 3505 }
3506 3506
3507 } // namespace blink 3507 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698