Bug 1144975 - Video dimensions for tab mirroring can be smaller than the devices display. r=snorp

--HG--
extra : rebase_source : 78a9719e7489b3b98754d523924303da79794e59
This commit is contained in:
Randall Barker 2015-03-19 14:24:00 -04:00
Родитель e5d4f2f9fa
Коммит 1e31bd225a
1 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -199,19 +199,22 @@ MediaEngineTabVideoSource::Draw() {
return;
}
float pixelRatio;
win->GetDevicePixelRatio(&pixelRatio);
const int deviceInnerWidth = (int)(pixelRatio * innerWidth);
const int deviceInnerHeight = (int)(pixelRatio * innerHeight);
IntSize size;
// maintain source aspect ratio
if (mBufWidthMax/innerWidth < mBufHeightMax/innerHeight) {
// mBufWidthMax is quite large by default, so use innerWidth if less.
int32_t width = std::min(innerWidth, mBufWidthMax);
// adjust width to be divisible by 4 to work around bug 1125393
width = width - (width % 4);
size = IntSize(width, (width * ((float) innerHeight/innerWidth)));
if ((deviceInnerWidth <= mBufWidthMax) && (deviceInnerHeight <= mBufHeightMax)) {
size = IntSize(deviceInnerWidth, deviceInnerHeight);
} else {
int32_t width = std::min(innerHeight, mBufHeightMax) *
((float) innerWidth/innerHeight);
width = width - (width % 4);
size = IntSize(width, (width * ((float) innerHeight/innerWidth)));
const float scaleWidth = (float)mBufWidthMax / (float)deviceInnerWidth;
const float scaleHeight = (float)mBufHeightMax / (float)deviceInnerHeight;
const float scale = scaleWidth < scaleHeight ? scaleWidth : scaleHeight;
size = IntSize((int)(scale * deviceInnerWidth), (int)(scale * deviceInnerHeight));
}
gfxImageFormat format = gfxImageFormat::RGB24;