mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-12 14:37:50 +00:00
2cf9a19eef
find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)DIAGNOSTIC_\(NONE\|TILE_BORDERS\|LAYER_BORDERS\|BIGIMAGE_BORDERS\|FLASH_BORDERS\)\($\|[^A-Za-z0-9_]\)/\1DiagnosticTypes::\2\3/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/DiagnosticTypes\:\:NONE/DiagosticTypes::NO_DIAGNOSTIC/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)DIAGNOSTIC_\(IMAGE\|CONTENT\|CANVAS\|COLOR\|CONTAINER\|TILE\|BIGIMAGE\|COMPONENT_ALPHA\|REGION_RECT\)\($\|[^A-Za-z0-9_]\)/\1DiagnosticFlags::\2\3/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)EFFECT_\(MASK\|MAX_SECONDARY\|RGB\|YCBCR\|COMPONENT_ALPHA\|SOLID_COLOR\|RENDER_TARGET\|MAX\)\($\|[^A-Za-z0-9_]\)/\1EffectTypes::\2\3/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)TEXTURE_\(CONTENT\|SHMEM\|YCBCR\|SHARED_GL\|SHARED_GL_EXTERNAL\|STREAM_GL\|FALLBACK\)\($\|[^A-Za-z0-9_]\)/\1DeprecatedTextureClientType::\2\3/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)\(BUFFER_UNKNOWN\|BUFFER_IMAGE_SINGLE\|BUFFER_IMAGE_BUFFERED\|BUFFER_BRIDGE\|BUFFER_CONTENT\|BUFFER_CONTENT_DIRECT\|BUFFER_CONTENT_INC\|BUFFER_TILED\|BUFFER_SIMPLE_TILED\|COMPOSITABLE_IMAGE\|COMPOSITABLE_CONTENT_SINGLE\|COMPOSITABLE_CONTENT_DOUBLE\|BUFFER_COUNT\)\($\|[^A-Za-z0-9_]\)/\1CompositableType::\2\3/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/CompositableType\:\:COMPOSITABLE_/CompositableType::/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)TEXTURE_HOST_\(DEFAULT\|TILED\|COPY_PREVIOUS\)\($\|[^A-Za-z0-9_]\)/\1DeprecatedTextureHostFlags::\2\3/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)Texture\(Front\|Back\|OnWhiteFront\|OnWhiteBack\)\($\|[^A-Za-z0-9_]\)/\1TextureIdentifier::\2\3/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)\(OPEN_NONE\|OPEN_READ\|OPEN_WRITE\|OPEN_READ_WRITE\|OPEN_READ_ONLY\|OPEN_WRITE_ONLY\)\($\|[^A-Za-z0-9_]\)/\1OpenMode::\2\3/g' find gfx/layers -type f | grep -v CompositorTypes.h | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)\(MaskNone\|Mask2d\|Mask3d\|NumMaskTypes\)\($\|[^A-Za-z0-9_]\)/\1MaskType::\2\3/g' find gfx -type f | xargs sed -i 's/Diagostic/Diagnostic/g'
139 lines
3.6 KiB
C++
139 lines
3.6 KiB
C++
/* -*- 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 MOZILLA_GFX_CANVASCLIENT_H
|
|
#define MOZILLA_GFX_CANVASCLIENT_H
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
|
|
#include "mozilla/RefPtr.h" // for RefPtr, TemporaryRef
|
|
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
|
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo, etc
|
|
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
|
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
|
#include "mozilla/mozalloc.h" // for operator delete
|
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
|
|
|
namespace mozilla {
|
|
namespace gfx {
|
|
class SharedSurface;
|
|
}
|
|
}
|
|
|
|
namespace mozilla {
|
|
namespace layers {
|
|
|
|
class ClientCanvasLayer;
|
|
class CompositableForwarder;
|
|
|
|
/**
|
|
* Compositable client for 2d and webgl canvas.
|
|
*/
|
|
class CanvasClient : public CompositableClient
|
|
{
|
|
public:
|
|
/**
|
|
* Creates, configures, and returns a new canvas client. If necessary, a
|
|
* message will be sent to the compositor to create a corresponding image
|
|
* host.
|
|
*/
|
|
enum CanvasClientType {
|
|
CanvasClientSurface,
|
|
CanvasClientGLContext,
|
|
};
|
|
static TemporaryRef<CanvasClient> CreateCanvasClient(CanvasClientType aType,
|
|
CompositableForwarder* aFwd,
|
|
TextureFlags aFlags);
|
|
|
|
CanvasClient(CompositableForwarder* aFwd, TextureFlags aFlags)
|
|
: CompositableClient(aFwd, aFlags)
|
|
{
|
|
mTextureInfo.mTextureFlags = aFlags;
|
|
}
|
|
|
|
virtual ~CanvasClient() {}
|
|
|
|
virtual void Clear() {};
|
|
|
|
virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) = 0;
|
|
|
|
virtual void Updated() { }
|
|
|
|
protected:
|
|
TextureInfo mTextureInfo;
|
|
};
|
|
|
|
// Used for 2D canvases and WebGL canvas on non-GL systems where readback is requried.
|
|
class CanvasClient2D : public CanvasClient
|
|
{
|
|
public:
|
|
CanvasClient2D(CompositableForwarder* aLayerForwarder,
|
|
TextureFlags aFlags)
|
|
: CanvasClient(aLayerForwarder, aFlags)
|
|
{
|
|
}
|
|
|
|
TextureInfo GetTextureInfo() const
|
|
{
|
|
return TextureInfo(CompositableType::IMAGE);
|
|
}
|
|
|
|
virtual void Clear() MOZ_OVERRIDE
|
|
{
|
|
mBuffer = nullptr;
|
|
}
|
|
|
|
virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) MOZ_OVERRIDE;
|
|
|
|
virtual bool AddTextureClient(TextureClient* aTexture) MOZ_OVERRIDE
|
|
{
|
|
MOZ_ASSERT((mTextureInfo.mTextureFlags & aTexture->GetFlags()) == mTextureInfo.mTextureFlags);
|
|
return CompositableClient::AddTextureClient(aTexture);
|
|
}
|
|
|
|
virtual void OnDetach() MOZ_OVERRIDE
|
|
{
|
|
mBuffer = nullptr;
|
|
}
|
|
|
|
private:
|
|
RefPtr<TextureClient> mBuffer;
|
|
};
|
|
|
|
// Used for GL canvases where we don't need to do any readback, i.e., with a
|
|
// GL backend.
|
|
class CanvasClientSurfaceStream : public CanvasClient
|
|
{
|
|
public:
|
|
CanvasClientSurfaceStream(CompositableForwarder* aLayerForwarder, TextureFlags aFlags);
|
|
|
|
TextureInfo GetTextureInfo() const
|
|
{
|
|
return TextureInfo(CompositableType::IMAGE);
|
|
}
|
|
|
|
virtual void Clear() MOZ_OVERRIDE
|
|
{
|
|
mBuffer = nullptr;
|
|
}
|
|
|
|
virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) MOZ_OVERRIDE;
|
|
|
|
virtual void OnDetach() MOZ_OVERRIDE
|
|
{
|
|
mBuffer = nullptr;
|
|
}
|
|
|
|
private:
|
|
RefPtr<TextureClient> mBuffer;
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|