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

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

Issue 2345233004: Reuse cc::PictureLayers when possible for SPv2. (Closed)
Patch Set: none Created 4 years, 3 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/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, Vector <PaintChunk>& paintChunks) 18 void computeChunkBoundsAndOpaqueness(const DisplayItemList& displayItems, Vector <PaintChunk>& paintChunks)
19 { 19 {
20 for (PaintChunk& chunk : paintChunks) { 20 for (PaintChunk& chunk : paintChunks) {
21 FloatRect bounds; 21 FloatRect bounds;
22 SkRegion knownToBeOpaqueRegion; 22 FloatRect knownToBeOpaqueRegion;
23 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) { 23 for (const DisplayItem& item : displayItems.itemsInPaintChunk(chunk)) {
24 FloatRect visualRect(item.client().visualRect());
25
26 bounds.unite(visualRect);
24 if (!item.isDrawing()) 27 if (!item.isDrawing())
25 continue; 28 continue;
26 const auto& drawing = static_cast<const DrawingDisplayItem&>(item); 29 const auto& drawing = static_cast<const DrawingDisplayItem&>(item);
27 if (const SkPicture* picture = drawing.picture()) { 30 if (const SkPicture* picture = drawing.picture()) {
28 const SkRect& pictureRect = picture->cullRect();
29 bounds.unite(pictureRect);
30 if (drawing.knownToBeOpaque()) { 31 if (drawing.knownToBeOpaque()) {
Xianzhu 2016/09/20 23:13:41 There seems a problem: the picture may be smaller
chrishtr 2016/09/20 23:43:59 Good point. Reverted this part.
31 // TODO(pdr): This may be too conservative and fail due to 32 // TODO(pdr): It may be too conservative to round in to the enclosedIntRect.
32 // floating point precision issues. 33 knownToBeOpaqueRegion.unite(enclosedIntRect(visualRect));
33 SkIRect conservativelyRoundedPictureRect;
34 pictureRect.roundIn(&conservativelyRoundedPictureRect);
35 knownToBeOpaqueRegion.op(conservativelyRoundedPictureRect, S kRegion::kUnion_Op);
36 } 34 }
37 } 35 }
38 } 36 }
39 chunk.bounds = bounds; 37 chunk.bounds = bounds;
40 if (knownToBeOpaqueRegion.contains(enclosingIntRect(bounds))) 38 if (knownToBeOpaqueRegion.contains(enclosingIntRect(bounds)))
41 chunk.knownToBeOpaque = true; 39 chunk.knownToBeOpaque = true;
42 } 40 }
43 } 41 }
44 42
45 } // namespace 43 } // namespace
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList") ; 99 TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList") ;
102 size_t visualRectIndex = 0; 100 size_t visualRectIndex = 0;
103 for (const DisplayItem& displayItem : m_displayItemList) { 101 for (const DisplayItem& displayItem : m_displayItemList) {
104 displayItem.appendToWebDisplayItemList(m_displayItemList.visualRect(visu alRectIndex), list); 102 displayItem.appendToWebDisplayItemList(m_displayItemList.visualRect(visu alRectIndex), list);
105 visualRectIndex++; 103 visualRectIndex++;
106 } 104 }
107 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization()); 105 list->setIsSuitableForGpuRasterization(isSuitableForGpuRasterization());
108 } 106 }
109 107
110 } // namespace blink 108 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698