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