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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. Created 4 years, 6 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "public/platform/WebCompositorSupport.h" 51 #include "public/platform/WebCompositorSupport.h"
52 #include "public/platform/WebFloatPoint.h" 52 #include "public/platform/WebFloatPoint.h"
53 #include "public/platform/WebFloatRect.h" 53 #include "public/platform/WebFloatRect.h"
54 #include "public/platform/WebLayer.h" 54 #include "public/platform/WebLayer.h"
55 #include "public/platform/WebPoint.h" 55 #include "public/platform/WebPoint.h"
56 #include "public/platform/WebSize.h" 56 #include "public/platform/WebSize.h"
57 #include "wtf/CurrentTime.h" 57 #include "wtf/CurrentTime.h"
58 #include "wtf/HashMap.h" 58 #include "wtf/HashMap.h"
59 #include "wtf/HashSet.h" 59 #include "wtf/HashSet.h"
60 #include "wtf/MathExtras.h" 60 #include "wtf/MathExtras.h"
61 #include "wtf/PtrUtil.h"
61 #include "wtf/text/StringUTF8Adaptor.h" 62 #include "wtf/text/StringUTF8Adaptor.h"
62 #include "wtf/text/WTFString.h" 63 #include "wtf/text/WTFString.h"
63 #include <algorithm> 64 #include <algorithm>
64 #include <cmath> 65 #include <cmath>
66 #include <memory>
65 #include <utility> 67 #include <utility>
66 68
67 #ifndef NDEBUG 69 #ifndef NDEBUG
68 #include <stdio.h> 70 #include <stdio.h>
69 #endif 71 #endif
70 72
71 namespace blink { 73 namespace blink {
72 74
73 static bool s_drawDebugRedFill = true; 75 static bool s_drawDebugRedFill = true;
74 76
(...skipping 26 matching lines...) Expand all
101 #endif 103 #endif
102 }; 104 };
103 105
104 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati onTrackingMap; 106 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati onTrackingMap;
105 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() 107 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap()
106 { 108 {
107 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); 109 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ());
108 return map; 110 return map;
109 } 111 }
110 112
111 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client) 113 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client )
112 { 114 {
113 return adoptPtr(new GraphicsLayer(client)); 115 return wrapUnique(new GraphicsLayer(client));
114 } 116 }
115 117
116 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) 118 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
117 : m_client(client) 119 : m_client(client)
118 , m_backgroundColor(Color::transparent) 120 , m_backgroundColor(Color::transparent)
119 , m_opacity(1) 121 , m_opacity(1)
120 , m_blendMode(WebBlendModeNormal) 122 , m_blendMode(WebBlendModeNormal)
121 , m_hasTransformOrigin(false) 123 , m_hasTransformOrigin(false)
122 , m_contentsOpaque(false) 124 , m_contentsOpaque(false)
123 , m_shouldFlattenTransform(true) 125 , m_shouldFlattenTransform(true)
(...skipping 18 matching lines...) Expand all
142 , m_contentsLayer(0) 144 , m_contentsLayer(0)
143 , m_contentsLayerId(0) 145 , m_contentsLayerId(0)
144 , m_scrollableArea(nullptr) 146 , m_scrollableArea(nullptr)
145 , m_3dRenderingContext(0) 147 , m_3dRenderingContext(0)
146 { 148 {
147 #if ENABLE(ASSERT) 149 #if ENABLE(ASSERT)
148 if (m_client) 150 if (m_client)
149 m_client->verifyNotPainting(); 151 m_client->verifyNotPainting();
150 #endif 152 #endif
151 153
152 m_contentLayerDelegate = adoptPtr(new ContentLayerDelegate(this)); 154 m_contentLayerDelegate = wrapUnique(new ContentLayerDelegate(this));
153 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_contentLayerDelegate.get())); 155 m_layer = wrapUnique(Platform::current()->compositorSupport()->createContent Layer(m_contentLayerDelegate.get()));
154 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); 156 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
155 m_layer->layer()->setLayerClient(this); 157 m_layer->layer()->setLayerClient(this);
156 } 158 }
157 159
158 GraphicsLayer::~GraphicsLayer() 160 GraphicsLayer::~GraphicsLayer()
159 { 161 {
160 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 162 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
161 m_linkHighlights[i]->clearCurrentGraphicsLayer(); 163 m_linkHighlights[i]->clearCurrentGraphicsLayer();
162 m_linkHighlights.clear(); 164 m_linkHighlights.clear();
163 165
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 1167
1166 if (image && skImage && image->isBitmapImage()) { 1168 if (image && skImage && image->isBitmapImage()) {
1167 if (respectImageOrientation == RespectImageOrientation) { 1169 if (respectImageOrientation == RespectImageOrientation) {
1168 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra meOrientation(); 1170 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra meOrientation();
1169 skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOr ientation); 1171 skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOr ientation);
1170 } 1172 }
1171 } 1173 }
1172 1174
1173 if (image && skImage) { 1175 if (image && skImage) {
1174 if (!m_imageLayer) { 1176 if (!m_imageLayer) {
1175 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateImageLayer()); 1177 m_imageLayer = wrapUnique(Platform::current()->compositorSupport()-> createImageLayer());
1176 registerContentsLayer(m_imageLayer->layer()); 1178 registerContentsLayer(m_imageLayer->layer());
1177 } 1179 }
1178 m_imageLayer->setImage(skImage.get()); 1180 m_imageLayer->setImage(skImage.get());
1179 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); 1181 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque());
1180 updateContentsRect(); 1182 updateContentsRect();
1181 } else { 1183 } else {
1182 if (m_imageLayer) { 1184 if (m_imageLayer) {
1183 unregisterContentsLayer(m_imageLayer->layer()); 1185 unregisterContentsLayer(m_imageLayer->layer());
1184 m_imageLayer.reset(); 1186 m_imageLayer.reset();
1185 } 1187 }
1186 } 1188 }
1187 1189
1188 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); 1190 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0);
1189 } 1191 }
1190 1192
1191 WebLayer* GraphicsLayer::platformLayer() const 1193 WebLayer* GraphicsLayer::platformLayer() const
1192 { 1194 {
1193 return m_layer->layer(); 1195 return m_layer->layer();
1194 } 1196 }
1195 1197
1196 void GraphicsLayer::setFilters(const FilterOperations& filters) 1198 void GraphicsLayer::setFilters(const FilterOperations& filters)
1197 { 1199 {
1198 OwnPtr<CompositorFilterOperations> webFilters = adoptPtr(CompositorFactory:: current().createFilterOperations()); 1200 std::unique_ptr<CompositorFilterOperations> webFilters = wrapUnique(Composit orFactory::current().createFilterOperations());
1199 SkiaImageFilterBuilder::buildFilterOperations(filters, webFilters.get()); 1201 SkiaImageFilterBuilder::buildFilterOperations(filters, webFilters.get());
1200 m_layer->layer()->setFilters(webFilters->asFilterOperations()); 1202 m_layer->layer()->setFilters(webFilters->asFilterOperations());
1201 } 1203 }
1202 1204
1203 void GraphicsLayer::setBackdropFilters(const FilterOperations& filters) 1205 void GraphicsLayer::setBackdropFilters(const FilterOperations& filters)
1204 { 1206 {
1205 OwnPtr<CompositorFilterOperations> webFilters = adoptPtr(CompositorFactory:: current().createFilterOperations()); 1207 std::unique_ptr<CompositorFilterOperations> webFilters = wrapUnique(Composit orFactory::current().createFilterOperations());
1206 SkiaImageFilterBuilder::buildFilterOperations(filters, webFilters.get()); 1208 SkiaImageFilterBuilder::buildFilterOperations(filters, webFilters.get());
1207 m_layer->layer()->setBackgroundFilters(webFilters->asFilterOperations()); 1209 m_layer->layer()->setBackgroundFilters(webFilters->asFilterOperations());
1208 } 1210 }
1209 1211
1210 void GraphicsLayer::setFilterQuality(SkFilterQuality filterQuality) 1212 void GraphicsLayer::setFilterQuality(SkFilterQuality filterQuality)
1211 { 1213 {
1212 if (m_imageLayer) 1214 if (m_imageLayer)
1213 m_imageLayer->setNearestNeighbor(filterQuality == kNone_SkFilterQuality) ; 1215 m_imageLayer->setNearestNeighbor(filterQuality == kNone_SkFilterQuality) ;
1214 } 1216 }
1215 1217
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 { 1388 {
1387 if (!layer) { 1389 if (!layer) {
1388 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); 1390 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n");
1389 return; 1391 return;
1390 } 1392 }
1391 1393
1392 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); 1394 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo);
1393 fprintf(stderr, "%s\n", output.utf8().data()); 1395 fprintf(stderr, "%s\n", output.utf8().data());
1394 } 1396 }
1395 #endif 1397 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698