| 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/paint/PaintArtifact.h" | 5 #include "platform/graphics/paint/PaintArtifact.h" |
| 6 | 6 |
| 7 #include "platform/TraceEvent.h" | 7 #include "platform/TraceEvent.h" |
| 8 #include "platform/geometry/IntRect.h" | 8 #include "platform/geometry/IntRect.h" |
| 9 #include "platform/graphics/paint/DrawingDisplayItem.h" | 9 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 10 #include "third_party/skia/include/core/SkRegion.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 void computeChunkBounds(const DisplayItemList& displayItems, Vector<PaintChunk>&
paintChunks) | 16 void computeChunkBoundsAndOpaqueness(const DisplayItemList& displayItems, Vector
<PaintChunk>& paintChunks) |
| 16 { | 17 { |
| 17 for (PaintChunk& chunk : paintChunks) { | 18 for (PaintChunk& chunk : paintChunks) { |
| 18 FloatRect bounds; | 19 FloatRect bounds; |
| 20 SkRegion knownToBeOpaqueRegion; |
| 19 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { | 21 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { |
| 20 if (!item.isDrawing()) | 22 if (!item.isDrawing()) |
| 21 continue; | 23 continue; |
| 22 const auto& drawing = static_cast<const DrawingDisplayItem&>(item); | 24 const auto& drawing = static_cast<const DrawingDisplayItem&>(item); |
| 23 if (const SkPicture* picture = drawing.picture()) | 25 if (const SkPicture* picture = drawing.picture()) { |
| 24 bounds.unite(picture->cullRect()); | 26 const SkRect& pictureRect = picture->cullRect(); |
| 27 bounds.unite(pictureRect); |
| 28 if (drawing.knownToBeOpaque()) { |
| 29 // TODO(pdr): This may be too conservative and fail due to |
| 30 // floating point precision issues. |
| 31 SkIRect conservativelyRoundedPictureRect; |
| 32 pictureRect.roundIn(&conservativelyRoundedPictureRect); |
| 33 knownToBeOpaqueRegion.op(conservativelyRoundedPictureRect, S
kRegion::kUnion_Op); |
| 34 } |
| 35 } |
| 25 } | 36 } |
| 26 chunk.bounds = bounds; | 37 chunk.bounds = bounds; |
| 38 if (knownToBeOpaqueRegion.contains(enclosingIntRect(bounds))) |
| 39 chunk.knownToBeOpaque = true; |
| 27 } | 40 } |
| 28 } | 41 } |
| 29 | 42 |
| 30 } // namespace | 43 } // namespace |
| 31 | 44 |
| 32 PaintArtifact::PaintArtifact() | 45 PaintArtifact::PaintArtifact() |
| 33 : m_displayItemList(0) | 46 : m_displayItemList(0) |
| 34 { | 47 { |
| 35 } | 48 } |
| 36 | 49 |
| 37 PaintArtifact::PaintArtifact(DisplayItemList displayItems, Vector<PaintChunk> pa
intChunks) | 50 PaintArtifact::PaintArtifact(DisplayItemList displayItems, Vector<PaintChunk> pa
intChunks) |
| 38 : m_displayItemList(std::move(displayItems)) | 51 : m_displayItemList(std::move(displayItems)) |
| 39 , m_paintChunks(std::move(paintChunks)) | 52 , m_paintChunks(std::move(paintChunks)) |
| 40 { | 53 { |
| 41 computeChunkBounds(m_displayItemList, m_paintChunks); | 54 computeChunkBoundsAndOpaqueness(m_displayItemList, m_paintChunks); |
| 42 } | 55 } |
| 43 | 56 |
| 44 PaintArtifact::PaintArtifact(PaintArtifact&& source) | 57 PaintArtifact::PaintArtifact(PaintArtifact&& source) |
| 45 : m_displayItemList(std::move(source.m_displayItemList)) | 58 : m_displayItemList(std::move(source.m_displayItemList)) |
| 46 , m_paintChunks(std::move(source.m_paintChunks)) | 59 , m_paintChunks(std::move(source.m_paintChunks)) |
| 47 { | 60 { |
| 48 } | 61 } |
| 49 | 62 |
| 50 PaintArtifact::~PaintArtifact() | 63 PaintArtifact::~PaintArtifact() |
| 51 { | 64 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 #if ENABLE(ASSERT) | 96 #if ENABLE(ASSERT) |
| 84 m_displayItemList.assertDisplayItemClientsAreAlive(); | 97 m_displayItemList.assertDisplayItemClientsAreAlive(); |
| 85 #endif | 98 #endif |
| 86 for (const DisplayItem& displayItem : m_displayItemList) { | 99 for (const DisplayItem& displayItem : m_displayItemList) { |
| 87 // TODO(wkorman): Pass the actual visual rect for the display item. | 100 // TODO(wkorman): Pass the actual visual rect for the display item. |
| 88 displayItem.appendToWebDisplayItemList(IntRect(), list); | 101 displayItem.appendToWebDisplayItemList(IntRect(), list); |
| 89 } | 102 } |
| 90 } | 103 } |
| 91 | 104 |
| 92 } // namespace blink | 105 } // namespace blink |
| OLD | NEW |