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

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

Issue 2769533002: Clean up calls to ToSkPicture (Closed)
Patch Set: Rebase Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/PaintGeneratedImage.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 19 matching lines...) Expand all
30 return m_record.get(); 30 return m_record.get();
31 } 31 }
32 32
33 void DrawingDisplayItem::analyzeForGpuRasterization( 33 void DrawingDisplayItem::analyzeForGpuRasterization(
34 SkPictureGpuAnalyzer& analyzer) const { 34 SkPictureGpuAnalyzer& analyzer) const {
35 // TODO(enne): Need an SkPictureGpuAnalyzer on PictureRecord. 35 // TODO(enne): Need an SkPictureGpuAnalyzer on PictureRecord.
36 // This is a bit overkill to ToSkPicture a record just to get 36 // This is a bit overkill to ToSkPicture a record just to get
37 // numSlowPaths. 37 // numSlowPaths.
38 if (!m_record) 38 if (!m_record)
39 return; 39 return;
40 analyzer.analyzePicture(ToSkPicture(m_record.get())); 40 analyzer.analyzePicture(ToSkPicture(m_record).get());
41 } 41 }
42 42
43 #ifndef NDEBUG 43 #ifndef NDEBUG
44 void DrawingDisplayItem::dumpPropertiesAsDebugString( 44 void DrawingDisplayItem::dumpPropertiesAsDebugString(
45 StringBuilder& stringBuilder) const { 45 StringBuilder& stringBuilder) const {
46 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); 46 DisplayItem::dumpPropertiesAsDebugString(stringBuilder);
47 if (m_record) { 47 if (m_record) {
48 stringBuilder.append( 48 stringBuilder.append(
49 String::format(", rect: [%f,%f %fx%f]", m_record->cullRect().x(), 49 String::format(", rect: [%f,%f %fx%f]", m_record->cullRect().x(),
50 m_record->cullRect().y(), m_record->cullRect().width(), 50 m_record->cullRect().y(), m_record->cullRect().width(),
51 m_record->cullRect().height())); 51 m_record->cullRect().height()));
52 } 52 }
53 } 53 }
54 #endif 54 #endif
55 55
56 static bool recordsEqual(const PaintRecord* record1, 56 static bool recordsEqual(sk_sp<const PaintRecord> record1,
57 const PaintRecord* record2) { 57 sk_sp<const PaintRecord> record2) {
58 if (record1->approximateOpCount() != record2->approximateOpCount()) 58 if (record1->approximateOpCount() != record2->approximateOpCount())
59 return false; 59 return false;
60 60
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(sk_sp<const PaintRecord> record) { 67 static SkBitmap recordToBitmap(sk_sp<const PaintRecord> record) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 const sk_sp<const PaintRecord>& record = this->GetPaintRecord(); 110 const sk_sp<const PaintRecord>& record = this->GetPaintRecord();
111 const sk_sp<const PaintRecord>& otherRecord = 111 const sk_sp<const PaintRecord>& otherRecord =
112 static_cast<const DrawingDisplayItem&>(other).GetPaintRecord(); 112 static_cast<const DrawingDisplayItem&>(other).GetPaintRecord();
113 113
114 if (!record && !otherRecord) 114 if (!record && !otherRecord)
115 return true; 115 return true;
116 if (!record || !otherRecord) 116 if (!record || !otherRecord)
117 return false; 117 return false;
118 118
119 if (recordsEqual(record.get(), otherRecord.get())) 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(std::move(record), std::move(otherRecord)); 124 return bitmapsEqual(std::move(record), std::move(otherRecord));
125 } 125 }
126 126
127 } // namespace blink 127 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/PaintGeneratedImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698