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

This commit is contained in:
Randall Barker 2015-03-19 14:24:00 -04:00
parent 61bf144dbf
commit 30173c7915

View File

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