| 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 "skia/ext/cdl_picture.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 | 15 |
| 16 void SimDisplayItemList::appendDrawingItem(const WebRect&, | 16 void SimDisplayItemList::appendDrawingItem(const WebRect&, |
| 17 sk_sp<const SkPicture> picture) { | 17 sk_sp<const CdlPicture> picture) { |
| 18 SkIRect bounds = picture->cullRect().roundOut(); | 18 SkIRect bounds = picture->cullRect().roundOut(); |
| 19 SimCanvas canvas(bounds.width(), bounds.height()); | 19 SimCanvas canvas(bounds.width(), bounds.height()); |
| 20 picture->playback(&canvas); | 20 picture->playback(&canvas); |
| 21 m_commands.append(canvas.commands().data(), canvas.commands().size()); | 21 m_commands.append(canvas.commands().data(), canvas.commands().size()); |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool SimDisplayItemList::contains(SimCanvas::CommandType type, | 24 bool SimDisplayItemList::contains(SimCanvas::CommandType type, |
| 25 const String& colorString) const { | 25 const String& colorString) const { |
| 26 Color color = 0; | 26 Color color = 0; |
| 27 if (!colorString.isNull()) | 27 if (!colorString.isNull()) |
| 28 CHECK(CSSParser::parseColor(color, colorString, true)); | 28 CHECK(CSSParser::parseColor(color, colorString, true)); |
| 29 for (auto& command : m_commands) { | 29 for (auto& command : m_commands) { |
| 30 if (command.type == type && | 30 if (command.type == type && |
| 31 (colorString.isNull() || command.color == color.rgb())) | 31 (colorString.isNull() || command.color == color.rgb())) |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 return false; | 34 return false; |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace blink | 37 } // namespace blink |
| OLD | NEW |