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

Side by Side Diff: Source/core/rendering/compositing/CompositedLayerMapping.cpp

Issue 491773002: Directly composited images are images: ASSERT that (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (m_owningLayer.reflectionInfo()->reflectionLayer()->hasCompositedLaye rMapping()) { 450 if (m_owningLayer.reflectionInfo()->reflectionLayer()->hasCompositedLaye rMapping()) {
451 GraphicsLayer* reflectionLayer = m_owningLayer.reflectionInfo()->ref lectionLayer()->compositedLayerMapping()->mainGraphicsLayer(); 451 GraphicsLayer* reflectionLayer = m_owningLayer.reflectionInfo()->ref lectionLayer()->compositedLayerMapping()->mainGraphicsLayer();
452 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); 452 m_graphicsLayer->setReplicatedByLayer(reflectionLayer);
453 } 453 }
454 } else { 454 } else {
455 m_graphicsLayer->setReplicatedByLayer(0); 455 m_graphicsLayer->setReplicatedByLayer(0);
456 } 456 }
457 457
458 updateBackgroundColor(); 458 updateBackgroundColor();
459 459
460 if (isDirectlyCompositedImage()) 460 if (renderer->isImage()) {
461 updateImageContents(); 461 if (isDirectlyCompositedImage())
462 462 updateImageContents();
463 if (WebLayer* layer = platformLayerForPlugin(renderer)) { 463 } else if (WebLayer* layer = platformLayerForPlugin(renderer)) {
464 m_graphicsLayer->setContentsToPlatformLayer(layer); 464 m_graphicsLayer->setContentsToPlatformLayer(layer);
Ian Vollick 2014/08/21 03:43:29 IIUC, it looks like previously, we could still exe
Noel Gordon 2014/08/21 06:16:19 Good point, and I wonder which of them would be en
465 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to HTMLFrameOwnerElement(renderer->node())->contentFrame()) { 465 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to HTMLFrameOwnerElement(renderer->node())->contentFrame()) {
466 WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->contentFram e()->remotePlatformLayer(); 466 WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->contentFram e()->remotePlatformLayer();
467 if (layer) 467 if (layer)
468 m_graphicsLayer->setContentsToPlatformLayer(layer); 468 m_graphicsLayer->setContentsToPlatformLayer(layer);
469 } else if (renderer->isVideo()) { 469 } else if (renderer->isVideo()) {
470 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer->node()); 470 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer->node());
471 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer( )); 471 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer( ));
472 } else if (isAcceleratedCanvas(renderer)) { 472 } else if (isAcceleratedCanvas(renderer)) {
473 HTMLCanvasElement* canvas = toHTMLCanvasElement(renderer->node()); 473 HTMLCanvasElement* canvas = toHTMLCanvasElement(renderer->node());
474 if (CanvasRenderingContext* context = canvas->renderingContext()) 474 if (CanvasRenderingContext* context = canvas->renderingContext())
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 } 1691 }
1692 1692
1693 return false; 1693 return false;
1694 } 1694 }
1695 1695
1696 bool CompositedLayerMapping::containsPaintedContent() const 1696 bool CompositedLayerMapping::containsPaintedContent() const
1697 { 1697 {
1698 if (paintsIntoCompositedAncestor() || m_owningLayer.isReflection()) 1698 if (paintsIntoCompositedAncestor() || m_owningLayer.isReflection())
1699 return false; 1699 return false;
1700 1700
1701 if (isDirectlyCompositedImage()) 1701 if (renderer()->isImage())
1702 return false; 1702 return !isDirectlyCompositedImage();
Ian Vollick 2014/08/21 03:43:29 Similarly, it looks like we used to be possible to
Noel Gordon 2014/08/21 06:16:19 Originally had this as: if (renderer()->isImage
1703 1703
1704 RenderObject* renderObject = renderer(); 1704 RenderObject* renderObject = renderer();
1705 // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely, 1705 // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely,
1706 // and set background color on the layer in that case, instead of allocating backing store and painting. 1706 // and set background color on the layer in that case, instead of allocating backing store and painting.
1707 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo ()) 1707 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo ())
1708 return m_owningLayer.hasBoxDecorationsOrBackground(); 1708 return m_owningLayer.hasBoxDecorationsOrBackground();
1709 1709
1710 if (m_owningLayer.hasVisibleBoxDecorations()) 1710 if (m_owningLayer.hasVisibleBoxDecorations())
1711 return true; 1711 return true;
1712 1712
(...skipping 22 matching lines...) Expand all
1735 } 1735 }
1736 1736
1737 // FIXME: it's O(n^2). A better solution is needed. 1737 // FIXME: it's O(n^2). A better solution is needed.
1738 return paintsChildren(); 1738 return paintsChildren();
1739 } 1739 }
1740 1740
1741 // An image can be directly compositing if it's the sole content of the layer, a nd has no box decorations 1741 // An image can be directly compositing if it's the sole content of the layer, a nd has no box decorations
1742 // that require painting. Direct compositing saves backing store. 1742 // that require painting. Direct compositing saves backing store.
1743 bool CompositedLayerMapping::isDirectlyCompositedImage() const 1743 bool CompositedLayerMapping::isDirectlyCompositedImage() const
1744 { 1744 {
1745 ASSERT(renderer()->isImage());
1746
1745 RenderObject* renderObject = renderer(); 1747 RenderObject* renderObject = renderer();
1746 1748 if (m_owningLayer.hasBoxDecorationsOrBackground() || renderObject->hasClip() )
1747 if (!renderObject->isImage() || m_owningLayer.hasBoxDecorationsOrBackground( ) || renderObject->hasClip())
1748 return false; 1749 return false;
1749 1750
1750 RenderImage* imageRenderer = toRenderImage(renderObject); 1751 RenderImage* imageRenderer = toRenderImage(renderObject);
1751 if (ImageResource* cachedImage = imageRenderer->cachedImage()) { 1752 if (ImageResource* cachedImage = imageRenderer->cachedImage()) {
1752 if (!cachedImage->hasImage()) 1753 if (!cachedImage->hasImage())
1753 return false; 1754 return false;
1754 1755
1755 Image* image = cachedImage->imageForRenderer(imageRenderer); 1756 Image* image = cachedImage->imageForRenderer(imageRenderer);
1756 return image->isBitmapImage(); 1757 return image->isBitmapImage();
1757 } 1758 }
(...skipping 26 matching lines...) Expand all
1784 Image* image = cachedImage->imageForRenderer(imageRenderer); 1785 Image* image = cachedImage->imageForRenderer(imageRenderer);
1785 if (!image) 1786 if (!image)
1786 return; 1787 return;
1787 1788
1788 // We have to wait until the image is fully loaded before setting it on the layer. 1789 // We have to wait until the image is fully loaded before setting it on the layer.
1789 if (!cachedImage->isLoaded()) 1790 if (!cachedImage->isLoaded())
1790 return; 1791 return;
1791 1792
1792 // This is a no-op if the layer doesn't have an inner layer for the image. 1793 // This is a no-op if the layer doesn't have an inner layer for the image.
1793 m_graphicsLayer->setContentsToImage(image); 1794 m_graphicsLayer->setContentsToImage(image);
1795
1796 // Prevent double-drawing: https://bugs.webkit.org/show_bug.cgi?id=58632
1794 updateDrawsContent(); 1797 updateDrawsContent();
1795 1798
1796 // Image animation is "lazy", in that it automatically stops unless someone is drawing 1799 // Image animation is "lazy", in that it automatically stops unless someone is drawing
1797 // the image. So we have to kick the animation each time; this has the downs ide that the 1800 // the image. So we have to kick the animation each time; this has the downs ide that the
1798 // image will keep animating, even if its layer is not visible. 1801 // image will keep animating, even if its layer is not visible.
1799 image->startAnimation(); 1802 image->startAnimation();
1800 } 1803 }
1801 1804
1802 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde rBox) const 1805 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde rBox) const
1803 { 1806 {
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2281 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2279 name = "Scrolling Block Selection Layer"; 2282 name = "Scrolling Block Selection Layer";
2280 } else { 2283 } else {
2281 ASSERT_NOT_REACHED(); 2284 ASSERT_NOT_REACHED();
2282 } 2285 }
2283 2286
2284 return name; 2287 return name;
2285 } 2288 }
2286 2289
2287 } // namespace blink 2290 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698