mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 989904 - Remove the remaining deprecated textures code. r=mattwoodrow
This commit is contained in:
parent
917d2e24b6
commit
9e32afc054
@ -7,7 +7,7 @@
|
||||
#include <stdint.h> // for uint64_t, uint32_t
|
||||
#include "gfxPlatform.h" // for gfxPlatform
|
||||
#include "mozilla/layers/CompositableForwarder.h"
|
||||
#include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient, etc
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
||||
#include "mozilla/layers/TextureClientOGL.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "gfxASurface.h" // for gfxContentType
|
||||
|
@ -22,7 +22,6 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class CompositableClient;
|
||||
class DeprecatedTextureClient;
|
||||
class TextureClient;
|
||||
class BufferTextureClient;
|
||||
class ImageBridgeChild;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo, etc
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsPoint.h" // for nsIntPoint
|
||||
@ -304,10 +304,10 @@ protected:
|
||||
};
|
||||
|
||||
/**
|
||||
* A double buffered ContentClient. mDeprecatedTextureClient is the back buffer, which
|
||||
* A double buffered ContentClient. mTextureClient is the back buffer, which
|
||||
* we draw into. mFrontClient is the front buffer which we may read from, but
|
||||
* not write to, when the compositor does not have the 'soft' lock. We can write
|
||||
* into mDeprecatedTextureClient at any time.
|
||||
* into mTextureClient at any time.
|
||||
*
|
||||
* The ContentHost keeps a reference to both corresponding texture hosts, in
|
||||
* response to our UpdateTextureRegion message, the compositor swaps its
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
||||
#include "mozilla/layers/CompositorTypes.h" // for CompositableType, etc
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient, etc
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsRect.h" // for nsIntRect
|
||||
@ -127,7 +127,7 @@ protected:
|
||||
/**
|
||||
* Image class to be used for async image uploads using the image bridge
|
||||
* protocol.
|
||||
* We store the ImageBridge id in the DeprecatedTextureClientIdentifier.
|
||||
* We store the ImageBridge id in the TextureClientIdentifier.
|
||||
*/
|
||||
class ImageClientBridge : public ImageClient
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <utility> // for pair
|
||||
#include "ContentHost.h" // for ContentHostDoubleBuffered, etc
|
||||
#include "Effects.h" // for EffectMask, Effect, etc
|
||||
#include "ImageHost.h" // for DeprecatedImageHostBuffered, etc
|
||||
#include "ImageHost.h" // for ImageHostBuffered, etc
|
||||
#include "TiledContentHost.h" // for TiledContentHost
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/TextureHost.h" // for TextureHost, etc
|
||||
@ -76,35 +76,15 @@ CompositableHost::SetCompositor(Compositor* aCompositor)
|
||||
mCompositor = aCompositor;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositableHost::Update(const SurfaceDescriptor& aImage,
|
||||
SurfaceDescriptor* aResult)
|
||||
{
|
||||
if (!GetDeprecatedTextureHost()) {
|
||||
*aResult = aImage;
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(!GetDeprecatedTextureHost()->GetBuffer(),
|
||||
"This path not suitable for texture-level double buffering.");
|
||||
GetDeprecatedTextureHost()->Update(aImage);
|
||||
*aResult = aImage;
|
||||
return GetDeprecatedTextureHost()->IsValid();
|
||||
}
|
||||
|
||||
bool
|
||||
CompositableHost::AddMaskEffect(EffectChain& aEffects,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
bool aIs3D)
|
||||
{
|
||||
RefPtr<TextureSource> source;
|
||||
RefPtr<DeprecatedTextureHost> oldHost = GetDeprecatedTextureHost();
|
||||
if (oldHost && oldHost->Lock()) {
|
||||
source = oldHost;
|
||||
} else {
|
||||
RefPtr<TextureHost> host = GetAsTextureHost();
|
||||
if (host && host->Lock()) {
|
||||
source = host->GetTextureSources();
|
||||
}
|
||||
RefPtr<TextureHost> host = GetAsTextureHost();
|
||||
if (host && host->Lock()) {
|
||||
source = host->GetTextureSources();
|
||||
}
|
||||
|
||||
if (!source) {
|
||||
@ -123,14 +103,9 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects,
|
||||
void
|
||||
CompositableHost::RemoveMaskEffect()
|
||||
{
|
||||
RefPtr<DeprecatedTextureHost> oldHost = GetDeprecatedTextureHost();
|
||||
if (oldHost) {
|
||||
oldHost->Unlock();
|
||||
} else {
|
||||
RefPtr<TextureHost> host = GetAsTextureHost();
|
||||
if (host) {
|
||||
host->Unlock();
|
||||
}
|
||||
RefPtr<TextureHost> host = GetAsTextureHost();
|
||||
if (host) {
|
||||
host->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,25 +149,6 @@ CompositableHost::Create(const TextureInfo& aTextureInfo)
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
void
|
||||
CompositableHost::DumpDeprecatedTextureHost(FILE* aFile, DeprecatedTextureHost* aTexture)
|
||||
{
|
||||
if (!aTexture) {
|
||||
return;
|
||||
}
|
||||
RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
|
||||
gfxPlatform *platform = gfxPlatform::GetPlatform();
|
||||
RefPtr<gfx::DrawTarget> dt = platform->CreateDrawTargetForData(dSurf->GetData(),
|
||||
dSurf->GetSize(),
|
||||
dSurf->Stride(),
|
||||
dSurf->GetFormat());
|
||||
nsRefPtr<gfxASurface> surf = platform->GetThebesSurfaceForDrawTarget(dt);
|
||||
if (!surf) {
|
||||
return;
|
||||
}
|
||||
surf->DumpAsDataURL(aFile ? aFile : stderr);
|
||||
}
|
||||
|
||||
void
|
||||
CompositableHost::DumpTextureHost(FILE* aFile, TextureHost* aTexture)
|
||||
{
|
||||
|
@ -46,7 +46,6 @@ struct TiledLayerProperties
|
||||
};
|
||||
|
||||
class Layer;
|
||||
class DeprecatedTextureHost;
|
||||
class SurfaceDescriptor;
|
||||
class Compositor;
|
||||
class ISurfaceAllocator;
|
||||
@ -159,12 +158,6 @@ public:
|
||||
const nsIntRegion* aVisibleRegion = nullptr,
|
||||
TiledLayerProperties* aLayerProperties = nullptr) = 0;
|
||||
|
||||
/**
|
||||
* @return true if we should schedule a composition.
|
||||
*/
|
||||
virtual bool Update(const SurfaceDescriptor& aImage,
|
||||
SurfaceDescriptor* aResult = nullptr);
|
||||
|
||||
/**
|
||||
* Update the content host.
|
||||
* aUpdated is the region which should be updated
|
||||
@ -217,8 +210,6 @@ public:
|
||||
MOZ_ASSERT(false, "should be implemented or not used");
|
||||
}
|
||||
|
||||
virtual DeprecatedTextureHost* GetDeprecatedTextureHost() { return nullptr; }
|
||||
|
||||
/**
|
||||
* Returns the front buffer.
|
||||
*/
|
||||
@ -296,7 +287,6 @@ public:
|
||||
virtual void Dump(FILE* aFile=nullptr,
|
||||
const char* aPrefix="",
|
||||
bool aDumpHtml=false) { }
|
||||
static void DumpDeprecatedTextureHost(FILE* aFile, DeprecatedTextureHost* aTexture);
|
||||
static void DumpTextureHost(FILE* aFile, TextureHost* aTexture);
|
||||
|
||||
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() { return nullptr; }
|
||||
|
@ -285,242 +285,6 @@ ContentHostTexture::Dump(FILE* aFile,
|
||||
}
|
||||
#endif
|
||||
|
||||
DeprecatedContentHostBase::DeprecatedContentHostBase(const TextureInfo& aTextureInfo)
|
||||
: ContentHost(aTextureInfo)
|
||||
, mPaintWillResample(false)
|
||||
, mInitialised(false)
|
||||
{}
|
||||
|
||||
DeprecatedContentHostBase::~DeprecatedContentHostBase()
|
||||
{}
|
||||
|
||||
DeprecatedTextureHost*
|
||||
DeprecatedContentHostBase::GetDeprecatedTextureHost()
|
||||
{
|
||||
return mDeprecatedTextureHost;
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::DestroyFrontHost()
|
||||
{
|
||||
MOZ_ASSERT(!mDeprecatedTextureHost || mDeprecatedTextureHost->GetDeAllocator(),
|
||||
"We won't be able to destroy our SurfaceDescriptor");
|
||||
MOZ_ASSERT(!mDeprecatedTextureHostOnWhite || mDeprecatedTextureHostOnWhite->GetDeAllocator(),
|
||||
"We won't be able to destroy our SurfaceDescriptor");
|
||||
mDeprecatedTextureHost = nullptr;
|
||||
mDeprecatedTextureHostOnWhite = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const Filter& aFilter,
|
||||
const Rect& aClipRect,
|
||||
const nsIntRegion* aVisibleRegion,
|
||||
TiledLayerProperties* aLayerProperties)
|
||||
{
|
||||
NS_ASSERTION(aVisibleRegion, "Requires a visible region");
|
||||
|
||||
AutoLockDeprecatedTextureHost lock(mDeprecatedTextureHost);
|
||||
AutoLockDeprecatedTextureHost lockOnWhite(mDeprecatedTextureHostOnWhite);
|
||||
|
||||
if (!mDeprecatedTextureHost ||
|
||||
!lock.IsValid() ||
|
||||
!lockOnWhite.IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<TexturedEffect> effect =
|
||||
CreateTexturedEffect(mDeprecatedTextureHost, mDeprecatedTextureHostOnWhite, aFilter);
|
||||
if (!effect) {
|
||||
return;
|
||||
}
|
||||
|
||||
aEffectChain.mPrimaryEffect = effect;
|
||||
|
||||
nsIntRegion tmpRegion;
|
||||
const nsIntRegion* renderRegion;
|
||||
if (PaintWillResample()) {
|
||||
// If we're resampling, then the texture image will contain exactly the
|
||||
// entire visible region's bounds, and we should draw it all in one quad
|
||||
// to avoid unexpected aliasing.
|
||||
tmpRegion = aVisibleRegion->GetBounds();
|
||||
renderRegion = &tmpRegion;
|
||||
} else {
|
||||
renderRegion = aVisibleRegion;
|
||||
}
|
||||
|
||||
nsIntRegion region(*renderRegion);
|
||||
nsIntPoint origin = GetOriginOffset();
|
||||
region.MoveBy(-origin); // translate into TexImage space, buffer origin might not be at texture (0,0)
|
||||
|
||||
// Figure out the intersecting draw region
|
||||
TextureSource* source = mDeprecatedTextureHost;
|
||||
MOZ_ASSERT(source);
|
||||
gfx::IntSize texSize = source->GetSize();
|
||||
nsIntRect textureRect = nsIntRect(0, 0, texSize.width, texSize.height);
|
||||
textureRect.MoveBy(region.GetBounds().TopLeft());
|
||||
nsIntRegion subregion;
|
||||
subregion.And(region, textureRect);
|
||||
if (subregion.IsEmpty()) {
|
||||
// Region is empty, nothing to draw
|
||||
return;
|
||||
}
|
||||
|
||||
nsIntRegion screenRects;
|
||||
nsIntRegion regionRects;
|
||||
|
||||
// Collect texture/screen coordinates for drawing
|
||||
nsIntRegionRectIterator iter(subregion);
|
||||
while (const nsIntRect* iterRect = iter.Next()) {
|
||||
nsIntRect regionRect = *iterRect;
|
||||
nsIntRect screenRect = regionRect;
|
||||
screenRect.MoveBy(origin);
|
||||
|
||||
screenRects.Or(screenRects, screenRect);
|
||||
regionRects.Or(regionRects, regionRect);
|
||||
}
|
||||
|
||||
TileIterator* tileIter = source->AsTileIterator();
|
||||
TileIterator* iterOnWhite = nullptr;
|
||||
if (tileIter) {
|
||||
tileIter->BeginTileIteration();
|
||||
}
|
||||
|
||||
if (mDeprecatedTextureHostOnWhite) {
|
||||
iterOnWhite = mDeprecatedTextureHostOnWhite->AsTileIterator();
|
||||
MOZ_ASSERT(!tileIter || tileIter->GetTileCount() == iterOnWhite->GetTileCount(),
|
||||
"Tile count mismatch on component alpha texture");
|
||||
if (iterOnWhite) {
|
||||
iterOnWhite->BeginTileIteration();
|
||||
}
|
||||
}
|
||||
|
||||
bool usingTiles = (tileIter && tileIter->GetTileCount() > 1);
|
||||
do {
|
||||
if (iterOnWhite) {
|
||||
MOZ_ASSERT(iterOnWhite->GetTileRect() == tileIter->GetTileRect(),
|
||||
"component alpha textures should be the same size.");
|
||||
}
|
||||
|
||||
nsIntRect texRect = tileIter ? tileIter->GetTileRect()
|
||||
: nsIntRect(0, 0,
|
||||
texSize.width,
|
||||
texSize.height);
|
||||
|
||||
// Draw texture. If we're using tiles, we do repeating manually, as texture
|
||||
// repeat would cause each individual tile to repeat instead of the
|
||||
// compound texture as a whole. This involves drawing at most 4 sections,
|
||||
// 2 for each axis that has texture repeat.
|
||||
for (int y = 0; y < (usingTiles ? 2 : 1); y++) {
|
||||
for (int x = 0; x < (usingTiles ? 2 : 1); x++) {
|
||||
nsIntRect currentTileRect(texRect);
|
||||
currentTileRect.MoveBy(x * texSize.width, y * texSize.height);
|
||||
|
||||
nsIntRegionRectIterator screenIter(screenRects);
|
||||
nsIntRegionRectIterator regionIter(regionRects);
|
||||
|
||||
const nsIntRect* screenRect;
|
||||
const nsIntRect* regionRect;
|
||||
while ((screenRect = screenIter.Next()) &&
|
||||
(regionRect = regionIter.Next())) {
|
||||
nsIntRect tileScreenRect(*screenRect);
|
||||
nsIntRect tileRegionRect(*regionRect);
|
||||
|
||||
// When we're using tiles, find the intersection between the tile
|
||||
// rect and this region rect. Tiling is then handled by the
|
||||
// outer for-loops and modifying the tile rect.
|
||||
if (usingTiles) {
|
||||
tileScreenRect.MoveBy(-origin);
|
||||
tileScreenRect = tileScreenRect.Intersect(currentTileRect);
|
||||
tileScreenRect.MoveBy(origin);
|
||||
|
||||
if (tileScreenRect.IsEmpty())
|
||||
continue;
|
||||
|
||||
tileRegionRect = regionRect->Intersect(currentTileRect);
|
||||
tileRegionRect.MoveBy(-currentTileRect.TopLeft());
|
||||
}
|
||||
gfx::Rect rect(tileScreenRect.x, tileScreenRect.y,
|
||||
tileScreenRect.width, tileScreenRect.height);
|
||||
|
||||
effect->mTextureCoords = Rect(Float(tileRegionRect.x) / texRect.width,
|
||||
Float(tileRegionRect.y) / texRect.height,
|
||||
Float(tileRegionRect.width) / texRect.width,
|
||||
Float(tileRegionRect.height) / texRect.height);
|
||||
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform);
|
||||
if (usingTiles) {
|
||||
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT | DIAGNOSTIC_BIGIMAGE;
|
||||
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect,
|
||||
aTransform, mFlashCounter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iterOnWhite) {
|
||||
iterOnWhite->NextTile();
|
||||
}
|
||||
} while (usingTiles && tileIter->NextTile());
|
||||
|
||||
if (tileIter) {
|
||||
tileIter->EndTileIteration();
|
||||
}
|
||||
if (iterOnWhite) {
|
||||
iterOnWhite->EndTileIteration();
|
||||
}
|
||||
|
||||
DiagnosticTypes diagnostics = DIAGNOSTIC_CONTENT;
|
||||
diagnostics |= iterOnWhite ? DIAGNOSTIC_COMPONENT_ALPHA : 0;
|
||||
GetCompositor()->DrawDiagnostics(diagnostics, *aVisibleRegion, aClipRect,
|
||||
aTransform, mFlashCounter);
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositableHost::SetCompositor(aCompositor);
|
||||
if (mDeprecatedTextureHost) {
|
||||
mDeprecatedTextureHost->SetCompositor(aCompositor);
|
||||
}
|
||||
if (mDeprecatedTextureHostOnWhite) {
|
||||
mDeprecatedTextureHostOnWhite->SetCompositor(aCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::Dump(FILE* aFile,
|
||||
const char* aPrefix,
|
||||
bool aDumpHtml)
|
||||
{
|
||||
if (!aDumpHtml) {
|
||||
return;
|
||||
}
|
||||
if (!aFile) {
|
||||
aFile = stderr;
|
||||
}
|
||||
fprintf_stderr(aFile, "<ul>");
|
||||
if (mDeprecatedTextureHost) {
|
||||
fprintf_stderr(aFile, "%s", aPrefix);
|
||||
fprintf_stderr(aFile, "<li> <a href=");
|
||||
DumpDeprecatedTextureHost(aFile, mDeprecatedTextureHost);
|
||||
fprintf_stderr(aFile, "> Front buffer </a></li> ");
|
||||
}
|
||||
if (mDeprecatedTextureHostOnWhite) {
|
||||
fprintf_stderr(aFile, "%s", aPrefix);
|
||||
fprintf_stderr(aFile, "<li> <a href=");
|
||||
DumpDeprecatedTextureHost(aFile, mDeprecatedTextureHostOnWhite);
|
||||
fprintf_stderr(aFile, "> Front buffer on white </a> </li> ");
|
||||
}
|
||||
fprintf_stderr(aFile, "</ul>");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool
|
||||
ContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
const nsIntRegion& aUpdated,
|
||||
@ -912,18 +676,6 @@ ContentHostTexture::GetRenderState()
|
||||
return result;
|
||||
}
|
||||
|
||||
LayerRenderState
|
||||
DeprecatedContentHostBase::GetRenderState()
|
||||
{
|
||||
LayerRenderState result = mDeprecatedTextureHost->GetRenderState();
|
||||
|
||||
if (mBufferRotation != nsIntPoint()) {
|
||||
result.mFlags |= LAYER_RENDER_STATE_BUFFER_ROTATION;
|
||||
}
|
||||
result.SetOffset(GetOriginOffset());
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
TemporaryRef<gfx::DataSourceSurface>
|
||||
ContentHostTexture::GetAsSurface()
|
||||
@ -935,11 +687,6 @@ ContentHostTexture::GetAsSurface()
|
||||
return mTextureHost->GetAsSurface();
|
||||
}
|
||||
|
||||
TemporaryRef<gfx::DataSourceSurface>
|
||||
DeprecatedContentHostBase::GetAsSurface()
|
||||
{
|
||||
return mDeprecatedTextureHost->GetAsSurface();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "mozilla/layers/ISurfaceAllocator.h" // for ISurfaceAllocator
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/LayersTypes.h" // for etc
|
||||
#include "mozilla/layers/TextureHost.h" // for DeprecatedTextureHost
|
||||
#include "mozilla/layers/TextureHost.h" // for TextureHost
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsAutoPtr.h" // for nsAutoPtr
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
@ -76,8 +76,8 @@ protected:
|
||||
* Base class for non-tiled ContentHosts.
|
||||
*
|
||||
* Ownership of the SurfaceDescriptor and the resources it represents is passed
|
||||
* from the ContentClient to the ContentHost when the DeprecatedTextureClient/Hosts are
|
||||
* created, that is recevied here by SetDeprecatedTextureHosts which assigns one or two
|
||||
* from the ContentClient to the ContentHost when the TextureClient/Hosts are
|
||||
* created, that is recevied here by SetTextureHosts which assigns one or two
|
||||
* texture hosts (for single and double buffering) to the ContentHost.
|
||||
*
|
||||
* It is the responsibility of the ContentHost to destroy its resources when
|
||||
@ -192,74 +192,6 @@ protected:
|
||||
bool mLocked;
|
||||
};
|
||||
|
||||
class DeprecatedContentHostBase : public ContentHost
|
||||
{
|
||||
public:
|
||||
typedef RotatedContentBuffer::ContentType ContentType;
|
||||
typedef RotatedContentBuffer::PaintState PaintState;
|
||||
|
||||
DeprecatedContentHostBase(const TextureInfo& aTextureInfo);
|
||||
~DeprecatedContentHostBase();
|
||||
|
||||
virtual void Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
const gfx::Matrix4x4& aTransform,
|
||||
const gfx::Filter& aFilter,
|
||||
const gfx::Rect& aClipRect,
|
||||
const nsIntRegion* aVisibleRegion = nullptr,
|
||||
TiledLayerProperties* aLayerProperties = nullptr);
|
||||
|
||||
virtual PaintState BeginPaint(ContentType, uint32_t)
|
||||
{
|
||||
NS_RUNTIMEABORT("shouldn't BeginPaint for a shadow layer");
|
||||
return PaintState();
|
||||
}
|
||||
|
||||
virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface();
|
||||
|
||||
virtual void Dump(FILE* aFile=nullptr,
|
||||
const char* aPrefix="",
|
||||
bool aDumpHtml=false) MOZ_OVERRIDE;
|
||||
#endif
|
||||
|
||||
virtual DeprecatedTextureHost* GetDeprecatedTextureHost() MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetPaintWillResample(bool aResample) { mPaintWillResample = aResample; }
|
||||
// The client has destroyed its texture clients and we should destroy our
|
||||
// texture hosts and SurfaceDescriptors. Note that we don't immediately
|
||||
// destroy our front buffer so that we can continue to composite.
|
||||
virtual void DestroyTextures() = 0;
|
||||
|
||||
protected:
|
||||
virtual nsIntPoint GetOriginOffset()
|
||||
{
|
||||
return mBufferRect.TopLeft() - mBufferRotation;
|
||||
}
|
||||
|
||||
bool PaintWillResample() { return mPaintWillResample; }
|
||||
|
||||
// Destroy the front buffer's texture host. This should only happen when
|
||||
// we have a new front buffer to use or the ContentHost is going to die.
|
||||
void DestroyFrontHost();
|
||||
|
||||
nsIntRect mBufferRect;
|
||||
nsIntPoint mBufferRotation;
|
||||
RefPtr<DeprecatedTextureHost> mDeprecatedTextureHost;
|
||||
RefPtr<DeprecatedTextureHost> mDeprecatedTextureHostOnWhite;
|
||||
// When we set a new front buffer DeprecatedTextureHost, we don't want to stomp on
|
||||
// the old one which might still be used for compositing. So we store it
|
||||
// here and move it to mDeprecatedTextureHost once we do the first buffer swap.
|
||||
RefPtr<DeprecatedTextureHost> mNewFrontHost;
|
||||
RefPtr<DeprecatedTextureHost> mNewFrontHostOnWhite;
|
||||
bool mPaintWillResample;
|
||||
bool mInitialised;
|
||||
};
|
||||
|
||||
/**
|
||||
* Double buffering is implemented by swapping the front and back TextureHosts.
|
||||
* We assume that whenever we use double buffering, then we have
|
||||
@ -287,7 +219,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Single buffered, therefore we must synchronously upload the image from the
|
||||
* DeprecatedTextureHost in the layers transaction (i.e., in UpdateThebes).
|
||||
* TextureHost in the layers transaction (i.e., in UpdateThebes).
|
||||
*/
|
||||
class ContentHostSingleBuffered : public ContentHostTexture
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo, etc
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc
|
||||
#include "mozilla/layers/TextureHost.h" // for DeprecatedTextureHost, etc
|
||||
#include "mozilla/layers/TextureHost.h" // for TextureHost, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsRect.h" // for nsIntRect
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "mozilla/gfx/Rect.h" // for Rect
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/Effects.h" // for EffectChain
|
||||
#include "mozilla/layers/TextureHost.h" // for DeprecatedTextureHost, etc
|
||||
#include "mozilla/layers/TextureHost.h" // for TextureHost, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsAString.h"
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
@ -120,10 +120,8 @@ ImageLayerComposite::ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransform
|
||||
gfxRect sourceRect(0, 0, 0, 0);
|
||||
if (mImageHost &&
|
||||
mImageHost->IsAttached() &&
|
||||
(mImageHost->GetDeprecatedTextureHost() || mImageHost->GetAsTextureHost())) {
|
||||
IntSize size =
|
||||
mImageHost->GetAsTextureHost() ? mImageHost->GetAsTextureHost()->GetSize()
|
||||
: mImageHost->GetDeprecatedTextureHost()->GetSize();
|
||||
mImageHost->GetAsTextureHost()) {
|
||||
IntSize size = mImageHost->GetAsTextureHost()->GetSize();
|
||||
sourceRect.SizeTo(size.width, size.height);
|
||||
if (mScaleMode != ScaleMode::SCALE_NONE &&
|
||||
sourceRect.width != 0.0 && sourceRect.height != 0.0) {
|
||||
|
@ -115,34 +115,6 @@ TextureHost::GetIPDLActor()
|
||||
return mActor;
|
||||
}
|
||||
|
||||
// implemented in TextureOGL.cpp
|
||||
TemporaryRef<DeprecatedTextureHost> CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
|
||||
uint32_t aDeprecatedTextureHostFlags,
|
||||
uint32_t aTextureFlags);
|
||||
|
||||
/* static */ TemporaryRef<DeprecatedTextureHost>
|
||||
DeprecatedTextureHost::CreateDeprecatedTextureHost(SurfaceDescriptorType aDescriptorType,
|
||||
uint32_t aDeprecatedTextureHostFlags,
|
||||
uint32_t aTextureFlags,
|
||||
CompositableHost* aCompositableHost)
|
||||
{
|
||||
switch (Compositor::GetBackend()) {
|
||||
case LayersBackend::LAYERS_OPENGL:
|
||||
{
|
||||
RefPtr<DeprecatedTextureHost> result;
|
||||
result = CreateDeprecatedTextureHostOGL(aDescriptorType,
|
||||
aDeprecatedTextureHostFlags,
|
||||
aTextureFlags);
|
||||
if (aCompositableHost) {
|
||||
result->SetCompositableBackendSpecificData(aCompositableHost->GetCompositableBackendSpecificData());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
MOZ_CRASH("Couldn't create texture host");
|
||||
}
|
||||
}
|
||||
|
||||
// implemented in TextureHostOGL.cpp
|
||||
TemporaryRef<TextureHost> CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
@ -295,80 +267,6 @@ TextureSource::~TextureSource()
|
||||
MOZ_COUNT_DTOR(TextureSource);
|
||||
}
|
||||
|
||||
DeprecatedTextureHost::DeprecatedTextureHost()
|
||||
: mFlags(0)
|
||||
, mBuffer(nullptr)
|
||||
, mDeAllocator(nullptr)
|
||||
, mFormat(gfx::SurfaceFormat::UNKNOWN)
|
||||
{
|
||||
MOZ_COUNT_CTOR(DeprecatedTextureHost);
|
||||
}
|
||||
|
||||
DeprecatedTextureHost::~DeprecatedTextureHost()
|
||||
{
|
||||
if (mBuffer) {
|
||||
if (!(mFlags & TEXTURE_DEALLOCATE_CLIENT)) {
|
||||
if (mDeAllocator) {
|
||||
mDeAllocator->DestroySharedSurface(mBuffer);
|
||||
} else {
|
||||
MOZ_ASSERT(mBuffer->type() == SurfaceDescriptor::Tnull_t);
|
||||
}
|
||||
}
|
||||
delete mBuffer;
|
||||
}
|
||||
MOZ_COUNT_DTOR(DeprecatedTextureHost);
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureHost::Update(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset)
|
||||
{
|
||||
UpdateImpl(aImage, aRegion, aOffset);
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureHost::SwapTextures(const SurfaceDescriptor& aImage,
|
||||
SurfaceDescriptor* aResult,
|
||||
nsIntRegion* aRegion)
|
||||
{
|
||||
SwapTexturesImpl(aImage, aRegion);
|
||||
|
||||
MOZ_ASSERT(mBuffer, "trying to swap a non-buffered texture host?");
|
||||
if (aResult) {
|
||||
*aResult = *mBuffer;
|
||||
}
|
||||
*mBuffer = aImage;
|
||||
SetBuffer(mBuffer, mDeAllocator);
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureHost::OnShutdown()
|
||||
{
|
||||
if (ISurfaceAllocator::IsShmem(mBuffer)) {
|
||||
*mBuffer = SurfaceDescriptor();
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureHost::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
aTo += aPrefix;
|
||||
aTo += nsPrintfCString("%s (0x%p)", Name(), this);
|
||||
AppendToString(aTo, GetSize(), " [size=", "]");
|
||||
AppendToString(aTo, GetFormat(), " [format=", "]");
|
||||
AppendToString(aTo, mFlags, " [flags=", "]");
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureHost::SetBuffer(SurfaceDescriptor* aBuffer, ISurfaceAllocator* aAllocator)
|
||||
{
|
||||
MOZ_ASSERT(!mBuffer || mBuffer == aBuffer, "Will leak the old mBuffer");
|
||||
mBuffer = aBuffer;
|
||||
mDeAllocator = aAllocator;
|
||||
}
|
||||
|
||||
BufferTextureHost::BufferTextureHost(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags)
|
||||
: TextureHost(aFlags)
|
||||
|
@ -129,7 +129,6 @@ protected:
|
||||
RefPtr<CompositableBackendSpecificData> mCompositableBackendData;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* XXX - merge this class with TextureSource when deprecated texture classes
|
||||
* are completely removed.
|
||||
@ -585,248 +584,6 @@ protected:
|
||||
uint8_t* mBuffer;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* XXX - This class is deprectaed, will be removed soon.
|
||||
*
|
||||
* DeprecatedTextureHost is a thin abstraction over texture data that need to be shared
|
||||
* or transfered from the content process to the compositor process. It is the
|
||||
* compositor-side half of a DeprecatedTextureClient/DeprecatedTextureHost pair. A corresponding
|
||||
* DeprecatedTextureClient lives on the client-side.
|
||||
*
|
||||
* DeprecatedTextureHost only knows how to deserialize or synchronize generic image data
|
||||
* (SurfaceDescriptor) and provide access to one or more TextureSource objects
|
||||
* (these provide the necessary APIs for compositor backends to composite the
|
||||
* image).
|
||||
*
|
||||
* A DeprecatedTextureHost should mostly correspond to one or several SurfaceDescriptor
|
||||
* types. This means that for YCbCr planes, even though they are represented as
|
||||
* 3 textures internally, use 1 DeprecatedTextureHost and not 3, because the 3 planes
|
||||
* arrive in the same IPC message.
|
||||
*
|
||||
* The Lock/Unlock mechanism here mirrors Lock/Unlock in DeprecatedTextureClient. These two
|
||||
* methods don't always have to use blocking locks, unless a resource is shared
|
||||
* between the two sides (like shared texture handles). For instance, in some
|
||||
* cases the data received in Update(...) is a copy in shared memory of the data
|
||||
* owned by the content process, in which case no blocking lock is required.
|
||||
*
|
||||
* DeprecatedTextureHosts can be changed at any time, for example if we receive a
|
||||
* SurfaceDescriptor type that was not expected. This should be an incentive
|
||||
* to keep the ownership model simple (especially on the OpenGL case, where
|
||||
* we have additionnal constraints).
|
||||
*
|
||||
* There are two fundamental operations carried out on texture hosts - update
|
||||
* from the content thread and composition. Texture upload can occur in either
|
||||
* phase. Update happens in response to an IPDL message from content and
|
||||
* composition when the compositor 'ticks'. We may composite many times before
|
||||
* update.
|
||||
*
|
||||
* Update ends up at DeprecatedTextureHost::UpdateImpl. It always occurs in a layers
|
||||
* transacton. (TextureParent should call EnsureTexture before updating to
|
||||
* ensure the DeprecatedTextureHost exists and is of the correct type).
|
||||
*
|
||||
* CompositableHost::Composite does compositing. It should check the texture
|
||||
* host exists (and give up otherwise), then lock the texture host
|
||||
* (DeprecatedTextureHost::Lock). Then it passes the texture host to the Compositor in an
|
||||
* effect as a texture source, which does the actual composition. Finally the
|
||||
* compositable calls Unlock on the DeprecatedTextureHost.
|
||||
*
|
||||
* The class TextureImageDeprecatedTextureHostOGL is a good example of a DeprecatedTextureHost
|
||||
* implementation.
|
||||
*
|
||||
* This class is used only on the compositor side.
|
||||
*/
|
||||
class DeprecatedTextureHost : public TextureSource
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Create a new texture host to handle surfaces of aDescriptorType
|
||||
*
|
||||
* @param aDescriptorType The SurfaceDescriptor type being passed
|
||||
* @param aDeprecatedTextureHostFlags Modifier flags that specify changes in
|
||||
* the usage of a aDescriptorType, see DeprecatedTextureHostFlags
|
||||
* @param aTextureFlags Flags to pass to the new DeprecatedTextureHost
|
||||
*/
|
||||
static TemporaryRef<DeprecatedTextureHost> CreateDeprecatedTextureHost(SurfaceDescriptorType aDescriptorType,
|
||||
uint32_t aDeprecatedTextureHostFlags,
|
||||
uint32_t aTextureFlags,
|
||||
CompositableHost* aCompositableHost);
|
||||
|
||||
DeprecatedTextureHost();
|
||||
virtual ~DeprecatedTextureHost();
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
|
||||
|
||||
virtual bool IsValid() const { return true; }
|
||||
|
||||
/**
|
||||
* Update the texture host using the data from aSurfaceDescriptor.
|
||||
*
|
||||
* @param aImage Source image to update with.
|
||||
* @param aRegion Region of the texture host to update.
|
||||
* @param aOffset Offset in the source to update from
|
||||
*/
|
||||
void Update(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion = nullptr,
|
||||
nsIntPoint* aOffset = nullptr);
|
||||
|
||||
/**
|
||||
* Change the current surface of the texture host to aImage. aResult will return
|
||||
* the previous surface.
|
||||
*/
|
||||
void SwapTextures(const SurfaceDescriptor& aImage,
|
||||
SurfaceDescriptor* aResult = nullptr,
|
||||
nsIntRegion *aRegion = nullptr);
|
||||
|
||||
/**
|
||||
* Update for tiled texture hosts could probably have a better signature, but we
|
||||
* will replace it with PTexture stuff anyway, so nm.
|
||||
*/
|
||||
virtual void Update(gfxReusableSurfaceWrapper* aReusableSurface,
|
||||
TextureFlags aFlags,
|
||||
const gfx::IntSize& aSize) {}
|
||||
|
||||
/**
|
||||
* Lock the texture host for compositing, returns true if the DeprecatedTextureHost is
|
||||
* valid for composition.
|
||||
*/
|
||||
virtual bool Lock() { return IsValid(); }
|
||||
|
||||
/**
|
||||
* Unlock the texture host after compositing.
|
||||
* Should handle the case where Lock failed without crashing.
|
||||
*/
|
||||
virtual void Unlock() {}
|
||||
|
||||
void SetFlags(TextureFlags aFlags) { mFlags = aFlags; }
|
||||
void AddFlag(TextureFlags aFlag) { mFlags |= aFlag; }
|
||||
TextureFlags GetFlags() { return mFlags; }
|
||||
|
||||
/**
|
||||
* Sets ths DeprecatedTextureHost's compositor.
|
||||
* A DeprecatedTextureHost can change compositor on certain occasions, in particular if
|
||||
* it belongs to an async Compositable.
|
||||
* aCompositor can be null, in which case the DeprecatedTextureHost must cleanup all
|
||||
* of it's device textures.
|
||||
*/
|
||||
virtual void SetCompositor(Compositor* aCompositor) {}
|
||||
|
||||
ISurfaceAllocator* GetDeAllocator()
|
||||
{
|
||||
return mDeAllocator;
|
||||
}
|
||||
|
||||
bool operator== (const DeprecatedTextureHost& o) const
|
||||
{
|
||||
return GetIdentifier() == o.GetIdentifier();
|
||||
}
|
||||
bool operator!= (const DeprecatedTextureHost& o) const
|
||||
{
|
||||
return GetIdentifier() != o.GetIdentifier();
|
||||
}
|
||||
|
||||
virtual LayerRenderState GetRenderState()
|
||||
{
|
||||
return LayerRenderState();
|
||||
}
|
||||
|
||||
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() = 0;
|
||||
|
||||
virtual const char *Name() = 0;
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||
|
||||
/**
|
||||
* TEMPORARY.
|
||||
*
|
||||
* Ensure that a buffer of the given size/type has been allocated so that
|
||||
* we can update it using Update and/or CopyTo.
|
||||
*/
|
||||
virtual void EnsureBuffer(const nsIntSize& aSize, gfxContentType aType)
|
||||
{
|
||||
NS_RUNTIMEABORT("DeprecatedTextureHost doesn't support EnsureBuffer");
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the contents of this DeprecatedTextureHost to aDest. aDest must already
|
||||
* have a suitable buffer allocated using EnsureBuffer.
|
||||
*
|
||||
* @param aSourceRect Area of this texture host to copy.
|
||||
* @param aDest Destination texture host.
|
||||
* @param aDestRect Destination rect.
|
||||
*/
|
||||
virtual void CopyTo(const nsIntRect& aSourceRect,
|
||||
DeprecatedTextureHost *aDest,
|
||||
const nsIntRect& aDestRect)
|
||||
{
|
||||
NS_RUNTIMEABORT("DeprecatedTextureHost doesn't support CopyTo");
|
||||
}
|
||||
|
||||
|
||||
SurfaceDescriptor* GetBuffer() const { return mBuffer; }
|
||||
virtual SurfaceDescriptor* LockSurfaceDescriptor() const { return GetBuffer(); }
|
||||
|
||||
/**
|
||||
* Set a SurfaceDescriptor for this texture host. By setting a buffer and
|
||||
* allocator/de-allocator for the DeprecatedTextureHost, you cause the DeprecatedTextureHost to
|
||||
* retain a SurfaceDescriptor.
|
||||
* Ownership of the SurfaceDescriptor passes to this.
|
||||
*/
|
||||
virtual void SetBuffer(SurfaceDescriptor* aBuffer, ISurfaceAllocator* aAllocator);
|
||||
|
||||
// used only for hacky fix in gecko 23 for bug 862324
|
||||
// see bug 865908 about fixing this.
|
||||
virtual void ForgetBuffer() {}
|
||||
|
||||
void OnShutdown();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Should be implemented by the backend-specific DeprecatedTextureHost classes
|
||||
*
|
||||
* It should not take a reference to aImage, unless it knows the data
|
||||
* to be thread-safe.
|
||||
*/
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion,
|
||||
nsIntPoint *aOffset = nullptr)
|
||||
{
|
||||
NS_RUNTIMEABORT("Should not be reached");
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be implemented by the backend-specific DeprecatedTextureHost classes.
|
||||
*
|
||||
* Doesn't need to do the actual surface descriptor swap, just
|
||||
* any preparation work required to use the new descriptor.
|
||||
*
|
||||
* If the implementation doesn't define anything in particular
|
||||
* for handling swaps, then we can just do an update instead.
|
||||
*/
|
||||
virtual void SwapTexturesImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion *aRegion)
|
||||
{
|
||||
UpdateImpl(aImage, aRegion, nullptr);
|
||||
}
|
||||
|
||||
// An internal identifier for this texture host. Two texture hosts
|
||||
// should be considered equal iff their identifiers match. Should
|
||||
// not be exposed publicly.
|
||||
virtual uint64_t GetIdentifier() const
|
||||
{
|
||||
return reinterpret_cast<uint64_t>(this);
|
||||
}
|
||||
|
||||
// Texture info
|
||||
TextureFlags mFlags;
|
||||
SurfaceDescriptor* mBuffer; // FIXME [bjacob] it's terrible to have a SurfaceDescriptor here,
|
||||
// because SurfaceDescriptor's may have raw pointers to IPDL actors,
|
||||
// which can go away under our feet at any time. This is the cause
|
||||
// of bug 862324 among others. Our current understanding is that
|
||||
// this will be gone in Gecko 24. See bug 858914.
|
||||
RefPtr<ISurfaceAllocator> mDeAllocator;
|
||||
gfx::SurfaceFormat mFormat;
|
||||
};
|
||||
|
||||
class MOZ_STACK_CLASS AutoLockTextureHost
|
||||
{
|
||||
public:
|
||||
@ -850,32 +607,6 @@ private:
|
||||
bool mLocked;
|
||||
};
|
||||
|
||||
class AutoLockDeprecatedTextureHost
|
||||
{
|
||||
public:
|
||||
AutoLockDeprecatedTextureHost(DeprecatedTextureHost* aHost)
|
||||
: mDeprecatedTextureHost(aHost)
|
||||
, mIsValid(true)
|
||||
{
|
||||
if (mDeprecatedTextureHost) {
|
||||
mIsValid = mDeprecatedTextureHost->Lock();
|
||||
}
|
||||
}
|
||||
|
||||
~AutoLockDeprecatedTextureHost()
|
||||
{
|
||||
if (mDeprecatedTextureHost && mIsValid) {
|
||||
mDeprecatedTextureHost->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsValid() { return mIsValid; }
|
||||
|
||||
private:
|
||||
DeprecatedTextureHost *mDeprecatedTextureHost;
|
||||
bool mIsValid;
|
||||
};
|
||||
|
||||
/**
|
||||
* This can be used as an offscreen rendering target by the compositor, and
|
||||
* subsequently can be used as a source by the compositor.
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo, etc
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc
|
||||
#include "mozilla/layers/TextureHost.h" // for DeprecatedTextureHost
|
||||
#include "mozilla/layers/TextureHost.h" // for TextureHost
|
||||
#include "mozilla/layers/TiledContentClient.h"
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
|
@ -172,8 +172,7 @@ public:
|
||||
static bool IsShmem(SurfaceDescriptor* aSurface);
|
||||
|
||||
protected:
|
||||
// this method is needed for a temporary fix, will be removed after
|
||||
// DeprecatedTextureClient/Host rework.
|
||||
|
||||
virtual bool IsOnCompositorSide() const = 0;
|
||||
bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
|
||||
virtual bool PlatformAllocSurfaceDescriptor(const gfx::IntSize& aSize,
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient, etc
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
@ -56,20 +56,6 @@ CreateCompositableBackendSpecificDataOGL()
|
||||
#endif
|
||||
}
|
||||
|
||||
TemporaryRef<DeprecatedTextureHost>
|
||||
CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
|
||||
uint32_t aDeprecatedTextureHostFlags,
|
||||
uint32_t aTextureFlags)
|
||||
{
|
||||
RefPtr<DeprecatedTextureHost> result = nullptr;
|
||||
|
||||
result = new TextureImageDeprecatedTextureHostOGL();
|
||||
|
||||
result->SetFlags(aTextureFlags);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
|
||||
TemporaryRef<TextureHost>
|
||||
CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
@ -654,155 +640,5 @@ StreamTextureHostOGL::GetSize() const
|
||||
return mTextureSource->GetSize();
|
||||
}
|
||||
|
||||
TextureImageDeprecatedTextureHostOGL::~TextureImageDeprecatedTextureHostOGL()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TextureImageDeprecatedTextureHostOGL);
|
||||
if (mTexture && mTexture->InUpdate()) {
|
||||
mTexture->EndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
gfx::IntSize
|
||||
TextureImageDeprecatedTextureHostOGL::GetSize() const
|
||||
{
|
||||
if (mTexture) {
|
||||
if (mIterating) {
|
||||
return mTexture->GetTileRect().Size();
|
||||
}
|
||||
return mTexture->GetSize();
|
||||
}
|
||||
return gfx::IntSize(0, 0);
|
||||
}
|
||||
|
||||
nsIntRect TextureImageDeprecatedTextureHostOGL::GetTileRect()
|
||||
{
|
||||
return ThebesIntRect(mTexture->GetTileRect());
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageDeprecatedTextureHostOGL::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositorOGL* glCompositor = static_cast<CompositorOGL*>(aCompositor);
|
||||
GLContext* newGL = glCompositor ? glCompositor->gl() : nullptr;
|
||||
if (mGL != newGL) {
|
||||
mGL = newGL;
|
||||
mTexture = nullptr;
|
||||
// if we have a buffer we reupload it with the new gl context
|
||||
// Post landing TODO: the new DeprecatedTextureClient/Host model will make this
|
||||
// go away.
|
||||
if (newGL && mBuffer && IsSurfaceDescriptorValid(*mBuffer)) {
|
||||
UpdateImpl(*mBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageDeprecatedTextureHostOGL::EnsureBuffer(const nsIntSize& aSize,
|
||||
gfxContentType aContentType)
|
||||
{
|
||||
if (!mTexture ||
|
||||
mTexture->GetSize() != aSize.ToIntSize() ||
|
||||
mTexture->GetContentType() != aContentType) {
|
||||
mTexture = CreateTextureImage(mGL,
|
||||
aSize.ToIntSize(),
|
||||
aContentType,
|
||||
WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
|
||||
FlagsToGLFlags(mFlags));
|
||||
}
|
||||
mTexture->Resize(aSize.ToIntSize());
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageDeprecatedTextureHostOGL::CopyTo(const nsIntRect& aSourceRect,
|
||||
DeprecatedTextureHost *aDest,
|
||||
const nsIntRect& aDestRect)
|
||||
{
|
||||
MOZ_ASSERT(aDest->AsSourceOGL(), "Incompatible destination type!");
|
||||
TextureImageDeprecatedTextureHostOGL *dest =
|
||||
aDest->AsSourceOGL()->AsTextureImageDeprecatedTextureHost();
|
||||
MOZ_ASSERT(dest, "Incompatible destination type!");
|
||||
|
||||
mGL->BlitTextureImageHelper()->BlitTextureImage(mTexture, aSourceRect,
|
||||
dest->mTexture, aDestRect);
|
||||
dest->mTexture->MarkValid();
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageDeprecatedTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset)
|
||||
{
|
||||
if (!mGL) {
|
||||
NS_WARNING("trying to update TextureImageDeprecatedTextureHostOGL without a compositor?");
|
||||
return;
|
||||
}
|
||||
|
||||
AutoOpenSurface surf(OPEN_READ_ONLY, aImage);
|
||||
gfx::IntSize size = surf.Size();
|
||||
TextureImage::ImageFormat format = surf.ImageFormat();
|
||||
|
||||
if (!mTexture ||
|
||||
(mTexture->GetSize() != size && !aOffset) ||
|
||||
mTexture->GetContentType() != surf.ContentType() ||
|
||||
(mTexture->GetImageFormat() != format &&
|
||||
mTexture->GetImageFormat() != gfxImageFormat::Unknown)) {
|
||||
|
||||
mTexture = CreateTextureImage(mGL,
|
||||
size,
|
||||
surf.ContentType(),
|
||||
WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
|
||||
FlagsToGLFlags(mFlags),
|
||||
format);
|
||||
}
|
||||
|
||||
// XXX this is always just ridiculously slow
|
||||
nsIntRegion updateRegion;
|
||||
|
||||
if (!aRegion) {
|
||||
updateRegion = nsIntRegion(nsIntRect(0, 0, size.width, size.height));
|
||||
} else {
|
||||
updateRegion = *aRegion;
|
||||
}
|
||||
gfx::IntPoint offset;
|
||||
if (aOffset) {
|
||||
offset.x = aOffset->x;
|
||||
offset.y = aOffset->y;
|
||||
}
|
||||
nsRefPtr<gfxImageSurface> thebesSurf = surf.GetAsImage();
|
||||
RefPtr<DataSourceSurface> sourceSurf =
|
||||
gfx::Factory::CreateWrappingDataSourceSurface(thebesSurf->Data(),
|
||||
thebesSurf->Stride(),
|
||||
ToIntSize(thebesSurf->GetSize()),
|
||||
ImageFormatToSurfaceFormat(thebesSurf->Format()));
|
||||
mTexture->DirectUpdate(sourceSurf, updateRegion, offset);
|
||||
mFormat = mTexture->GetTextureFormat();
|
||||
|
||||
if (mTexture->InUpdate()) {
|
||||
mTexture->EndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TextureImageDeprecatedTextureHostOGL::Lock()
|
||||
{
|
||||
if (!mTexture) {
|
||||
NS_WARNING("TextureImageDeprecatedTextureHost to be composited without texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
mFormat = mTexture->GetTextureFormat();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TemporaryRef<gfx::DataSourceSurface>
|
||||
TextureImageDeprecatedTextureHostOGL::GetAsSurface() {
|
||||
RefPtr<gfx::DataSourceSurface> surf =
|
||||
IsValid() ? ReadBackSurface(mGL, mTexture->GetTextureID(),
|
||||
false, mTexture->GetTextureFormat())
|
||||
: nullptr;
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "mozilla/gfx/Types.h" // for SurfaceFormat, etc
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureFlags
|
||||
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
||||
#include "mozilla/layers/TextureHost.h" // for DeprecatedTextureHost, etc
|
||||
#include "mozilla/layers/TextureHost.h" // for TextureHost, etc
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
@ -53,7 +53,6 @@ namespace layers {
|
||||
|
||||
class Compositor;
|
||||
class CompositorOGL;
|
||||
class TextureImageDeprecatedTextureHostOGL;
|
||||
class TextureImageTextureSourceOGL;
|
||||
|
||||
/**
|
||||
@ -129,7 +128,6 @@ public:
|
||||
|
||||
virtual gfx::Matrix4x4 GetTextureTransform() { return gfx::Matrix4x4(); }
|
||||
|
||||
virtual TextureImageDeprecatedTextureHostOGL* AsTextureImageDeprecatedTextureHost() { return nullptr; }
|
||||
virtual TextureImageTextureSourceOGL* AsTextureImageTextureSource() { return nullptr; }
|
||||
|
||||
void SetFilter(gl::GLContext* aGL, gfx::Filter aFilter)
|
||||
@ -487,130 +485,6 @@ protected:
|
||||
RefPtr<StreamTextureSourceOGL> mTextureSource;
|
||||
};
|
||||
|
||||
/**
|
||||
* DeprecatedTextureHost implementation using a TextureImage as the underlying texture.
|
||||
*/
|
||||
class TextureImageDeprecatedTextureHostOGL : public DeprecatedTextureHost
|
||||
, public TextureSourceOGL
|
||||
, public TileIterator
|
||||
{
|
||||
public:
|
||||
TextureImageDeprecatedTextureHostOGL(gl::TextureImage* aTexImage = nullptr)
|
||||
: mTexture(aTexImage)
|
||||
, mGL(nullptr)
|
||||
, mIterating(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TextureImageDeprecatedTextureHostOGL);
|
||||
}
|
||||
|
||||
~TextureImageDeprecatedTextureHostOGL();
|
||||
|
||||
TextureSourceOGL* AsSourceOGL() MOZ_OVERRIDE
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
virtual TextureImageDeprecatedTextureHostOGL* AsTextureImageDeprecatedTextureHost() MOZ_OVERRIDE
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
// This is a hack that is here to not break on-main-thread ThebesLayerBuffer
|
||||
// please do not use it anywhere else, use SetCompositor instead.
|
||||
void SetGLContext(gl::GLContext* aGL)
|
||||
{
|
||||
mGL = aGL;
|
||||
}
|
||||
|
||||
// DeprecatedTextureHost
|
||||
|
||||
void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion = nullptr,
|
||||
nsIntPoint* aOffset = nullptr) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void EnsureBuffer(const nsIntSize& aSize, gfxContentType aType) MOZ_OVERRIDE;
|
||||
|
||||
virtual void CopyTo(const nsIntRect& aSourceRect,
|
||||
DeprecatedTextureHost *aDest,
|
||||
const nsIntRect& aDestRect) MOZ_OVERRIDE;
|
||||
|
||||
bool IsValid() const MOZ_OVERRIDE
|
||||
{
|
||||
return !!mTexture;
|
||||
}
|
||||
|
||||
virtual bool Lock() MOZ_OVERRIDE;
|
||||
|
||||
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
// textureSource
|
||||
void BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) MOZ_OVERRIDE
|
||||
{
|
||||
mTexture->BindTexture(aTextureUnit);
|
||||
}
|
||||
|
||||
gfx::IntSize GetSize() const MOZ_OVERRIDE;
|
||||
|
||||
GLenum GetWrapMode() const MOZ_OVERRIDE
|
||||
{
|
||||
return mTexture->GetWrapMode();
|
||||
}
|
||||
|
||||
gl::TextureImage* GetTextureImage()
|
||||
{
|
||||
return mTexture;
|
||||
}
|
||||
|
||||
void SetTextureImage(gl::TextureImage* aImage)
|
||||
{
|
||||
mTexture = aImage;
|
||||
}
|
||||
|
||||
// TileIterator
|
||||
|
||||
TileIterator* AsTileIterator() MOZ_OVERRIDE
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void BeginTileIteration() MOZ_OVERRIDE
|
||||
{
|
||||
mTexture->BeginTileIteration();
|
||||
mIterating = true;
|
||||
}
|
||||
|
||||
void EndTileIteration() MOZ_OVERRIDE
|
||||
{
|
||||
mIterating = false;
|
||||
}
|
||||
|
||||
nsIntRect GetTileRect() MOZ_OVERRIDE;
|
||||
|
||||
size_t GetTileCount() MOZ_OVERRIDE
|
||||
{
|
||||
return mTexture->GetTileCount();
|
||||
}
|
||||
|
||||
bool NextTile() MOZ_OVERRIDE
|
||||
{
|
||||
return mTexture->NextTile();
|
||||
}
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
|
||||
{
|
||||
return DeprecatedTextureHost::GetFormat();
|
||||
}
|
||||
|
||||
virtual const char* Name() { return "TextureImageDeprecatedTextureHostOGL"; }
|
||||
|
||||
protected:
|
||||
nsRefPtr<gl::TextureImage> mTexture;
|
||||
gl::GLContext* mGL;
|
||||
bool mIterating;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user