2017-01-20 05:26:13 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
#include "AsyncImagePipelineManager.h"
|
2017-01-20 05:26:13 +03:00
|
|
|
|
|
|
|
#include "CompositableHost.h"
|
2017-07-17 08:38:22 +03:00
|
|
|
#include "gfxEnv.h"
|
2017-06-02 10:11:34 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2017-03-07 13:37:28 +03:00
|
|
|
#include "mozilla/layers/WebRenderImageHost.h"
|
|
|
|
#include "mozilla/layers/WebRenderTextureHost.h"
|
2017-05-17 03:28:20 +03:00
|
|
|
#include "mozilla/webrender/WebRenderAPI.h"
|
2017-09-26 16:30:55 +03:00
|
|
|
#include "mozilla/webrender/WebRenderTypes.h"
|
2017-01-20 05:26:13 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::AsyncImagePipeline::AsyncImagePipeline()
|
2017-06-02 10:11:53 +03:00
|
|
|
: mInitialised(false)
|
|
|
|
, mIsChanged(false)
|
2017-06-05 10:30:10 +03:00
|
|
|
, mUseExternalImage(false)
|
2017-07-19 10:28:58 +03:00
|
|
|
, mFilter(wr::ImageRendering::Auto)
|
|
|
|
, mMixBlendMode(wr::MixBlendMode::Normal)
|
2017-06-02 10:11:53 +03:00
|
|
|
{}
|
|
|
|
|
2017-08-09 15:46:25 +03:00
|
|
|
AsyncImagePipelineManager::AsyncImagePipelineManager(already_AddRefed<wr::WebRenderAPI>&& aApi)
|
|
|
|
: mApi(aApi)
|
|
|
|
, mIdNamespace(mApi->GetNamespace())
|
2017-05-09 11:19:48 +03:00
|
|
|
, mResourceId(0)
|
2017-06-02 10:11:34 +03:00
|
|
|
, mAsyncImageEpoch(0)
|
|
|
|
, mDestroyed(false)
|
2017-01-20 05:26:13 +03:00
|
|
|
{
|
2017-07-25 11:54:36 +03:00
|
|
|
MOZ_COUNT_CTOR(AsyncImagePipelineManager);
|
2017-01-20 05:26:13 +03:00
|
|
|
}
|
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::~AsyncImagePipelineManager()
|
2017-01-20 05:26:13 +03:00
|
|
|
{
|
2017-07-25 11:54:36 +03:00
|
|
|
MOZ_COUNT_DTOR(AsyncImagePipelineManager);
|
2017-01-20 05:26:13 +03:00
|
|
|
}
|
|
|
|
|
2017-06-02 10:11:34 +03:00
|
|
|
void
|
2017-08-09 15:46:25 +03:00
|
|
|
AsyncImagePipelineManager::Destroy()
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
2017-08-09 15:46:25 +03:00
|
|
|
MOZ_ASSERT(!mDestroyed);
|
|
|
|
mApi = nullptr;
|
2017-06-02 10:11:34 +03:00
|
|
|
mDestroyed = true;
|
|
|
|
}
|
|
|
|
|
2017-01-20 05:26:13 +03:00
|
|
|
void
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::AddPipeline(const wr::PipelineId& aPipelineId)
|
2017-01-20 05:26:13 +03:00
|
|
|
{
|
2017-06-02 10:11:34 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
2017-03-22 04:27:38 +03:00
|
|
|
uint64_t id = wr::AsUint64(aPipelineId);
|
|
|
|
|
2017-06-30 04:06:11 +03:00
|
|
|
PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
|
|
|
|
if(holder) {
|
|
|
|
// This could happen during tab move between different windows.
|
|
|
|
// Previously removed holder could be still alive for waiting destroyed.
|
|
|
|
MOZ_ASSERT(holder->mDestroyedEpoch.isSome());
|
|
|
|
holder->mDestroyedEpoch = Nothing(); // Revive holder
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
holder = new PipelineTexturesHolder();
|
2017-03-22 04:27:38 +03:00
|
|
|
mPipelineTexturesHolders.Put(id, holder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::RemovePipeline(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch)
|
2017-03-22 04:27:38 +03:00
|
|
|
{
|
2017-06-02 10:11:34 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-17 03:28:20 +03:00
|
|
|
PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
|
|
|
|
MOZ_ASSERT(holder);
|
|
|
|
if (!holder) {
|
|
|
|
return;
|
2017-03-07 13:37:28 +03:00
|
|
|
}
|
2017-05-17 03:28:20 +03:00
|
|
|
holder->mDestroyedEpoch = Some(aEpoch);
|
2017-01-20 05:26:13 +03:00
|
|
|
}
|
|
|
|
|
2017-06-02 10:11:34 +03:00
|
|
|
void
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::AddAsyncImagePipeline(const wr::PipelineId& aPipelineId, WebRenderImageHost* aImageHost)
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(aImageHost);
|
|
|
|
uint64_t id = wr::AsUint64(aPipelineId);
|
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
MOZ_ASSERT(!mAsyncImagePipelines.Get(id));
|
|
|
|
AsyncImagePipeline* holder = new AsyncImagePipeline();
|
2017-06-02 10:11:34 +03:00
|
|
|
holder->mImageHost = aImageHost;
|
2017-07-25 11:54:36 +03:00
|
|
|
mAsyncImagePipelines.Put(id, holder);
|
2017-06-02 10:11:34 +03:00
|
|
|
AddPipeline(aPipelineId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-08-09 15:46:25 +03:00
|
|
|
AsyncImagePipelineManager::RemoveAsyncImagePipeline(const wr::PipelineId& aPipelineId)
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t id = wr::AsUint64(aPipelineId);
|
2017-07-25 11:54:36 +03:00
|
|
|
if (auto entry = mAsyncImagePipelines.Lookup(id)) {
|
|
|
|
AsyncImagePipeline* holder = entry.Data();
|
2017-06-28 02:03:16 +03:00
|
|
|
++mAsyncImageEpoch; // Update webrender epoch
|
2017-09-04 14:59:12 +03:00
|
|
|
mApi->ClearDisplayList(wr::NewEpoch(mAsyncImageEpoch), aPipelineId);
|
2017-09-04 14:59:42 +03:00
|
|
|
wr::ResourceUpdateQueue resources;
|
2017-06-28 02:03:16 +03:00
|
|
|
for (wr::ImageKey key : holder->mKeys) {
|
2017-09-04 14:59:42 +03:00
|
|
|
resources.DeleteImage(key);
|
2017-06-28 02:03:16 +03:00
|
|
|
}
|
2017-09-04 14:59:42 +03:00
|
|
|
mApi->UpdateResources(resources);
|
2017-06-28 02:03:16 +03:00
|
|
|
entry.Remove();
|
|
|
|
RemovePipeline(aPipelineId, wr::NewEpoch(mAsyncImageEpoch));
|
2017-06-02 10:11:53 +03:00
|
|
|
}
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::UpdateAsyncImagePipeline(const wr::PipelineId& aPipelineId,
|
2017-10-19 05:25:11 +03:00
|
|
|
const LayoutDeviceRect& aScBounds,
|
2017-07-25 11:54:36 +03:00
|
|
|
const gfx::Matrix4x4& aScTransform,
|
|
|
|
const gfx::MaybeIntSize& aScaleToSize,
|
|
|
|
const wr::ImageRendering& aFilter,
|
|
|
|
const wr::MixBlendMode& aMixBlendMode)
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipeline* pipeline = mAsyncImagePipelines.Get(wr::AsUint64(aPipelineId));
|
|
|
|
if (!pipeline) {
|
2017-06-02 10:11:34 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-07-25 11:54:36 +03:00
|
|
|
pipeline->mInitialised = true;
|
|
|
|
pipeline->mIsChanged = true;
|
|
|
|
pipeline->mScBounds = aScBounds;
|
|
|
|
pipeline->mScTransform = aScTransform;
|
|
|
|
pipeline->mScaleToSize = aScaleToSize;
|
|
|
|
pipeline->mFilter = aFilter;
|
|
|
|
pipeline->mMixBlendMode = aMixBlendMode;
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
Maybe<TextureHost::ResourceUpdateOp>
|
|
|
|
AsyncImagePipelineManager::UpdateImageKeys(wr::ResourceUpdateQueue& aResources,
|
|
|
|
AsyncImagePipeline* aPipeline,
|
2017-09-26 16:31:08 +03:00
|
|
|
nsTArray<wr::ImageKey>& aKeys)
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aKeys.IsEmpty());
|
2017-09-26 16:30:55 +03:00
|
|
|
MOZ_ASSERT(aPipeline);
|
|
|
|
if (!aPipeline->mInitialised) {
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureHost* texture = aPipeline->mImageHost->GetAsTextureHostForComposite();
|
|
|
|
TextureHost* previousTexture = aPipeline->mCurrentTexture.get();
|
|
|
|
|
|
|
|
if (!aPipeline->mIsChanged && texture == previousTexture) {
|
|
|
|
// The texture has not changed, just reuse previous ImageKeys.
|
|
|
|
// No need to update DisplayList.
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!texture) {
|
|
|
|
// We don't have a new texture, there isn't much we can do.
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
aPipeline->mIsChanged = false;
|
|
|
|
aPipeline->mCurrentTexture = texture;
|
|
|
|
|
|
|
|
WebRenderTextureHost* wrTexture = texture->AsWebRenderTextureHost();
|
|
|
|
|
|
|
|
bool useExternalImage = !gfxEnv::EnableWebRenderRecording() && wrTexture;
|
|
|
|
aPipeline->mUseExternalImage = useExternalImage;
|
|
|
|
|
|
|
|
// The non-external image code path falls back to converting the texture into
|
|
|
|
// an rgb image.
|
|
|
|
auto numKeys = useExternalImage ? texture->NumSubTextures() : 1;
|
2017-06-02 10:11:34 +03:00
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
// If we already had a texture and the format hasn't changed, better to reuse the image keys
|
|
|
|
// than create new ones.
|
|
|
|
bool canUpdate = !!previousTexture
|
|
|
|
&& previousTexture->GetFormat() == texture->GetFormat()
|
|
|
|
&& aPipeline->mKeys.Length() == numKeys;
|
2017-06-02 10:11:34 +03:00
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
if (!canUpdate) {
|
2017-09-26 16:31:08 +03:00
|
|
|
for (auto key : aPipeline->mKeys) {
|
|
|
|
aResources.DeleteImage(key);
|
|
|
|
}
|
2017-09-26 16:30:55 +03:00
|
|
|
aPipeline->mKeys.Clear();
|
2017-09-26 16:30:46 +03:00
|
|
|
for (uint32_t i = 0; i < numKeys; ++i) {
|
2017-09-26 16:30:55 +03:00
|
|
|
aPipeline->mKeys.AppendElement(GenerateImageKey());
|
2017-09-26 16:30:46 +03:00
|
|
|
}
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
aKeys = aPipeline->mKeys;
|
2017-06-02 10:11:53 +03:00
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
auto op = canUpdate ? TextureHost::UPDATE_IMAGE : TextureHost::ADD_IMAGE;
|
2017-06-02 10:11:53 +03:00
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
if (!useExternalImage) {
|
|
|
|
return UpdateWithoutExternalImage(aResources, texture, aKeys[0], op);
|
2017-06-02 10:11:53 +03:00
|
|
|
}
|
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
Range<wr::ImageKey> keys(&aKeys[0], aKeys.Length());
|
|
|
|
wrTexture->PushResourceUpdates(aResources, op, keys, wrTexture->GetExternalImageKey());
|
|
|
|
|
|
|
|
return Some(op);
|
|
|
|
}
|
2017-06-02 10:11:53 +03:00
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
Maybe<TextureHost::ResourceUpdateOp>
|
|
|
|
AsyncImagePipelineManager::UpdateWithoutExternalImage(wr::ResourceUpdateQueue& aResources,
|
|
|
|
TextureHost* aTexture,
|
|
|
|
wr::ImageKey aKey,
|
|
|
|
TextureHost::ResourceUpdateOp aOp)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aTexture);
|
|
|
|
|
|
|
|
RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
|
|
|
|
if (!dSurf) {
|
|
|
|
NS_ERROR("TextureHost does not return DataSourceSurface");
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
gfx::DataSourceSurface::MappedSurface map;
|
|
|
|
if (!dSurf->Map(gfx::DataSourceSurface::MapType::READ, &map)) {
|
|
|
|
NS_ERROR("DataSourceSurface failed to map");
|
|
|
|
return Nothing();
|
2017-06-02 10:11:53 +03:00
|
|
|
}
|
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
gfx::IntSize size = dSurf->GetSize();
|
|
|
|
wr::ImageDescriptor descriptor(size, map.mStride, dSurf->GetFormat());
|
2017-06-02 10:11:53 +03:00
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
// Costly copy right here...
|
|
|
|
wr::Vec_u8 bytes;
|
|
|
|
bytes.PushBytes(Range<uint8_t>(map.mData, size.height * map.mStride));
|
|
|
|
|
|
|
|
if (aOp == TextureHost::UPDATE_IMAGE) {
|
|
|
|
aResources.UpdateImageBuffer(aKey, descriptor, bytes);
|
|
|
|
} else {
|
|
|
|
aResources.AddImage(aKey, descriptor, bytes);
|
2017-06-02 10:11:53 +03:00
|
|
|
}
|
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
dSurf->Unmap();
|
|
|
|
|
|
|
|
return Some(aOp);
|
2017-06-02 10:11:53 +03:00
|
|
|
}
|
|
|
|
|
2017-06-02 10:11:34 +03:00
|
|
|
void
|
2017-08-09 15:46:25 +03:00
|
|
|
AsyncImagePipelineManager::ApplyAsyncImages()
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
2017-07-25 11:54:36 +03:00
|
|
|
if (mDestroyed || mAsyncImagePipelines.Count() == 0) {
|
2017-06-02 10:11:34 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-06-02 10:11:53 +03:00
|
|
|
|
2017-06-02 10:11:34 +03:00
|
|
|
++mAsyncImageEpoch; // Update webrender epoch
|
|
|
|
wr::Epoch epoch = wr::NewEpoch(mAsyncImageEpoch);
|
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
// We use a pipeline with a very small display list for each video element.
|
|
|
|
// Update each of them if needed.
|
2017-07-25 11:54:36 +03:00
|
|
|
for (auto iter = mAsyncImagePipelines.Iter(); !iter.Done(); iter.Next()) {
|
2017-09-26 16:30:55 +03:00
|
|
|
wr::ResourceUpdateQueue resourceUpdates;
|
2017-06-02 10:11:34 +03:00
|
|
|
wr::PipelineId pipelineId = wr::AsPipelineId(iter.Key());
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipeline* pipeline = iter.Data();
|
2017-06-02 10:11:34 +03:00
|
|
|
|
2017-06-02 10:11:53 +03:00
|
|
|
nsTArray<wr::ImageKey> keys;
|
2017-09-26 16:31:08 +03:00
|
|
|
auto op = UpdateImageKeys(resourceUpdates, pipeline, keys);
|
2017-09-26 16:30:55 +03:00
|
|
|
|
|
|
|
if (op != Some(TextureHost::ADD_IMAGE)) {
|
|
|
|
// We don't need to update the display list, either because we can't or because
|
|
|
|
// the previous one is still up to date.
|
|
|
|
// We may, however, have updated some resources.
|
2017-10-20 17:42:53 +03:00
|
|
|
mApi->UpdatePipelineResources(resourceUpdates, pipelineId, epoch);
|
|
|
|
if (pipeline->mCurrentTexture) {
|
|
|
|
HoldExternalImage(pipelineId, epoch, pipeline->mCurrentTexture->AsWebRenderTextureHost());
|
|
|
|
}
|
2017-06-02 10:11:53 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-08-14 15:29:28 +03:00
|
|
|
wr::LayoutSize contentSize { pipeline->mScBounds.Width(), pipeline->mScBounds.Height() };
|
2017-06-02 10:11:34 +03:00
|
|
|
wr::DisplayListBuilder builder(pipelineId, contentSize);
|
|
|
|
|
2017-09-26 16:30:55 +03:00
|
|
|
MOZ_ASSERT(!keys.IsEmpty());
|
|
|
|
MOZ_ASSERT(pipeline->mCurrentTexture.get());
|
|
|
|
|
|
|
|
float opacity = 1.0f;
|
|
|
|
builder.PushStackingContext(wr::ToLayoutRect(pipeline->mScBounds),
|
|
|
|
0,
|
|
|
|
&opacity,
|
|
|
|
pipeline->mScTransform.IsIdentity() ? nullptr : &pipeline->mScTransform,
|
|
|
|
wr::TransformStyle::Flat,
|
|
|
|
nullptr,
|
|
|
|
pipeline->mMixBlendMode,
|
|
|
|
nsTArray<wr::WrFilterOp>(),
|
|
|
|
true);
|
|
|
|
|
2017-10-19 05:25:11 +03:00
|
|
|
LayoutDeviceRect rect(0, 0, pipeline->mCurrentTexture->GetSize().width, pipeline->mCurrentTexture->GetSize().height);
|
2017-09-26 16:30:55 +03:00
|
|
|
if (pipeline->mScaleToSize.isSome()) {
|
2017-10-19 05:25:11 +03:00
|
|
|
rect = LayoutDeviceRect(0, 0, pipeline->mScaleToSize.value().width, pipeline->mScaleToSize.value().height);
|
2017-09-26 16:30:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pipeline->mUseExternalImage) {
|
|
|
|
MOZ_ASSERT(pipeline->mCurrentTexture->AsWebRenderTextureHost());
|
2017-09-26 16:31:00 +03:00
|
|
|
Range<wr::ImageKey> range_keys(&keys[0], keys.Length());
|
|
|
|
pipeline->mCurrentTexture->PushDisplayItems(builder,
|
|
|
|
wr::ToLayoutRect(rect),
|
|
|
|
wr::ToLayoutRect(rect),
|
|
|
|
pipeline->mFilter,
|
|
|
|
range_keys);
|
2017-09-26 16:30:55 +03:00
|
|
|
HoldExternalImage(pipelineId, epoch, pipeline->mCurrentTexture->AsWebRenderTextureHost());
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(keys.Length() == 1);
|
|
|
|
builder.PushImage(wr::ToLayoutRect(rect),
|
|
|
|
wr::ToLayoutRect(rect),
|
|
|
|
true,
|
|
|
|
pipeline->mFilter,
|
|
|
|
keys[0]);
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
2017-09-26 16:30:55 +03:00
|
|
|
builder.PopStackingContext();
|
2017-06-02 10:11:34 +03:00
|
|
|
|
|
|
|
wr::BuiltDisplayList dl;
|
2017-07-19 01:32:46 +03:00
|
|
|
wr::LayoutSize builderContentSize;
|
2017-06-02 10:11:34 +03:00
|
|
|
builder.Finalize(builderContentSize, dl);
|
2017-09-04 14:59:12 +03:00
|
|
|
mApi->SetDisplayList(gfx::Color(0.f, 0.f, 0.f, 0.f), epoch, LayerSize(pipeline->mScBounds.Width(), pipeline->mScBounds.Height()),
|
|
|
|
pipelineId, builderContentSize,
|
2017-09-04 14:59:42 +03:00
|
|
|
dl.dl_desc, dl.dl.inner.data, dl.dl.inner.length,
|
|
|
|
resourceUpdates);
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-20 05:26:13 +03:00
|
|
|
void
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::HoldExternalImage(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, WebRenderTextureHost* aTexture)
|
2017-01-20 05:26:13 +03:00
|
|
|
{
|
2017-06-02 10:11:34 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
2017-03-07 13:37:28 +03:00
|
|
|
MOZ_ASSERT(aTexture);
|
2017-05-17 03:28:20 +03:00
|
|
|
|
2017-03-22 04:27:38 +03:00
|
|
|
PipelineTexturesHolder* holder = mPipelineTexturesHolders.Get(wr::AsUint64(aPipelineId));
|
|
|
|
MOZ_ASSERT(holder);
|
|
|
|
if (!holder) {
|
|
|
|
return;
|
|
|
|
}
|
2017-03-07 13:37:28 +03:00
|
|
|
// Hold WebRenderTextureHost until end of its usage on RenderThread
|
2017-03-22 04:27:38 +03:00
|
|
|
holder->mTextureHosts.push(ForwardingTextureHost(aEpoch, aTexture));
|
2017-01-20 05:26:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::Update(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch)
|
2017-01-20 05:26:13 +03:00
|
|
|
{
|
2017-06-02 10:11:34 +03:00
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
2017-06-28 02:03:16 +03:00
|
|
|
if (auto entry = mPipelineTexturesHolders.Lookup(wr::AsUint64(aPipelineId))) {
|
|
|
|
PipelineTexturesHolder* holder = entry.Data();
|
|
|
|
// Remove Pipeline
|
|
|
|
if (holder->mDestroyedEpoch.isSome() && holder->mDestroyedEpoch.ref() <= aEpoch) {
|
|
|
|
entry.Remove();
|
|
|
|
return;
|
|
|
|
}
|
2017-03-22 04:27:38 +03:00
|
|
|
|
2017-06-28 02:03:16 +03:00
|
|
|
// Release TextureHosts based on Epoch
|
|
|
|
while (!holder->mTextureHosts.empty()) {
|
|
|
|
if (aEpoch <= holder->mTextureHosts.front().mEpoch) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
holder->mTextureHosts.pop();
|
2017-03-07 13:37:28 +03:00
|
|
|
}
|
2017-01-20 05:26:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|