| 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 "public/platform/WebDisplayItemList.h" | 8 #include "public/platform/WebDisplayItemList.h" |
| 9 #include "third_party/skia/include/core/SkPictureAnalyzer.h" | |
| 10 | |
| 11 #if ENABLE(ASSERT) | |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 14 #include "third_party/skia/include/core/SkData.h" | 11 #include "third_party/skia/include/core/SkData.h" |
| 12 #include "third_party/skia/include/core/SkPictureAnalyzer.h" |
| 15 #include "third_party/skia/include/core/SkStream.h" | 13 #include "third_party/skia/include/core/SkStream.h" |
| 16 #endif | |
| 17 | 14 |
| 18 namespace blink { | 15 namespace blink { |
| 19 | 16 |
| 20 void DrawingDisplayItem::replay(GraphicsContext& context) const | 17 void DrawingDisplayItem::replay(GraphicsContext& context) const |
| 21 { | 18 { |
| 22 if (m_picture) | 19 if (m_picture) |
| 23 context.drawPicture(m_picture.get()); | 20 context.drawPicture(m_picture.get()); |
| 24 } | 21 } |
| 25 | 22 |
| 26 void DrawingDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, W
ebDisplayItemList* list) const | 23 void DrawingDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, W
ebDisplayItemList* list) const |
| (...skipping 17 matching lines...) Expand all Loading... |
| 44 { | 41 { |
| 45 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); | 42 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); |
| 46 if (m_picture) { | 43 if (m_picture) { |
| 47 stringBuilder.append(String::format(", rect: [%f,%f %fx%f]", | 44 stringBuilder.append(String::format(", rect: [%f,%f %fx%f]", |
| 48 m_picture->cullRect().x(), m_picture->cullRect().y(), | 45 m_picture->cullRect().x(), m_picture->cullRect().y(), |
| 49 m_picture->cullRect().width(), m_picture->cullRect().height())); | 46 m_picture->cullRect().width(), m_picture->cullRect().height())); |
| 50 } | 47 } |
| 51 } | 48 } |
| 52 #endif | 49 #endif |
| 53 | 50 |
| 54 #if ENABLE(ASSERT) | |
| 55 static bool picturesEqual(const SkPicture* picture1, const SkPicture* picture2) | 51 static bool picturesEqual(const SkPicture* picture1, const SkPicture* picture2) |
| 56 { | 52 { |
| 57 if (picture1->approximateOpCount() != picture2->approximateOpCount()) | 53 if (picture1->approximateOpCount() != picture2->approximateOpCount()) |
| 58 return false; | 54 return false; |
| 59 | 55 |
| 60 SkDynamicMemoryWStream picture1Serialized; | 56 SkDynamicMemoryWStream picture1Serialized; |
| 61 picture1->serialize(&picture1Serialized); | 57 picture1->serialize(&picture1Serialized); |
| 62 SkDynamicMemoryWStream picture2Serialized; | 58 SkDynamicMemoryWStream picture2Serialized; |
| 63 picture2->serialize(&picture2Serialized); | 59 picture2->serialize(&picture2Serialized); |
| 64 if (picture1Serialized.bytesWritten() != picture2Serialized.bytesWritten()) | 60 if (picture1Serialized.bytesWritten() != picture2Serialized.bytesWritten()) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 if (!picture || !otherPicture) | 116 if (!picture || !otherPicture) |
| 121 return false; | 117 return false; |
| 122 | 118 |
| 123 if (picturesEqual(picture, otherPicture)) | 119 if (picturesEqual(picture, otherPicture)) |
| 124 return true; | 120 return true; |
| 125 | 121 |
| 126 // Sometimes the client may produce different pictures for the same visual r
esult | 122 // Sometimes the client may produce different pictures for the same visual r
esult |
| 127 // which should be treated as equal. | 123 // which should be treated as equal. |
| 128 return bitmapsEqual(picture, otherPicture); | 124 return bitmapsEqual(picture, otherPicture); |
| 129 } | 125 } |
| 130 #endif // ENABLE(ASSERT) | |
| 131 | 126 |
| 132 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |