зеркало из https://github.com/mozilla/gecko-dev.git
Bug 863397 - Remove all the eglLockSurface-using code; leave the GL symbols in - r=jgilbert
This commit is contained in:
Родитель
e996b0a66e
Коммит
0c8945b8ca
|
@ -696,11 +696,6 @@ GLContext::CanUploadSubTextures()
|
||||||
if (!mWorkAroundDriverBugs)
|
if (!mWorkAroundDriverBugs)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Lock surface feature allows to mmap texture memory and modify it directly
|
|
||||||
// this feature allow us modify texture partially without full upload
|
|
||||||
if (HasLockSurface())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// There are certain GPUs that we don't want to use glTexSubImage2D on
|
// There are certain GPUs that we don't want to use glTexSubImage2D on
|
||||||
// because that function can be very slow and/or buggy
|
// because that function can be very slow and/or buggy
|
||||||
if (Renderer() == RendererAdreno200 || Renderer() == RendererAdreno205)
|
if (Renderer() == RendererAdreno200 || Renderer() == RendererAdreno205)
|
||||||
|
|
|
@ -324,7 +324,6 @@ public:
|
||||||
bool CanUploadNonPowerOfTwo();
|
bool CanUploadNonPowerOfTwo();
|
||||||
|
|
||||||
bool WantsSmallTiles();
|
bool WantsSmallTiles();
|
||||||
virtual bool HasLockSurface() { return false; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this context wraps a double-buffered target, swap the back
|
* If this context wraps a double-buffered target, swap the back
|
||||||
|
|
|
@ -681,10 +681,6 @@ public:
|
||||||
static already_AddRefed<GLContextEGL>
|
static already_AddRefed<GLContextEGL>
|
||||||
CreateEGLPBufferOffscreenContext(const gfxIntSize& size);
|
CreateEGLPBufferOffscreenContext(const gfxIntSize& size);
|
||||||
|
|
||||||
virtual bool HasLockSurface() {
|
|
||||||
return sEGLLibrary.HasKHRLockSurface();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType,
|
virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType,
|
||||||
void* buffer,
|
void* buffer,
|
||||||
SharedTextureBufferType bufferType);
|
SharedTextureBufferType bufferType);
|
||||||
|
@ -1184,7 +1180,6 @@ public:
|
||||||
, mConfig(nullptr)
|
, mConfig(nullptr)
|
||||||
, mTextureState(aTextureState)
|
, mTextureState(aTextureState)
|
||||||
, mBound(false)
|
, mBound(false)
|
||||||
, mIsLocked(false)
|
|
||||||
{
|
{
|
||||||
mUpdateFormat = gfxPlatform::GetPlatform()->OptimalFormatForContent(GetContentType());
|
mUpdateFormat = gfxPlatform::GetPlatform()->OptimalFormatForContent(GetContentType());
|
||||||
|
|
||||||
|
@ -1290,21 +1285,8 @@ public:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_GONK
|
|
||||||
if (mGraphicBuffer != nullptr) {
|
|
||||||
mUpdateSurface = GetLockSurface();
|
|
||||||
|
|
||||||
return mUpdateSurface;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (mBackingSurface) {
|
if (mBackingSurface) {
|
||||||
if (sEGLLibrary.HasKHRLockSurface()) {
|
mUpdateSurface = mBackingSurface;
|
||||||
mUpdateSurface = GetLockSurface();
|
|
||||||
} else {
|
|
||||||
mUpdateSurface = mBackingSurface;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mUpdateSurface;
|
return mUpdateSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1323,13 +1305,6 @@ public:
|
||||||
{
|
{
|
||||||
NS_ASSERTION(!!mUpdateSurface, "EndUpdate() without BeginUpdate()?");
|
NS_ASSERTION(!!mUpdateSurface, "EndUpdate() without BeginUpdate()?");
|
||||||
|
|
||||||
if (mIsLocked) {
|
|
||||||
UnlockSurface();
|
|
||||||
mTextureState = Valid;
|
|
||||||
mUpdateSurface = nullptr;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mBackingSurface && mUpdateSurface == mBackingSurface) {
|
if (mBackingSurface && mUpdateSurface == mBackingSurface) {
|
||||||
#ifdef MOZ_X11
|
#ifdef MOZ_X11
|
||||||
if (mBackingSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
|
if (mBackingSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
|
||||||
|
@ -1413,30 +1388,13 @@ public:
|
||||||
region = aRegion;
|
region = aRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mBackingSurface && sEGLLibrary.HasKHRLockSurface())
|
mShaderType =
|
||||||
#ifdef MOZ_WIDGET_GONK
|
mGLContext->UploadSurfaceToTexture(aSurf,
|
||||||
|| (mGraphicBuffer != nullptr)
|
region,
|
||||||
#endif
|
mTexture,
|
||||||
) {
|
mTextureState == Created,
|
||||||
mUpdateSurface = GetLockSurface();
|
bounds.TopLeft() + aFrom,
|
||||||
if (mUpdateSurface) {
|
false);
|
||||||
nsRefPtr<gfxContext> ctx = new gfxContext(mUpdateSurface);
|
|
||||||
gfxUtils::ClipToRegion(ctx, aRegion);
|
|
||||||
ctx->SetSource(aSurf, gfxPoint(-aFrom.x, -aFrom.y));
|
|
||||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
||||||
ctx->Paint();
|
|
||||||
mUpdateSurface = nullptr;
|
|
||||||
UnlockSurface();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mShaderType =
|
|
||||||
mGLContext->UploadSurfaceToTexture(aSurf,
|
|
||||||
region,
|
|
||||||
mTexture,
|
|
||||||
mTextureState == Created,
|
|
||||||
bounds.TopLeft() + aFrom,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
|
|
||||||
mTextureState = Valid;
|
mTextureState = Valid;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1543,96 +1501,6 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual already_AddRefed<gfxImageSurface> GetLockSurface()
|
|
||||||
{
|
|
||||||
if (mIsLocked) {
|
|
||||||
NS_WARNING("Can't lock surface twice");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_GONK
|
|
||||||
if (mGraphicBuffer != nullptr) {
|
|
||||||
// Unset the EGLImage target so that we don't get clashing locks
|
|
||||||
mGLContext->MakeCurrent(true);
|
|
||||||
mGLContext->UnbindExternalBuffer(mTexture);
|
|
||||||
|
|
||||||
void *vaddr;
|
|
||||||
if (mGraphicBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN |
|
|
||||||
GraphicBuffer::USAGE_SW_WRITE_OFTEN,
|
|
||||||
&vaddr) != OK) {
|
|
||||||
LOG("Could not lock GraphicBuffer");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRefPtr<gfxImageSurface> surface =
|
|
||||||
new gfxImageSurface(reinterpret_cast<unsigned char *>(vaddr),
|
|
||||||
gfxIntSize(mSize.width, mSize.height),
|
|
||||||
mGraphicBuffer->getStride() * gfxUtils::ImageFormatToDepth(mUpdateFormat) / 8,
|
|
||||||
mUpdateFormat);
|
|
||||||
|
|
||||||
mIsLocked = true;
|
|
||||||
|
|
||||||
return surface.forget();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!sEGLLibrary.HasKHRLockSurface()) {
|
|
||||||
NS_WARNING("GetLockSurface called, but no EGL_KHR_lock_surface extension!");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CreateEGLSurface(mBackingSurface)) {
|
|
||||||
NS_WARNING("Failed to create EGL surface");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static EGLint lock_attribs[] = {
|
|
||||||
LOCAL_EGL_MAP_PRESERVE_PIXELS_KHR, LOCAL_EGL_TRUE,
|
|
||||||
LOCAL_EGL_LOCK_USAGE_HINT_KHR, LOCAL_EGL_READ_SURFACE_BIT_KHR | LOCAL_EGL_WRITE_SURFACE_BIT_KHR,
|
|
||||||
LOCAL_EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
sEGLLibrary.fLockSurface(EGL_DISPLAY(), mSurface, lock_attribs);
|
|
||||||
|
|
||||||
mIsLocked = true;
|
|
||||||
|
|
||||||
unsigned char *data = nullptr;
|
|
||||||
int pitch = 0;
|
|
||||||
int pixsize = 0;
|
|
||||||
|
|
||||||
sEGLLibrary.fQuerySurface(EGL_DISPLAY(), mSurface, LOCAL_EGL_BITMAP_POINTER_KHR, (EGLint*)&data);
|
|
||||||
sEGLLibrary.fQuerySurface(EGL_DISPLAY(), mSurface, LOCAL_EGL_BITMAP_PITCH_KHR, &pitch);
|
|
||||||
sEGLLibrary.fQuerySurface(EGL_DISPLAY(), mSurface, LOCAL_EGL_BITMAP_PIXEL_SIZE_KHR, &pixsize);
|
|
||||||
|
|
||||||
nsRefPtr<gfxImageSurface> sharedImage =
|
|
||||||
new gfxImageSurface(data,
|
|
||||||
mBackingSurface->GetSize(),
|
|
||||||
pitch,
|
|
||||||
mUpdateFormat);
|
|
||||||
|
|
||||||
return sharedImage.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void UnlockSurface()
|
|
||||||
{
|
|
||||||
if (!mIsLocked) {
|
|
||||||
NS_WARNING("UnlockSurface called, surface not locked!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mIsLocked = false;
|
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_GONK
|
|
||||||
if (mGraphicBuffer != nullptr) {
|
|
||||||
mGraphicBuffer->unlock();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sEGLLibrary.fUnlockSurface(EGL_DISPLAY(), mSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual already_AddRefed<gfxASurface> GetBackingSurface()
|
virtual already_AddRefed<gfxASurface> GetBackingSurface()
|
||||||
{
|
{
|
||||||
nsRefPtr<gfxASurface> copy = mBackingSurface;
|
nsRefPtr<gfxASurface> copy = mBackingSurface;
|
||||||
|
@ -1795,7 +1663,6 @@ protected:
|
||||||
TextureState mTextureState;
|
TextureState mTextureState;
|
||||||
|
|
||||||
bool mBound;
|
bool mBound;
|
||||||
bool mIsLocked;
|
|
||||||
|
|
||||||
virtual void ApplyFilter()
|
virtual void ApplyFilter()
|
||||||
{
|
{
|
||||||
|
@ -2222,17 +2089,8 @@ CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig)
|
||||||
LOCAL_EGL_NONE
|
LOCAL_EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
static EGLint pixmap_lock_config[] = {
|
|
||||||
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PIXMAP_BIT | LOCAL_EGL_LOCK_SURFACE_BIT_KHR,
|
|
||||||
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
|
|
||||||
LOCAL_EGL_DEPTH_SIZE, 0,
|
|
||||||
LOCAL_EGL_BIND_TO_TEXTURE_RGB, LOCAL_EGL_TRUE,
|
|
||||||
LOCAL_EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(),
|
if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(),
|
||||||
sEGLLibrary.HasKHRLockSurface() ?
|
pixmap_config,
|
||||||
pixmap_lock_config : pixmap_config,
|
|
||||||
configs, numConfigs, &numConfigs)
|
configs, numConfigs, &numConfigs)
|
||||||
|| numConfigs == 0)
|
|| numConfigs == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -428,10 +428,6 @@ public:
|
||||||
return IsExtensionSupported(KHR_gl_texture_2D_image);
|
return IsExtensionSupported(KHR_gl_texture_2D_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasKHRLockSurface() {
|
|
||||||
return IsExtensionSupported(KHR_lock_surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HasANGLESurfaceD3DTexture2DShareHandle() {
|
bool HasANGLESurfaceD3DTexture2DShareHandle() {
|
||||||
return IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle);
|
return IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче