OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/DrawingDisplayItem.h" | 5 #include "platform/graphics/paint/DrawingDisplayItem.h" |
6 | 6 |
7 #include "platform/graphics/GraphicsContext.h" | 7 #include "platform/graphics/GraphicsContext.h" |
8 #include "platform/graphics/paint/PaintCanvas.h" | 8 #include "platform/graphics/paint/PaintCanvas.h" |
9 #include "public/platform/WebDisplayItemList.h" | 9 #include "public/platform/WebDisplayItemList.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
11 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
12 #include "third_party/skia/include/core/SkData.h" | 12 #include "third_party/skia/include/core/SkData.h" |
13 #include "third_party/skia/include/core/SkPictureAnalyzer.h" | |
14 | 13 |
15 namespace blink { | 14 namespace blink { |
16 | 15 |
17 void DrawingDisplayItem::replay(GraphicsContext& context) const { | 16 void DrawingDisplayItem::replay(GraphicsContext& context) const { |
18 if (m_record) | 17 if (m_record) |
19 context.drawRecord(m_record); | 18 context.drawRecord(m_record); |
20 } | 19 } |
21 | 20 |
22 void DrawingDisplayItem::appendToWebDisplayItemList( | 21 void DrawingDisplayItem::appendToWebDisplayItemList( |
23 const IntRect& visualRect, | 22 const IntRect& visualRect, |
24 WebDisplayItemList* list) const { | 23 WebDisplayItemList* list) const { |
25 if (m_record) | 24 if (m_record) |
26 list->appendDrawingItem(visualRect, m_record); | 25 list->appendDrawingItem(visualRect, m_record); |
27 } | 26 } |
28 | 27 |
29 bool DrawingDisplayItem::drawsContent() const { | 28 bool DrawingDisplayItem::drawsContent() const { |
30 return m_record.get(); | 29 return m_record.get(); |
31 } | 30 } |
32 | 31 |
33 void DrawingDisplayItem::analyzeForGpuRasterization( | 32 int DrawingDisplayItem::numberOfSlowPaths() const { |
34 SkPictureGpuAnalyzer& analyzer) const { | 33 return m_record ? m_record->numSlowPaths() : 0; |
35 // TODO(enne): Need an SkPictureGpuAnalyzer on PictureRecord. | |
36 // This is a bit overkill to ToSkPicture a record just to get | |
37 // numSlowPaths. | |
38 if (!m_record) | |
39 return; | |
40 analyzer.analyzePicture(ToSkPicture(m_record).get()); | |
41 } | 34 } |
42 | 35 |
43 #ifndef NDEBUG | 36 #ifndef NDEBUG |
44 void DrawingDisplayItem::dumpPropertiesAsDebugString( | 37 void DrawingDisplayItem::dumpPropertiesAsDebugString( |
45 StringBuilder& stringBuilder) const { | 38 StringBuilder& stringBuilder) const { |
46 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); | 39 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); |
47 if (m_record) { | 40 if (m_record) { |
48 stringBuilder.append( | 41 stringBuilder.append( |
49 String::format(", rect: [%f,%f %fx%f]", m_record->cullRect().x(), | 42 String::format(", rect: [%f,%f %fx%f]", m_record->cullRect().x(), |
50 m_record->cullRect().y(), m_record->cullRect().width(), | 43 m_record->cullRect().y(), m_record->cullRect().width(), |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 111 |
119 if (recordsEqual(record, otherRecord)) | 112 if (recordsEqual(record, otherRecord)) |
120 return true; | 113 return true; |
121 | 114 |
122 // Sometimes the client may produce different records for the same visual | 115 // Sometimes the client may produce different records for the same visual |
123 // result, which should be treated as equal. | 116 // result, which should be treated as equal. |
124 return bitmapsEqual(std::move(record), std::move(otherRecord)); | 117 return bitmapsEqual(std::move(record), std::move(otherRecord)); |
125 } | 118 } |
126 | 119 |
127 } // namespace blink | 120 } // namespace blink |
OLD | NEW |