Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) | 94 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) |
| 95 , m_contentsOrientation(CompositingCoordinatesTopDown) | 95 , m_contentsOrientation(CompositingCoordinatesTopDown) |
| 96 , m_parent(0) | 96 , m_parent(0) |
| 97 , m_maskLayer(0) | 97 , m_maskLayer(0) |
| 98 , m_contentsClippingMaskLayer(0) | 98 , m_contentsClippingMaskLayer(0) |
| 99 , m_replicaLayer(0) | 99 , m_replicaLayer(0) |
| 100 , m_replicatedLayer(0) | 100 , m_replicatedLayer(0) |
| 101 , m_paintCount(0) | 101 , m_paintCount(0) |
| 102 , m_contentsLayer(0) | 102 , m_contentsLayer(0) |
| 103 , m_contentsLayerId(0) | 103 , m_contentsLayerId(0) |
| 104 , m_contentsLayerPurpose(NoContentsLayer) | |
| 105 , m_scrollableArea(0) | 104 , m_scrollableArea(0) |
| 106 , m_compositingReasons(blink::CompositingReasonUnknown) | 105 , m_compositingReasons(blink::CompositingReasonUnknown) |
| 107 { | 106 { |
| 108 #ifndef NDEBUG | 107 #ifndef NDEBUG |
| 109 if (m_client) | 108 if (m_client) |
| 110 m_client->verifyNotPainting(); | 109 m_client->verifyNotPainting(); |
| 111 #endif | 110 #endif |
| 112 | 111 |
| 113 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingCo ntentLayerDelegate(this)); | 112 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingCo ntentLayerDelegate(this)); |
| 114 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_opaqueRectTrackingContentLayerDelegate.get())); | 113 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_opaqueRectTrackingContentLayerDelegate.get())); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 } | 441 } |
| 443 | 442 |
| 444 void GraphicsLayer::unregisterContentsLayer(WebLayer* layer) | 443 void GraphicsLayer::unregisterContentsLayer(WebLayer* layer) |
| 445 { | 444 { |
| 446 ASSERT(s_registeredLayerSet); | 445 ASSERT(s_registeredLayerSet); |
| 447 if (!s_registeredLayerSet->contains(layer->id())) | 446 if (!s_registeredLayerSet->contains(layer->id())) |
| 448 CRASH(); | 447 CRASH(); |
| 449 s_registeredLayerSet->remove(layer->id()); | 448 s_registeredLayerSet->remove(layer->id()); |
| 450 } | 449 } |
| 451 | 450 |
| 452 void GraphicsLayer::setContentsTo(ContentsLayerPurpose purpose, WebLayer* layer) | 451 void GraphicsLayer::setContentsTo(WebLayer* layer) |
| 453 { | 452 { |
| 454 bool childrenChanged = false; | 453 bool childrenChanged = false; |
| 455 if (layer) { | 454 if (layer) { |
| 456 ASSERT(s_registeredLayerSet); | 455 ASSERT(s_registeredLayerSet); |
| 457 if (!s_registeredLayerSet->contains(layer->id())) | 456 if (!s_registeredLayerSet->contains(layer->id())) |
| 458 CRASH(); | 457 CRASH(); |
| 459 if (m_contentsLayerId != layer->id()) { | 458 if (m_contentsLayerId != layer->id()) { |
| 460 setupContentsLayer(layer); | 459 setupContentsLayer(layer); |
| 461 m_contentsLayerPurpose = purpose; | |
| 462 childrenChanged = true; | 460 childrenChanged = true; |
| 463 } | 461 } |
| 464 updateContentsRect(); | 462 updateContentsRect(); |
| 465 } else { | 463 } else { |
| 466 if (m_contentsLayer) { | 464 if (m_contentsLayer) { |
| 467 childrenChanged = true; | 465 childrenChanged = true; |
| 468 | 466 |
| 469 // The old contents layer will be removed via updateChildList. | 467 // The old contents layer will be removed via updateChildList. |
| 470 m_contentsLayer = 0; | 468 m_contentsLayer = 0; |
| 471 m_contentsLayerId = 0; | 469 m_contentsLayerId = 0; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 965 { | 963 { |
| 966 if (rect == m_contentsRect) | 964 if (rect == m_contentsRect) |
| 967 return; | 965 return; |
| 968 | 966 |
| 969 m_contentsRect = rect; | 967 m_contentsRect = rect; |
| 970 updateContentsRect(); | 968 updateContentsRect(); |
| 971 } | 969 } |
| 972 | 970 |
| 973 void GraphicsLayer::setContentsToImage(Image* image) | 971 void GraphicsLayer::setContentsToImage(Image* image) |
| 974 { | 972 { |
| 975 bool childrenChanged = false; | |
| 976 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr ame() : 0; | 973 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr ame() : 0; |
| 977 if (nativeImage) { | 974 if (nativeImage) { |
| 978 if (m_contentsLayerPurpose != ContentsLayerForImage) { | 975 if (!m_imageLayer) { |
| 979 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateImageLayer()); | 976 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateImageLayer()); |
| 980 registerContentsLayer(m_imageLayer->layer()); | 977 registerContentsLayer(m_imageLayer->layer()); |
| 981 | |
| 982 setupContentsLayer(m_imageLayer->layer()); | |
| 983 m_contentsLayerPurpose = ContentsLayerForImage; | |
| 984 childrenChanged = true; | |
| 985 } | 978 } |
| 986 m_imageLayer->setBitmap(nativeImage->bitmap()); | 979 m_imageLayer->setBitmap(nativeImage->bitmap()); |
| 987 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); | 980 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); |
| 988 updateContentsRect(); | 981 updateContentsRect(); |
| 989 } else { | 982 } else { |
| 990 if (m_imageLayer) { | 983 if (m_imageLayer) { |
| 991 childrenChanged = true; | |
| 992 | |
| 993 unregisterContentsLayer(m_imageLayer->layer()); | 984 unregisterContentsLayer(m_imageLayer->layer()); |
| 994 m_imageLayer.clear(); | 985 m_imageLayer.clear(); |
| 995 } | 986 } |
| 996 // The old contents layer will be removed via updateChildList. | |
| 997 m_contentsLayer = 0; | |
| 998 } | 987 } |
| 999 | 988 |
| 1000 if (childrenChanged) | 989 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); |
| 1001 updateChildList(); | |
| 1002 } | 990 } |
| 1003 | 991 |
| 1004 void GraphicsLayer::setContentsToNinePatch(Image* image, const IntRect& aperture ) | 992 void GraphicsLayer::setContentsToNinePatch(Image* image, const IntRect& aperture ) |
| 1005 { | 993 { |
| 1006 if (m_ninePatchLayer) { | 994 if (m_ninePatchLayer) { |
| 1007 unregisterContentsLayer(m_ninePatchLayer->layer()); | 995 unregisterContentsLayer(m_ninePatchLayer->layer()); |
| 1008 m_ninePatchLayer.clear(); | 996 m_ninePatchLayer.clear(); |
| 1009 } | 997 } |
| 1010 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr ame() : 0; | 998 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr ame() : 0; |
| 1011 if (nativeImage) { | 999 if (nativeImage) { |
| 1012 m_ninePatchLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateNinePatchLayer()); | 1000 m_ninePatchLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateNinePatchLayer()); |
| 1013 m_ninePatchLayer->setBitmap(nativeImage->bitmap(), aperture); | 1001 m_ninePatchLayer->setBitmap(nativeImage->bitmap(), aperture); |
| 1014 m_ninePatchLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque( )); | 1002 m_ninePatchLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque( )); |
| 1015 registerContentsLayer(m_ninePatchLayer->layer()); | 1003 registerContentsLayer(m_ninePatchLayer->layer()); |
| 1016 } | 1004 } |
| 1017 setContentsTo(ContentsLayerForNinePatch, m_ninePatchLayer ? m_ninePatchLayer ->layer() : 0); | 1005 setContentsTo(m_ninePatchLayer ? m_ninePatchLayer->layer() : 0); |
| 1018 } | 1006 } |
| 1019 | 1007 |
| 1020 void GraphicsLayer::setContentsToCanvas(WebLayer* layer) | 1008 void GraphicsLayer::setContentsToCanvas(WebLayer* layer) |
|
jamesr
2013/11/21 20:46:02
i assume you'll remove these functions in a follow
| |
| 1021 { | 1009 { |
| 1022 setContentsTo(ContentsLayerForCanvas, layer); | 1010 setContentsTo(layer); |
| 1023 } | 1011 } |
| 1024 | 1012 |
| 1025 void GraphicsLayer::setContentsToMedia(WebLayer* layer) | 1013 void GraphicsLayer::setContentsToMedia(WebLayer* layer) |
| 1026 { | 1014 { |
| 1027 setContentsTo(ContentsLayerForVideo, layer); | 1015 setContentsTo(layer); |
| 1028 } | 1016 } |
| 1029 | 1017 |
| 1030 bool GraphicsLayer::addAnimation(PassOwnPtr<WebAnimation> popAnimation) | 1018 bool GraphicsLayer::addAnimation(PassOwnPtr<WebAnimation> popAnimation) |
| 1031 { | 1019 { |
| 1032 OwnPtr<WebAnimation> animation(popAnimation); | 1020 OwnPtr<WebAnimation> animation(popAnimation); |
| 1033 ASSERT(animation); | 1021 ASSERT(animation); |
| 1034 platformLayer()->setAnimationDelegate(this); | 1022 platformLayer()->setAnimationDelegate(this); |
| 1035 | 1023 |
| 1036 // Remove any existing animations with the same animation id and target prop erty. | 1024 // Remove any existing animations with the same animation id and target prop erty. |
| 1037 platformLayer()->removeAnimation(animation->id(), animation->targetProperty( )); | 1025 platformLayer()->removeAnimation(animation->id(), animation->targetProperty( )); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1211 #ifndef NDEBUG | 1199 #ifndef NDEBUG |
| 1212 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) | 1200 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) |
| 1213 { | 1201 { |
| 1214 if (!layer) | 1202 if (!layer) |
| 1215 return; | 1203 return; |
| 1216 | 1204 |
| 1217 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); | 1205 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); |
| 1218 fprintf(stderr, "%s\n", output.utf8().data()); | 1206 fprintf(stderr, "%s\n", output.utf8().data()); |
| 1219 } | 1207 } |
| 1220 #endif | 1208 #endif |
| OLD | NEW |