OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "web/tests/sim/SimDisplayItemList.h" | 5 #include "web/tests/sim/SimDisplayItemList.h" |
6 | 6 |
7 #include "core/css/parser/CSSParser.h" | 7 #include "core/css/parser/CSSParser.h" |
8 #include "platform/graphics/LoggingCanvas.h" | 8 #include "platform/graphics/LoggingCanvas.h" |
9 #include "third_party/skia/include/core/SkPicture.h" | 9 #include "third_party/skia/include/core/SkPicture.h" |
10 #include "third_party/skia/include/core/SkRect.h" | 10 #include "third_party/skia/include/core/SkRect.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 SimDisplayItemList::SimDisplayItemList() | 14 SimDisplayItemList::SimDisplayItemList() |
15 : m_containsText(false) | 15 : m_containsText(false) |
16 { | 16 { |
17 } | 17 } |
18 | 18 |
19 void SimDisplayItemList::appendDrawingItem(const WebRect&, const SkPicture* pict
ure) | 19 void SimDisplayItemList::appendDrawingItem(const WebRect&, sk_sp<const SkPicture
> picture) |
20 { | 20 { |
21 m_containsText |= picture->hasText(); | 21 m_containsText |= picture->hasText(); |
22 | 22 |
23 SkIRect bounds = picture->cullRect().roundOut(); | 23 SkIRect bounds = picture->cullRect().roundOut(); |
24 SimCanvas canvas(bounds.width(), bounds.height()); | 24 SimCanvas canvas(bounds.width(), bounds.height()); |
25 picture->playback(&canvas); | 25 picture->playback(&canvas); |
26 m_commands.append(canvas.commands().data(), canvas.commands().size()); | 26 m_commands.append(canvas.commands().data(), canvas.commands().size()); |
27 } | 27 } |
28 | 28 |
29 bool SimDisplayItemList::contains(SimCanvas::CommandType type, const String& col
orString) const | 29 bool SimDisplayItemList::contains(SimCanvas::CommandType type, const String& col
orString) const |
30 { | 30 { |
31 Color color = 0; | 31 Color color = 0; |
32 if (!colorString.isNull()) | 32 if (!colorString.isNull()) |
33 RELEASE_ASSERT(CSSParser::parseColor(color, colorString, true)); | 33 RELEASE_ASSERT(CSSParser::parseColor(color, colorString, true)); |
34 for (auto& command : m_commands) { | 34 for (auto& command : m_commands) { |
35 if (command.type == type && (colorString.isNull() || command.color == co
lor.rgb())) | 35 if (command.type == type && (colorString.isNull() || command.color == co
lor.rgb())) |
36 return true; | 36 return true; |
37 } | 37 } |
38 return false; | 38 return false; |
39 } | 39 } |
40 | 40 |
41 } // namespace blink | 41 } // namespace blink |
OLD | NEW |