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" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 void DrawingDisplayItem::Replay(GraphicsContext& context) const { | 17 void DrawingDisplayItem::Replay(GraphicsContext& context) const { |
17 if (record_) | 18 if (record_) |
18 context.DrawRecord(record_); | 19 context.DrawRecord(record_); |
19 } | 20 } |
20 | 21 |
21 void DrawingDisplayItem::AppendToWebDisplayItemList( | 22 void DrawingDisplayItem::AppendToWebDisplayItemList( |
22 const IntRect& visual_rect, | 23 const IntRect& visual_rect, |
23 WebDisplayItemList* list) const { | 24 WebDisplayItemList* list) const { |
24 if (record_) | 25 if (record_) |
25 list->AppendDrawingItem(visual_rect, record_); | 26 list->AppendDrawingItem(visual_rect, record_); |
26 } | 27 } |
27 | 28 |
28 bool DrawingDisplayItem::DrawsContent() const { | 29 bool DrawingDisplayItem::DrawsContent() const { |
29 return record_.get(); | 30 return record_.get(); |
30 } | 31 } |
31 | 32 |
32 int DrawingDisplayItem::NumberOfSlowPaths() const { | 33 void DrawingDisplayItem::AnalyzeForGpuRasterization( |
33 return record_ ? record_->numSlowPaths() : 0; | 34 SkPictureGpuAnalyzer& analyzer) const { |
| 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 (!record_) |
| 39 return; |
| 40 analyzer.analyzePicture(ToSkPicture(record_).get()); |
34 } | 41 } |
35 | 42 |
36 #ifndef NDEBUG | 43 #ifndef NDEBUG |
37 void DrawingDisplayItem::DumpPropertiesAsDebugString( | 44 void DrawingDisplayItem::DumpPropertiesAsDebugString( |
38 StringBuilder& string_builder) const { | 45 StringBuilder& string_builder) const { |
39 DisplayItem::DumpPropertiesAsDebugString(string_builder); | 46 DisplayItem::DumpPropertiesAsDebugString(string_builder); |
40 if (record_) { | 47 if (record_) { |
41 string_builder.Append( | 48 string_builder.Append( |
42 String::Format(", rect: [%f,%f %fx%f]", record_->cullRect().x(), | 49 String::Format(", rect: [%f,%f %fx%f]", record_->cullRect().x(), |
43 record_->cullRect().y(), record_->cullRect().width(), | 50 record_->cullRect().y(), record_->cullRect().width(), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 114 |
108 if (RecordsEqual(record, other_record)) | 115 if (RecordsEqual(record, other_record)) |
109 return true; | 116 return true; |
110 | 117 |
111 // Sometimes the client may produce different records for the same visual | 118 // Sometimes the client may produce different records for the same visual |
112 // result, which should be treated as equal. | 119 // result, which should be treated as equal. |
113 return BitmapsEqual(std::move(record), std::move(other_record)); | 120 return BitmapsEqual(std::move(record), std::move(other_record)); |
114 } | 121 } |
115 | 122 |
116 } // namespace blink | 123 } // namespace blink |
OLD | NEW |