示例#1
0
void UtestShell::runOneTest(TestPlugin* plugin, TestResult& result)
{
    HelperTestRunInfo runInfo(this, plugin, &result);
    if (isRunInSeperateProcess())
        PlatformSpecificSetJmp(helperDoRunOneTestSeperateProcess, &runInfo);
    else
        PlatformSpecificSetJmp(helperDoRunOneTestInCurrentProcess, &runInfo);
}
示例#2
0
void EmbeddedObjectPainter::paintReplaced(const PaintInfo& paintInfo,
                                          const LayoutPoint& paintOffset) {
  if (!m_layoutEmbeddedObject.showsUnavailablePluginIndicator())
    return;

  if (paintInfo.phase == PaintPhaseSelection)
    return;

  GraphicsContext& context = paintInfo.context;
  if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(
          context, m_layoutEmbeddedObject, paintInfo.phase))
    return;

  LayoutRect contentRect(m_layoutEmbeddedObject.contentBoxRect());
  contentRect.moveBy(paintOffset);
  LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutEmbeddedObject,
                                              paintInfo.phase, contentRect);
  GraphicsContextStateSaver stateSaver(context);
  context.clip(pixelSnappedIntRect(contentRect));

  Font font = replacementTextFont();
  const SimpleFontData* fontData = font.primaryFont();
  DCHECK(fontData);
  if (!fontData)
    return;

  TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText());
  FloatSize textGeometry(font.width(textRun),
                         fontData->getFontMetrics().height());

  LayoutRect backgroundRect(
      0, 0,
      textGeometry.width() + 2 * replacementTextRoundedRectLeftRightTextMargin,
      replacementTextRoundedRectHeight);
  backgroundRect.move(contentRect.center() - backgroundRect.center());
  backgroundRect = LayoutRect(pixelSnappedIntRect(backgroundRect));
  Path roundedBackgroundRect;
  FloatRect floatBackgroundRect(backgroundRect);
  roundedBackgroundRect.addRoundedRect(
      floatBackgroundRect, FloatSize(replacementTextRoundedRectRadius,
                                     replacementTextRoundedRectRadius));
  context.setFillColor(
      scaleAlpha(Color::white, replacementTextRoundedRectOpacity));
  context.fillPath(roundedBackgroundRect);

  FloatRect textRect(FloatPoint(), textGeometry);
  textRect.move(FloatPoint(contentRect.center()) - textRect.center());
  TextRunPaintInfo runInfo(textRun);
  runInfo.bounds = floatBackgroundRect;
  context.setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity));
  context.drawBidiText(
      font, runInfo,
      textRect.location() + FloatSize(0, fontData->getFontMetrics().ascent()));
}
示例#3
0
文件: Postmortem.cpp 项目: jachamp/ia
void Postmortem::readKeysMenu(const vector<StrAndClr>& linesAndClr,
                              bool* const quitGame) {
  MenuBrowser browser(5, 0);

  renderMenu(browser);

  bool done = false;
  while(done == false) {
    const MenuAction action = eng.menuInputHandler->getAction(browser);
    switch(action) {
      case MenuAction::browsed: {
        renderMenu(browser);
      } break;

      case MenuAction::esc: {
        *quitGame = true;
        done      = true;
      } break;

      case MenuAction::space:
      case MenuAction::selectedShift: {} break;

      case MenuAction::selected: {
        if(browser.isPosAtElement(0)) {
          runInfo(linesAndClr);
          renderMenu(browser);
        }
        if(browser.isPosAtElement(1)) {
          eng.highScore->runHighScoreScreen();
          renderMenu(browser);
        }
        if(browser.isPosAtElement(2)) {
          eng.log->displayHistory();
          renderMenu(browser);
        }
        if(browser.isPosAtElement(3)) {
          done = true;
        }
        if(browser.isPosAtElement(4)) {
          *quitGame = true;
          done      = true;
        }
      } break;
    }
  }
}
示例#4
0
void Postmortem::readKeysMenu(bool* const quitGame) {
  MenuBrowser browser(5, 0);

  renderMenu(browser);

  bool done = false;
  while(done == false) {
    const MenuAction_t action = eng->menuInputHandler->getAction(browser);
    switch(action) {
    case menuAction_browsed: {
      renderMenu(browser);
    }
    break;
    case menuAction_canceled: {
    }
    break;
    case menuAction_selected: {
      if(browser.isPosAtKey('a')) {
        runInfo();
        renderMenu(browser);
      }
      if(browser.isPosAtKey('b')) {
        eng->highScore->runHighScoreScreen();
        renderMenu(browser);
      }
      if(browser.isPosAtKey('c')) {
        eng->log->displayHistory();
        renderMenu(browser);
      }
      if(browser.isPosAtKey('d')) {
        done = true;
      }
      if(browser.isPosAtKey('e')) {
        *quitGame = true;
        done = true;
      }
    }
    break;
    case menuAction_selectedWithShift:
    {} break;
    }
  }
}
示例#5
0
void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFloatPoint& leftBaseline,
                           WebColor color, const WebRect& clip, bool canvasIsOpaque,
                           int from, int to) const
{
    FontCachePurgePreventer fontCachePurgePreventer;
    FloatRect textClipRect(clip);
    TextRun textRun(run);
    TextRunPaintInfo runInfo(textRun);
    runInfo.from = from;
    runInfo.to = to == -1 ? textRun.length() : to;
    runInfo.bounds = textClipRect;
    GraphicsContext gc(canvas, nullptr);

    gc.save();
    gc.setCertainlyOpaque(canvasIsOpaque);
    gc.setFillColor(color);
    gc.clip(textClipRect);
    m_font.drawText(&gc, runInfo, leftBaseline);
    gc.restore();
}
示例#6
0
void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFloatPoint& leftBaseline,
                           WebColor color, const WebRect& clip, bool canvasIsOpaque,
                           int from, int to) const
{
    FontCachePurgePreventer fontCachePurgePreventer;
    WebCore::FloatRect textClipRect(clip);
    TextRun textRun(run);
    TextRunPaintInfo runInfo(textRun);
    runInfo.from = from;
    runInfo.to = to == -1 ? textRun.length() : to;
    runInfo.bounds = textClipRect;
    GraphicsContext gc(canvas);

    gc.save();
    gc.setCertainlyOpaque(canvasIsOpaque);
    gc.setFillColor(color);
    gc.clip(textClipRect);
    m_font.drawText(&gc, runInfo, leftBaseline);
    gc.restore();

#if defined(WIN32)
    if (canvasIsOpaque && SkColorGetA(color) == 0xFF && !canvas->isDrawingToLayer()) {
        // The text drawing logic on Windows ignores the alpha component
        // intentionally, for performance reasons.
        // (Please see TransparencyAwareFontPainter::initializeForGDI in
        // FontChromiumWin.cpp.)
        const SkBitmap& bitmap = canvas->getTopDevice()->accessBitmap(true);
        IntRect textBounds = estimateTextBounds(run, leftBaseline);
        IntRect destRect = gc.getCTM().mapRect(textBounds);
        destRect.intersect(IntRect(0, 0, bitmap.width(), bitmap.height()));
        for (int y = destRect.y(), maxY = destRect.maxY(); y < maxY; y++) {
            uint32_t* row = bitmap.getAddr32(0, y);
            for (int x = destRect.x(), maxX = destRect.maxX(); x < maxX; x++)
                row[x] |= (0xFF << SK_A32_SHIFT);
        }
    }
#endif
}
示例#7
0
void WebFont::drawText(WebCanvas* canvas, const WebTextRun& run,
    const WebFloatPoint& leftBaseline, WebColor color, const WebRect& clip) const
{
    FontCachePurgePreventer fontCachePurgePreventer;
    FloatRect textClipRect(clip);
    TextRun textRun(run);
    TextRunPaintInfo runInfo(textRun);
    runInfo.bounds = textClipRect;

    IntRect intRect(clip);
    SkPictureBuilder pictureBuilder(intRect);
    GraphicsContext& context = pictureBuilder.context();

    {
        DrawingRecorder drawingRecorder(context, pictureBuilder, DisplayItem::WebFont, intRect);
        context.save();
        context.setFillColor(color);
        context.clip(textClipRect);
        context.drawText(m_private->getFont(), runInfo, leftBaseline);
        context.restore();
    }

    pictureBuilder.endRecording()->playback(canvas);
}