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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "public/platform/WebCompositorSupport.h" | 50 #include "public/platform/WebCompositorSupport.h" |
51 #include "public/platform/WebFloatPoint.h" | 51 #include "public/platform/WebFloatPoint.h" |
52 #include "public/platform/WebFloatRect.h" | 52 #include "public/platform/WebFloatRect.h" |
53 #include "public/platform/WebLayer.h" | 53 #include "public/platform/WebLayer.h" |
54 #include "public/platform/WebPoint.h" | 54 #include "public/platform/WebPoint.h" |
55 #include "public/platform/WebSize.h" | 55 #include "public/platform/WebSize.h" |
56 #include "wtf/CurrentTime.h" | 56 #include "wtf/CurrentTime.h" |
57 #include "wtf/HashMap.h" | 57 #include "wtf/HashMap.h" |
58 #include "wtf/HashSet.h" | 58 #include "wtf/HashSet.h" |
59 #include "wtf/MathExtras.h" | 59 #include "wtf/MathExtras.h" |
60 #include "wtf/PtrUtil.h" | |
61 #include "wtf/text/StringUTF8Adaptor.h" | 60 #include "wtf/text/StringUTF8Adaptor.h" |
62 #include "wtf/text/WTFString.h" | 61 #include "wtf/text/WTFString.h" |
63 #include <algorithm> | 62 #include <algorithm> |
64 #include <cmath> | 63 #include <cmath> |
65 #include <memory> | |
66 #include <utility> | 64 #include <utility> |
67 | 65 |
68 #ifndef NDEBUG | 66 #ifndef NDEBUG |
69 #include <stdio.h> | 67 #include <stdio.h> |
70 #endif | 68 #endif |
71 | 69 |
72 namespace blink { | 70 namespace blink { |
73 | 71 |
74 static bool s_drawDebugRedFill = true; | 72 static bool s_drawDebugRedFill = true; |
75 | 73 |
(...skipping 26 matching lines...) Expand all Loading... |
102 #endif | 100 #endif |
103 }; | 101 }; |
104 | 102 |
105 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati
onTrackingMap; | 103 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati
onTrackingMap; |
106 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() | 104 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() |
107 { | 105 { |
108 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); | 106 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); |
109 return map; | 107 return map; |
110 } | 108 } |
111 | 109 |
112 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client
) | 110 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client) |
113 { | 111 { |
114 return wrapUnique(new GraphicsLayer(client)); | 112 return adoptPtr(new GraphicsLayer(client)); |
115 } | 113 } |
116 | 114 |
117 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) | 115 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) |
118 : m_client(client) | 116 : m_client(client) |
119 , m_backgroundColor(Color::transparent) | 117 , m_backgroundColor(Color::transparent) |
120 , m_opacity(1) | 118 , m_opacity(1) |
121 , m_blendMode(WebBlendModeNormal) | 119 , m_blendMode(WebBlendModeNormal) |
122 , m_hasTransformOrigin(false) | 120 , m_hasTransformOrigin(false) |
123 , m_contentsOpaque(false) | 121 , m_contentsOpaque(false) |
124 , m_shouldFlattenTransform(true) | 122 , m_shouldFlattenTransform(true) |
(...skipping 18 matching lines...) Expand all Loading... |
143 , m_contentsLayer(0) | 141 , m_contentsLayer(0) |
144 , m_contentsLayerId(0) | 142 , m_contentsLayerId(0) |
145 , m_scrollableArea(nullptr) | 143 , m_scrollableArea(nullptr) |
146 , m_3dRenderingContext(0) | 144 , m_3dRenderingContext(0) |
147 { | 145 { |
148 #if ENABLE(ASSERT) | 146 #if ENABLE(ASSERT) |
149 if (m_client) | 147 if (m_client) |
150 m_client->verifyNotPainting(); | 148 m_client->verifyNotPainting(); |
151 #endif | 149 #endif |
152 | 150 |
153 m_contentLayerDelegate = wrapUnique(new ContentLayerDelegate(this)); | 151 m_contentLayerDelegate = adoptPtr(new ContentLayerDelegate(this)); |
154 m_layer = wrapUnique(Platform::current()->compositorSupport()->createContent
Layer(m_contentLayerDelegate.get())); | 152 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa
yer(m_contentLayerDelegate.get())); |
155 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); | 153 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); |
156 m_layer->layer()->setLayerClient(this); | 154 m_layer->layer()->setLayerClient(this); |
157 } | 155 } |
158 | 156 |
159 GraphicsLayer::~GraphicsLayer() | 157 GraphicsLayer::~GraphicsLayer() |
160 { | 158 { |
161 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 159 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
162 m_linkHighlights[i]->clearCurrentGraphicsLayer(); | 160 m_linkHighlights[i]->clearCurrentGraphicsLayer(); |
163 m_linkHighlights.clear(); | 161 m_linkHighlights.clear(); |
164 | 162 |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 | 1148 |
1151 if (image && skImage && image->isBitmapImage()) { | 1149 if (image && skImage && image->isBitmapImage()) { |
1152 if (respectImageOrientation == RespectImageOrientation) { | 1150 if (respectImageOrientation == RespectImageOrientation) { |
1153 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra
meOrientation(); | 1151 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra
meOrientation(); |
1154 skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOr
ientation); | 1152 skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOr
ientation); |
1155 } | 1153 } |
1156 } | 1154 } |
1157 | 1155 |
1158 if (image && skImage) { | 1156 if (image && skImage) { |
1159 if (!m_imageLayer) { | 1157 if (!m_imageLayer) { |
1160 m_imageLayer = wrapUnique(Platform::current()->compositorSupport()->
createImageLayer()); | 1158 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr
eateImageLayer()); |
1161 registerContentsLayer(m_imageLayer->layer()); | 1159 registerContentsLayer(m_imageLayer->layer()); |
1162 } | 1160 } |
1163 m_imageLayer->setImage(skImage.get()); | 1161 m_imageLayer->setImage(skImage.get()); |
1164 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); | 1162 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); |
1165 updateContentsRect(); | 1163 updateContentsRect(); |
1166 } else { | 1164 } else { |
1167 if (m_imageLayer) { | 1165 if (m_imageLayer) { |
1168 unregisterContentsLayer(m_imageLayer->layer()); | 1166 unregisterContentsLayer(m_imageLayer->layer()); |
1169 m_imageLayer.reset(); | 1167 m_imageLayer.reset(); |
1170 } | 1168 } |
1171 } | 1169 } |
1172 | 1170 |
1173 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); | 1171 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); |
1174 } | 1172 } |
1175 | 1173 |
1176 WebLayer* GraphicsLayer::platformLayer() const | 1174 WebLayer* GraphicsLayer::platformLayer() const |
1177 { | 1175 { |
1178 return m_layer->layer(); | 1176 return m_layer->layer(); |
1179 } | 1177 } |
1180 | 1178 |
1181 void GraphicsLayer::setFilters(const FilterOperations& filters) | 1179 void GraphicsLayer::setFilters(const FilterOperations& filters) |
1182 { | 1180 { |
1183 std::unique_ptr<CompositorFilterOperations> compositorFilters = CompositorFi
lterOperations::create(); | 1181 OwnPtr<CompositorFilterOperations> compositorFilters = CompositorFilterOpera
tions::create(); |
1184 SkiaImageFilterBuilder::buildFilterOperations(filters, compositorFilters.get
()); | 1182 SkiaImageFilterBuilder::buildFilterOperations(filters, compositorFilters.get
()); |
1185 m_layer->layer()->setFilters(compositorFilters->asFilterOperations()); | 1183 m_layer->layer()->setFilters(compositorFilters->asFilterOperations()); |
1186 } | 1184 } |
1187 | 1185 |
1188 void GraphicsLayer::setBackdropFilters(const FilterOperations& filters) | 1186 void GraphicsLayer::setBackdropFilters(const FilterOperations& filters) |
1189 { | 1187 { |
1190 std::unique_ptr<CompositorFilterOperations> compositorFilters = CompositorFi
lterOperations::create(); | 1188 OwnPtr<CompositorFilterOperations> compositorFilters = CompositorFilterOpera
tions::create(); |
1191 SkiaImageFilterBuilder::buildFilterOperations(filters, compositorFilters.get
()); | 1189 SkiaImageFilterBuilder::buildFilterOperations(filters, compositorFilters.get
()); |
1192 m_layer->layer()->setBackgroundFilters(compositorFilters->asFilterOperations
()); | 1190 m_layer->layer()->setBackgroundFilters(compositorFilters->asFilterOperations
()); |
1193 } | 1191 } |
1194 | 1192 |
1195 void GraphicsLayer::setFilterQuality(SkFilterQuality filterQuality) | 1193 void GraphicsLayer::setFilterQuality(SkFilterQuality filterQuality) |
1196 { | 1194 { |
1197 if (m_imageLayer) | 1195 if (m_imageLayer) |
1198 m_imageLayer->setNearestNeighbor(filterQuality == kNone_SkFilterQuality)
; | 1196 m_imageLayer->setNearestNeighbor(filterQuality == kNone_SkFilterQuality)
; |
1199 } | 1197 } |
1200 | 1198 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 { | 1369 { |
1372 if (!layer) { | 1370 if (!layer) { |
1373 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1371 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1374 return; | 1372 return; |
1375 } | 1373 } |
1376 | 1374 |
1377 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1375 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1378 fprintf(stderr, "%s\n", output.utf8().data()); | 1376 fprintf(stderr, "%s\n", output.utf8().data()); |
1379 } | 1377 } |
1380 #endif | 1378 #endif |
OLD | NEW |