mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Add a new Image class that wraps drawable TextureClients. (bug 1217665 part 4, r=nical)
--HG-- extra : rebase_source : 417abc16c591dd7442228e9200639a35aff15368
This commit is contained in:
parent
a195616940
commit
7dfba52625
@ -86,7 +86,12 @@ enum class ImageFormat {
|
||||
/**
|
||||
* A share handle to a ID3D11Texture2D.
|
||||
*/
|
||||
D3D11_SHARE_HANDLE_TEXTURE
|
||||
D3D11_SHARE_HANDLE_TEXTURE,
|
||||
|
||||
/**
|
||||
* A wrapper around a drawable TextureClient.
|
||||
*/
|
||||
TEXTURE_WRAPPER
|
||||
};
|
||||
|
||||
enum class StereoMode {
|
||||
|
53
gfx/layers/TextureWrapperImage.cpp
Normal file
53
gfx/layers/TextureWrapperImage.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/* -*- 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/. */
|
||||
#include "TextureWrapperImage.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
TextureWrapperImage::TextureWrapperImage(TextureClient* aClient, const IntRect& aPictureRect)
|
||||
: Image(nullptr, ImageFormat::TEXTURE_WRAPPER),
|
||||
mPictureRect(aPictureRect),
|
||||
mTextureClient(aClient)
|
||||
{
|
||||
}
|
||||
|
||||
TextureWrapperImage::~TextureWrapperImage()
|
||||
{
|
||||
}
|
||||
|
||||
gfx::IntSize
|
||||
TextureWrapperImage::GetSize()
|
||||
{
|
||||
return mTextureClient->GetSize();
|
||||
}
|
||||
|
||||
gfx::IntRect
|
||||
TextureWrapperImage::GetPictureRect()
|
||||
{
|
||||
return mPictureRect;
|
||||
}
|
||||
|
||||
already_AddRefed<gfx::SourceSurface>
|
||||
TextureWrapperImage::GetAsSourceSurface()
|
||||
{
|
||||
TextureClientAutoLock autoLock(mTextureClient, OpenMode::OPEN_READ);
|
||||
if (!autoLock.Succeeded()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mTextureClient->BorrowDrawTarget()->Snapshot();
|
||||
}
|
||||
|
||||
TextureClient*
|
||||
TextureWrapperImage::GetTextureClient(CompositableClient* aClient)
|
||||
{
|
||||
return mTextureClient;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
37
gfx/layers/TextureWrapperImage.h
Normal file
37
gfx/layers/TextureWrapperImage.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef GFX_LAYERS_TEXTUREWRAPPINGIMAGE_H_
|
||||
#define GFX_LAYERS_TEXTUREWRAPPINGIMAGE_H_
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
// Wraps a TextureClient into an Image. This may only be used on the main
|
||||
// thread, and only with TextureClients that support BorrowDrawTarget().
|
||||
class TextureWrapperImage final : public Image
|
||||
{
|
||||
public:
|
||||
TextureWrapperImage(TextureClient* aClient, const gfx::IntRect& aPictureRect);
|
||||
~TextureWrapperImage() override;
|
||||
|
||||
gfx::IntSize GetSize() override;
|
||||
gfx::IntRect GetPictureRect() override;
|
||||
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
|
||||
TextureClient* GetTextureClient(CompositableClient* aClient) override;
|
||||
|
||||
private:
|
||||
gfx::IntRect mPictureRect;
|
||||
RefPtr<TextureClient> mTextureClient;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // GFX_LAYERS_TEXTUREWRAPPINGIMAGE_H_
|
@ -10,9 +10,11 @@
|
||||
#include "gfxPlatform.h" // for gfxPlatform
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
|
||||
#include "mozilla/layers/AsyncTransactionTracker.h"
|
||||
#include "mozilla/layers/CompositableForwarder.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
#include "mozilla/layers/ImageDataSerializer.h"
|
||||
#include "mozilla/layers/TextureClientRecycleAllocator.h"
|
||||
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
||||
@ -27,6 +29,7 @@
|
||||
#include "gfxUtils.h" // for gfxUtils::GetAsLZ4Base64Str
|
||||
#include "IPDLActor.h"
|
||||
#include "BufferTexture.h"
|
||||
#include "gfxPrefs.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "mozilla/layers/TextureD3D9.h"
|
||||
|
@ -125,7 +125,7 @@ PaintedLayerComposite::RenderLayer(const gfx::IntRect& aClipRect)
|
||||
|
||||
|
||||
RenderWithAllMasks(this, compositor, aClipRect,
|
||||
[&](EffectChain& effectChain, const Rect& clipRect) {
|
||||
[&](EffectChain& effectChain, const gfx::Rect& clipRect) {
|
||||
mBuffer->SetPaintWillResample(MayResample());
|
||||
|
||||
mBuffer->Composite(this, effectChain,
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/layers/ImageHost.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -177,6 +177,7 @@ EXPORTS.mozilla.layers += [
|
||||
'opengl/TextureHostOGL.h',
|
||||
'PersistentBufferProvider.h',
|
||||
'RenderTrace.h',
|
||||
'TextureWrapperImage.h',
|
||||
'TransactionIdAllocator.h',
|
||||
'YCbCrImageDataSerializer.h',
|
||||
]
|
||||
@ -348,6 +349,7 @@ UNIFIED_SOURCES += [
|
||||
'ReadbackProcessor.cpp',
|
||||
'RenderTrace.cpp',
|
||||
'RotatedBuffer.cpp',
|
||||
'TextureWrapperImage.cpp',
|
||||
'YCbCrImageDataSerializer.cpp',
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user