Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/DrawingDisplayItem.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Self-review. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 9 #include "third_party/skia/include/core/SkPictureAnalyzer.h"
10 10
11 #if ENABLE(ASSERT) 11 #if ENABLE(ASSERT)
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkData.h" 14 #include "third_party/skia/include/core/SkData.h"
15 #include "third_party/skia/include/core/SkStream.h" 15 #include "third_party/skia/include/core/SkStream.h"
16 #endif 16 #endif
17 17
18 namespace blink { 18 namespace blink {
19 19
20 void DrawingDisplayItem::replay(GraphicsContext& context) const 20 void DrawingDisplayItem::replay(GraphicsContext& context) const
21 { 21 {
22 if (m_picture) 22 if (m_picture)
23 context.drawPicture(m_picture.get()); 23 context.drawPicture(m_picture.get());
24 } 24 }
25 25
26 void DrawingDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, W ebDisplayItemList* list) const 26 void DrawingDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, W ebDisplayItemList* list) const
27 { 27 {
28 if (m_picture) 28 if (m_picture)
29 list->appendDrawingItem(visualRect, toSkSp(m_picture)); 29 list->appendDrawingItem(visualRect, m_picture);
30 } 30 }
31 31
32 bool DrawingDisplayItem::drawsContent() const 32 bool DrawingDisplayItem::drawsContent() const
33 { 33 {
34 return m_picture.get(); 34 return m_picture.get();
35 } 35 }
36 36
37 void DrawingDisplayItem::analyzeForGpuRasterization(SkPictureGpuAnalyzer& analyz er) const 37 void DrawingDisplayItem::analyzeForGpuRasterization(SkPictureGpuAnalyzer& analyz er) const
38 { 38 {
39 analyzer.analyzePicture(m_picture.get()); 39 analyzer.analyzePicture(m_picture.get());
(...skipping 17 matching lines...) Expand all
57 if (picture1->approximateOpCount() != picture2->approximateOpCount()) 57 if (picture1->approximateOpCount() != picture2->approximateOpCount())
58 return false; 58 return false;
59 59
60 SkDynamicMemoryWStream picture1Serialized; 60 SkDynamicMemoryWStream picture1Serialized;
61 picture1->serialize(&picture1Serialized); 61 picture1->serialize(&picture1Serialized);
62 SkDynamicMemoryWStream picture2Serialized; 62 SkDynamicMemoryWStream picture2Serialized;
63 picture2->serialize(&picture2Serialized); 63 picture2->serialize(&picture2Serialized);
64 if (picture1Serialized.bytesWritten() != picture2Serialized.bytesWritten()) 64 if (picture1Serialized.bytesWritten() != picture2Serialized.bytesWritten())
65 return false; 65 return false;
66 66
67 RefPtr<SkData> data1 = adoptRef(picture1Serialized.copyToData()); 67 sk_sp<SkData> data1(picture1Serialized.copyToData());
68 RefPtr<SkData> data2 = adoptRef(picture2Serialized.copyToData()); 68 sk_sp<SkData> data2(picture2Serialized.copyToData());
69 return data1->equals(data2.get()); 69 return data1->equals(data2.get());
70 } 70 }
71 71
72 static SkBitmap pictureToBitmap(const SkPicture* picture) 72 static SkBitmap pictureToBitmap(const SkPicture* picture)
73 { 73 {
74 SkBitmap bitmap; 74 SkBitmap bitmap;
75 SkRect rect = picture->cullRect(); 75 SkRect rect = picture->cullRect();
76 bitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height())); 76 bitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()));
77 SkCanvas canvas(bitmap); 77 SkCanvas canvas(bitmap);
78 canvas.translate(-rect.x(), -rect.y()); 78 canvas.translate(-rect.x(), -rect.y());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (picturesEqual(picture, otherPicture)) 123 if (picturesEqual(picture, otherPicture))
124 return true; 124 return true;
125 125
126 // 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
127 // which should be treated as equal. 127 // which should be treated as equal.
128 return bitmapsEqual(picture, otherPicture); 128 return bitmapsEqual(picture, otherPicture);
129 } 129 }
130 #endif // ENABLE(ASSERT) 130 #endif // ENABLE(ASSERT)
131 131
132 } // namespace blink 132 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698