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/GraphicsLayer.h" | 9 #include "platform/graphics/GraphicsLayer.h" |
10 #include "platform/graphics/paint/DrawingDisplayItem.h" | 10 #include "platform/graphics/paint/DrawingDisplayItem.h" |
11 #include "public/platform/WebDisplayItemList.h" | 11 #include "public/platform/WebDisplayItemList.h" |
12 #include "third_party/skia/include/core/SkRegion.h" | 12 #include "third_party/skia/include/core/SkRegion.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 void computeChunkBoundsAndOpaqueness(const DisplayItemList& displayItems, | 18 void computeChunkBoundsAndOpaqueness(const DisplayItemList& displayItems, |
19 Vector<PaintChunk>& paintChunks) { | 19 Vector<PaintChunk>& paintChunks) { |
20 for (PaintChunk& chunk : paintChunks) { | 20 for (PaintChunk& chunk : paintChunks) { |
21 FloatRect bounds; | 21 FloatRect bounds; |
22 SkRegion knownToBeOpaqueRegion; | 22 SkRegion knownToBeOpaqueRegion; |
23 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { | 23 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { |
24 bounds.unite(FloatRect(item.client().visualRect())); | 24 bounds.unite(FloatRect(item.client().visualRect())); |
25 if (!item.isDrawing()) | 25 if (!item.isDrawing()) |
26 continue; | 26 continue; |
27 const auto& drawing = static_cast<const DrawingDisplayItem&>(item); | 27 const auto& drawing = static_cast<const DrawingDisplayItem&>(item); |
28 if (const SkPicture* picture = drawing.picture()) { | 28 if (const SkPicture* picture = drawing.picture()) { |
29 if (drawing.knownToBeOpaque()) { | 29 if (drawing.knownToBeOpaque()) { |
30 // TODO(pdr): It may be too conservative to round in to the enclosedIn
tRect. | 30 // TODO(pdr): It may be too conservative to round in to the |
| 31 // enclosedIntRect. |
31 SkIRect conservativelyRoundedPictureRect; | 32 SkIRect conservativelyRoundedPictureRect; |
32 const SkRect& pictureRect = picture->cullRect(); | 33 const SkRect& pictureRect = picture->cullRect(); |
33 pictureRect.roundIn(&conservativelyRoundedPictureRect); | 34 pictureRect.roundIn(&conservativelyRoundedPictureRect); |
34 knownToBeOpaqueRegion.op(conservativelyRoundedPictureRect, | 35 knownToBeOpaqueRegion.op(conservativelyRoundedPictureRect, |
35 SkRegion::kUnion_Op); | 36 SkRegion::kUnion_Op); |
36 } | 37 } |
37 } | 38 } |
38 } | 39 } |
39 chunk.bounds = bounds; | 40 chunk.bounds = bounds; |
40 if (knownToBeOpaqueRegion.contains(enclosingIntRect(bounds))) | 41 if (knownToBeOpaqueRegion.contains(enclosingIntRect(bounds))) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 size_t visualRectIndex = 0; | 92 size_t visualRectIndex = 0; |
92 for (const DisplayItem& displayItem : m_displayItemList) { | 93 for (const DisplayItem& displayItem : m_displayItemList) { |
93 displayItem.appendToWebDisplayItemList( | 94 displayItem.appendToWebDisplayItemList( |
94 m_displayItemList.visualRect(visualRectIndex), list); | 95 m_displayItemList.visualRect(visualRectIndex), list); |
95 visualRectIndex++; | 96 visualRectIndex++; |
96 } | 97 } |
97 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); | 98 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); |
98 } | 99 } |
99 | 100 |
100 } // namespace blink | 101 } // namespace blink |
OLD | NEW |