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
|
|
|
|
|
|
|
|
#include "LayerManagerOGL.h"
|
|
|
|
#include "gfxASurface.h"
|
2013-02-13 15:26:24 -08:00
|
|
|
#include "GLDefs.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
|
2012-11-26 00:08:22 -08:00
|
|
|
#if defined(GL_PROVIDER_GLX)
|
2011-03-08 13:41:10 -08:00
|
|
|
#include "GLXLibrary.h"
|
|
|
|
#include "mozilla/X11Util.h"
|
|
|
|
#endif
|
2010-05-17 21:04:22 -07:00
|
|
|
|
2012-08-21 20:29:06 -07:00
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-05-29 14:59:24 -07:00
|
|
|
class CanvasLayerOGL :
|
2010-05-17 21:04:22 -07:00
|
|
|
public CanvasLayer,
|
|
|
|
public LayerOGL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CanvasLayerOGL(LayerManagerOGL *aManager)
|
2013-07-20 01:48:55 -07:00
|
|
|
: CanvasLayer(aManager, nullptr)
|
2013-02-13 15:26:24 -08:00
|
|
|
, LayerOGL(aManager)
|
2013-07-04 10:25:50 -07:00
|
|
|
, mLayerProgram(RGBALayerProgramType)
|
2013-02-13 15:26:24 -08:00
|
|
|
, mTexture(0)
|
|
|
|
, mTextureTarget(LOCAL_GL_TEXTURE_2D)
|
|
|
|
, mDelayedUpdates(false)
|
|
|
|
, mIsGLAlphaPremult(false)
|
|
|
|
, mUploadTexture(0)
|
2012-11-26 00:08:22 -08:00
|
|
|
#if defined(GL_PROVIDER_GLX)
|
2013-02-13 15:26:24 -08:00
|
|
|
, mPixmap(0)
|
2011-03-08 13:41:10 -08:00
|
|
|
#endif
|
2010-05-17 21:04:22 -07:00
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
mImplData = static_cast<LayerOGL*>(this);
|
|
|
|
mForceReadback = Preferences::GetBool("webgl.force-layers-readback", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
~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;
|
2013-02-13 15:26:24 -08:00
|
|
|
nsRefPtr<GLContext> mGLContext;
|
2013-07-04 10:25:50 -07:00
|
|
|
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;
|
2012-07-31 08:17:43 -07:00
|
|
|
GLenum mTextureTarget;
|
2010-05-17 21:04:22 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDelayedUpdates;
|
2013-02-13 15:26:24 -08:00
|
|
|
bool mIsGLAlphaPremult;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNeedsYFlip;
|
2012-08-21 20:29:06 -07:00
|
|
|
bool mForceReadback;
|
2013-02-13 15:26:24 -08:00
|
|
|
GLuint mUploadTexture;
|
2012-11-26 00:08:22 -08:00
|
|
|
#if defined(GL_PROVIDER_GLX)
|
2011-03-08 13:41:10 -08:00
|
|
|
GLXPixmap mPixmap;
|
|
|
|
#endif
|
2012-03-25 12:50:26 -07:00
|
|
|
|
|
|
|
nsRefPtr<gfxImageSurface> mCachedTempSurface;
|
|
|
|
gfxIntSize mCachedSize;
|
2012-08-19 12:33:25 -07:00
|
|
|
gfxASurface::gfxImageFormat mCachedFormat;
|
2012-03-25 12:50:26 -07:00
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
gfxImageSurface* GetTempSurface(const gfxIntSize& aSize,
|
|
|
|
const gfxASurface::gfxImageFormat aFormat)
|
2012-03-25 12:50:26 -07:00
|
|
|
{
|
|
|
|
if (!mCachedTempSurface ||
|
|
|
|
aSize.width != mCachedSize.width ||
|
|
|
|
aSize.height != mCachedSize.height ||
|
|
|
|
aFormat != mCachedFormat)
|
|
|
|
{
|
|
|
|
mCachedTempSurface = new gfxImageSurface(aSize, aFormat);
|
|
|
|
mCachedSize = aSize;
|
|
|
|
mCachedFormat = aFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mCachedTempSurface;
|
|
|
|
}
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
void DiscardTempSurface() {
|
2012-07-30 07:20:58 -07:00
|
|
|
mCachedTempSurface = nullptr;
|
2012-03-25 12:50:26 -07:00
|
|
|
}
|
2010-05-17 21:04:22 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* layers */
|
|
|
|
} /* mozilla */
|
|
|
|
#endif /* GFX_IMAGELAYEROGL_H */
|