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-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);
|
|
|
|
DeleteOldAsyncImages();
|
|
|
|
mApi = nullptr;
|
2017-06-02 10:11:34 +03:00
|
|
|
mDestroyed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipelineManager::HasKeysToDelete()
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
|
|
|
return !mKeysToDelete.IsEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-08-09 15:46:25 +03:00
|
|
|
AsyncImagePipelineManager::DeleteOldAsyncImages()
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
2017-08-09 15:46:25 +03:00
|
|
|
MOZ_ASSERT(!mDestroyed);
|
2017-06-02 10:11:34 +03:00
|
|
|
for (wr::ImageKey key : mKeysToDelete) {
|
2017-08-09 15:46:25 +03:00
|
|
|
mApi->DeleteImage(key);
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
|
|
|
mKeysToDelete.Clear();
|
|
|
|
}
|
|
|
|
|
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-08-09 15:46:25 +03:00
|
|
|
mApi->ClearRootDisplayList(wr::NewEpoch(mAsyncImageEpoch), aPipelineId);
|
2017-06-28 02:03:16 +03:00
|
|
|
for (wr::ImageKey key : holder->mKeys) {
|
2017-08-09 15:46:25 +03:00
|
|
|
mApi->DeleteImage(key);
|
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,
|
|
|
|
const LayerRect& aScBounds,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-08-09 15:46:25 +03:00
|
|
|
AsyncImagePipelineManager::GenerateImageKeyForTextureHost(TextureHost* aTexture, nsTArray<wr::ImageKey>& aKeys)
|
2017-06-02 10:11:34 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aKeys.IsEmpty());
|
2017-06-02 10:11:53 +03:00
|
|
|
MOZ_ASSERT(aTexture);
|
2017-06-02 10:11:34 +03:00
|
|
|
|
|
|
|
WebRenderTextureHost* wrTexture = aTexture->AsWebRenderTextureHost();
|
|
|
|
|
2017-07-17 08:38:22 +03:00
|
|
|
if (!gfxEnv::EnableWebRenderRecording() && wrTexture) {
|
2017-07-25 11:54:36 +03:00
|
|
|
wrTexture->GetWRImageKeys(aKeys, std::bind(&AsyncImagePipelineManager::GenerateImageKey, this));
|
2017-06-02 10:11:34 +03:00
|
|
|
MOZ_ASSERT(!aKeys.IsEmpty());
|
|
|
|
Range<const wr::ImageKey> keys(&aKeys[0], aKeys.Length());
|
2017-08-09 15:46:25 +03:00
|
|
|
wrTexture->AddWRImage(mApi, keys, wrTexture->GetExternalImageKey());
|
2017-06-02 10:11:34 +03:00
|
|
|
return true;
|
|
|
|
} else {
|
2017-06-07 18:44:03 +03:00
|
|
|
RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
|
2017-06-02 10:11:34 +03:00
|
|
|
if (!dSurf) {
|
|
|
|
NS_ERROR("TextureHost does not return DataSourceSurface");
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-07 18:44:03 +03:00
|
|
|
gfx::DataSourceSurface::MappedSurface map;
|
2017-06-02 10:11:34 +03:00
|
|
|
if (!dSurf->Map(gfx::DataSourceSurface::MapType::READ, &map)) {
|
|
|
|
NS_ERROR("DataSourceSurface failed to map");
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-07 18:44:03 +03:00
|
|
|
gfx::IntSize size = dSurf->GetSize();
|
2017-06-02 10:11:34 +03:00
|
|
|
wr::ImageDescriptor descriptor(size, map.mStride, dSurf->GetFormat());
|
|
|
|
auto slice = Range<uint8_t>(map.mData, size.height * map.mStride);
|
|
|
|
|
2017-07-25 11:54:20 +03:00
|
|
|
wr::ImageKey key = GenerateImageKey();
|
2017-06-02 10:11:34 +03:00
|
|
|
aKeys.AppendElement(key);
|
2017-08-09 15:46:25 +03:00
|
|
|
mApi->AddImage(key, descriptor, slice);
|
2017-06-02 10:11:34 +03:00
|
|
|
dSurf->Unmap();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-02 10:11:53 +03:00
|
|
|
bool
|
2017-08-09 15:46:25 +03:00
|
|
|
AsyncImagePipelineManager::UpdateImageKeys(bool& aUseExternalImage,
|
2017-07-25 11:54:36 +03:00
|
|
|
AsyncImagePipeline* aImageMgr,
|
|
|
|
nsTArray<wr::ImageKey>& aKeys,
|
|
|
|
nsTArray<wr::ImageKey>& aKeysToDelete)
|
2017-06-02 10:11:53 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aKeys.IsEmpty());
|
2017-07-25 11:54:36 +03:00
|
|
|
MOZ_ASSERT(aImageMgr);
|
|
|
|
TextureHost* texture = aImageMgr->mImageHost->GetAsTextureHostForComposite();
|
2017-06-02 10:11:53 +03:00
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
if (!aImageMgr->mInitialised) {
|
2017-06-02 10:11:53 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// No change
|
2017-07-25 11:54:36 +03:00
|
|
|
if (!aImageMgr->mIsChanged && texture == aImageMgr->mCurrentTexture) {
|
2017-06-02 10:11:53 +03:00
|
|
|
// No need to update DisplayList.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
aImageMgr->mIsChanged = false;
|
2017-06-02 10:11:53 +03:00
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
if (texture == aImageMgr->mCurrentTexture) {
|
2017-06-02 10:11:53 +03:00
|
|
|
// Reuse previous ImageKeys.
|
2017-07-25 11:54:36 +03:00
|
|
|
aKeys.AppendElements(aImageMgr->mKeys);
|
|
|
|
aUseExternalImage = aImageMgr->mUseExternalImage;
|
2017-06-02 10:11:53 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete old ImageKeys
|
2017-07-25 11:54:36 +03:00
|
|
|
aKeysToDelete.AppendElements(aImageMgr->mKeys);
|
|
|
|
aImageMgr->mKeys.Clear();
|
|
|
|
aImageMgr->mCurrentTexture = nullptr;
|
2017-06-02 10:11:53 +03:00
|
|
|
|
|
|
|
// No txture to render
|
|
|
|
if (!texture) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-08-09 15:46:25 +03:00
|
|
|
aUseExternalImage = aImageMgr->mUseExternalImage = GenerateImageKeyForTextureHost(texture, aKeys);
|
2017-06-02 10:11:53 +03:00
|
|
|
MOZ_ASSERT(!aKeys.IsEmpty());
|
2017-07-25 11:54:36 +03:00
|
|
|
aImageMgr->mKeys.AppendElements(aKeys);
|
|
|
|
aImageMgr->mCurrentTexture = texture;
|
2017-06-02 10:11:53 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
nsTArray<wr::ImageKey> keysToDelete;
|
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
for (auto iter = mAsyncImagePipelines.Iter(); !iter.Done(); iter.Next()) {
|
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;
|
|
|
|
bool useExternalImage = false;
|
2017-08-09 15:46:25 +03:00
|
|
|
bool updateDisplayList = UpdateImageKeys(useExternalImage,
|
2017-07-25 11:54:36 +03:00
|
|
|
pipeline,
|
2017-06-02 10:11:53 +03:00
|
|
|
keys,
|
|
|
|
keysToDelete);
|
|
|
|
if (!updateDisplayList) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
wr::LayoutSize contentSize { pipeline->mScBounds.width, pipeline->mScBounds.height };
|
2017-06-02 10:11:34 +03:00
|
|
|
wr::DisplayListBuilder builder(pipelineId, contentSize);
|
|
|
|
|
|
|
|
if (!keys.IsEmpty()) {
|
2017-07-25 11:54:36 +03:00
|
|
|
MOZ_ASSERT(pipeline->mCurrentTexture.get());
|
2017-06-02 10:11:53 +03:00
|
|
|
|
|
|
|
float opacity = 1.0f;
|
2017-07-25 11:54:36 +03:00
|
|
|
builder.PushStackingContext(wr::ToLayoutRect(pipeline->mScBounds),
|
2017-06-02 10:11:53 +03:00
|
|
|
0,
|
|
|
|
&opacity,
|
2017-07-25 11:54:36 +03:00
|
|
|
pipeline->mScTransform.IsIdentity() ? nullptr : &pipeline->mScTransform,
|
2017-07-19 10:28:58 +03:00
|
|
|
wr::TransformStyle::Flat,
|
2017-07-25 11:54:36 +03:00
|
|
|
pipeline->mMixBlendMode,
|
2017-06-28 02:20:36 +03:00
|
|
|
nsTArray<wr::WrFilterOp>());
|
2017-06-02 10:11:53 +03:00
|
|
|
|
2017-07-25 11:54:36 +03:00
|
|
|
LayerRect rect(0, 0, pipeline->mCurrentTexture->GetSize().width, pipeline->mCurrentTexture->GetSize().height);
|
|
|
|
if (pipeline->mScaleToSize.isSome()) {
|
|
|
|
rect = LayerRect(0, 0, pipeline->mScaleToSize.value().width, pipeline->mScaleToSize.value().height);
|
2017-06-02 10:11:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (useExternalImage) {
|
2017-07-25 11:54:36 +03:00
|
|
|
MOZ_ASSERT(pipeline->mCurrentTexture->AsWebRenderTextureHost());
|
2017-06-07 18:44:03 +03:00
|
|
|
Range<const wr::ImageKey> range_keys(&keys[0], keys.Length());
|
2017-07-25 11:54:36 +03:00
|
|
|
pipeline->mCurrentTexture->PushExternalImage(builder,
|
|
|
|
wr::ToLayoutRect(rect),
|
|
|
|
wr::ToLayoutRect(rect),
|
|
|
|
pipeline->mFilter,
|
|
|
|
range_keys);
|
|
|
|
HoldExternalImage(pipelineId, epoch, pipeline->mCurrentTexture->AsWebRenderTextureHost());
|
2017-06-02 10:11:34 +03:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(keys.Length() == 1);
|
2017-07-19 01:32:46 +03:00
|
|
|
builder.PushImage(wr::ToLayoutRect(rect),
|
|
|
|
wr::ToLayoutRect(rect),
|
2017-07-25 11:54:36 +03:00
|
|
|
pipeline->mFilter,
|
2017-06-02 10:11:34 +03:00
|
|
|
keys[0]);
|
|
|
|
}
|
2017-06-02 10:11:53 +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-08-09 15:46:25 +03:00
|
|
|
mApi->SetRootDisplayList(gfx::Color(0.f, 0.f, 0.f, 0.f), epoch, LayerSize(pipeline->mScBounds.width, pipeline->mScBounds.height),
|
2017-06-02 10:11:34 +03:00
|
|
|
pipelineId, builderContentSize,
|
|
|
|
dl.dl_desc, dl.dl.inner.data, dl.dl.inner.length);
|
|
|
|
}
|
2017-08-09 15:46:25 +03:00
|
|
|
DeleteOldAsyncImages();
|
2017-06-02 10:11:34 +03:00
|
|
|
mKeysToDelete.SwapElements(keysToDelete);
|
|
|
|
}
|
|
|
|
|
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
|