| 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/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 11 #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" | 12 #include "third_party/skia/include/core/SkPictureAnalyzer.h" |
| 13 #include "third_party/skia/include/core/SkStream.h" | 13 #include "third_party/skia/include/core/SkStream.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 void DrawingDisplayItem::replay(GraphicsContext& context) const | 17 void DrawingDisplayItem::replay(GraphicsContext& context) const |
| 18 { | 18 { |
| 19 if (m_picture) | 19 if (m_picture) |
| 20 context.drawPicture(m_picture.get()); | 20 context.drawPicture(m_picture.get()); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void DrawingDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, W
ebDisplayItemList* list) const | 23 void DrawingDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, W
ebDisplayItemList* list) const |
| 24 { | 24 { |
| 25 if (m_picture) | 25 if (m_picture) |
| 26 list->appendDrawingItem(visualRect, toSkSp(m_picture)); | 26 list->appendDrawingItem(visualRect, m_picture); |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool DrawingDisplayItem::drawsContent() const | 29 bool DrawingDisplayItem::drawsContent() const |
| 30 { | 30 { |
| 31 return m_picture.get(); | 31 return m_picture.get(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void DrawingDisplayItem::analyzeForGpuRasterization(SkPictureGpuAnalyzer& analyz
er) const | 34 void DrawingDisplayItem::analyzeForGpuRasterization(SkPictureGpuAnalyzer& analyz
er) const |
| 35 { | 35 { |
| 36 analyzer.analyzePicture(m_picture.get()); | 36 analyzer.analyzePicture(m_picture.get()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 if (picture1->approximateOpCount() != picture2->approximateOpCount()) | 53 if (picture1->approximateOpCount() != picture2->approximateOpCount()) |
| 54 return false; | 54 return false; |
| 55 | 55 |
| 56 SkDynamicMemoryWStream picture1Serialized; | 56 SkDynamicMemoryWStream picture1Serialized; |
| 57 picture1->serialize(&picture1Serialized); | 57 picture1->serialize(&picture1Serialized); |
| 58 SkDynamicMemoryWStream picture2Serialized; | 58 SkDynamicMemoryWStream picture2Serialized; |
| 59 picture2->serialize(&picture2Serialized); | 59 picture2->serialize(&picture2Serialized); |
| 60 if (picture1Serialized.bytesWritten() != picture2Serialized.bytesWritten()) | 60 if (picture1Serialized.bytesWritten() != picture2Serialized.bytesWritten()) |
| 61 return false; | 61 return false; |
| 62 | 62 |
| 63 RefPtr<SkData> data1 = adoptRef(picture1Serialized.copyToData()); | 63 sk_sp<SkData> data1(picture1Serialized.copyToData()); |
| 64 RefPtr<SkData> data2 = adoptRef(picture2Serialized.copyToData()); | 64 sk_sp<SkData> data2(picture2Serialized.copyToData()); |
| 65 return data1->equals(data2.get()); | 65 return data1->equals(data2.get()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 static SkBitmap pictureToBitmap(const SkPicture* picture) | 68 static SkBitmap pictureToBitmap(const SkPicture* picture) |
| 69 { | 69 { |
| 70 SkBitmap bitmap; | 70 SkBitmap bitmap; |
| 71 SkRect rect = picture->cullRect(); | 71 SkRect rect = picture->cullRect(); |
| 72 bitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height())); | 72 bitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height())); |
| 73 SkCanvas canvas(bitmap); | 73 SkCanvas canvas(bitmap); |
| 74 canvas.translate(-rect.x(), -rect.y()); | 74 canvas.translate(-rect.x(), -rect.y()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 if (picturesEqual(picture, otherPicture)) | 119 if (picturesEqual(picture, otherPicture)) |
| 120 return true; | 120 return true; |
| 121 | 121 |
| 122 // 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 |
| 123 // which should be treated as equal. | 123 // which should be treated as equal. |
| 124 return bitmapsEqual(picture, otherPicture); | 124 return bitmapsEqual(picture, otherPicture); |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |