зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1795768, bug 1804924) for causing build bustages CLOSED TREE
Backed out changeset 220d6288fe81 (bug 1795768) Backed out changeset 5d43ff0044fe (bug 1804924)
This commit is contained in:
Родитель
edd1ee2ec0
Коммит
aa4fd6f08c
|
@ -1348,13 +1348,7 @@ void CanvasRenderingContext2D::RestoreClipsAndTransformToTarget() {
|
|||
|
||||
bool CanvasRenderingContext2D::BorrowTarget(const IntRect& aPersistedRect,
|
||||
bool aNeedsClear) {
|
||||
// We are attempting to request a DrawTarget from the current
|
||||
// PersistentBufferProvider. However, if the provider needs to be refreshed,
|
||||
// or if it is accelerated and the application has requested that we disallow
|
||||
// acceleration, then we skip trying to use this provider so that it will be
|
||||
// recreated by EnsureTarget later.
|
||||
if (!mBufferProvider || mBufferProvider->RequiresRefresh() ||
|
||||
(mBufferProvider->IsAccelerated() && mWillReadFrequently)) {
|
||||
if (!mBufferProvider || mBufferProvider->RequiresRefresh()) {
|
||||
return false;
|
||||
}
|
||||
mTarget = mBufferProvider->BorrowDrawTarget(aPersistedRect);
|
||||
|
@ -1570,9 +1564,7 @@ bool CanvasRenderingContext2D::TryAcceleratedTarget(
|
|||
// to be refreshed and we should avoid using acceleration in the future.
|
||||
mAllowAcceleration = false;
|
||||
}
|
||||
// Don't try creating an accelerate DrawTarget if either acceleration failed
|
||||
// previously or if the application expects acceleration to be slow.
|
||||
if (!mAllowAcceleration || mWillReadFrequently) {
|
||||
if (!mAllowAcceleration) {
|
||||
return false;
|
||||
}
|
||||
aOutDT = DrawTargetWebgl::Create(GetSize(), GetSurfaceFormat());
|
||||
|
@ -1824,8 +1816,6 @@ CanvasRenderingContext2D::SetContextOptions(JSContext* aCx,
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
mWillReadFrequently = attributes.mWillReadFrequently;
|
||||
|
||||
mContextAttributesHasAlpha = attributes.mAlpha;
|
||||
UpdateIsOpaque();
|
||||
|
||||
|
|
|
@ -750,9 +750,6 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal,
|
|||
|
||||
// Whether we should try to create an accelerated buffer provider.
|
||||
bool mAllowAcceleration = true;
|
||||
// Whether the application expects to use operations that perform poorly with
|
||||
// acceleration.
|
||||
bool mWillReadFrequently = false;
|
||||
|
||||
RefPtr<CanvasShutdownObserver> mShutdownObserver;
|
||||
virtual void AddShutdownObserver();
|
||||
|
|
|
@ -147,22 +147,18 @@ void PersistentBufferProviderAccelerated::OnMemoryPressure() {
|
|||
|
||||
static already_AddRefed<TextureClient> CreateTexture(
|
||||
KnowsCompositor* aKnowsCompositor, gfx::SurfaceFormat aFormat,
|
||||
gfx::IntSize aSize, bool aWillReadFrequently) {
|
||||
TextureAllocationFlags flags = ALLOC_DEFAULT;
|
||||
if (aWillReadFrequently) {
|
||||
flags = TextureAllocationFlags(flags | ALLOC_DO_NOT_ACCELERATE);
|
||||
}
|
||||
gfx::IntSize aSize) {
|
||||
return TextureClient::CreateForDrawing(
|
||||
aKnowsCompositor, aFormat, aSize, BackendSelector::Canvas,
|
||||
TextureFlags::DEFAULT | TextureFlags::NON_BLOCKING_READ_LOCK, flags);
|
||||
TextureFlags::DEFAULT | TextureFlags::NON_BLOCKING_READ_LOCK,
|
||||
TextureAllocationFlags::ALLOC_DEFAULT);
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<PersistentBufferProviderShared>
|
||||
PersistentBufferProviderShared::Create(gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
KnowsCompositor* aKnowsCompositor,
|
||||
bool aWillReadFrequently) {
|
||||
KnowsCompositor* aKnowsCompositor) {
|
||||
if (!aKnowsCompositor || !aKnowsCompositor->GetTextureForwarder() ||
|
||||
!aKnowsCompositor->GetTextureForwarder()->IPCOpen()) {
|
||||
return nullptr;
|
||||
|
@ -183,27 +179,25 @@ PersistentBufferProviderShared::Create(gfx::IntSize aSize,
|
|||
#endif
|
||||
|
||||
RefPtr<TextureClient> texture =
|
||||
CreateTexture(aKnowsCompositor, aFormat, aSize, aWillReadFrequently);
|
||||
CreateTexture(aKnowsCompositor, aFormat, aSize);
|
||||
if (!texture) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<PersistentBufferProviderShared> provider =
|
||||
new PersistentBufferProviderShared(aSize, aFormat, aKnowsCompositor,
|
||||
texture, aWillReadFrequently);
|
||||
texture);
|
||||
return provider.forget();
|
||||
}
|
||||
|
||||
PersistentBufferProviderShared::PersistentBufferProviderShared(
|
||||
gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||
KnowsCompositor* aKnowsCompositor, RefPtr<TextureClient>& aTexture,
|
||||
bool aWillReadFrequently)
|
||||
KnowsCompositor* aKnowsCompositor, RefPtr<TextureClient>& aTexture)
|
||||
|
||||
: mSize(aSize),
|
||||
mFormat(aFormat),
|
||||
mKnowsCompositor(aKnowsCompositor),
|
||||
mFront(Nothing()),
|
||||
mWillReadFrequently(aWillReadFrequently) {
|
||||
mFront(Nothing()) {
|
||||
MOZ_ASSERT(aKnowsCompositor);
|
||||
if (mTextures.append(aTexture)) {
|
||||
mBack = Some<uint32_t>(0);
|
||||
|
@ -259,7 +253,7 @@ bool PersistentBufferProviderShared::SetKnowsCompositor(
|
|||
|
||||
if (prevTexture) {
|
||||
RefPtr<TextureClient> newTexture =
|
||||
CreateTexture(aKnowsCompositor, mFormat, mSize, mWillReadFrequently);
|
||||
CreateTexture(aKnowsCompositor, mFormat, mSize);
|
||||
|
||||
MOZ_ASSERT(newTexture);
|
||||
if (!newTexture) {
|
||||
|
@ -389,7 +383,7 @@ PersistentBufferProviderShared::BorrowDrawTarget(
|
|||
}
|
||||
|
||||
RefPtr<TextureClient> newTexture =
|
||||
CreateTexture(mKnowsCompositor, mFormat, mSize, mWillReadFrequently);
|
||||
CreateTexture(mKnowsCompositor, mFormat, mSize);
|
||||
|
||||
MOZ_ASSERT(newTexture);
|
||||
if (newTexture) {
|
||||
|
@ -422,8 +416,7 @@ PersistentBufferProviderShared::BorrowDrawTarget(
|
|||
// We are about to read lock a texture that is in use by the compositor
|
||||
// and has synchronization. To prevent possible future contention we
|
||||
// switch to using a permanent back buffer.
|
||||
mPermanentBackBuffer = CreateTexture(mKnowsCompositor, mFormat, mSize,
|
||||
mWillReadFrequently);
|
||||
mPermanentBackBuffer = CreateTexture(mKnowsCompositor, mFormat, mSize);
|
||||
if (!mPermanentBackBuffer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -560,8 +553,7 @@ PersistentBufferProviderShared::BorrowSnapshot(gfx::DrawTarget* aTarget) {
|
|||
// We are about to read lock a texture that is in use by the compositor and
|
||||
// has synchronization. To prevent possible future contention we switch to
|
||||
// using a permanent back buffer.
|
||||
mPermanentBackBuffer =
|
||||
CreateTexture(mKnowsCompositor, mFormat, mSize, mWillReadFrequently);
|
||||
mPermanentBackBuffer = CreateTexture(mKnowsCompositor, mFormat, mSize);
|
||||
if (!mPermanentBackBuffer ||
|
||||
!mPermanentBackBuffer->Lock(OpenMode::OPEN_READ_WRITE)) {
|
||||
return nullptr;
|
||||
|
@ -654,19 +646,5 @@ void PersistentBufferProviderShared::Destroy() {
|
|||
mTextures.clear();
|
||||
}
|
||||
|
||||
bool PersistentBufferProviderShared::IsAccelerated() const {
|
||||
#ifdef XP_WIN
|
||||
// Detect if we're using D2D canvas.
|
||||
if (mWillReadFrequently || mTextures.empty()) {
|
||||
return false;
|
||||
}
|
||||
TextureClient* texture = mTextures.front();
|
||||
if (texture->GetInternalData()->AsD3D11TetxureData()) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -187,7 +187,7 @@ class PersistentBufferProviderShared : public PersistentBufferProvider,
|
|||
|
||||
static already_AddRefed<PersistentBufferProviderShared> Create(
|
||||
gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||
KnowsCompositor* aKnowsCompositor, bool aWillReadFrequently = false);
|
||||
KnowsCompositor* aKnowsCompositor);
|
||||
|
||||
bool IsShared() const override { return true; }
|
||||
|
||||
|
@ -213,13 +213,10 @@ class PersistentBufferProviderShared : public PersistentBufferProvider,
|
|||
|
||||
bool PreservesDrawingState() const override { return false; }
|
||||
|
||||
bool IsAccelerated() const override;
|
||||
|
||||
protected:
|
||||
PersistentBufferProviderShared(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||
KnowsCompositor* aKnowsCompositor,
|
||||
RefPtr<TextureClient>& aTexture,
|
||||
bool aWillReadFrequently);
|
||||
RefPtr<TextureClient>& aTexture);
|
||||
|
||||
~PersistentBufferProviderShared();
|
||||
|
||||
|
@ -242,8 +239,6 @@ class PersistentBufferProviderShared : public PersistentBufferProvider,
|
|||
Maybe<uint32_t> mBack;
|
||||
// Offset of the texture in mTextures that is presented to the compositor.
|
||||
Maybe<uint32_t> mFront;
|
||||
// Whether to avoid acceleration.
|
||||
bool mWillReadFrequently = false;
|
||||
|
||||
RefPtr<gfx::DrawTarget> mDrawTarget;
|
||||
RefPtr<gfx::SourceSurface> mSnapshot;
|
||||
|
|
|
@ -267,7 +267,7 @@ static TextureType GetTextureType(gfx::SurfaceFormat aFormat,
|
|||
(moz2DBackend == gfx::BackendType::DIRECT2D ||
|
||||
moz2DBackend == gfx::BackendType::DIRECT2D1_1) &&
|
||||
aSize.width <= maxTextureSize && aSize.height <= maxTextureSize &&
|
||||
!(aAllocFlags & (ALLOC_UPDATE_FROM_SURFACE | ALLOC_DO_NOT_ACCELERATE))) {
|
||||
!(aAllocFlags & ALLOC_UPDATE_FROM_SURFACE)) {
|
||||
return TextureType::D3D11;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -95,9 +95,6 @@ enum TextureAllocationFlags {
|
|||
// The texture is going to be updated using UpdateFromSurface and needs to
|
||||
// support that call.
|
||||
ALLOC_UPDATE_FROM_SURFACE = 1 << 7,
|
||||
|
||||
// Do not use an accelerated texture type.
|
||||
ALLOC_DO_NOT_ACCELERATE = 1 << 8,
|
||||
};
|
||||
|
||||
enum class BackendSelector { Content, Canvas };
|
||||
|
|
Загрузка…
Ссылка в новой задаче