Bug 1372803 - Move the RenderTextureHost creation from WebRenderTextureHost to the corresponding TextureHost. r=sotaro

MozReview-Commit-ID: JF19ntiQKfa
This commit is contained in:
JerryShih 2017-06-15 17:07:46 +08:00
Родитель 6175226606
Коммит 8731715817
5 изменённых файлов: 39 добавлений и 16 удалений

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

@ -22,6 +22,8 @@
#include "mozilla/layers/TextureClient.h"
#include "mozilla/layers/GPUVideoTextureHost.h"
#include "mozilla/layers/WebRenderTextureHost.h"
#include "mozilla/webrender/RenderBufferTextureHost.h"
#include "mozilla/webrender/RenderThread.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "nsAString.h"
#include "mozilla/RefPtr.h" // for nsRefPtr
@ -556,6 +558,15 @@ BufferTextureHost::Unlock()
mLocked = false;
}
void
BufferTextureHost::CreateRenderTexture(const wr::ExternalImageId& aExternalImageId)
{
RefPtr<wr::RenderTextureHost> texture =
new wr::RenderBufferTextureHost(GetBuffer(), GetBufferDescriptor());
wr::RenderThread::Get()->RegisterExternalImage(wr::AsUint64(aExternalImageId), texture.forget());
}
void
BufferTextureHost::GetWRImageKeys(nsTArray<wr::ImageKey>& aImageKeys,
const std::function<wr::ImageKey()>& aImageKeyAllocator)

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

@ -598,6 +598,13 @@ public:
virtual MacIOSurfaceTextureHostOGL* AsMacIOSurfaceTextureHost() { return nullptr; }
virtual WebRenderTextureHost* AsWebRenderTextureHost() { return nullptr; }
// Create the corresponding RenderTextureHost type of this texture, and
// register the RenderTextureHost into render thread.
virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId)
{
MOZ_ASSERT_UNREACHABLE("No CreateRenderTexture() implementation for this TextureHost type.");
}
// Create all necessary image keys for this textureHost rendering.
// @param aImageKeys - [out] The set of ImageKeys used for this textureHost
// composing.
@ -716,6 +723,8 @@ public:
const BufferDescriptor& GetBufferDescriptor() const { return mDescriptor; }
virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId) override;
virtual void GetWRImageKeys(nsTArray<wr::ImageKey>& aImageKeys,
const std::function<wr::ImageKey()>& aImageKeyAllocator) override;

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

@ -5,6 +5,8 @@
#include "MacIOSurfaceTextureHostOGL.h"
#include "mozilla/gfx/MacIOSurface.h"
#include "mozilla/webrender/RenderMacIOSurfaceTextureHostOGL.h"
#include "mozilla/webrender/RenderThread.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "GLContextCGL.h"
@ -114,6 +116,15 @@ MacIOSurfaceTextureHostOGL::gl() const
return mProvider ? mProvider->GetGLContext() : nullptr;
}
void
MacIOSurfaceTextureHostOGL::CreateRenderTexture(const wr::ExternalImageId& aExternalImageId)
{
RefPtr<wr::RenderTextureHost> texture =
new wr::RenderMacIOSurfaceTextureHostOGL(GetMacIOSurface());
wr::RenderThread::Get()->RegisterExternalImage(wr::AsUint64(aExternalImageId), texture.forget());
}
void
MacIOSurfaceTextureHostOGL::GetWRImageKeys(nsTArray<wr::ImageKey>& aImageKeys,
const std::function<wr::ImageKey()>& aImageKeyAllocator)

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

@ -62,6 +62,8 @@ public:
return mSurface;
}
virtual void CreateRenderTexture(const wr::ExternalImageId& aExternalImageId) override;
virtual void GetWRImageKeys(nsTArray<wr::ImageKey>& aImageKeys,
const std::function<wr::ImageKey()>& aImageKeyAllocator) override;

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

@ -7,15 +7,8 @@
#include "mozilla/layers/ImageDataSerializer.h"
#include "mozilla/layers/LayersSurfaces.h"
#include "mozilla/webrender/RenderBufferTextureHost.h"
#include "mozilla/webrender/RenderTextureHost.h"
#include "mozilla/webrender/RenderThread.h"
#ifdef XP_MACOSX
#include "mozilla/layers/MacIOSurfaceTextureHostOGL.h"
#include "mozilla/webrender/RenderMacIOSurfaceTextureHostOGL.h"
#endif
namespace mozilla {
namespace layers {
@ -52,22 +45,15 @@ void
WebRenderTextureHost::CreateRenderTextureHost(const layers::SurfaceDescriptor& aDesc,
TextureHost* aTexture)
{
RefPtr<wr::RenderTextureHost> texture;
MOZ_ASSERT(aTexture);
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorBuffer: {
BufferTextureHost* bufferTexture = aTexture->AsBufferTextureHost();
MOZ_ASSERT(bufferTexture);
texture = new wr::RenderBufferTextureHost(bufferTexture->GetBuffer(),
bufferTexture->GetBufferDescriptor());
mIsWrappingNativeHandle = false;
break;
}
#ifdef XP_MACOSX
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: {
MacIOSurfaceTextureHostOGL* macTexture = aTexture->AsMacIOSurfaceTextureHost();
MOZ_ASSERT(macTexture);
texture = new wr::RenderMacIOSurfaceTextureHostOGL(macTexture->GetMacIOSurface());
mIsWrappingNativeHandle = true;
break;
}
@ -76,7 +62,7 @@ WebRenderTextureHost::CreateRenderTextureHost(const layers::SurfaceDescriptor& a
gfxCriticalError() << "No WR implement for texture type:" << aDesc.type();
}
wr::RenderThread::Get()->RegisterExternalImage(wr::AsUint64(mExternalImageId), texture.forget());
aTexture->CreateRenderTexture(mExternalImageId);
}
bool
@ -169,7 +155,9 @@ void
WebRenderTextureHost::GetWRImageKeys(nsTArray<wr::ImageKey>& aImageKeys,
const std::function<wr::ImageKey()>& aImageKeyAllocator)
{
MOZ_ASSERT(mWrappedTextureHost);
MOZ_ASSERT(aImageKeys.IsEmpty());
mWrappedTextureHost->GetWRImageKeys(aImageKeys, aImageKeyAllocator);
}
@ -191,7 +179,9 @@ WebRenderTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys)
{
MOZ_ASSERT(mWrappedTextureHost);
MOZ_ASSERT(aImageKeys.length() > 0);
mWrappedTextureHost->PushExternalImage(aBuilder,
aBounds,
aClip,