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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h"
6 6
7 #include "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/layers/picture_layer.h" 9 #include "cc/layers/picture_layer.h"
10 #include "cc/playback/display_item_list.h" 10 #include "cc/playback/display_item_list.h"
(...skipping 14 matching lines...) Expand all
25 #include "ui/gfx/geometry/point.h" 25 #include "ui/gfx/geometry/point.h"
26 #include "ui/gfx/geometry/point_f.h" 26 #include "ui/gfx/geometry/point_f.h"
27 #include "ui/gfx/geometry/rect.h" 27 #include "ui/gfx/geometry/rect.h"
28 #include "ui/gfx/geometry/rect_f.h" 28 #include "ui/gfx/geometry/rect_f.h"
29 #include "ui/gfx/geometry/size.h" 29 #include "ui/gfx/geometry/size.h"
30 #include "ui/gfx/geometry/size_conversions.h" 30 #include "ui/gfx/geometry/size_conversions.h"
31 #include "ui/gfx/geometry/size_f.h" 31 #include "ui/gfx/geometry/size_f.h"
32 #include "ui/gfx/skia_util.h" 32 #include "ui/gfx/skia_util.h"
33 #include "wtf/Allocator.h" 33 #include "wtf/Allocator.h"
34 #include "wtf/Noncopyable.h" 34 #include "wtf/Noncopyable.h"
35 #include "wtf/PassOwnPtr.h" 35 #include "wtf/PtrUtil.h"
36 #include <algorithm> 36 #include <algorithm>
37 #include <memory>
37 #include <utility> 38 #include <utility>
38 39
39 namespace blink { 40 namespace blink {
40 41
41 class PaintArtifactCompositor::ContentLayerClientImpl : public cc::ContentLayerC lient { 42 class PaintArtifactCompositor::ContentLayerClientImpl : public cc::ContentLayerC lient {
42 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl); 43 WTF_MAKE_NONCOPYABLE(ContentLayerClientImpl);
43 USING_FAST_MALLOC(ContentLayerClientImpl); 44 USING_FAST_MALLOC(ContentLayerClientImpl);
44 public: 45 public:
45 ContentLayerClientImpl(scoped_refptr<cc::DisplayItemList> list, const gfx::R ect& paintableRegion) 46 ContentLayerClientImpl(scoped_refptr<cc::DisplayItemList> list, const gfx::R ect& paintableRegion)
46 : m_ccDisplayItemList(std::move(list)), m_paintableRegion(paintableRegio n) { } 47 : m_ccDisplayItemList(std::move(list)), m_paintableRegion(paintableRegio n) { }
(...skipping 14 matching lines...) Expand all
61 private: 62 private:
62 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList; 63 scoped_refptr<cc::DisplayItemList> m_ccDisplayItemList;
63 gfx::Rect m_paintableRegion; 64 gfx::Rect m_paintableRegion;
64 }; 65 };
65 66
66 PaintArtifactCompositor::PaintArtifactCompositor() 67 PaintArtifactCompositor::PaintArtifactCompositor()
67 { 68 {
68 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 69 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
69 return; 70 return;
70 m_rootLayer = cc::Layer::Create(); 71 m_rootLayer = cc::Layer::Create();
71 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF romCCLayer(m_rootLayer.get())); 72 m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLaye rFromCCLayer(m_rootLayer.get()));
72 } 73 }
73 74
74 PaintArtifactCompositor::~PaintArtifactCompositor() 75 PaintArtifactCompositor::~PaintArtifactCompositor()
75 { 76 {
76 } 77 }
77 78
78 namespace { 79 namespace {
79 80
80 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem, cc::DisplayItemList* list) 81 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem, cc::DisplayItemList* list)
81 { 82 {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 391
391 scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(const Paint Artifact& paintArtifact, const PaintChunk& paintChunk, gfx::Transform transform) 392 scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(const Paint Artifact& paintArtifact, const PaintChunk& paintChunk, gfx::Transform transform)
392 { 393 {
393 // If the paint chunk is a foreign layer, just return that layer. 394 // If the paint chunk is a foreign layer, just return that layer.
394 if (scoped_refptr<cc::Layer> foreignLayer = foreignLayerForPaintChunk(paintA rtifact, paintChunk, transform)) 395 if (scoped_refptr<cc::Layer> foreignLayer = foreignLayerForPaintChunk(paintA rtifact, paintChunk, transform))
395 return foreignLayer; 396 return foreignLayer;
396 397
397 // The common case: create a layer for painted content. 398 // The common case: create a layer for painted content.
398 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); 399 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds);
399 scoped_refptr<cc::DisplayItemList> displayList = recordPaintChunk(paintArtif act, paintChunk, combinedBounds); 400 scoped_refptr<cc::DisplayItemList> displayList = recordPaintChunk(paintArtif act, paintChunk, combinedBounds);
400 OwnPtr<ContentLayerClientImpl> contentLayerClient = adoptPtr( 401 std::unique_ptr<ContentLayerClientImpl> contentLayerClient = wrapUnique(
401 new ContentLayerClientImpl(std::move(displayList), gfx::Rect(combinedBou nds.size()))); 402 new ContentLayerClientImpl(std::move(displayList), gfx::Rect(combinedBou nds.size())));
402 403
403 // Include the offset in the transform, because it needs to apply in 404 // Include the offset in the transform, because it needs to apply in
404 // this layer's transform space (whereas layer position applies in its 405 // this layer's transform space (whereas layer position applies in its
405 // parent's transform space). 406 // parent's transform space).
406 gfx::Vector2dF offset = gfx::PointF(combinedBounds.origin()).OffsetFromOrigi n(); 407 gfx::Vector2dF offset = gfx::PointF(combinedBounds.origin()).OffsetFromOrigi n();
407 transform.Translate(offset.x(), offset.y()); 408 transform.Translate(offset.x(), offset.y());
408 409
409 // If a clip was applied, its origin needs to be cancelled out in 410 // If a clip was applied, its origin needs to be cancelled out in
410 // this transform. 411 // this transform.
411 if (const auto* clip = paintChunk.properties.clip.get()) { 412 if (const auto* clip = paintChunk.properties.clip.get()) {
412 FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location(); 413 FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location();
413 gfx::Transform undoClipOffset; 414 gfx::Transform undoClipOffset;
414 undoClipOffset.Translate(-offsetDueToClipOffset.x(), -offsetDueToClipOff set.y()); 415 undoClipOffset.Translate(-offsetDueToClipOffset.x(), -offsetDueToClipOff set.y());
415 transform.ConcatTransform(undoClipOffset); 416 transform.ConcatTransform(undoClipOffset);
416 } 417 }
417 418
418 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(contentLaye rClient.get()); 419 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(contentLaye rClient.get());
419 layer->SetBounds(combinedBounds.size()); 420 layer->SetBounds(combinedBounds.size());
420 layer->SetTransform(transform); 421 layer->SetTransform(transform);
421 layer->SetIsDrawable(true); 422 layer->SetIsDrawable(true);
422 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden); 423 layer->SetDoubleSided(!paintChunk.properties.backfaceHidden);
423 if (paintChunk.knownToBeOpaque) 424 if (paintChunk.knownToBeOpaque)
424 layer->SetContentsOpaque(true); 425 layer->SetContentsOpaque(true);
425 m_contentLayerClients.append(std::move(contentLayerClient)); 426 m_contentLayerClients.append(std::move(contentLayerClient));
426 return layer; 427 return layer;
427 } 428 }
428 429
429 } // namespace blink 430 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698