| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 m_rootLayer = cc::Layer::Create(); | 76 m_rootLayer = cc::Layer::Create(); |
| 77 m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLaye
rFromCCLayer(m_rootLayer.get())); | 77 m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLaye
rFromCCLayer(m_rootLayer.get())); |
| 78 } | 78 } |
| 79 | 79 |
| 80 PaintArtifactCompositor::~PaintArtifactCompositor() | 80 PaintArtifactCompositor::~PaintArtifactCompositor() |
| 81 { | 81 { |
| 82 } | 82 } |
| 83 | 83 |
| 84 namespace { | 84 namespace { |
| 85 | 85 |
| 86 static gfx::Rect largeRect(-200000, -200000, 400000, 400000); | |
| 87 | |
| 88 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
cc::DisplayItemList* list) | 86 static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
cc::DisplayItemList* list) |
| 89 { | 87 { |
| 90 if (DisplayItem::isDrawingType(displayItem.getType())) { | 88 if (DisplayItem::isDrawingType(displayItem.getType())) { |
| 91 const SkPicture* picture = static_cast<const DrawingDisplayItem&>(displa
yItem).picture(); | 89 const SkPicture* picture = static_cast<const DrawingDisplayItem&>(displa
yItem).picture(); |
| 92 if (!picture) | 90 if (!picture) |
| 93 return; | 91 return; |
| 94 // In theory we would pass the bounds of the picture, previously done as
: | 92 gfx::Rect bounds = gfx::SkIRectToRect(picture->cullRect().roundOut()); |
| 95 // gfx::Rect bounds = gfx::SkIRectToRect(picture->cullRect().roundOut())
; | 93 list->CreateAndAppendItem<cc::DrawingDisplayItem>(bounds, sk_ref_sp(pict
ure)); |
| 96 // or use the visual rect directly. However, clip content layers attempt | |
| 97 // to raster in a different space than that of the visual rects. We'll b
e | |
| 98 // reworking visual rects further for SPv2, so for now we just pass a | |
| 99 // visual rect large enough to make sure items raster. | |
| 100 list->CreateAndAppendItem<cc::DrawingDisplayItem>(largeRect, sk_ref_sp(p
icture)); | |
| 101 } | 94 } |
| 102 } | 95 } |
| 103 | 96 |
| 104 static scoped_refptr<cc::DisplayItemList> recordPaintChunk(const PaintArtifact&
artifact, const PaintChunk& chunk, const gfx::Rect& combinedBounds) | 97 static scoped_refptr<cc::DisplayItemList> recordPaintChunk(const PaintArtifact&
artifact, const PaintChunk& chunk, const gfx::Rect& combinedBounds) |
| 105 { | 98 { |
| 106 cc::DisplayItemListSettings settings; | 99 cc::DisplayItemListSettings settings; |
| 107 scoped_refptr<cc::DisplayItemList> list = cc::DisplayItemList::Create(settin
gs); | 100 scoped_refptr<cc::DisplayItemList> list = cc::DisplayItemList::Create( |
| 101 gfx::Rect(combinedBounds.size()), settings); |
| 108 | 102 |
| 109 gfx::Transform translation; | 103 gfx::Transform translation; |
| 110 translation.Translate(-combinedBounds.x(), -combinedBounds.y()); | 104 translation.Translate(-combinedBounds.x(), -combinedBounds.y()); |
| 111 // Passing combinedBounds as the visual rect for the begin/end transform ite
m | 105 // TODO(jbroman, wkorman): What visual rectangle is wanted here? |
| 112 // would normally be the sensible thing to do, but see comment above re: | 106 list->CreateAndAppendItem<cc::TransformDisplayItem>(gfx::Rect(), translation
); |
| 113 // visual rects for drawing items and further rework in flight. | |
| 114 list->CreateAndAppendItem<cc::TransformDisplayItem>(largeRect, translation); | |
| 115 | 107 |
| 116 const DisplayItemList& displayItems = artifact.getDisplayItemList(); | 108 const DisplayItemList& displayItems = artifact.getDisplayItemList(); |
| 117 for (const auto& displayItem : displayItems.itemsInPaintChunk(chunk)) | 109 for (const auto& displayItem : displayItems.itemsInPaintChunk(chunk)) |
| 118 appendDisplayItemToCcDisplayItemList(displayItem, list.get()); | 110 appendDisplayItemToCcDisplayItemList(displayItem, list.get()); |
| 119 | 111 |
| 120 list->CreateAndAppendItem<cc::EndTransformDisplayItem>(largeRect); | 112 list->CreateAndAppendItem<cc::EndTransformDisplayItem>(gfx::Rect()); |
| 121 | 113 |
| 122 list->Finalize(); | 114 list->Finalize(); |
| 123 return list; | 115 return list; |
| 124 } | 116 } |
| 125 | 117 |
| 126 static gfx::Transform transformToTransformSpace(const TransformPaintPropertyNode
* currentSpace, const TransformPaintPropertyNode* targetSpace) | 118 static gfx::Transform transformToTransformSpace(const TransformPaintPropertyNode
* currentSpace, const TransformPaintPropertyNode* targetSpace) |
| 127 { | 119 { |
| 128 TransformationMatrix matrix; | 120 TransformationMatrix matrix; |
| 129 while (currentSpace != targetSpace) { | 121 while (currentSpace != targetSpace) { |
| 130 TransformationMatrix localMatrix = currentSpace->matrix(); | 122 TransformationMatrix localMatrix = currentSpace->matrix(); |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 if (m_extraDataForTestingEnabled) | 594 if (m_extraDataForTestingEnabled) |
| 603 m_extraDataForTesting->contentLayers.append(layer); | 595 m_extraDataForTesting->contentLayers.append(layer); |
| 604 } | 596 } |
| 605 | 597 |
| 606 // Mark the property trees as having been rebuilt. | 598 // Mark the property trees as having been rebuilt. |
| 607 host->property_trees()->sequence_number = kPropertyTreeSequenceNumber; | 599 host->property_trees()->sequence_number = kPropertyTreeSequenceNumber; |
| 608 host->property_trees()->needs_rebuild = false; | 600 host->property_trees()->needs_rebuild = false; |
| 609 } | 601 } |
| 610 | 602 |
| 611 } // namespace blink | 603 } // namespace blink |
| OLD | NEW |