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

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

Issue 2738573002: Streamline the presentation of ImageBitmapRenderingContext (Closed)
Patch Set: Fixed expectations Created 3 years, 8 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 static IntRect backgroundRect(const LayoutObject& layoutObject) { 103 static IntRect backgroundRect(const LayoutObject& layoutObject) {
104 if (!layoutObject.isBox()) 104 if (!layoutObject.isBox())
105 return IntRect(); 105 return IntRect();
106 106
107 LayoutRect rect; 107 LayoutRect rect;
108 const LayoutBox& box = toLayoutBox(layoutObject); 108 const LayoutBox& box = toLayoutBox(layoutObject);
109 return pixelSnappedIntRect(box.backgroundRect(BackgroundClipRect)); 109 return pixelSnappedIntRect(box.backgroundRect(BackgroundClipRect));
110 } 110 }
111 111
112 static inline bool isAcceleratedCanvas(const LayoutObject& layoutObject) { 112 static inline bool isCompositedCanvas(const LayoutObject& layoutObject) {
113 if (layoutObject.isCanvas()) { 113 if (layoutObject.isCanvas()) {
114 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); 114 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node());
115 if (CanvasRenderingContext* context = canvas->renderingContext()) 115 if (CanvasRenderingContext* context = canvas->renderingContext())
116 return context->isAccelerated(); 116 return context->isComposited();
117 } 117 }
118 return false; 118 return false;
119 } 119 }
120 120
121 static inline bool isPlaceholderCanvas(const LayoutObject& layoutObject) { 121 static inline bool isPlaceholderCanvas(const LayoutObject& layoutObject) {
122 if (layoutObject.isCanvas()) { 122 if (layoutObject.isCanvas()) {
123 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); 123 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node());
124 return canvas->surfaceLayerBridge(); 124 return canvas->surfaceLayerBridge();
125 } 125 }
126 return false; 126 return false;
(...skipping 19 matching lines...) Expand all
146 } 146 }
147 147
148 static WebLayer* platformLayerForPlugin(LayoutObject& layoutObject) { 148 static WebLayer* platformLayerForPlugin(LayoutObject& layoutObject) {
149 if (!layoutObject.isEmbeddedObject()) 149 if (!layoutObject.isEmbeddedObject())
150 return nullptr; 150 return nullptr;
151 PluginView* plugin = toLayoutEmbeddedObject(layoutObject).plugin(); 151 PluginView* plugin = toLayoutEmbeddedObject(layoutObject).plugin();
152 return plugin ? plugin->platformLayer() : nullptr; 152 return plugin ? plugin->platformLayer() : nullptr;
153 } 153 }
154 154
155 static inline bool isAcceleratedContents(LayoutObject& layoutObject) { 155 static inline bool isAcceleratedContents(LayoutObject& layoutObject) {
156 return isAcceleratedCanvas(layoutObject) || 156 return isCompositedCanvas(layoutObject) ||
157 (layoutObject.isEmbeddedObject() && 157 (layoutObject.isEmbeddedObject() &&
158 toLayoutEmbeddedObject(layoutObject) 158 toLayoutEmbeddedObject(layoutObject)
159 .requiresAcceleratedCompositing()) || 159 .requiresAcceleratedCompositing()) ||
160 layoutObject.isVideo(); 160 layoutObject.isVideo();
161 } 161 }
162 162
163 // Get the scrolling coordinator in a way that works inside 163 // Get the scrolling coordinator in a way that works inside
164 // CompositedLayerMapping's destructor. 164 // CompositedLayerMapping's destructor.
165 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { 165 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) {
166 Page* page = layer.layoutObject().frame()->page(); 166 Page* page = layer.layoutObject().frame()->page();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 paintLocation & BackgroundPaintInGraphicsLayer; 432 paintLocation & BackgroundPaintInGraphicsLayer;
433 if (shouldPaintOntoGraphicsLayer != !!m_backgroundPaintsOntoGraphicsLayer) { 433 if (shouldPaintOntoGraphicsLayer != !!m_backgroundPaintsOntoGraphicsLayer) {
434 m_backgroundPaintsOntoGraphicsLayer = shouldPaintOntoGraphicsLayer; 434 m_backgroundPaintsOntoGraphicsLayer = shouldPaintOntoGraphicsLayer;
435 // The graphics layer needs to be updated for changed 435 // The graphics layer needs to be updated for changed
436 // m_backgroundPaintsOntoGraphicsLayer. 436 // m_backgroundPaintsOntoGraphicsLayer.
437 m_graphicsLayer->setNeedsDisplay(); 437 m_graphicsLayer->setNeedsDisplay();
438 } 438 }
439 } 439 }
440 440
441 void CompositedLayerMapping::updateContentsOpaque() { 441 void CompositedLayerMapping::updateContentsOpaque() {
442 if (isAcceleratedCanvas(layoutObject())) { 442 if (isCompositedCanvas(layoutObject())) {
443 CanvasRenderingContext* context = 443 CanvasRenderingContext* context =
444 toHTMLCanvasElement(layoutObject().node())->renderingContext(); 444 toHTMLCanvasElement(layoutObject().node())->renderingContext();
445 WebLayer* layer = context ? context->platformLayer() : nullptr; 445 WebLayer* layer = context ? context->platformLayer() : nullptr;
446 // Determine whether the external texture layer covers the whole graphics 446 // Determine whether the external texture layer covers the whole graphics
447 // layer. This may not be the case if there are box decorations or 447 // layer. This may not be the case if there are box decorations or
448 // shadows. 448 // shadows.
449 if (layer && 449 if (layer &&
450 layer->bounds() == m_graphicsLayer->platformLayer()->bounds()) { 450 layer->bounds() == m_graphicsLayer->platformLayer()->bounds()) {
451 // Determine whether the rendering context's external texture layer is 451 // Determine whether the rendering context's external texture layer is
452 // opaque. 452 // opaque.
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 m_graphicsLayer->setContentsToPlatformLayer(layer); 802 m_graphicsLayer->setContentsToPlatformLayer(layer);
803 } 803 }
804 } else if (layoutObject.isVideo()) { 804 } else if (layoutObject.isVideo()) {
805 HTMLMediaElement* mediaElement = toHTMLMediaElement(layoutObject.node()); 805 HTMLMediaElement* mediaElement = toHTMLMediaElement(layoutObject.node());
806 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer()); 806 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer());
807 } else if (isPlaceholderCanvas(layoutObject)) { 807 } else if (isPlaceholderCanvas(layoutObject)) {
808 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); 808 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node());
809 m_graphicsLayer->setContentsToPlatformLayer( 809 m_graphicsLayer->setContentsToPlatformLayer(
810 canvas->surfaceLayerBridge()->getWebLayer()); 810 canvas->surfaceLayerBridge()->getWebLayer());
811 layerConfigChanged = true; 811 layerConfigChanged = true;
812 } else if (isAcceleratedCanvas(layoutObject)) { 812 } else if (isCompositedCanvas(layoutObject)) {
813 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); 813 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node());
814 if (CanvasRenderingContext* context = canvas->renderingContext()) 814 if (CanvasRenderingContext* context = canvas->renderingContext())
815 m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer()); 815 m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer());
816 layerConfigChanged = true; 816 layerConfigChanged = true;
817 } 817 }
818 if (layoutObject.isLayoutPart()) { 818 if (layoutObject.isLayoutPart()) {
819 if (PaintLayerCompositor::attachFrameContentLayersToIframeLayer( 819 if (PaintLayerCompositor::attachFrameContentLayersToIframeLayer(
820 toLayoutPart(layoutObject))) 820 toLayoutPart(layoutObject)))
821 layerConfigChanged = true; 821 layerConfigChanged = true;
822 } 822 }
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 // contents need to paint. 1746 // contents need to paint.
1747 m_scrollingContentsAreEmpty = 1747 m_scrollingContentsAreEmpty =
1748 !m_owningLayer.hasVisibleContent() || 1748 !m_owningLayer.hasVisibleContent() ||
1749 !(layoutObject().styleRef().hasBackground() || 1749 !(layoutObject().styleRef().hasBackground() ||
1750 layoutObject().hasBackdropFilter() || paintsChildren()); 1750 layoutObject().hasBackdropFilter() || paintsChildren());
1751 m_scrollingContentsLayer->setDrawsContent(!m_scrollingContentsAreEmpty); 1751 m_scrollingContentsLayer->setDrawsContent(!m_scrollingContentsAreEmpty);
1752 } 1752 }
1753 1753
1754 m_drawsBackgroundOntoContentLayer = false; 1754 m_drawsBackgroundOntoContentLayer = false;
1755 1755
1756 if (hasPaintedContent && isAcceleratedCanvas(layoutObject())) { 1756 if (hasPaintedContent && isCompositedCanvas(layoutObject())) {
1757 CanvasRenderingContext* context = 1757 CanvasRenderingContext* context =
1758 toHTMLCanvasElement(layoutObject().node())->renderingContext(); 1758 toHTMLCanvasElement(layoutObject().node())->renderingContext();
1759 // Content layer may be null if context is lost. 1759 // Content layer may be null if context is lost.
1760 if (WebLayer* contentLayer = context->platformLayer()) { 1760 if (WebLayer* contentLayer = context->platformLayer()) {
1761 Color bgColor(Color::transparent); 1761 Color bgColor(Color::transparent);
1762 if (contentLayerSupportsDirectBackgroundComposition(layoutObject())) { 1762 if (contentLayerSupportsDirectBackgroundComposition(layoutObject())) {
1763 bgColor = layoutObjectBackgroundColor(); 1763 bgColor = layoutObjectBackgroundColor();
1764 hasPaintedContent = false; 1764 hasPaintedContent = false;
1765 m_drawsBackgroundOntoContentLayer = true; 1765 m_drawsBackgroundOntoContentLayer = true;
1766 } 1766 }
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 return false; 2667 return false;
2668 } 2668 }
2669 2669
2670 void CompositedLayerMapping::contentChanged(ContentChangeType changeType) { 2670 void CompositedLayerMapping::contentChanged(ContentChangeType changeType) {
2671 if ((changeType == ImageChanged) && layoutObject().isImage() && 2671 if ((changeType == ImageChanged) && layoutObject().isImage() &&
2672 isDirectlyCompositedImage()) { 2672 isDirectlyCompositedImage()) {
2673 updateImageContents(); 2673 updateImageContents();
2674 return; 2674 return;
2675 } 2675 }
2676 2676
2677 if (changeType == CanvasChanged && isAcceleratedCanvas(layoutObject())) { 2677 if (changeType == CanvasChanged && isCompositedCanvas(layoutObject())) {
2678 m_graphicsLayer->setContentsNeedsDisplay(); 2678 m_graphicsLayer->setContentsNeedsDisplay();
2679 return; 2679 return;
2680 } 2680 }
2681 } 2681 }
2682 2682
2683 void CompositedLayerMapping::updateImageContents() { 2683 void CompositedLayerMapping::updateImageContents() {
2684 DCHECK(layoutObject().isImage()); 2684 DCHECK(layoutObject().isImage());
2685 LayoutImage& imageLayoutObject = toLayoutImage(layoutObject()); 2685 LayoutImage& imageLayoutObject = toLayoutImage(layoutObject());
2686 2686
2687 ImageResourceContent* cachedImage = imageLayoutObject.cachedImage(); 2687 ImageResourceContent* cachedImage = imageLayoutObject.cachedImage();
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
3546 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { 3546 } else if (graphicsLayer == m_decorationOutlineLayer.get()) {
3547 name = "Decoration Layer"; 3547 name = "Decoration Layer";
3548 } else { 3548 } else {
3549 NOTREACHED(); 3549 NOTREACHED();
3550 } 3550 }
3551 3551
3552 return name; 3552 return name;
3553 } 3553 }
3554 3554
3555 } // namespace blink 3555 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698