Bug 1210189 - Use nsScreenGonk in nsWindow::StartRemoteDrawing() r=mwu

This commit is contained in:
Sotaro Ikeda 2015-10-03 17:06:19 -07:00
Родитель 318ee7ff3b
Коммит ebcecadcbd
3 изменённых файлов: 39 добавлений и 4 удалений

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

@ -359,6 +359,39 @@ nsScreenGonk::BringToTop(nsWindow* aWindow)
mTopWindows.InsertElementAt(0, aWindow);
}
ANativeWindowBuffer*
nsScreenGonk::DequeueBuffer()
{
ANativeWindowBuffer* buf = nullptr;
#if ANDROID_VERSION >= 17
int fenceFd = -1;
mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf, &fenceFd);
android::sp<android::Fence> fence(new android::Fence(fenceFd));
#if ANDROID_VERSION == 17
fence->waitForever(1000, "nsScreenGonk_DequeueBuffer");
// 1000 is what Android uses. It is a warning timeout in ms.
// This timeout was removed in ANDROID_VERSION 18.
#else
fence->waitForever("nsScreenGonk_DequeueBuffer");
#endif
#else
mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf);
#endif
return buf;
}
bool
nsScreenGonk::QueueBuffer(ANativeWindowBuffer* buf)
{
#if ANDROID_VERSION >= 17
int ret = mNativeWindow->queueBuffer(mNativeWindow.get(), buf, -1);
return ret == 0;
#else
int ret = mNativeWindow->queueBuffer(mNativeWindow.get(), buf);
return ret == 0;
#endif
}
#if ANDROID_VERSION >= 17
android::DisplaySurface*
nsScreenGonk::GetDisplaySurface()

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

@ -74,6 +74,9 @@ public:
ScreenConfiguration GetConfiguration();
bool IsPrimaryScreen();
ANativeWindowBuffer* DequeueBuffer();
bool QueueBuffer(ANativeWindowBuffer* buf);
#if ANDROID_VERSION >= 17
android::DisplaySurface* GetDisplaySurface();
int GetPrevDispAcquireFd();

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

@ -654,8 +654,7 @@ HalFormatToSurfaceFormat(int aHalFormat, int* bytepp)
already_AddRefed<DrawTarget>
nsWindow::StartRemoteDrawing()
{
GonkDisplay* display = GetGonkDisplay();
mFramebuffer = display->DequeueBuffer();
mFramebuffer = mScreen->DequeueBuffer();
int width = mFramebuffer->width, height = mFramebuffer->height;
void *vaddr;
if (gralloc_module()->lock(gralloc_module(), mFramebuffer->handle,
@ -667,7 +666,7 @@ nsWindow::StartRemoteDrawing()
return nullptr;
}
int bytepp;
SurfaceFormat format = HalFormatToSurfaceFormat(display->surfaceformat,
SurfaceFormat format = HalFormatToSurfaceFormat(mScreen->GetSurfaceFormat(),
&bytepp);
mFramebufferTarget = Factory::CreateDrawTargetForData(
BackendType::CAIRO, (uint8_t*)vaddr,
@ -696,7 +695,7 @@ nsWindow::EndRemoteDrawing()
gralloc_module()->unlock(gralloc_module(), mFramebuffer->handle);
}
if (mFramebuffer) {
GetGonkDisplay()->QueueBuffer(mFramebuffer);
mScreen->QueueBuffer(mFramebuffer);
}
mFramebuffer = nullptr;
mFramebufferTarget = nullptr;