зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1322650 - Support a 'continuous' mode for SurfaceTexture r=jgilbert
This is needed to support Flash on Android MozReview-Commit-ID: 5yNIoZHonla
This commit is contained in:
Родитель
0f332539ae
Коммит
40d0e705e9
|
@ -133,7 +133,7 @@ public:
|
|||
|
||||
if (size > 0) {
|
||||
RefPtr<layers::Image> img = new SurfaceTextureImage(
|
||||
mDecoder->mSurfaceHandle, inputInfo.mImageSize,
|
||||
mDecoder->mSurfaceHandle, inputInfo.mImageSize, false /* NOT continuous */,
|
||||
gl::OriginPos::BottomLeft);
|
||||
|
||||
RefPtr<VideoData> v = VideoData::CreateFromImage(
|
||||
|
|
|
@ -272,7 +272,7 @@ SharedSurface_SurfaceTexture::WaitForBufferOwnership()
|
|||
bool
|
||||
SharedSurface_SurfaceTexture::ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor)
|
||||
{
|
||||
*out_descriptor = layers::SurfaceTextureDescriptor(mSurface->GetHandle(), mSize);
|
||||
*out_descriptor = layers::SurfaceTextureDescriptor(mSurface->GetHandle(), mSize, false /* NOT continuous */);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,10 +100,12 @@ GLImage::GetAsSourceSurface()
|
|||
#ifdef MOZ_WIDGET_ANDROID
|
||||
SurfaceTextureImage::SurfaceTextureImage(AndroidSurfaceTextureHandle aHandle,
|
||||
const gfx::IntSize& aSize,
|
||||
bool aContinuous,
|
||||
gl::OriginPos aOriginPos)
|
||||
: GLImage(ImageFormat::SURFACE_TEXTURE),
|
||||
mHandle(aHandle),
|
||||
mSize(aSize),
|
||||
mContinuous(aContinuous),
|
||||
mOriginPos(aOriginPos)
|
||||
{
|
||||
MOZ_ASSERT(mHandle);
|
||||
|
|
|
@ -66,12 +66,16 @@ class SurfaceTextureImage : public GLImage {
|
|||
public:
|
||||
SurfaceTextureImage(AndroidSurfaceTextureHandle aHandle,
|
||||
const gfx::IntSize& aSize,
|
||||
bool aContinuous,
|
||||
gl::OriginPos aOriginPos);
|
||||
|
||||
gfx::IntSize GetSize() override { return mSize; }
|
||||
AndroidSurfaceTextureHandle GetHandle() const {
|
||||
return mHandle;
|
||||
}
|
||||
bool GetContinuous() const {
|
||||
return mContinuous;
|
||||
}
|
||||
gl::OriginPos GetOriginPos() const {
|
||||
return mOriginPos;
|
||||
}
|
||||
|
@ -83,6 +87,7 @@ public:
|
|||
private:
|
||||
AndroidSurfaceTextureHandle mHandle;
|
||||
gfx::IntSize mSize;
|
||||
bool mContinuous;
|
||||
gl::OriginPos mOriginPos;
|
||||
};
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ ImageClient::CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwar
|
|||
} else if (aImage->GetFormat() == ImageFormat::SURFACE_TEXTURE) {
|
||||
SurfaceTextureImage* typedImage = aImage->AsSurfaceTextureImage();
|
||||
texture = AndroidSurfaceTextureData::CreateTextureClient(
|
||||
typedImage->GetHandle(), size, typedImage->GetOriginPos(),
|
||||
typedImage->GetHandle(), size, typedImage->GetContinuous(), typedImage->GetOriginPos(),
|
||||
aForwarder->GetTextureForwarder(), TextureFlags::DEFAULT);
|
||||
#endif
|
||||
} else {
|
||||
|
|
|
@ -62,6 +62,7 @@ struct SurfaceDescriptorMacIOSurface {
|
|||
struct SurfaceTextureDescriptor {
|
||||
uint64_t handle;
|
||||
IntSize size;
|
||||
bool continuous;
|
||||
};
|
||||
|
||||
struct EGLImageDescriptor {
|
||||
|
|
|
@ -81,6 +81,7 @@ EGLImageTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
|
|||
already_AddRefed<TextureClient>
|
||||
AndroidSurfaceTextureData::CreateTextureClient(AndroidSurfaceTextureHandle aHandle,
|
||||
gfx::IntSize aSize,
|
||||
bool aContinuous,
|
||||
gl::OriginPos aOriginPos,
|
||||
LayersIPCChannel* aAllocator,
|
||||
TextureFlags aFlags)
|
||||
|
@ -90,15 +91,16 @@ AndroidSurfaceTextureData::CreateTextureClient(AndroidSurfaceTextureHandle aHand
|
|||
}
|
||||
|
||||
return TextureClient::CreateWithData(
|
||||
new AndroidSurfaceTextureData(aHandle, aSize),
|
||||
new AndroidSurfaceTextureData(aHandle, aSize, aContinuous),
|
||||
aFlags, aAllocator
|
||||
);
|
||||
}
|
||||
|
||||
AndroidSurfaceTextureData::AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle,
|
||||
gfx::IntSize aSize)
|
||||
gfx::IntSize aSize, bool aContinuous)
|
||||
: mHandle(aHandle)
|
||||
, mSize(aSize)
|
||||
, mContinuous(aContinuous)
|
||||
{
|
||||
MOZ_ASSERT(mHandle);
|
||||
}
|
||||
|
@ -120,7 +122,7 @@ AndroidSurfaceTextureData::FillInfo(TextureData::Info& aInfo) const
|
|||
bool
|
||||
AndroidSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
|
||||
{
|
||||
aOutDescriptor = SurfaceTextureDescriptor(mHandle, mSize);
|
||||
aOutDescriptor = SurfaceTextureDescriptor(mHandle, mSize, mContinuous);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
static already_AddRefed<TextureClient>
|
||||
CreateTextureClient(AndroidSurfaceTextureHandle aHandle,
|
||||
gfx::IntSize aSize,
|
||||
bool aContinuous,
|
||||
gl::OriginPos aOriginPos,
|
||||
LayersIPCChannel* aAllocator,
|
||||
TextureFlags aFlags);
|
||||
|
@ -75,10 +76,11 @@ public:
|
|||
virtual void Deallocate(LayersIPCChannel*) override {}
|
||||
|
||||
protected:
|
||||
AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize);
|
||||
AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous);
|
||||
|
||||
const AndroidSurfaceTextureHandle mHandle;
|
||||
const gfx::IntSize mSize;
|
||||
const bool mContinuous;
|
||||
};
|
||||
|
||||
#endif // MOZ_WIDGET_ANDROID
|
||||
|
|
|
@ -62,7 +62,8 @@ CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
|
|||
|
||||
result = new SurfaceTextureHost(aFlags,
|
||||
surfaceTexture,
|
||||
desc.size());
|
||||
desc.size(),
|
||||
desc.continuous());
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -411,11 +412,15 @@ SurfaceTextureSource::DeallocateDeviceData()
|
|||
|
||||
SurfaceTextureHost::SurfaceTextureHost(TextureFlags aFlags,
|
||||
mozilla::java::GeckoSurfaceTexture::Ref& aSurfTex,
|
||||
gfx::IntSize aSize)
|
||||
gfx::IntSize aSize,
|
||||
bool aContinuousUpdate)
|
||||
: TextureHost(aFlags)
|
||||
, mSurfTex(aSurfTex)
|
||||
, mSize(aSize)
|
||||
, mContinuousUpdate(aContinuousUpdate)
|
||||
{
|
||||
// Continuous update makes no sense with single buffer mode
|
||||
MOZ_ASSERT(!mSurfTex->IsSingleBuffer() || !mContinuousUpdate);
|
||||
}
|
||||
|
||||
SurfaceTextureHost::~SurfaceTextureHost()
|
||||
|
@ -430,9 +435,13 @@ SurfaceTextureHost::PrepareTextureSource(CompositableTextureSourceRef& aTexture)
|
|||
return;
|
||||
}
|
||||
|
||||
// This advances the SurfaceTexture's internal buffer queue. We only want to do this
|
||||
// once per transaction. We can then composite that texture as many times as needed.
|
||||
mSurfTex->UpdateTexImage();
|
||||
if (!mContinuousUpdate) {
|
||||
// UpdateTexImage() advances the internal buffer queue, so we only want to call this
|
||||
// once per transactionwhen we are not in continuous mode (as we are here). Otherwise,
|
||||
// the SurfaceTexture content will be de-synced from the rest of the page in subsequent
|
||||
// compositor passes.
|
||||
mSurfTex->UpdateTexImage();
|
||||
}
|
||||
}
|
||||
|
||||
gl::GLContext*
|
||||
|
@ -450,6 +459,10 @@ SurfaceTextureHost::Lock()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mContinuousUpdate) {
|
||||
mSurfTex->UpdateTexImage();
|
||||
}
|
||||
|
||||
if (!mTextureSource) {
|
||||
gfx::SurfaceFormat format = gfx::SurfaceFormat::R8G8B8A8;
|
||||
GLenum target = LOCAL_GL_TEXTURE_EXTERNAL; // This is required by SurfaceTexture
|
||||
|
|
|
@ -389,7 +389,8 @@ class SurfaceTextureHost : public TextureHost
|
|||
public:
|
||||
SurfaceTextureHost(TextureFlags aFlags,
|
||||
mozilla::java::GeckoSurfaceTexture::Ref& aSurfTex,
|
||||
gfx::IntSize aSize);
|
||||
gfx::IntSize aSize,
|
||||
bool aContinuousUpdate);
|
||||
|
||||
virtual ~SurfaceTextureHost();
|
||||
|
||||
|
@ -425,6 +426,7 @@ public:
|
|||
protected:
|
||||
mozilla::java::GeckoSurfaceTexture::GlobalRef mSurfTex;
|
||||
const gfx::IntSize mSize;
|
||||
bool mContinuousUpdate;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
RefPtr<SurfaceTextureSource> mTextureSource;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче