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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "platform/graphics/GraphicsLayer.h" | 27 #include "platform/graphics/GraphicsLayer.h" |
28 | 28 |
29 #include "SkImageFilter.h" | 29 #include "SkImageFilter.h" |
30 #include "SkMatrix44.h" | 30 #include "SkMatrix44.h" |
| 31 #include "platform/DragImage.h" |
31 #include "platform/TraceEvent.h" | 32 #include "platform/TraceEvent.h" |
32 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
33 #include "platform/geometry/LayoutRect.h" | 34 #include "platform/geometry/LayoutRect.h" |
| 35 #include "platform/graphics/BitmapImage.h" |
34 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 36 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
35 #include "platform/graphics/GraphicsContext.h" | 37 #include "platform/graphics/GraphicsContext.h" |
36 #include "platform/graphics/GraphicsLayerFactory.h" | 38 #include "platform/graphics/GraphicsLayerFactory.h" |
37 #include "platform/graphics/Image.h" | 39 #include "platform/graphics/Image.h" |
38 #include "platform/graphics/LinkHighlight.h" | 40 #include "platform/graphics/LinkHighlight.h" |
39 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 41 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
40 #include "platform/graphics/paint/DisplayItemList.h" | 42 #include "platform/graphics/paint/DisplayItemList.h" |
41 #include "platform/graphics/paint/DrawingRecorder.h" | 43 #include "platform/graphics/paint/DrawingRecorder.h" |
42 #include "platform/scroll/ScrollableArea.h" | 44 #include "platform/scroll/ScrollableArea.h" |
43 #include "platform/text/TextStream.h" | 45 #include "platform/text/TextStream.h" |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 | 1001 |
1000 void GraphicsLayer::setContentsRect(const IntRect& rect) | 1002 void GraphicsLayer::setContentsRect(const IntRect& rect) |
1001 { | 1003 { |
1002 if (rect == m_contentsRect) | 1004 if (rect == m_contentsRect) |
1003 return; | 1005 return; |
1004 | 1006 |
1005 m_contentsRect = rect; | 1007 m_contentsRect = rect; |
1006 updateContentsRect(); | 1008 updateContentsRect(); |
1007 } | 1009 } |
1008 | 1010 |
1009 void GraphicsLayer::setContentsToImage(Image* image) | 1011 void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum
respectImageOrientation) |
1010 { | 1012 { |
1011 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; | 1013 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; |
1012 if (image && skImage) { | 1014 if (image && skImage) { |
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 } |
| 1019 if (respectImageOrientation == RespectImageOrientation && image->isBitma
pImage()) { |
| 1020 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra
meOrientation(); |
| 1021 bool usesWidthAsHeight = imageOrientation.usesWidthAsHeight(); |
| 1022 IntSize size = usesWidthAsHeight ? image->size().transposedSize() :
image->size(); |
| 1023 skImage = adjustedImage(skImage.release(), size, imageOrientation.tr
ansformFromDefault(size), 1.0f); |
| 1024 } |
1017 m_imageLayer->setImage(skImage.get()); | 1025 m_imageLayer->setImage(skImage.get()); |
1018 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); | 1026 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); |
1019 updateContentsRect(); | 1027 updateContentsRect(); |
1020 } else { | 1028 } else { |
1021 if (m_imageLayer) { | 1029 if (m_imageLayer) { |
1022 unregisterContentsLayer(m_imageLayer->layer()); | 1030 unregisterContentsLayer(m_imageLayer->layer()); |
1023 m_imageLayer.clear(); | 1031 m_imageLayer.clear(); |
1024 } | 1032 } |
1025 } | 1033 } |
1026 | 1034 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 { | 1167 { |
1160 if (!layer) { | 1168 if (!layer) { |
1161 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1169 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1162 return; | 1170 return; |
1163 } | 1171 } |
1164 | 1172 |
1165 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1173 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1166 fprintf(stderr, "%s\n", output.utf8().data()); | 1174 fprintf(stderr, "%s\n", output.utf8().data()); |
1167 } | 1175 } |
1168 #endif | 1176 #endif |
OLD | NEW |