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