void ContentLayerDelegate::paintContents(
    WebDisplayItemList* webDisplayItemList, const WebRect& clip,
    WebContentLayerClient::PaintingControlSetting paintingControl)
{
    TRACE_EVENT1("blink,benchmark", "ContentLayerDelegate::paintContents", "clip_rect", toTracedValue(clip));

    // TODO(pdr): Remove when slimming paint v2 is further along. This is only
    // here so the browser is usable during development and does not crash due
    // to committing the new display items twice.
    if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) {
        m_painter->displayItemList()->paintArtifact().appendToWebDisplayItemList(webDisplayItemList);
        return;
    }

    DisplayItemList* displayItemList = m_painter->displayItemList();
    ASSERT(displayItemList);
    displayItemList->setDisplayItemConstructionIsDisabled(
        paintingControl == WebContentLayerClient::DisplayListConstructionDisabled);

    // We also disable caching when Painting or Construction are disabled. In both cases we would like
    // to compare assuming the full cost of recording, not the cost of re-using cached content.
    if (paintingControl != WebContentLayerClient::PaintDefaultBehavior)
        displayItemList->invalidateAll();

    GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled;
    if (paintingControl == WebContentLayerClient::DisplayListPaintingDisabled
        || paintingControl == WebContentLayerClient::DisplayListConstructionDisabled)
        disabledMode = GraphicsContext::FullyDisabled;
    GraphicsContext context(displayItemList, disabledMode);

    m_painter->paint(context, clip);

    displayItemList->commitNewDisplayItems();
    displayItemList->paintArtifact().appendToWebDisplayItemList(webDisplayItemList);
}
Esempio n. 2
0
void WebPopupMenuImpl::paintContents(WebCanvas* canvas, const WebRect& rect, WebContentLayerClient::PaintingControlSetting paintingControl)
{
    if (!m_widget)
        return;

    OwnPtr<GraphicsContext> context;
    GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled;
    if (paintingControl == PaintingControlSetting::DisplayListPaintingDisabled
        || paintingControl == PaintingControlSetting::DisplayListConstructionDisabled)
        disabledMode = GraphicsContext::FullyDisabled;

    DisplayItemList* itemList = displayItemList();
    if (itemList) {
        context = adoptPtr(new GraphicsContext(itemList, disabledMode));
        itemList->setDisplayItemConstructionIsDisabled(paintingControl == PaintingControlSetting::DisplayListConstructionDisabled);
    } else {
        context = GraphicsContext::deprecatedCreateWithCanvas(canvas, disabledMode);
    }
    m_widget->paint(context.get(), rect);

    if (itemList)
        itemList->commitNewDisplayItems();
}