| 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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 | 1038 |
| 1037 void GraphicsLayer::setContentsRect(const IntRect& rect) | 1039 void GraphicsLayer::setContentsRect(const IntRect& rect) |
| 1038 { | 1040 { |
| 1039 if (rect == m_contentsRect) | 1041 if (rect == m_contentsRect) |
| 1040 return; | 1042 return; |
| 1041 | 1043 |
| 1042 m_contentsRect = rect; | 1044 m_contentsRect = rect; |
| 1043 updateContentsRect(); | 1045 updateContentsRect(); |
| 1044 } | 1046 } |
| 1045 | 1047 |
| 1046 void GraphicsLayer::setContentsToImage(Image* image) | 1048 void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum
respectImageOrientation) |
| 1047 { | 1049 { |
| 1048 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; | 1050 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; |
| 1049 if (image && skImage) { | 1051 if (image && skImage) { |
| 1050 if (!m_imageLayer) { | 1052 if (!m_imageLayer) { |
| 1051 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateImageLayer()); | 1053 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateImageLayer()); |
| 1052 registerContentsLayer(m_imageLayer->layer()); | 1054 registerContentsLayer(m_imageLayer->layer()); |
| 1053 } | 1055 } |
| 1056 if (respectImageOrientation == RespectImageOrientation && image->isBitma
pImage()) { |
| 1057 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra
meOrientation(); |
| 1058 bool usesWidthAsHeight = imageOrientation.usesWidthAsHeight(); |
| 1059 IntSize size = usesWidthAsHeight ? image->size().transposedSize() :
image->size(); |
| 1060 skImage = adjustedImage(skImage.release(), size, imageOrientation.tr
ansformFromDefault(size), 1.0f); |
| 1061 } |
| 1054 m_imageLayer->setImage(skImage.get()); | 1062 m_imageLayer->setImage(skImage.get()); |
| 1055 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); | 1063 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); |
| 1056 updateContentsRect(); | 1064 updateContentsRect(); |
| 1057 } else { | 1065 } else { |
| 1058 if (m_imageLayer) { | 1066 if (m_imageLayer) { |
| 1059 unregisterContentsLayer(m_imageLayer->layer()); | 1067 unregisterContentsLayer(m_imageLayer->layer()); |
| 1060 m_imageLayer.clear(); | 1068 m_imageLayer.clear(); |
| 1061 } | 1069 } |
| 1062 } | 1070 } |
| 1063 | 1071 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 { | 1204 { |
| 1197 if (!layer) { | 1205 if (!layer) { |
| 1198 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1206 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
| 1199 return; | 1207 return; |
| 1200 } | 1208 } |
| 1201 | 1209 |
| 1202 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1210 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
| 1203 fprintf(stderr, "%s\n", output.utf8().data()); | 1211 fprintf(stderr, "%s\n", output.utf8().data()); |
| 1204 } | 1212 } |
| 1205 #endif | 1213 #endif |
| OLD | NEW |