Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp

Issue 1632263002: Calculate and track display item opaqueness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Be more conservative about rounding Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 SkIRect conservativelyRoundedPictureRect;
30 pictureRect.roundIn(&conservativelyRoundedPictureRect);
31 knownToBeOpaqueRegion.op(conservativelyRoundedPictureRect, S kRegion::kUnion_Op);
32 }
33 }
25 } 34 }
26 chunk.bounds = bounds; 35 chunk.bounds = bounds;
36
37 if (knownToBeOpaqueRegion.contains(enclosedIntRect(bounds)))
38 chunk.knownToBeOpaque = true;
27 } 39 }
28 } 40 }
29 41
30 } // namespace 42 } // namespace
31 43
32 PaintArtifact::PaintArtifact() 44 PaintArtifact::PaintArtifact()
33 : m_displayItemList(0) 45 : m_displayItemList(0)
34 { 46 {
35 } 47 }
36 48
37 PaintArtifact::PaintArtifact(DisplayItemList displayItems, Vector<PaintChunk> pa intChunks) 49 PaintArtifact::PaintArtifact(DisplayItemList displayItems, Vector<PaintChunk> pa intChunks)
38 : m_displayItemList(std::move(displayItems)) 50 : m_displayItemList(std::move(displayItems))
39 , m_paintChunks(std::move(paintChunks)) 51 , m_paintChunks(std::move(paintChunks))
40 { 52 {
41 computeChunkBounds(m_displayItemList, m_paintChunks); 53 computeChunkBoundsAndOpaqueness(m_displayItemList, m_paintChunks);
42 } 54 }
43 55
44 PaintArtifact::PaintArtifact(PaintArtifact&& source) 56 PaintArtifact::PaintArtifact(PaintArtifact&& source)
45 : m_displayItemList(std::move(source.m_displayItemList)) 57 : m_displayItemList(std::move(source.m_displayItemList))
46 , m_paintChunks(std::move(source.m_paintChunks)) 58 , m_paintChunks(std::move(source.m_paintChunks))
47 { 59 {
48 } 60 }
49 61
50 PaintArtifact::~PaintArtifact() 62 PaintArtifact::~PaintArtifact()
51 { 63 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 #if ENABLE(ASSERT) 95 #if ENABLE(ASSERT)
84 m_displayItemList.assertDisplayItemClientsAreAlive(); 96 m_displayItemList.assertDisplayItemClientsAreAlive();
85 #endif 97 #endif
86 for (const DisplayItem& displayItem : m_displayItemList) { 98 for (const DisplayItem& displayItem : m_displayItemList) {
87 // TODO(wkorman): Pass the actual visual rect for the display item. 99 // TODO(wkorman): Pass the actual visual rect for the display item.
88 displayItem.appendToWebDisplayItemList(IntRect(), list); 100 displayItem.appendToWebDisplayItemList(IntRect(), list);
89 } 101 }
90 } 102 }
91 103
92 } // namespace blink 104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698