Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1409)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Self-review. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 int y; 87 int y;
88 SkColor oldPixel; 88 SkColor oldPixel;
89 SkColor newPixel; 89 SkColor newPixel;
90 }; 90 };
91 #endif 91 #endif
92 92
93 struct PaintInvalidationTracking { 93 struct PaintInvalidationTracking {
94 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 94 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
95 Vector<PaintInvalidationInfo> trackedPaintInvalidations; 95 Vector<PaintInvalidationInfo> trackedPaintInvalidations;
96 #if DCHECK_IS_ON() 96 #if DCHECK_IS_ON()
97 RefPtr<SkPicture> lastPaintedPicture; 97 sk_sp<SkPicture> lastPaintedPicture;
98 Region paintInvalidationRegionSinceLastPaint; 98 Region paintInvalidationRegionSinceLastPaint;
99 Vector<UnderPaintInvalidation> underPaintInvalidations; 99 Vector<UnderPaintInvalidation> underPaintInvalidations;
100 #endif 100 #endif
101 }; 101 };
102 102
103 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati onTrackingMap; 103 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati onTrackingMap;
104 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() 104 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap()
105 { 105 {
106 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); 106 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ());
107 return map; 107 return map;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 { 331 {
332 return m_previousInterestRect; 332 return m_previousInterestRect;
333 } 333 }
334 334
335 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled Mode disabledMode) 335 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled Mode disabledMode)
336 { 336 {
337 if (paintWithoutCommit(interestRect, disabledMode)) { 337 if (paintWithoutCommit(interestRect, disabledMode)) {
338 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub pixelAccumulation()); 338 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub pixelAccumulation());
339 #if DCHECK_IS_ON() 339 #if DCHECK_IS_ON()
340 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnable d()) { 340 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnable d()) {
341 RefPtr<SkPicture> newPicture = capturePicture(); 341 sk_sp<SkPicture> newPicture = capturePicture();
342 checkPaintUnderInvalidations(*newPicture); 342 checkPaintUnderInvalidations(*newPicture);
343 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap() .add(this, PaintInvalidationTracking()).storedValue->value; 343 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap() .add(this, PaintInvalidationTracking()).storedValue->value;
344 tracking.lastPaintedPicture = newPicture; 344 tracking.lastPaintedPicture = newPicture;
f(malita) 2016/09/01 03:55:38 Not new to this CL (and prolly not very important
Łukasz Anforowicz 2016/09/01 20:50:58 Done.
345 tracking.paintInvalidationRegionSinceLastPaint = Region(); 345 tracking.paintInvalidationRegionSinceLastPaint = Region();
346 } 346 }
347 #endif 347 #endif
348 } 348 }
349 } 349 }
350 350
351 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont ext::DisabledMode disabledMode) 351 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont ext::DisabledMode disabledMode)
352 { 352 {
353 ASSERT(drawsContent()); 353 ASSERT(drawsContent());
354 354
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 { 1113 {
1114 if (rect == m_contentsRect) 1114 if (rect == m_contentsRect)
1115 return; 1115 return;
1116 1116
1117 m_contentsRect = rect; 1117 m_contentsRect = rect;
1118 updateContentsRect(); 1118 updateContentsRect();
1119 } 1119 }
1120 1120
1121 void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum respectImageOrientation) 1121 void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum respectImageOrientation)
1122 { 1122 {
1123 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; 1123 sk_sp<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr;
1124 1124
1125 if (image && skImage && image->isBitmapImage()) { 1125 if (image && skImage && image->isBitmapImage()) {
1126 if (respectImageOrientation == RespectImageOrientation) { 1126 if (respectImageOrientation == RespectImageOrientation) {
1127 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra meOrientation(); 1127 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra meOrientation();
1128 skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOr ientation); 1128 skImage = DragImage::resizeAndOrientImage(std::move(skImage), imageO rientation);
1129 } 1129 }
1130 } 1130 }
1131 1131
1132 if (image && skImage) { 1132 if (image && skImage) {
1133 if (!m_imageLayer) { 1133 if (!m_imageLayer) {
1134 m_imageLayer = wrapUnique(Platform::current()->compositorSupport()-> createImageLayer()); 1134 m_imageLayer = wrapUnique(Platform::current()->compositorSupport()-> createImageLayer());
1135 registerContentsLayer(m_imageLayer->layer()); 1135 registerContentsLayer(m_imageLayer->layer());
1136 } 1136 }
1137 m_imageLayer->setImage(skImage.get()); 1137 m_imageLayer->setImage(skImage.get());
1138 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); 1138 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 } 1248 }
1249 1249
1250 void GraphicsLayer::setCompositorMutableProperties(uint32_t properties) 1250 void GraphicsLayer::setCompositorMutableProperties(uint32_t properties)
1251 { 1251 {
1252 if (WebLayer* layer = platformLayer()) 1252 if (WebLayer* layer = platformLayer())
1253 layer->setCompositorMutableProperties(properties); 1253 layer->setCompositorMutableProperties(properties);
1254 } 1254 }
1255 1255
1256 #if DCHECK_IS_ON() 1256 #if DCHECK_IS_ON()
1257 1257
1258 PassRefPtr<SkPicture> GraphicsLayer::capturePicture() 1258 sk_sp<SkPicture> GraphicsLayer::capturePicture()
1259 { 1259 {
1260 if (!drawsContent()) 1260 if (!drawsContent())
1261 return nullptr; 1261 return nullptr;
1262 1262
1263 IntSize intSize = expandedIntSize(size()); 1263 IntSize intSize = expandedIntSize(size());
1264 GraphicsContext graphicsContext(getPaintController()); 1264 GraphicsContext graphicsContext(getPaintController());
1265 graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize)); 1265 graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize));
1266 getPaintController().paintArtifact().replay(graphicsContext); 1266 getPaintController().paintArtifact().replay(graphicsContext);
1267 return graphicsContext.endRecording(); 1267 return graphicsContext.endRecording();
1268 } 1268 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 } 1331 }
1332 1332
1333 oldBitmap.unlockPixels(); 1333 oldBitmap.unlockPixels();
1334 newBitmap.unlockPixels(); 1334 newBitmap.unlockPixels();
1335 1335
1336 // Visualize under-invalidations by overlaying the new bitmap (containing re d pixels indicating under-invalidations, 1336 // Visualize under-invalidations by overlaying the new bitmap (containing re d pixels indicating under-invalidations,
1337 // and transparent pixels otherwise) onto the painting. 1337 // and transparent pixels otherwise) onto the painting.
1338 SkPictureRecorder recorder; 1338 SkPictureRecorder recorder;
1339 recorder.beginRecording(width, height); 1339 recorder.beginRecording(width, height);
1340 recorder.getRecordingCanvas()->drawBitmap(newBitmap, 0, 0); 1340 recorder.getRecordingCanvas()->drawBitmap(newBitmap, 0, 0);
1341 RefPtr<SkPicture> picture = fromSkSp(recorder.finishRecordingAsPicture()); 1341 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
1342 getPaintController().appendDebugDrawingAfterCommit(*this, picture, offsetFro mLayoutObjectWithSubpixelAccumulation()); 1342 getPaintController().appendDebugDrawingAfterCommit(*this, picture, offsetFro mLayoutObjectWithSubpixelAccumulation());
1343 } 1343 }
1344 1344
1345 #endif // DCHECK_IS_ON() 1345 #endif // DCHECK_IS_ON()
1346 1346
1347 } // namespace blink 1347 } // namespace blink
1348 1348
1349 #ifndef NDEBUG 1349 #ifndef NDEBUG
1350 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) 1350 void showGraphicsLayerTree(const blink::GraphicsLayer* layer)
1351 { 1351 {
1352 if (!layer) { 1352 if (!layer) {
1353 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); 1353 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n");
1354 return; 1354 return;
1355 } 1355 }
1356 1356
1357 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); 1357 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo);
1358 fprintf(stderr, "%s\n", output.utf8().data()); 1358 fprintf(stderr, "%s\n", output.utf8().data());
1359 } 1359 }
1360 #endif 1360 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698