2013-04-30 17:42:05 -07:00
|
|
|
/* -*- 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_BASICCOMPOSITOR_H
|
|
|
|
#define MOZILLA_GFX_BASICCOMPOSITOR_H
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
#include "mozilla/layers/Compositor.h"
|
|
|
|
#include "mozilla/layers/TextureHost.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-09-24 13:45:14 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
|
|
|
|
class gfxContext;
|
2013-04-30 17:42:05 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class BasicCompositingRenderTarget : public CompositingRenderTarget
|
|
|
|
{
|
|
|
|
public:
|
2013-11-07 01:53:08 -08:00
|
|
|
BasicCompositingRenderTarget(gfx::DrawTarget* aDrawTarget, const gfx::IntRect& aRect)
|
|
|
|
: CompositingRenderTarget(aRect.TopLeft())
|
|
|
|
, mDrawTarget(aDrawTarget)
|
|
|
|
, mSize(aRect.Size())
|
2013-04-30 17:42:05 -07:00
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
|
|
|
|
|
2013-08-27 01:52:14 -07:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return mDrawTarget ? mDrawTarget->GetFormat()
|
2014-01-10 11:06:16 -08:00
|
|
|
: gfx::SurfaceFormat(gfx::SurfaceFormat::UNKNOWN);
|
2013-08-27 01:52:14 -07:00
|
|
|
}
|
|
|
|
|
2013-04-30 17:42:05 -07:00
|
|
|
RefPtr<gfx::DrawTarget> mDrawTarget;
|
|
|
|
gfx::IntSize mSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BasicCompositor : public Compositor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BasicCompositor(nsIWidget *aWidget);
|
|
|
|
|
|
|
|
virtual ~BasicCompositor();
|
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
|
2013-04-30 17:42:05 -07:00
|
|
|
virtual bool Initialize() MOZ_OVERRIDE { return true; };
|
|
|
|
|
2013-07-08 21:21:05 -07:00
|
|
|
virtual void Destroy() MOZ_OVERRIDE;
|
2013-04-30 17:42:05 -07:00
|
|
|
|
|
|
|
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() MOZ_OVERRIDE
|
|
|
|
{
|
2014-01-23 10:26:41 -08:00
|
|
|
return TextureFactoryIdentifier(LayersBackend::LAYERS_BASIC,
|
2013-08-04 00:46:17 -07:00
|
|
|
XRE_GetProcessType(),
|
|
|
|
GetMaxTextureSize());
|
2013-04-30 17:42:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual TemporaryRef<CompositingRenderTarget>
|
|
|
|
CreateRenderTarget(const gfx::IntRect &aRect, SurfaceInitMode aInit) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual TemporaryRef<CompositingRenderTarget>
|
|
|
|
CreateRenderTargetFromSource(const gfx::IntRect &aRect,
|
2013-11-07 01:53:07 -08:00
|
|
|
const CompositingRenderTarget *aSource,
|
|
|
|
const gfx::IntPoint &aSourcePoint) MOZ_OVERRIDE;
|
2013-04-30 17:42:05 -07:00
|
|
|
|
2013-08-27 01:52:14 -07:00
|
|
|
virtual TemporaryRef<DataTextureSource>
|
2014-04-25 19:34:05 -07:00
|
|
|
CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) MOZ_OVERRIDE;
|
2013-08-27 01:52:14 -07:00
|
|
|
|
|
|
|
virtual bool SupportsEffect(EffectTypes aEffect) MOZ_OVERRIDE;
|
|
|
|
|
2013-04-30 17:42:05 -07:00
|
|
|
virtual void SetRenderTarget(CompositingRenderTarget *aSource) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
mRenderTarget = static_cast<BasicCompositingRenderTarget*>(aSource);
|
|
|
|
}
|
2014-04-02 00:27:42 -07:00
|
|
|
virtual CompositingRenderTarget* GetCurrentRenderTarget() const MOZ_OVERRIDE
|
2013-04-30 17:42:05 -07:00
|
|
|
{
|
|
|
|
return mRenderTarget;
|
|
|
|
}
|
|
|
|
|
2013-11-07 01:53:08 -08:00
|
|
|
virtual void DrawQuad(const gfx::Rect& aRect,
|
|
|
|
const gfx::Rect& aClipRect,
|
2013-04-30 17:42:05 -07:00
|
|
|
const EffectChain &aEffectChain,
|
2013-11-07 01:53:08 -08:00
|
|
|
gfx::Float aOpacity,
|
|
|
|
const gfx::Matrix4x4 &aTransform) MOZ_OVERRIDE;
|
2013-04-30 17:42:05 -07:00
|
|
|
|
2014-05-21 19:36:26 -07:00
|
|
|
virtual void ClearRect(const gfx::Rect& aRect) MOZ_OVERRIDE;
|
|
|
|
|
2013-11-21 11:25:16 -08:00
|
|
|
virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
|
|
|
|
const gfx::Rect *aClipRectIn,
|
2014-01-15 23:22:19 -08:00
|
|
|
const gfx::Matrix& aTransform,
|
2013-04-30 17:42:05 -07:00
|
|
|
const gfx::Rect& aRenderBounds,
|
|
|
|
gfx::Rect *aClipRectOut = nullptr,
|
|
|
|
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
|
|
|
|
virtual void EndFrame() MOZ_OVERRIDE;
|
2014-01-15 23:22:19 -08:00
|
|
|
virtual void EndFrameForExternalComposition(const gfx::Matrix& aTransform) MOZ_OVERRIDE
|
2013-04-30 17:42:05 -07:00
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("We shouldn't ever hit this");
|
|
|
|
}
|
|
|
|
virtual void AbortFrame() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool SupportsPartialTextureUpdate() { return true; }
|
2013-09-26 17:37:19 -07:00
|
|
|
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE { return true; }
|
2013-04-30 17:42:05 -07:00
|
|
|
virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE { return INT32_MAX; }
|
|
|
|
virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE { }
|
|
|
|
|
2013-06-03 07:00:02 -07:00
|
|
|
virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) MOZ_OVERRIDE {
|
2013-04-30 17:42:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) { }
|
|
|
|
|
|
|
|
virtual void PrepareViewport(const gfx::IntSize& aSize,
|
2014-01-27 12:25:20 -08:00
|
|
|
const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE { }
|
2013-04-30 17:42:05 -07:00
|
|
|
|
|
|
|
virtual const char* Name() const { return "Basic"; }
|
|
|
|
|
2014-02-17 16:30:05 -08:00
|
|
|
virtual LayersBackend GetBackendType() const MOZ_OVERRIDE {
|
|
|
|
return LayersBackend::LAYERS_BASIC;
|
|
|
|
}
|
|
|
|
|
2013-04-30 17:42:05 -07:00
|
|
|
virtual nsIWidget* GetWidget() const MOZ_OVERRIDE { return mWidget; }
|
|
|
|
|
|
|
|
gfx::DrawTarget *GetDrawTarget() { return mDrawTarget; }
|
|
|
|
|
|
|
|
private:
|
2014-04-25 04:38:17 -07:00
|
|
|
|
|
|
|
virtual gfx::IntSize GetWidgetSize() const MOZ_OVERRIDE { return mWidgetSize; }
|
|
|
|
|
2013-04-30 17:42:05 -07:00
|
|
|
// Widget associated with this compositor
|
|
|
|
nsIWidget *mWidget;
|
2014-04-25 04:38:17 -07:00
|
|
|
gfx::IntSize mWidgetSize;
|
2013-04-30 17:42:05 -07:00
|
|
|
|
|
|
|
// The final destination surface
|
|
|
|
RefPtr<gfx::DrawTarget> mDrawTarget;
|
|
|
|
// The current render target for drawing
|
|
|
|
RefPtr<BasicCompositingRenderTarget> mRenderTarget;
|
2013-11-21 11:25:16 -08:00
|
|
|
|
|
|
|
gfx::IntRect mInvalidRect;
|
|
|
|
nsIntRegion mInvalidRegion;
|
2013-04-30 17:42:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_BASICCOMPOSITOR_H */
|