2010-05-27 13:04:26 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2010-03-29 21:48:52 -07:00
|
|
|
|
|
|
|
#ifndef GFX_THEBESLAYEROGL_H
|
|
|
|
#define GFX_THEBESLAYEROGL_H
|
|
|
|
|
2011-04-02 19:14:00 -07:00
|
|
|
#include "mozilla/layers/PLayers.h"
|
|
|
|
#include "mozilla/layers/ShadowLayers.h"
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2010-03-29 21:48:52 -07:00
|
|
|
#include "Layers.h"
|
|
|
|
#include "LayerManagerOGL.h"
|
|
|
|
#include "gfxImageSurface.h"
|
2010-06-23 07:01:29 -07:00
|
|
|
#include "GLContext.h"
|
2012-03-17 05:07:02 -07:00
|
|
|
#include "base/task.h"
|
2010-03-29 21:48:52 -07:00
|
|
|
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2010-07-22 13:29:37 -07:00
|
|
|
class ThebesLayerBufferOGL;
|
2010-10-01 20:56:56 -07:00
|
|
|
class BasicBufferOGL;
|
2010-10-13 15:55:45 -07:00
|
|
|
class ShadowBufferOGL;
|
2010-07-22 13:29:37 -07:00
|
|
|
|
2010-03-29 21:48:52 -07:00
|
|
|
class ThebesLayerOGL : public ThebesLayer,
|
2010-08-06 22:09:18 -07:00
|
|
|
public LayerOGL
|
2010-03-29 21:48:52 -07:00
|
|
|
{
|
2010-07-22 13:29:37 -07:00
|
|
|
typedef ThebesLayerBufferOGL Buffer;
|
2010-07-01 09:30:38 -07:00
|
|
|
|
2010-03-29 21:48:52 -07:00
|
|
|
public:
|
2010-04-26 19:09:47 -07:00
|
|
|
ThebesLayerOGL(LayerManagerOGL *aManager);
|
2010-03-29 21:48:52 -07:00
|
|
|
virtual ~ThebesLayerOGL();
|
|
|
|
|
|
|
|
/** Layer implementation */
|
|
|
|
void SetVisibleRegion(const nsIntRegion& aRegion);
|
|
|
|
|
|
|
|
/** ThebesLayer implementation */
|
|
|
|
void InvalidateRegion(const nsIntRegion& aRegion);
|
|
|
|
|
|
|
|
/** LayerOGL implementation */
|
2010-08-06 22:09:18 -07:00
|
|
|
void Destroy();
|
2010-03-29 21:48:52 -07:00
|
|
|
Layer* GetLayer();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsEmpty();
|
2010-05-20 20:20:48 -07:00
|
|
|
virtual void RenderLayer(int aPreviousFrameBuffer,
|
2010-11-08 01:06:15 -08:00
|
|
|
const nsIntPoint& aOffset);
|
2012-01-15 21:41:55 -08:00
|
|
|
virtual void CleanupResources();
|
2010-03-29 21:48:52 -07:00
|
|
|
|
|
|
|
private:
|
2010-10-01 20:56:56 -07:00
|
|
|
friend class BasicBufferOGL;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool CreateSurface();
|
2010-03-29 21:48:52 -07:00
|
|
|
|
2010-07-22 13:29:37 -07:00
|
|
|
nsRefPtr<Buffer> mBuffer;
|
2010-03-29 21:48:52 -07:00
|
|
|
};
|
|
|
|
|
2012-03-17 05:07:02 -07:00
|
|
|
class ShadowThebesLayerBufferOGL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShadowThebesLayerBufferOGL()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ShadowThebesLayerBufferOGL);
|
|
|
|
}
|
|
|
|
|
|
|
|
~ShadowThebesLayerBufferOGL()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ShadowThebesLayerBufferOGL);
|
|
|
|
}
|
|
|
|
|
2012-07-12 05:51:58 -07:00
|
|
|
void Swap(const SurfaceDescriptor& aDescriptor,
|
2012-03-17 05:07:02 -07:00
|
|
|
const nsIntRect& aNewRect, const nsIntPoint& aNewRotation,
|
2012-07-12 05:51:58 -07:00
|
|
|
SurfaceDescriptor* aOldDescriptor,
|
2012-03-17 05:07:02 -07:00
|
|
|
nsIntRect* aOldRect, nsIntPoint* aOldRotation)
|
|
|
|
{
|
2012-07-12 05:51:58 -07:00
|
|
|
*aOldDescriptor = mBuffer;
|
2012-03-17 05:07:02 -07:00
|
|
|
*aOldRect = mBufferRect;
|
|
|
|
*aOldRotation = mBufferRotation;
|
|
|
|
|
2012-07-12 05:51:58 -07:00
|
|
|
mBuffer = aDescriptor;
|
2012-03-17 05:07:02 -07:00
|
|
|
mBufferRect = aNewRect;
|
|
|
|
mBufferRotation = aNewRotation;
|
|
|
|
}
|
|
|
|
|
2012-03-17 05:07:02 -07:00
|
|
|
nsIntRect Rect() {
|
|
|
|
return mBufferRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntPoint Rotation() {
|
|
|
|
return mBufferRotation;
|
|
|
|
}
|
|
|
|
|
2012-07-12 05:51:58 -07:00
|
|
|
SurfaceDescriptor Buffer() {
|
2012-03-17 05:07:02 -07:00
|
|
|
return mBuffer;
|
|
|
|
}
|
|
|
|
|
2012-03-17 05:07:02 -07:00
|
|
|
/**
|
|
|
|
* Wipe out all retained contents. Call this when the entire
|
|
|
|
* buffer becomes invalid.
|
|
|
|
*/
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
mBufferRect.SetEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2012-07-12 05:51:58 -07:00
|
|
|
SurfaceDescriptor mBuffer;
|
2012-03-17 05:07:02 -07:00
|
|
|
nsIntRect mBufferRect;
|
|
|
|
nsIntPoint mBufferRotation;
|
|
|
|
};
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
class ShadowThebesLayerOGL : public ShadowThebesLayer,
|
|
|
|
public LayerOGL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShadowThebesLayerOGL(LayerManagerOGL *aManager);
|
|
|
|
virtual ~ShadowThebesLayerOGL();
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
Swap(const ThebesBuffer& aNewFront, const nsIntRegion& aUpdatedRegion,
|
2011-10-10 09:47:27 -07:00
|
|
|
OptionalThebesBuffer* aNewBack, nsIntRegion* aNewBackValidRegion,
|
2010-11-05 00:17:07 -07:00
|
|
|
OptionalThebesBuffer* aReadOnlyFront, nsIntRegion* aFrontUpdatedRegion);
|
2010-10-13 15:55:45 -07:00
|
|
|
virtual void DestroyFrontBuffer();
|
|
|
|
|
2011-01-05 20:54:47 -08:00
|
|
|
virtual void Disconnect();
|
|
|
|
|
2012-03-17 05:07:02 -07:00
|
|
|
virtual void SetValidRegion(const nsIntRegion& aRegion)
|
|
|
|
{
|
|
|
|
ShadowThebesLayer::SetValidRegion(aRegion);
|
|
|
|
}
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
// LayerOGL impl
|
|
|
|
void Destroy();
|
|
|
|
Layer* GetLayer();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsEmpty();
|
2010-10-13 15:55:45 -07:00
|
|
|
virtual void RenderLayer(int aPreviousFrameBuffer,
|
2010-11-08 01:06:15 -08:00
|
|
|
const nsIntPoint& aOffset);
|
2012-01-15 21:41:55 -08:00
|
|
|
virtual void CleanupResources();
|
2010-10-13 15:55:45 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<ShadowBufferOGL> mBuffer;
|
2012-07-23 16:58:37 -07:00
|
|
|
SurfaceDescriptor mBufferDescriptor;
|
|
|
|
nsIntRegion mValidRegionForNextBackBuffer;
|
2010-10-13 15:55:45 -07:00
|
|
|
};
|
|
|
|
|
2010-03-29 21:48:52 -07:00
|
|
|
} /* layers */
|
|
|
|
} /* mozilla */
|
|
|
|
#endif /* GFX_THEBESLAYEROGL_H */
|