зеркало из https://github.com/mozilla/gecko-dev.git
Bug 751609 - Give up on locking a Surface after 10 failures r=blassey
This commit is contained in:
Родитель
57e20d6acb
Коммит
cbf379b8a1
|
@ -912,6 +912,23 @@ NextPowerOfTwo(int value) {
|
|||
return value + 1;
|
||||
}
|
||||
|
||||
#define MAX_LOCK_ATTEMPTS 10
|
||||
|
||||
static bool LockWindowWithRetry(void* window, unsigned char** bits, int* width, int* height, int* format, int* stride)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
while (count < MAX_LOCK_ATTEMPTS) {
|
||||
if (AndroidBridge::Bridge()->LockWindow(window, bits, width, height, format, stride))
|
||||
return true;
|
||||
|
||||
count++;
|
||||
usleep(500);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_EXPORT jobject JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits(JNIEnv* jenv, jclass, jobject surface)
|
||||
{
|
||||
|
@ -931,15 +948,14 @@ Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits(JNIEnv* jenv, jclass, jobjec
|
|||
int srcWidth, srcHeight, format, srcStride;
|
||||
|
||||
// So we lock/unlock once here in order to get whatever is currently the front buffer. It sucks.
|
||||
while (!AndroidBridge::Bridge()->LockWindow(window, &bits, &srcWidth, &srcHeight, &format, &srcStride)) {
|
||||
usleep(1000);
|
||||
}
|
||||
if (!LockWindowWithRetry(window, &bits, &srcWidth, &srcHeight, &format, &srcStride))
|
||||
return nsnull;
|
||||
|
||||
AndroidBridge::Bridge()->UnlockWindow(window);
|
||||
|
||||
// This is lock will result in the front buffer, since the last unlock rotated it to the back. Probably.
|
||||
while (!AndroidBridge::Bridge()->LockWindow(window, &bits, &srcWidth, &srcHeight, &format, &srcStride)) {
|
||||
usleep(1000);
|
||||
}
|
||||
if (!LockWindowWithRetry(window, &bits, &srcWidth, &srcHeight, &format, &srcStride))
|
||||
return nsnull;
|
||||
|
||||
// These are from android.graphics.PixelFormat
|
||||
int bpp;
|
||||
|
|
Загрузка…
Ссылка в новой задаче