Chromium Code Reviews| 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 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 void computeChunkBounds(const DisplayItemList& displayItems, Vector<PaintChunk>& paintChunks) | 15 void computeChunkBoundsAndOpaqueness(const DisplayItemList& displayItems, Vector <PaintChunk>& paintChunks) |
| 16 { | 16 { |
| 17 for (PaintChunk& chunk : paintChunks) { | 17 for (PaintChunk& chunk : paintChunks) { |
| 18 FloatRect bounds; | 18 FloatRect bounds; |
| 19 bool knownToBeOpaqueItems = false; | |
| 19 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { | 20 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { |
| 20 if (!item.isDrawing()) | 21 if (!item.isDrawing()) |
| 21 continue; | 22 continue; |
| 22 const auto& drawing = static_cast<const DrawingDisplayItem&>(item); | 23 const auto& drawing = static_cast<const DrawingDisplayItem&>(item); |
| 23 if (const SkPicture* picture = drawing.picture()) | 24 if (const SkPicture* picture = drawing.picture()) |
| 24 bounds.unite(picture->cullRect()); | 25 bounds.unite(picture->cullRect()); |
| 26 if (drawing.knownToBeOpaque()) | |
| 27 knownToBeOpaqueItems = true; | |
| 25 } | 28 } |
| 26 chunk.bounds = bounds; | 29 chunk.bounds = bounds; |
| 30 | |
| 31 // TODO(pdr): This should be optimized to not require a second walk of | |
| 32 // the items. It's not yet clear what the best approach is (regions, | |
| 33 // largest rects, first-N-rects, etc). | |
| 34 if (!knownToBeOpaqueItems) | |
|
jbroman
2016/01/26 17:50:14
I'd think SkRegion is both simple and reasonably e
pdr.
2016/01/26 23:38:08
Heck yeah, done.
| |
| 35 return; | |
| 36 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { | |
| 37 if (!item.isDrawing()) | |
| 38 continue; | |
| 39 const auto& drawing = static_cast<const DrawingDisplayItem&>(item); | |
| 40 if (!drawing.knownToBeOpaque()) | |
| 41 continue; | |
| 42 if (const SkPicture* picture = drawing.picture()) { | |
| 43 if (bounds.contains(picture->cullRect())) { | |
| 44 chunk.knownToBeOpaque = true; | |
| 45 break; | |
| 46 } | |
| 47 } | |
| 48 } | |
| 27 } | 49 } |
| 28 } | 50 } |
| 29 | 51 |
| 30 } // namespace | 52 } // namespace |
| 31 | 53 |
| 32 PaintArtifact::PaintArtifact() | 54 PaintArtifact::PaintArtifact() |
| 33 : m_displayItemList(0) | 55 : m_displayItemList(0) |
| 34 { | 56 { |
| 35 } | 57 } |
| 36 | 58 |
| 37 PaintArtifact::PaintArtifact(DisplayItemList displayItems, Vector<PaintChunk> pa intChunks) | 59 PaintArtifact::PaintArtifact(DisplayItemList displayItems, Vector<PaintChunk> pa intChunks) |
| 38 : m_displayItemList(std::move(displayItems)) | 60 : m_displayItemList(std::move(displayItems)) |
| 39 , m_paintChunks(std::move(paintChunks)) | 61 , m_paintChunks(std::move(paintChunks)) |
| 40 { | 62 { |
| 41 computeChunkBounds(m_displayItemList, m_paintChunks); | 63 computeChunkBoundsAndOpaqueness(m_displayItemList, m_paintChunks); |
| 42 } | 64 } |
| 43 | 65 |
| 44 PaintArtifact::PaintArtifact(PaintArtifact&& source) | 66 PaintArtifact::PaintArtifact(PaintArtifact&& source) |
| 45 : m_displayItemList(std::move(source.m_displayItemList)) | 67 : m_displayItemList(std::move(source.m_displayItemList)) |
| 46 , m_paintChunks(std::move(source.m_paintChunks)) | 68 , m_paintChunks(std::move(source.m_paintChunks)) |
| 47 { | 69 { |
| 48 } | 70 } |
| 49 | 71 |
| 50 PaintArtifact::~PaintArtifact() | 72 PaintArtifact::~PaintArtifact() |
| 51 { | 73 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 #if ENABLE(ASSERT) | 105 #if ENABLE(ASSERT) |
| 84 m_displayItemList.assertDisplayItemClientsAreAlive(); | 106 m_displayItemList.assertDisplayItemClientsAreAlive(); |
| 85 #endif | 107 #endif |
| 86 for (const DisplayItem& displayItem : m_displayItemList) { | 108 for (const DisplayItem& displayItem : m_displayItemList) { |
| 87 // TODO(wkorman): Pass the actual visual rect for the display item. | 109 // TODO(wkorman): Pass the actual visual rect for the display item. |
| 88 displayItem.appendToWebDisplayItemList(IntRect(), list); | 110 displayItem.appendToWebDisplayItemList(IntRect(), list); |
| 89 } | 111 } |
| 90 } | 112 } |
| 91 | 113 |
| 92 } // namespace blink | 114 } // namespace blink |
| OLD | NEW |