gecko/gfx/layers/client/ImageClient.h
Bas Schouten 341383c413 Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.

Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00

127 lines
3.7 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_IMAGECLIENT_H
#define MOZILLA_GFX_IMAGECLIENT_H
#include "mozilla/layers/LayersSurfaces.h"
#include "mozilla/layers/CompositableClient.h"
#include "mozilla/layers/TextureClient.h"
#include "gfxPattern.h"
namespace mozilla {
namespace layers {
class ImageContainer;
class ImageLayer;
class PlanarYCbCrImage;
/**
* Image clients are used by basic image layers on the content thread, they
* always match with an ImageHost on the compositor thread. See
* CompositableClient.h for information on connecting clients to hosts.
*/
class ImageClient : public CompositableClient
{
public:
/**
* Creates, configures, and returns a new image client. If necessary, a
* message will be sent to the compositor to create a corresponding image
* host.
*/
static TemporaryRef<ImageClient> CreateImageClient(LayersBackend aBackendType,
CompositableType aImageHostType,
CompositableForwarder* aFwd,
TextureFlags aFlags);
virtual ~ImageClient() {}
virtual CompositableType GetType() const MOZ_OVERRIDE
{
return mType;
}
/**
* Update this ImageClient from aContainer in aLayer
* returns false if this is the wrong kind of ImageClient for aContainer.
* Note that returning true does not necessarily imply success
*/
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) = 0;
/**
* Notify the compositor that this image client has been updated
*/
virtual void Updated() = 0;
/**
* The picture rect is the area of the texture which makes up the image. That
* is, the area that should be composited. In texture space.
*/
virtual void UpdatePictureRect(nsIntRect aPictureRect);
virtual already_AddRefed<Image> CreateImage(const uint32_t *aFormats,
uint32_t aNumFormats);
protected:
ImageClient(CompositableForwarder* aFwd, CompositableType aType);
gfxPattern::GraphicsFilter mFilter;
CompositableType mType;
int32_t mLastPaintedImageSerial;
nsIntRect mPictureRect;
};
/**
* An image client which uses a single texture client, may be single or double
* buffered. (As opposed to using two texture clients for buffering, as in
* ContentClientDoubleBuffered, or using multiple clients for YCbCr or tiled
* images).
*/
class ImageClientSingle : public ImageClient
{
public:
ImageClientSingle(CompositableForwarder* aFwd,
TextureFlags aFlags,
CompositableType aType);
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
void EnsureTextureClient(TextureClientType aType);
virtual void Updated();
private:
RefPtr<TextureClient> mTextureClient;
TextureFlags mFlags;
};
/**
* Image class to be used for async image uploads using the image bridge
* protocol.
* We store the ImageBridge id in the TextureClientIdentifier.
*/
class ImageClientBridge : public ImageClient
{
public:
ImageClientBridge(CompositableForwarder* aFwd,
TextureFlags aFlags);
virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
virtual bool Connect() { return false; }
virtual void Updated() {}
void SetLayer(ShadowableLayer* aLayer)
{
mLayer = aLayer;
}
protected:
uint64_t mAsyncContainerID;
ShadowableLayer* mLayer;
};
}
}
#endif