| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 client->isTrackingRasterInvalidations()), | 104 client->isTrackingRasterInvalidations()), |
| 105 m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip), | 105 m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip), |
| 106 m_parent(0), | 106 m_parent(0), |
| 107 m_maskLayer(0), | 107 m_maskLayer(0), |
| 108 m_contentsClippingMaskLayer(0), | 108 m_contentsClippingMaskLayer(0), |
| 109 m_paintCount(0), | 109 m_paintCount(0), |
| 110 m_contentsLayer(0), | 110 m_contentsLayer(0), |
| 111 m_contentsLayerId(0), | 111 m_contentsLayerId(0), |
| 112 m_scrollableArea(nullptr), | 112 m_scrollableArea(nullptr), |
| 113 m_renderingContext3d(0), | 113 m_renderingContext3d(0), |
| 114 m_colorBehavior(ColorBehavior::transformToGlobalTarget()), | |
| 115 m_hasPreferredRasterBounds(false) { | 114 m_hasPreferredRasterBounds(false) { |
| 116 #if DCHECK_IS_ON() | 115 #if DCHECK_IS_ON() |
| 117 if (m_client) | 116 if (m_client) |
| 118 m_client->verifyNotPainting(); | 117 m_client->verifyNotPainting(); |
| 119 #endif | 118 #endif |
| 120 | |
| 121 // In true color mode, no inputs are adjusted, and all colors are converted | |
| 122 // at rasterization time. | |
| 123 if (RuntimeEnabledFeatures::trueColorRenderingEnabled()) | |
| 124 m_colorBehavior = ColorBehavior::tag(); | |
| 125 | |
| 126 m_contentLayerDelegate = WTF::makeUnique<ContentLayerDelegate>(this); | 119 m_contentLayerDelegate = WTF::makeUnique<ContentLayerDelegate>(this); |
| 127 m_layer = Platform::current()->compositorSupport()->createContentLayer( | 120 m_layer = Platform::current()->compositorSupport()->createContentLayer( |
| 128 m_contentLayerDelegate.get()); | 121 m_contentLayerDelegate.get()); |
| 129 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); | 122 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); |
| 130 m_layer->layer()->setLayerClient(this); | 123 m_layer->layer()->setLayerClient(this); |
| 131 } | 124 } |
| 132 | 125 |
| 133 GraphicsLayer::~GraphicsLayer() { | 126 GraphicsLayer::~GraphicsLayer() { |
| 134 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 127 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 135 m_linkHighlights[i]->clearCurrentGraphicsLayer(); | 128 m_linkHighlights[i]->clearCurrentGraphicsLayer(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 m_client->computeInterestRect(this, m_previousInterestRect); | 320 m_client->computeInterestRect(this, m_previousInterestRect); |
| 328 interestRect = &newInterestRect; | 321 interestRect = &newInterestRect; |
| 329 } | 322 } |
| 330 | 323 |
| 331 if (!getPaintController().subsequenceCachingIsDisabled() && | 324 if (!getPaintController().subsequenceCachingIsDisabled() && |
| 332 !m_client->needsRepaint(*this) && !getPaintController().cacheIsEmpty() && | 325 !m_client->needsRepaint(*this) && !getPaintController().cacheIsEmpty() && |
| 333 m_previousInterestRect == *interestRect) { | 326 m_previousInterestRect == *interestRect) { |
| 334 return false; | 327 return false; |
| 335 } | 328 } |
| 336 | 329 |
| 337 GraphicsContext context(getPaintController(), disabledMode, nullptr, | 330 GraphicsContext context(getPaintController(), disabledMode, nullptr); |
| 338 m_colorBehavior); | |
| 339 | 331 |
| 340 m_previousInterestRect = *interestRect; | 332 m_previousInterestRect = *interestRect; |
| 341 m_client->paintContents(this, context, m_paintingPhase, *interestRect); | 333 m_client->paintContents(this, context, m_paintingPhase, *interestRect); |
| 342 return true; | 334 return true; |
| 343 } | 335 } |
| 344 | 336 |
| 345 void GraphicsLayer::updateChildList() { | 337 void GraphicsLayer::updateChildList() { |
| 346 WebLayer* childHost = m_layer->layer(); | 338 WebLayer* childHost = m_layer->layer(); |
| 347 childHost->removeAllChildren(); | 339 childHost->removeAllChildren(); |
| 348 | 340 |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 if (rect == m_contentsRect) | 1057 if (rect == m_contentsRect) |
| 1066 return; | 1058 return; |
| 1067 | 1059 |
| 1068 m_contentsRect = rect; | 1060 m_contentsRect = rect; |
| 1069 updateContentsRect(); | 1061 updateContentsRect(); |
| 1070 } | 1062 } |
| 1071 | 1063 |
| 1072 void GraphicsLayer::setContentsToImage( | 1064 void GraphicsLayer::setContentsToImage( |
| 1073 Image* image, | 1065 Image* image, |
| 1074 RespectImageOrientationEnum respectImageOrientation) { | 1066 RespectImageOrientationEnum respectImageOrientation) { |
| 1075 sk_sp<SkImage> skImage = | 1067 sk_sp<SkImage> skImage = image ? image->imageForCurrentFrame( |
| 1076 image ? image->imageForCurrentFrame(m_colorBehavior) : nullptr; | 1068 ColorBehavior::transformToGlobalTarget()) |
| 1069 : nullptr; |
| 1077 | 1070 |
| 1078 if (image && skImage && image->isBitmapImage()) { | 1071 if (image && skImage && image->isBitmapImage()) { |
| 1079 if (respectImageOrientation == RespectImageOrientation) { | 1072 if (respectImageOrientation == RespectImageOrientation) { |
| 1080 ImageOrientation imageOrientation = | 1073 ImageOrientation imageOrientation = |
| 1081 toBitmapImage(image)->currentFrameOrientation(); | 1074 toBitmapImage(image)->currentFrameOrientation(); |
| 1082 skImage = | 1075 skImage = |
| 1083 DragImage::resizeAndOrientImage(std::move(skImage), imageOrientation); | 1076 DragImage::resizeAndOrientImage(std::move(skImage), imageOrientation); |
| 1084 } | 1077 } |
| 1085 } | 1078 } |
| 1086 | 1079 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 if (WebLayer* layer = platformLayer()) | 1194 if (WebLayer* layer = platformLayer()) |
| 1202 layer->setCompositorMutableProperties(properties); | 1195 layer->setCompositorMutableProperties(properties); |
| 1203 } | 1196 } |
| 1204 | 1197 |
| 1205 sk_sp<PaintRecord> GraphicsLayer::captureRecord() { | 1198 sk_sp<PaintRecord> GraphicsLayer::captureRecord() { |
| 1206 if (!drawsContent()) | 1199 if (!drawsContent()) |
| 1207 return nullptr; | 1200 return nullptr; |
| 1208 | 1201 |
| 1209 IntSize intSize = expandedIntSize(size()); | 1202 IntSize intSize = expandedIntSize(size()); |
| 1210 GraphicsContext graphicsContext(getPaintController(), | 1203 GraphicsContext graphicsContext(getPaintController(), |
| 1211 GraphicsContext::NothingDisabled, nullptr, | 1204 GraphicsContext::NothingDisabled, nullptr); |
| 1212 m_colorBehavior); | |
| 1213 graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize)); | 1205 graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize)); |
| 1214 getPaintController().paintArtifact().replay(graphicsContext); | 1206 getPaintController().paintArtifact().replay(graphicsContext); |
| 1215 return graphicsContext.endRecording(); | 1207 return graphicsContext.endRecording(); |
| 1216 } | 1208 } |
| 1217 | 1209 |
| 1218 static bool pixelComponentsDiffer(int c1, int c2) { | 1210 static bool pixelComponentsDiffer(int c1, int c2) { |
| 1219 // Compare strictly for saturated values. | 1211 // Compare strictly for saturated values. |
| 1220 if (c1 == 0 || c1 == 255 || c2 == 0 || c2 == 255) | 1212 if (c1 == 0 || c1 == 255 || c2 == 0 || c2 == 255) |
| 1221 return c1 != c2; | 1213 return c1 != c2; |
| 1222 // Tolerate invisible differences that may occur in gradients etc. | 1214 // Tolerate invisible differences that may occur in gradients etc. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { | 1310 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { |
| 1319 if (!layer) { | 1311 if (!layer) { |
| 1320 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; | 1312 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; |
| 1321 return; | 1313 return; |
| 1322 } | 1314 } |
| 1323 | 1315 |
| 1324 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1316 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
| 1325 LOG(INFO) << output.utf8().data(); | 1317 LOG(INFO) << output.utf8().data(); |
| 1326 } | 1318 } |
| 1327 #endif | 1319 #endif |
| OLD | NEW |