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 21 matching lines...) Expand all Loading... |
32 #include "platform/TraceEvent.h" | 32 #include "platform/TraceEvent.h" |
33 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
34 #include "platform/geometry/LayoutRect.h" | 34 #include "platform/geometry/LayoutRect.h" |
35 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 35 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
36 #include "platform/graphics/GraphicsContext.h" | 36 #include "platform/graphics/GraphicsContext.h" |
37 #include "platform/graphics/GraphicsLayerFactory.h" | 37 #include "platform/graphics/GraphicsLayerFactory.h" |
38 #include "platform/graphics/Image.h" | 38 #include "platform/graphics/Image.h" |
39 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 39 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
40 #include "platform/graphics/paint/DisplayItemList.h" | 40 #include "platform/graphics/paint/DisplayItemList.h" |
41 #include "platform/graphics/paint/DrawingRecorder.h" | 41 #include "platform/graphics/paint/DrawingRecorder.h" |
42 #include "platform/graphics/skia/NativeImageSkia.h" | |
43 #include "platform/scroll/ScrollableArea.h" | 42 #include "platform/scroll/ScrollableArea.h" |
44 #include "platform/text/TextStream.h" | 43 #include "platform/text/TextStream.h" |
45 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
46 #include "public/platform/WebCompositorAnimation.h" | 45 #include "public/platform/WebCompositorAnimation.h" |
47 #include "public/platform/WebCompositorSupport.h" | 46 #include "public/platform/WebCompositorSupport.h" |
48 #include "public/platform/WebFilterOperations.h" | 47 #include "public/platform/WebFilterOperations.h" |
49 #include "public/platform/WebFloatPoint.h" | 48 #include "public/platform/WebFloatPoint.h" |
50 #include "public/platform/WebFloatRect.h" | 49 #include "public/platform/WebFloatRect.h" |
51 #include "public/platform/WebGraphicsLayerDebugInfo.h" | 50 #include "public/platform/WebGraphicsLayerDebugInfo.h" |
52 #include "public/platform/WebLayer.h" | 51 #include "public/platform/WebLayer.h" |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 { | 1000 { |
1002 if (rect == m_contentsRect) | 1001 if (rect == m_contentsRect) |
1003 return; | 1002 return; |
1004 | 1003 |
1005 m_contentsRect = rect; | 1004 m_contentsRect = rect; |
1006 updateContentsRect(); | 1005 updateContentsRect(); |
1007 } | 1006 } |
1008 | 1007 |
1009 void GraphicsLayer::setContentsToImage(Image* image) | 1008 void GraphicsLayer::setContentsToImage(Image* image) |
1010 { | 1009 { |
1011 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr
ame() : nullptr; | 1010 SkBitmap bitmap; |
1012 if (nativeImage) { | 1011 if (image) { |
| 1012 bitmap = image->bitmapForCurrentFrame(); |
| 1013 } |
| 1014 if (!bitmap.isNull()) { |
1013 if (!m_imageLayer) { | 1015 if (!m_imageLayer) { |
1014 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateImageLayer()); | 1016 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateImageLayer()); |
1015 registerContentsLayer(m_imageLayer->layer()); | 1017 registerContentsLayer(m_imageLayer->layer()); |
1016 } | 1018 } |
1017 m_imageLayer->setImageBitmap(nativeImage->bitmap()); | 1019 m_imageLayer->setImageBitmap(bitmap); |
1018 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); | 1020 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); |
1019 updateContentsRect(); | 1021 updateContentsRect(); |
1020 } else { | 1022 } else { |
1021 if (m_imageLayer) { | 1023 if (m_imageLayer) { |
1022 unregisterContentsLayer(m_imageLayer->layer()); | 1024 unregisterContentsLayer(m_imageLayer->layer()); |
1023 m_imageLayer.clear(); | 1025 m_imageLayer.clear(); |
1024 } | 1026 } |
1025 } | 1027 } |
1026 | 1028 |
1027 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); | 1029 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); |
1028 } | 1030 } |
1029 | 1031 |
1030 void GraphicsLayer::setContentsToNinePatch(Image* image, const IntRect& aperture
) | 1032 void GraphicsLayer::setContentsToNinePatch(Image* image, const IntRect& aperture
) |
1031 { | 1033 { |
1032 if (m_ninePatchLayer) { | 1034 if (m_ninePatchLayer) { |
1033 unregisterContentsLayer(m_ninePatchLayer->layer()); | 1035 unregisterContentsLayer(m_ninePatchLayer->layer()); |
1034 m_ninePatchLayer.clear(); | 1036 m_ninePatchLayer.clear(); |
1035 } | 1037 } |
1036 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr
ame() : nullptr; | 1038 SkBitmap bitmap; |
1037 if (nativeImage) { | 1039 if (image) { |
| 1040 bitmap = image->bitmapForCurrentFrame(); |
| 1041 } |
| 1042 if (!bitmap.isNull()) { |
1038 m_ninePatchLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateNinePatchLayer()); | 1043 m_ninePatchLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateNinePatchLayer()); |
1039 const SkBitmap& bitmap = nativeImage->bitmap(); | |
1040 int borderWidth = bitmap.width() - aperture.width(); | 1044 int borderWidth = bitmap.width() - aperture.width(); |
1041 int borderHeight = bitmap.height() - aperture.height(); | 1045 int borderHeight = bitmap.height() - aperture.height(); |
1042 WebRect border(aperture.x(), aperture.y(), borderWidth, borderHeight); | 1046 WebRect border(aperture.x(), aperture.y(), borderWidth, borderHeight); |
1043 | 1047 |
1044 m_ninePatchLayer->setBitmap(bitmap); | 1048 m_ninePatchLayer->setBitmap(bitmap); |
1045 m_ninePatchLayer->setAperture(aperture); | 1049 m_ninePatchLayer->setAperture(aperture); |
1046 m_ninePatchLayer->setBorder(border); | 1050 m_ninePatchLayer->setBorder(border); |
1047 | 1051 |
1048 m_ninePatchLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque(
)); | 1052 m_ninePatchLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque(
)); |
1049 registerContentsLayer(m_ninePatchLayer->layer()); | 1053 registerContentsLayer(m_ninePatchLayer->layer()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 #ifndef NDEBUG | 1176 #ifndef NDEBUG |
1173 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) | 1177 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) |
1174 { | 1178 { |
1175 if (!layer) | 1179 if (!layer) |
1176 return; | 1180 return; |
1177 | 1181 |
1178 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1182 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1179 fprintf(stderr, "%s\n", output.utf8().data()); | 1183 fprintf(stderr, "%s\n", output.utf8().data()); |
1180 } | 1184 } |
1181 #endif | 1185 #endif |
OLD | NEW |