| 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" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // TODO(enne): PaintRecord should have an operator== | 61 // TODO(enne): PaintRecord should have an operator== |
| 62 sk_sp<SkData> data1 = ToSkPicture(record1)->serialize(); | 62 sk_sp<SkData> data1 = ToSkPicture(record1)->serialize(); |
| 63 sk_sp<SkData> data2 = ToSkPicture(record2)->serialize(); | 63 sk_sp<SkData> data2 = ToSkPicture(record2)->serialize(); |
| 64 return data1->equals(data2.get()); | 64 return data1->equals(data2.get()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 static SkBitmap recordToBitmap(const PaintRecord* record) { | 67 static SkBitmap recordToBitmap(const PaintRecord* record) { |
| 68 SkBitmap bitmap; | 68 SkBitmap bitmap; |
| 69 SkRect rect = record->cullRect(); | 69 SkRect rect = record->cullRect(); |
| 70 bitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height())); | 70 bitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height())); |
| 71 PaintCanvas canvas(bitmap); | 71 SkiaPaintCanvas canvas(bitmap); |
| 72 canvas.clear(SK_ColorTRANSPARENT); | 72 canvas.clear(SK_ColorTRANSPARENT); |
| 73 canvas.translate(-rect.x(), -rect.y()); | 73 canvas.translate(-rect.x(), -rect.y()); |
| 74 canvas.drawPicture(record); | 74 canvas.drawPicture(record); |
| 75 return bitmap; | 75 return bitmap; |
| 76 } | 76 } |
| 77 | 77 |
| 78 static bool bitmapsEqual(const PaintRecord* record1, | 78 static bool bitmapsEqual(const PaintRecord* record1, |
| 79 const PaintRecord* record2) { | 79 const PaintRecord* record2) { |
| 80 SkRect rect = record1->cullRect(); | 80 SkRect rect = record1->cullRect(); |
| 81 if (rect != record2->cullRect()) | 81 if (rect != record2->cullRect()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 if (recordsEqual(record, otherRecord)) | 119 if (recordsEqual(record, otherRecord)) |
| 120 return true; | 120 return true; |
| 121 | 121 |
| 122 // Sometimes the client may produce different records for the same visual | 122 // Sometimes the client may produce different records for the same visual |
| 123 // result, which should be treated as equal. | 123 // result, which should be treated as equal. |
| 124 return bitmapsEqual(record, otherRecord); | 124 return bitmapsEqual(record, otherRecord); |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |