2010-05-17 21:04:22 -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-05-17 21:04:22 -07:00
|
|
|
|
|
|
|
#ifndef GFX_CANVASLAYEROGL_H
|
|
|
|
#define GFX_CANVASLAYEROGL_H
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
#include "LayerManagerOGL.h"
|
|
|
|
#include "gfxASurface.h"
|
2011-03-08 13:41:10 -08:00
|
|
|
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
|
|
|
#include "GLXLibrary.h"
|
|
|
|
#include "mozilla/X11Util.h"
|
|
|
|
#endif
|
2010-05-17 21:04:22 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class THEBES_API CanvasLayerOGL :
|
|
|
|
public CanvasLayer,
|
|
|
|
public LayerOGL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CanvasLayerOGL(LayerManagerOGL *aManager)
|
|
|
|
: CanvasLayer(aManager, NULL),
|
|
|
|
LayerOGL(aManager),
|
2010-12-16 23:19:28 -08:00
|
|
|
mTexture(0),
|
2011-10-17 07:59:28 -07:00
|
|
|
mDelayedUpdates(false)
|
2011-03-08 13:41:10 -08:00
|
|
|
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
|
|
|
,mPixmap(0)
|
|
|
|
#endif
|
2010-05-17 21:04:22 -07:00
|
|
|
{
|
|
|
|
mImplData = static_cast<LayerOGL*>(this);
|
|
|
|
}
|
2010-08-06 22:09:18 -07:00
|
|
|
~CanvasLayerOGL() { Destroy(); }
|
2010-05-17 21:04:22 -07:00
|
|
|
|
|
|
|
// CanvasLayer implementation
|
|
|
|
virtual void Initialize(const Data& aData);
|
|
|
|
|
|
|
|
// LayerOGL implementation
|
2010-08-06 22:09:18 -07:00
|
|
|
virtual void Destroy();
|
2010-05-17 21:04:22 -07:00
|
|
|
virtual Layer* GetLayer() { return this; }
|
2010-05-24 23:35:35 -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-05-17 21:04:22 -07:00
|
|
|
|
|
|
|
protected:
|
2011-03-27 16:59:46 -07:00
|
|
|
void UpdateSurface();
|
|
|
|
|
2010-05-24 23:35:35 -07:00
|
|
|
nsRefPtr<gfxASurface> mCanvasSurface;
|
|
|
|
nsRefPtr<GLContext> mCanvasGLContext;
|
2010-12-16 23:28:30 -08:00
|
|
|
gl::ShaderProgramType mLayerProgram;
|
2011-11-02 12:55:03 -07:00
|
|
|
RefPtr<gfx::DrawTarget> mDrawTarget;
|
2010-05-17 21:04:22 -07:00
|
|
|
|
2010-05-24 23:35:35 -07:00
|
|
|
GLuint mTexture;
|
2010-05-17 21:04:22 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDelayedUpdates;
|
|
|
|
bool mGLBufferIsPremultiplied;
|
|
|
|
bool mNeedsYFlip;
|
2011-03-08 13:41:10 -08:00
|
|
|
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
|
|
|
GLXPixmap mPixmap;
|
|
|
|
#endif
|
2012-03-25 12:50:26 -07:00
|
|
|
|
|
|
|
nsRefPtr<gfxImageSurface> mCachedTempSurface;
|
|
|
|
gfxIntSize mCachedSize;
|
|
|
|
gfxImageFormat mCachedFormat;
|
|
|
|
|
|
|
|
gfxImageSurface* GetTempSurface(const gfxIntSize& aSize, const gfxImageFormat aFormat)
|
|
|
|
{
|
|
|
|
if (!mCachedTempSurface ||
|
|
|
|
aSize.width != mCachedSize.width ||
|
|
|
|
aSize.height != mCachedSize.height ||
|
|
|
|
aFormat != mCachedFormat)
|
|
|
|
{
|
|
|
|
mCachedTempSurface = new gfxImageSurface(aSize, aFormat);
|
|
|
|
mCachedSize = aSize;
|
|
|
|
mCachedFormat = aFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mCachedTempSurface;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiscardTempSurface()
|
|
|
|
{
|
|
|
|
mCachedTempSurface = nsnull;
|
|
|
|
}
|
2010-05-17 21:04:22 -07:00
|
|
|
};
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
// NB: eventually we'll have separate shadow canvas2d and shadow
|
|
|
|
// canvas3d layers, but currently they look the same from the
|
|
|
|
// perspective of the compositor process
|
|
|
|
class ShadowCanvasLayerOGL : public ShadowCanvasLayer,
|
|
|
|
public LayerOGL
|
|
|
|
{
|
|
|
|
typedef gl::TextureImage TextureImage;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ShadowCanvasLayerOGL(LayerManagerOGL* aManager);
|
|
|
|
virtual ~ShadowCanvasLayerOGL();
|
|
|
|
|
|
|
|
// CanvasLayer impl
|
|
|
|
virtual void Initialize(const Data& aData);
|
2011-09-27 15:19:28 -07:00
|
|
|
virtual void Init(const CanvasSurface& aNewFront, bool needYFlip);
|
2011-04-20 14:45:57 -07:00
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
// This isn't meaningful for shadow canvas.
|
|
|
|
virtual void Updated(const nsIntRect&) {}
|
|
|
|
|
|
|
|
// ShadowCanvasLayer impl
|
2011-09-27 15:19:28 -07:00
|
|
|
virtual void Swap(const CanvasSurface& aNewFront,
|
|
|
|
bool needYFlip,
|
|
|
|
CanvasSurface* aNewBack);
|
2010-10-13 15:55:45 -07:00
|
|
|
|
|
|
|
virtual void DestroyFrontBuffer();
|
|
|
|
|
2011-01-05 20:54:47 -08:00
|
|
|
virtual void Disconnect();
|
|
|
|
|
2010-10-13 15:55:45 -07:00
|
|
|
// LayerOGL impl
|
|
|
|
void Destroy();
|
|
|
|
Layer* GetLayer();
|
|
|
|
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<TextureImage> mTexImage;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNeedsYFlip;
|
2012-05-31 18:30:08 -07:00
|
|
|
SurfaceDescriptor mFrontBufferDescriptor;
|
|
|
|
GLuint mTexture;
|
2010-10-13 15:55:45 -07:00
|
|
|
};
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
} /* layers */
|
|
|
|
} /* mozilla */
|
|
|
|
#endif /* GFX_IMAGELAYEROGL_H */
|