OLD | NEW |
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 Loading... |
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 Loading... |
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 { | 367 { |
367 DCHECK(paintChunk.size()); | 368 DCHECK(paintChunk.size()); |
368 | 369 |
369 // If the paint chunk is a foreign layer, just return that layer. | 370 // If the paint chunk is a foreign layer, just return that layer. |
370 if (scoped_refptr<cc::Layer> foreignLayer = foreignLayerForPaintChunk(paintA
rtifact, paintChunk, layerOffset)) | 371 if (scoped_refptr<cc::Layer> foreignLayer = foreignLayerForPaintChunk(paintA
rtifact, paintChunk, layerOffset)) |
371 return foreignLayer; | 372 return foreignLayer; |
372 | 373 |
373 // The common case: create a layer for painted content. | 374 // The common case: create a layer for painted content. |
374 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); | 375 gfx::Rect combinedBounds = enclosingIntRect(paintChunk.bounds); |
375 scoped_refptr<cc::DisplayItemList> displayList = recordPaintChunk(paintArtif
act, paintChunk, combinedBounds); | 376 scoped_refptr<cc::DisplayItemList> displayList = recordPaintChunk(paintArtif
act, paintChunk, combinedBounds); |
376 OwnPtr<ContentLayerClientImpl> contentLayerClient = adoptPtr( | 377 std::unique_ptr<ContentLayerClientImpl> contentLayerClient = wrapUnique( |
377 new ContentLayerClientImpl(std::move(displayList), gfx::Rect(combinedBou
nds.size()))); | 378 new ContentLayerClientImpl(std::move(displayList), gfx::Rect(combinedBou
nds.size()))); |
378 | 379 |
379 layerOffset = combinedBounds.OffsetFromOrigin(); | 380 layerOffset = combinedBounds.OffsetFromOrigin(); |
380 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(contentLaye
rClient.get()); | 381 scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(contentLaye
rClient.get()); |
381 layer->SetBounds(combinedBounds.size()); | 382 layer->SetBounds(combinedBounds.size()); |
382 layer->SetIsDrawable(true); | 383 layer->SetIsDrawable(true); |
383 if (paintChunk.knownToBeOpaque) | 384 if (paintChunk.knownToBeOpaque) |
384 layer->SetContentsOpaque(true); | 385 layer->SetContentsOpaque(true); |
385 m_contentLayerClients.append(std::move(contentLayerClient)); | 386 m_contentLayerClients.append(std::move(contentLayerClient)); |
386 return layer; | 387 return layer; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 layer->SetEffectTreeIndex(kSecondaryRootNodeId); | 422 layer->SetEffectTreeIndex(kSecondaryRootNodeId); |
422 layer->SetScrollTreeIndex(kSecondaryRootNodeId); | 423 layer->SetScrollTreeIndex(kSecondaryRootNodeId); |
423 } | 424 } |
424 | 425 |
425 // Mark the property trees as having been rebuilt. | 426 // Mark the property trees as having been rebuilt. |
426 host->property_trees()->sequence_number = kPropertyTreeSequenceNumber; | 427 host->property_trees()->sequence_number = kPropertyTreeSequenceNumber; |
427 host->property_trees()->needs_rebuild = false; | 428 host->property_trees()->needs_rebuild = false; |
428 } | 429 } |
429 | 430 |
430 } // namespace blink | 431 } // namespace blink |
OLD | NEW |