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

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: Rebasing... 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 84 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
85 int x; 85 int x;
86 int y; 86 int y;
87 SkColor oldPixel; 87 SkColor oldPixel;
88 SkColor newPixel; 88 SkColor newPixel;
89 }; 89 };
90 90
91 struct PaintInvalidationTracking { 91 struct PaintInvalidationTracking {
92 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 92 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
93 Vector<PaintInvalidationInfo> trackedPaintInvalidations; 93 Vector<PaintInvalidationInfo> trackedPaintInvalidations;
94 RefPtr<SkPicture> lastPaintedPicture; 94 sk_sp<SkPicture> lastPaintedPicture;
95 Region paintInvalidationRegionSinceLastPaint; 95 Region paintInvalidationRegionSinceLastPaint;
96 Vector<UnderPaintInvalidation> underPaintInvalidations; 96 Vector<UnderPaintInvalidation> underPaintInvalidations;
97 }; 97 };
98 98
99 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati onTrackingMap; 99 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati onTrackingMap;
100 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() 100 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap()
101 { 101 {
102 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); 102 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ());
103 return map; 103 return map;
104 } 104 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 IntRect GraphicsLayer::interestRect() 326 IntRect GraphicsLayer::interestRect()
327 { 327 {
328 return m_previousInterestRect; 328 return m_previousInterestRect;
329 } 329 }
330 330
331 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled Mode disabledMode) 331 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled Mode disabledMode)
332 { 332 {
333 if (paintWithoutCommit(interestRect, disabledMode)) { 333 if (paintWithoutCommit(interestRect, disabledMode)) {
334 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub pixelAccumulation()); 334 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub pixelAccumulation());
335 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { 335 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
336 RefPtr<SkPicture> newPicture = capturePicture(); 336 sk_sp<SkPicture> newPicture = capturePicture();
337 checkPaintUnderInvalidations(*newPicture); 337 checkPaintUnderInvalidations(*newPicture);
338 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap() .add(this, PaintInvalidationTracking()).storedValue->value; 338 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap() .add(this, PaintInvalidationTracking()).storedValue->value;
339 tracking.lastPaintedPicture = newPicture; 339 tracking.lastPaintedPicture = std::move(newPicture);
340 tracking.paintInvalidationRegionSinceLastPaint = Region(); 340 tracking.paintInvalidationRegionSinceLastPaint = Region();
341 } 341 }
342 } 342 }
343 } 343 }
344 344
345 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont ext::DisabledMode disabledMode) 345 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont ext::DisabledMode disabledMode)
346 { 346 {
347 ASSERT(drawsContent()); 347 ASSERT(drawsContent());
348 348
349 if (!m_client) 349 if (!m_client)
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 { 1104 {
1105 if (rect == m_contentsRect) 1105 if (rect == m_contentsRect)
1106 return; 1106 return;
1107 1107
1108 m_contentsRect = rect; 1108 m_contentsRect = rect;
1109 updateContentsRect(); 1109 updateContentsRect();
1110 } 1110 }
1111 1111
1112 void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum respectImageOrientation) 1112 void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum respectImageOrientation)
1113 { 1113 {
1114 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; 1114 sk_sp<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr;
1115 1115
1116 if (image && skImage && image->isBitmapImage()) { 1116 if (image && skImage && image->isBitmapImage()) {
1117 if (respectImageOrientation == RespectImageOrientation) { 1117 if (respectImageOrientation == RespectImageOrientation) {
1118 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra meOrientation(); 1118 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra meOrientation();
1119 skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOr ientation); 1119 skImage = DragImage::resizeAndOrientImage(std::move(skImage), imageO rientation);
1120 } 1120 }
1121 } 1121 }
1122 1122
1123 if (image && skImage) { 1123 if (image && skImage) {
1124 if (!m_imageLayer) { 1124 if (!m_imageLayer) {
1125 m_imageLayer = wrapUnique(Platform::current()->compositorSupport()-> createImageLayer()); 1125 m_imageLayer = wrapUnique(Platform::current()->compositorSupport()-> createImageLayer());
1126 registerContentsLayer(m_imageLayer->layer()); 1126 registerContentsLayer(m_imageLayer->layer());
1127 } 1127 }
1128 m_imageLayer->setImage(skImage.get()); 1128 m_imageLayer->setImage(skImage.get());
1129 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); 1129 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 if (WebLayer* layer = platformLayer()) 1237 if (WebLayer* layer = platformLayer())
1238 layer->setElementId(id); 1238 layer->setElementId(id);
1239 } 1239 }
1240 1240
1241 void GraphicsLayer::setCompositorMutableProperties(uint32_t properties) 1241 void GraphicsLayer::setCompositorMutableProperties(uint32_t properties)
1242 { 1242 {
1243 if (WebLayer* layer = platformLayer()) 1243 if (WebLayer* layer = platformLayer())
1244 layer->setCompositorMutableProperties(properties); 1244 layer->setCompositorMutableProperties(properties);
1245 } 1245 }
1246 1246
1247 PassRefPtr<SkPicture> GraphicsLayer::capturePicture() 1247 sk_sp<SkPicture> GraphicsLayer::capturePicture()
1248 { 1248 {
1249 if (!drawsContent()) 1249 if (!drawsContent())
1250 return nullptr; 1250 return nullptr;
1251 1251
1252 IntSize intSize = expandedIntSize(size()); 1252 IntSize intSize = expandedIntSize(size());
1253 GraphicsContext graphicsContext(getPaintController()); 1253 GraphicsContext graphicsContext(getPaintController());
1254 graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize)); 1254 graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize));
1255 getPaintController().paintArtifact().replay(graphicsContext); 1255 getPaintController().paintArtifact().replay(graphicsContext);
1256 return graphicsContext.endRecording(); 1256 return graphicsContext.endRecording();
1257 } 1257 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 } 1328 }
1329 1329
1330 oldBitmap.unlockPixels(); 1330 oldBitmap.unlockPixels();
1331 newBitmap.unlockPixels(); 1331 newBitmap.unlockPixels();
1332 1332
1333 // Visualize under-invalidations by overlaying the new bitmap (containing re d pixels indicating under-invalidations, 1333 // Visualize under-invalidations by overlaying the new bitmap (containing re d pixels indicating under-invalidations,
1334 // and transparent pixels otherwise) onto the painting. 1334 // and transparent pixels otherwise) onto the painting.
1335 SkPictureRecorder recorder; 1335 SkPictureRecorder recorder;
1336 recorder.beginRecording(width, height); 1336 recorder.beginRecording(width, height);
1337 recorder.getRecordingCanvas()->drawBitmap(newBitmap, 0, 0); 1337 recorder.getRecordingCanvas()->drawBitmap(newBitmap, 0, 0);
1338 RefPtr<SkPicture> picture = fromSkSp(recorder.finishRecordingAsPicture()); 1338 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
1339 getPaintController().appendDebugDrawingAfterCommit(*this, picture, offsetFro mLayoutObjectWithSubpixelAccumulation()); 1339 getPaintController().appendDebugDrawingAfterCommit(*this, picture, offsetFro mLayoutObjectWithSubpixelAccumulation());
1340 } 1340 }
1341 1341
1342 } // namespace blink 1342 } // namespace blink
1343 1343
1344 #ifndef NDEBUG 1344 #ifndef NDEBUG
1345 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) 1345 void showGraphicsLayerTree(const blink::GraphicsLayer* layer)
1346 { 1346 {
1347 if (!layer) { 1347 if (!layer) {
1348 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); 1348 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n");
1349 return; 1349 return;
1350 } 1350 }
1351 1351
1352 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); 1352 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo);
1353 fprintf(stderr, "%s\n", output.utf8().data()); 1353 fprintf(stderr, "%s\n", output.utf8().data());
1354 } 1354 }
1355 #endif 1355 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/GraphicsLayer.h ('k') | third_party/WebKit/Source/platform/graphics/Image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698