2017-06-28 15:03:27 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; 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/. */
|
|
|
|
|
|
|
|
#ifndef GFX_WEBRENDERUSERDATA_H
|
|
|
|
#define GFX_WEBRENDERUSERDATA_H
|
|
|
|
|
|
|
|
#include "mozilla/layers/StackingContextHelper.h"
|
|
|
|
#include "mozilla/webrender/WebRenderAPI.h"
|
2017-07-21 14:21:47 +08:00
|
|
|
#include "mozilla/layers/AnimationInfo.h"
|
2017-06-28 15:03:27 -07:00
|
|
|
|
2017-07-06 00:29:41 +08:00
|
|
|
class nsDisplayItemGeometry;
|
|
|
|
|
2017-06-28 15:03:27 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
class ImageClient;
|
|
|
|
class ImageContainer;
|
|
|
|
class WebRenderBridgeChild;
|
|
|
|
class WebRenderImageData;
|
2017-07-24 14:43:55 +08:00
|
|
|
class WebRenderFallbackData;
|
2017-06-28 15:03:27 -07:00
|
|
|
class WebRenderLayerManager;
|
|
|
|
|
|
|
|
class WebRenderUserData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(WebRenderUserData)
|
|
|
|
|
2017-08-03 11:20:53 +08:00
|
|
|
explicit WebRenderUserData(WebRenderLayerManager* aWRManager);
|
2017-06-28 15:03:27 -07:00
|
|
|
|
|
|
|
virtual WebRenderImageData* AsImageData() { return nullptr; }
|
2017-07-24 14:43:55 +08:00
|
|
|
virtual WebRenderFallbackData* AsFallbackData() { return nullptr; }
|
2017-06-28 15:03:27 -07:00
|
|
|
|
|
|
|
enum class UserDataType {
|
|
|
|
eImage,
|
2017-07-06 00:29:41 +08:00
|
|
|
eFallback,
|
2017-07-21 14:21:47 +08:00
|
|
|
eAnimation,
|
2017-06-28 15:03:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual UserDataType GetType() = 0;
|
|
|
|
|
|
|
|
protected:
|
2017-08-03 11:20:53 +08:00
|
|
|
virtual ~WebRenderUserData();
|
2017-06-28 15:03:27 -07:00
|
|
|
|
|
|
|
WebRenderBridgeChild* WrBridge() const;
|
|
|
|
|
2017-08-03 11:20:53 +08:00
|
|
|
RefPtr<WebRenderLayerManager> mWRManager;
|
2017-06-28 15:03:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class WebRenderImageData : public WebRenderUserData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit WebRenderImageData(WebRenderLayerManager* aWRManager);
|
|
|
|
virtual ~WebRenderImageData();
|
|
|
|
|
|
|
|
virtual WebRenderImageData* AsImageData() override { return this; }
|
|
|
|
virtual UserDataType GetType() override { return UserDataType::eImage; }
|
|
|
|
static UserDataType Type() { return UserDataType::eImage; }
|
2017-07-06 00:29:41 +08:00
|
|
|
Maybe<wr::ImageKey> GetKey() { return mKey; }
|
|
|
|
void SetKey(const wr::ImageKey& aKey) { mKey = Some(aKey); }
|
|
|
|
already_AddRefed<ImageClient> GetImageClient();
|
2017-06-28 15:03:27 -07:00
|
|
|
|
2017-07-06 00:29:41 +08:00
|
|
|
Maybe<wr::ImageKey> UpdateImageKey(ImageContainer* aContainer, bool aForceUpdate = false);
|
2017-06-28 15:03:27 -07:00
|
|
|
|
|
|
|
void CreateAsyncImageWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
|
|
|
ImageContainer* aContainer,
|
|
|
|
const StackingContextHelper& aSc,
|
|
|
|
const LayerRect& aBounds,
|
|
|
|
const LayerRect& aSCBounds,
|
|
|
|
const gfx::Matrix4x4& aSCTransform,
|
|
|
|
const gfx::MaybeIntSize& aScaleToSize,
|
2017-07-19 03:28:58 -04:00
|
|
|
const wr::ImageRendering& aFilter,
|
|
|
|
const wr::MixBlendMode& aMixBlendMode);
|
2017-06-28 15:03:27 -07:00
|
|
|
|
|
|
|
void CreateImageClientIfNeeded();
|
2017-07-06 00:29:41 +08:00
|
|
|
|
|
|
|
protected:
|
2017-06-28 15:03:27 -07:00
|
|
|
void CreateExternalImageIfNeeded();
|
|
|
|
|
|
|
|
wr::MaybeExternalImageId mExternalImageId;
|
|
|
|
Maybe<wr::ImageKey> mKey;
|
|
|
|
RefPtr<ImageClient> mImageClient;
|
|
|
|
Maybe<wr::PipelineId> mPipelineId;
|
|
|
|
RefPtr<ImageContainer> mContainer;
|
|
|
|
};
|
|
|
|
|
2017-07-06 00:29:41 +08:00
|
|
|
class WebRenderFallbackData : public WebRenderImageData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit WebRenderFallbackData(WebRenderLayerManager* aWRManager);
|
|
|
|
virtual ~WebRenderFallbackData();
|
|
|
|
|
2017-07-24 14:43:55 +08:00
|
|
|
virtual WebRenderFallbackData* AsFallbackData() override { return this; }
|
2017-07-06 00:29:41 +08:00
|
|
|
virtual UserDataType GetType() override { return UserDataType::eFallback; }
|
|
|
|
static UserDataType Type() { return UserDataType::eFallback; }
|
|
|
|
nsAutoPtr<nsDisplayItemGeometry> GetGeometry();
|
|
|
|
void SetGeometry(nsAutoPtr<nsDisplayItemGeometry> aGeometry);
|
|
|
|
nsRect GetBounds() { return mBounds; }
|
|
|
|
void SetBounds(const nsRect& aRect) { mBounds = aRect; }
|
2017-07-24 14:43:55 +08:00
|
|
|
void SetInvalid(bool aInvalid) { mInvalid = aInvalid; }
|
|
|
|
bool IsInvalid() { return mInvalid; }
|
2017-07-06 00:29:41 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
nsAutoPtr<nsDisplayItemGeometry> mGeometry;
|
|
|
|
nsRect mBounds;
|
2017-07-24 14:43:55 +08:00
|
|
|
bool mInvalid;
|
2017-07-06 00:29:41 +08:00
|
|
|
};
|
|
|
|
|
2017-07-21 14:21:47 +08:00
|
|
|
class WebRenderAnimationData : public WebRenderUserData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit WebRenderAnimationData(WebRenderLayerManager* aWRManager);
|
|
|
|
virtual ~WebRenderAnimationData() {}
|
|
|
|
|
|
|
|
virtual UserDataType GetType() override { return UserDataType::eAnimation; }
|
|
|
|
static UserDataType Type() { return UserDataType::eAnimation; }
|
|
|
|
AnimationInfo& GetAnimationInfo() { return mAnimationInfo; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
AnimationInfo mAnimationInfo;
|
|
|
|
};
|
|
|
|
|
2017-06-28 15:03:27 -07:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* GFX_WEBRENDERUSERDATA_H */
|