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.
6 #include "web/tests/sim/SimDisplayItemList.h"
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"
15 SimDisplayItemList::SimDisplayItemList()
16 : m_containsText(false)
20 void SimDisplayItemList::appendDrawingItem(const SkPicture
* picture
)
22 m_containsText
|= picture
->hasText();
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());
30 bool SimDisplayItemList::contains(SimCanvas::CommandType type
, const String
& colorString
) const
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
== color
))