Example #1
0
void RemoteDisplayClient::onDisplayConnected(
        const sp<ISurfaceTexture> &surfaceTexture,
        uint32_t width,
        uint32_t height,
        uint32_t flags) {
    ALOGI("onDisplayConnected width=%u, height=%u, flags = 0x%08x",
          width, height, flags);

    mSurfaceTexture = surfaceTexture;
    mDisplayBinder = mComposerClient->createDisplay(
            String8("foo"), false /* secure */);

    SurfaceComposerClient::openGlobalTransaction();
    mComposerClient->setDisplaySurface(mDisplayBinder, mSurfaceTexture);

    Rect layerStackRect(1280, 720);  // XXX fix this.
    Rect displayRect(1280, 720);

    mComposerClient->setDisplayProjection(
            mDisplayBinder, 0 /* 0 degree rotation */,
            layerStackRect,
            displayRect);

    SurfaceComposerClient::closeGlobalTransaction();
}
Example #2
0
void RemoteDisplayClient::onDisplayConnected(
        const sp<IGraphicBufferProducer> &bufferProducer,
        uint32_t width,
        uint32_t height,
        uint32_t flags,
        uint32_t session) {
    ALOGI("onDisplayConnected width=%u, height=%u, flags = 0x%08x, session=%d",
          width, height, flags, session);

    if (bufferProducer != NULL) {
        mSurfaceTexture = bufferProducer;
        mDisplayBinder = mComposerClient->createDisplay(
                String8("foo"), false /* secure */);

        SurfaceComposerClient::openGlobalTransaction();
        mComposerClient->setDisplaySurface(mDisplayBinder, mSurfaceTexture);

        Rect layerStackRect(1280, 720);  // XXX fix this.
        Rect displayRect(1280, 720);

        mComposerClient->setDisplayProjection(
                mDisplayBinder, 0 /* 0 degree rotation */,
                layerStackRect,
                displayRect);

        SurfaceComposerClient::closeGlobalTransaction();
    }
}
static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz,
        jobject tokenObj, jint orientation,
        jint layerStackRect_left, jint layerStackRect_top, jint layerStackRect_right, jint layerStackRect_bottom,
        jint displayRect_left, jint displayRect_top, jint displayRect_right, jint displayRect_bottom) {
    sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
    if (token == NULL) return;
    Rect layerStackRect(layerStackRect_left, layerStackRect_top, layerStackRect_right, layerStackRect_bottom);
    Rect displayRect(displayRect_left, displayRect_top, displayRect_right, displayRect_bottom);
    SurfaceComposerClient::setDisplayProjection(token, orientation, layerStackRect, displayRect);
}
Example #4
0
File: mhi.cpp Project: Olti/mythtv
// In MHEG the video is just another item in the display stack
// but when we create the OSD we overlay everything over the video.
// We need to cut out anything belowthe video on the display stack
// to leave the video area clear.
// The videoRect gives the size and position to which the video must be scaled.
// The displayRect gives the rectangle reserved for the video.
// e.g. part of the video may be clipped within the displayRect.
void MHIContext::DrawVideo(const QRect &videoRect, const QRect &dispRect)
{
    // tell the video player to resize the video stream
    if (m_parent->GetNVP())
    {
        QRect vidRect(SCALED_X(videoRect.x()),
                      SCALED_Y(videoRect.y()),
                      SCALED_X(videoRect.width()),
                      SCALED_Y(videoRect.height()));
        if (m_videoRect != vidRect)
        {
            m_parent->GetNVP()->SetVideoResize(vidRect.translated(m_displayRect.topLeft()));
            m_videoRect = vidRect;
        }
    }

    QMutexLocker locker(&m_display_lock);
    QRect displayRect(SCALED_X(dispRect.x()),
                      SCALED_Y(dispRect.y()),
                      SCALED_X(dispRect.width()),
                      SCALED_Y(dispRect.height()));

    list<MHIImageData*>::iterator it = m_display.begin();
    for (; it != m_display.end(); ++it)
    {
        MHIImageData *data = *it;
        QRect imageRect(data->m_x, data->m_y,
                        data->m_image.width(), data->m_image.height());
        if (displayRect.intersects(imageRect))
        {
            // Replace this item with a set of cut-outs.
            it = m_display.erase(it);

            QVector<QRect> rects =
                (QRegion(imageRect) - QRegion(displayRect)).rects();
            for (uint j = 0; j < (uint)rects.size(); j++)
            {
                QRect &rect = rects[j];
                QImage image =
                    data->m_image.copy(rect.x()-data->m_x, rect.y()-data->m_y,
                                       rect.width(), rect.height());
                MHIImageData *newData = new MHIImageData;
                newData->m_image = image;
                newData->m_x = rect.x();
                newData->m_y = rect.y();
                m_display.insert(it, newData);
                ++it;
            }
            delete data;
        }
    }
}
int DisplayManagerWin::getDisplayFromPoint(int x, int y)
{
  for (int displayId = 0; displayId < displays.size(); displayId++)
  {
    int currentMode = getCurrentDisplayMode(displayId);
    if (currentMode > 0)
    {
      DEVMODEW modeInfo;
      if (getModeInfo(displayId, currentMode, modeInfo))
      {
        QRect displayRect(modeInfo.dmPosition.x, modeInfo.dmPosition.y, modeInfo.dmPelsWidth,
                          modeInfo.dmPelsHeight);

        if (displayRect.contains(x, y))
          return displayId;
      }
    }
  }

  return -1;
}
int DisplayManagerWin::getDisplayFromPoint(int x, int y)
{
  foreach (int displayId, displays.keys())
  {
    int currentMode = getCurrentDisplayMode(displayId);
    if (currentMode >= 0)
    {
      DEVMODEW modeInfo;
      if (getModeInfo(displayId, currentMode, modeInfo))
      {
        QRect displayRect(modeInfo.dmPosition.x, modeInfo.dmPosition.y, modeInfo.dmPelsWidth,
                          modeInfo.dmPelsHeight);
        QLOG_DEBUG() << "Looking at display" << displayId << "mode" << currentMode
                     << "at" << displayRect;

        if (displayRect.contains(x, y))
          return displayId;
      }
    }
  }

  return -1;
}
Example #7
0
bool AgiEngine::handleMouseClicks(uint16 &key) {
	// No mouse click? -> exit
	if (key != AGI_MOUSE_BUTTON_LEFT)
		return false;

	if (!cycleInnerLoopIsActive()) {
		// Only do this, when no inner loop is currently active
		Common::Rect displayLineRect(DISPLAY_WIDTH, FONT_DISPLAY_HEIGHT);

		if (displayLineRect.contains(_mouse.pos)) {
			// Mouse is inside first line of the screen
			if (getFlag(VM_FLAG_MENUS_ACCESSIBLE) && _menu->isAvailable()) {
				_menu->delayedExecuteViaMouse();
				key = 0; // eat event
				return true;
			}
		}

		if (_text->promptIsEnabled()) {
			// Prompt is currently enabled
			int16 promptRow = _text->promptRow_Get();

			displayLineRect.moveTo(0, promptRow * FONT_DISPLAY_HEIGHT);

			if (displayLineRect.contains(_mouse.pos)) {
				// and user clicked within the line of the prompt
				showPredictiveDialog();

				key = 0; // eat event
				return true;
			}
		}
	}

	if (cycleInnerLoopIsActive()) {
		// inner loop active, check what kind of loop it is. Then process / forward it
		switch (_game.cycleInnerLoopType) {
		case CYCLE_INNERLOOP_GETSTRING:
		case CYCLE_INNERLOOP_GETNUMBER: {
			// process in here
			int16 stringRow, stringColumn, stringMaxLen;

			_text->stringPos_Get(stringRow, stringColumn);
			stringMaxLen = _text->stringGetMaxLen();

			Common::Rect displayRect(stringMaxLen * FONT_DISPLAY_WIDTH, FONT_DISPLAY_HEIGHT);
			displayRect.moveTo(stringColumn * FONT_DISPLAY_WIDTH, stringRow * FONT_DISPLAY_HEIGHT);

			if (displayRect.contains(_mouse.pos)) {
				// user clicked inside the input space
				showPredictiveDialog();

				key = 0; // eat event
				return true;
			}
			break;
		}
		case CYCLE_INNERLOOP_INVENTORY:
			// TODO: forward
			break;

		case CYCLE_INNERLOOP_MENU_VIA_KEYBOARD:
			_menu->mouseEvent(key);
			key = 0; // eat event
			break;

		case CYCLE_INNERLOOP_SYSTEMUI_SELECTSAVEDGAMESLOT:
			// TODO: forward
			break;

		default:
			break;
		}
	}
	return false;
}
Example #8
0
void PlaylistItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	const QRect & baseRect = option.rect;
	painter->save();
	painter->setClipRect(baseRect, Qt::ReplaceClip);

	QRect displayRect(baseRect);

	PlaylistModel::ActiveTrackState state =
			static_cast<PlaylistModel::ActiveTrackState>(
					index.data(PlaylistModel::ItemTrackStateRole).toInt());

	if (PlaylistModel::TrackStateNotActive != state) {
		// draw custom background
		if (option.state & QStyle::State_Selected) {
			painter->setPen(QPen(QApplication::palette().color(QPalette::HighlightedText)));
			painter->fillRect(baseRect, p->activeSelecteItemBgBrush);
		} else {
			painter->fillRect(baseRect, p->activeItemBgBrush);
		}

		if (index.column() == 0) {
			QImage stateImage;

			// draw track playing state icon in the first column
			switch (state) {
			case PlaylistModel::TrackStatePaused:
				stateImage.load(":track-state-paused.png");
				break;

			case PlaylistModel::TrackStatePlaying:
				stateImage.load(":track-state-playing.png");
				break;

			case PlaylistModel::TrackStateStopped:
				stateImage.load(":track-state-stopped.png");
				break;
				
			case PlaylistModel::TrackStateNotActive:
				break;
			}

			QRect r(baseRect);
			r.adjust(0, 0, 0, -1);
			QPoint sp(r.topLeft());
			sp += QPoint(2, 0);
			sp.setY(r.center().y() - stateImage.height()/2 + 1);

			painter->drawImage(sp, stateImage);

			displayRect.adjust(stateImage.width()+1, 0, 0, 0);

		}
		// adjust rect for text
		//displayRect.adjust(0, 2, 0, 0);

		// set font style: italic
		QFont f = painter->font();
		f.setItalic(true);
		painter->setFont(f);
	} else if (option.state & QStyle::State_Selected) {
		// if item is selected draw the selected item background
		painter->setPen(QPen(QApplication::palette().color(QPalette::HighlightedText)));
		painter->fillRect(baseRect, QApplication::palette().highlight());
	}

	displayRect.adjust(3, 0, 0, 0);
	painter->drawText(displayRect, Qt::TextSingleLine | Qt::TextDontClip,
			index.data(Qt::DisplayRole).toString());

	painter->restore();
}