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 && image->bitmapForCurrentFrame(&bitmap)) { |
1013 if (!m_imageLayer) { | 1012 if (!m_imageLayer) { |
1014 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateImageLayer()); | 1013 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateImageLayer()); |
1015 registerContentsLayer(m_imageLayer->layer()); | 1014 registerContentsLayer(m_imageLayer->layer()); |
1016 } | 1015 } |
1017 m_imageLayer->setImageBitmap(nativeImage->bitmap()); | 1016 m_imageLayer->setImageBitmap(bitmap); |
1018 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); | 1017 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); |
1019 updateContentsRect(); | 1018 updateContentsRect(); |
1020 } else { | 1019 } else { |
1021 if (m_imageLayer) { | 1020 if (m_imageLayer) { |
1022 unregisterContentsLayer(m_imageLayer->layer()); | 1021 unregisterContentsLayer(m_imageLayer->layer()); |
1023 m_imageLayer.clear(); | 1022 m_imageLayer.clear(); |
1024 } | 1023 } |
1025 } | 1024 } |
1026 | 1025 |
1027 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); | 1026 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); |
1028 } | 1027 } |
1029 | 1028 |
1030 void GraphicsLayer::setContentsToNinePatch(Image* image, const IntRect& aperture
) | 1029 void GraphicsLayer::setContentsToNinePatch(Image* image, const IntRect& aperture
) |
1031 { | 1030 { |
1032 if (m_ninePatchLayer) { | 1031 if (m_ninePatchLayer) { |
1033 unregisterContentsLayer(m_ninePatchLayer->layer()); | 1032 unregisterContentsLayer(m_ninePatchLayer->layer()); |
1034 m_ninePatchLayer.clear(); | 1033 m_ninePatchLayer.clear(); |
1035 } | 1034 } |
1036 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr
ame() : nullptr; | 1035 SkBitmap bitmap; |
1037 if (nativeImage) { | 1036 if (image && image->bitmapForCurrentFrame(&bitmap)) { |
1038 m_ninePatchLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateNinePatchLayer()); | 1037 m_ninePatchLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateNinePatchLayer()); |
1039 const SkBitmap& bitmap = nativeImage->bitmap(); | |
1040 int borderWidth = bitmap.width() - aperture.width(); | 1038 int borderWidth = bitmap.width() - aperture.width(); |
1041 int borderHeight = bitmap.height() - aperture.height(); | 1039 int borderHeight = bitmap.height() - aperture.height(); |
1042 WebRect border(aperture.x(), aperture.y(), borderWidth, borderHeight); | 1040 WebRect border(aperture.x(), aperture.y(), borderWidth, borderHeight); |
1043 | 1041 |
1044 m_ninePatchLayer->setBitmap(bitmap); | 1042 m_ninePatchLayer->setBitmap(bitmap); |
1045 m_ninePatchLayer->setAperture(aperture); | 1043 m_ninePatchLayer->setAperture(aperture); |
1046 m_ninePatchLayer->setBorder(border); | 1044 m_ninePatchLayer->setBorder(border); |
1047 | 1045 |
1048 m_ninePatchLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque(
)); | 1046 m_ninePatchLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque(
)); |
1049 registerContentsLayer(m_ninePatchLayer->layer()); | 1047 registerContentsLayer(m_ninePatchLayer->layer()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 #ifndef NDEBUG | 1170 #ifndef NDEBUG |
1173 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) | 1171 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) |
1174 { | 1172 { |
1175 if (!layer) | 1173 if (!layer) |
1176 return; | 1174 return; |
1177 | 1175 |
1178 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1176 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1179 fprintf(stderr, "%s\n", output.utf8().data()); | 1177 fprintf(stderr, "%s\n", output.utf8().data()); |
1180 } | 1178 } |
1181 #endif | 1179 #endif |
OLD | NEW |