2010-05-25 06:35:35 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2010-03-30 04:48:52 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Corporation code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Bas Schouten <bschouten@mozilla.org>
|
2010-05-25 06:35:35 +00:00
|
|
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
2010-03-30 04:48:52 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
#ifdef MOZ_IPC
|
|
|
|
# include "mozilla/layers/PLayers.h"
|
|
|
|
# include "mozilla/layers/ShadowLayers.h"
|
|
|
|
#endif
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
#include "ThebesLayerBuffer.h"
|
2010-03-30 04:48:52 +00:00
|
|
|
#include "ThebesLayerOGL.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
using gl::GLContext;
|
2010-07-22 20:29:37 +00:00
|
|
|
using gl::TextureImage;
|
|
|
|
|
2010-11-12 20:02:20 +00:00
|
|
|
// BindAndDrawQuadWithTextureRect can work with either GL_REPEAT (preferred)
|
|
|
|
// or GL_CLAMP_TO_EDGE textures. We select based on whether REPEAT is
|
|
|
|
// valid for non-power-of-two textures -- if we have NPOT support we use it,
|
|
|
|
// otherwise we stick with CLAMP_TO_EDGE and decompose.
|
|
|
|
static already_AddRefed<TextureImage>
|
|
|
|
CreateClampOrRepeatTextureImage(GLContext *aGl,
|
|
|
|
const nsIntSize& aSize,
|
|
|
|
TextureImage::ContentType aContentType)
|
|
|
|
{
|
|
|
|
GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
|
|
|
|
if (aGl->IsExtensionSupported(GLContext::ARB_texture_non_power_of_two) ||
|
|
|
|
aGl->IsExtensionSupported(GLContext::OES_texture_npot))
|
|
|
|
{
|
|
|
|
wrapMode = LOCAL_GL_REPEAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aGl->CreateTextureImage(aSize, aContentType, wrapMode);
|
|
|
|
}
|
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
// |aTexCoordRect| is the rectangle from the texture that we want to
|
|
|
|
// draw using the given program. The program already has a necessary
|
|
|
|
// offset and scale, so the geometry that needs to be drawn is a unit
|
|
|
|
// square from 0,0 to 1,1.
|
|
|
|
//
|
|
|
|
// |aTexSize| is the actual size of the texture, as it can be larger
|
|
|
|
// than the rectangle given by |aTexCoordRect|.
|
2010-07-22 20:29:37 +00:00
|
|
|
static void
|
2010-11-12 20:02:20 +00:00
|
|
|
BindAndDrawQuadWithTextureRect(GLContext* aGl,
|
|
|
|
LayerProgram *aProg,
|
2010-07-22 20:29:37 +00:00
|
|
|
const nsIntRect& aTexCoordRect,
|
2010-09-21 19:41:24 +00:00
|
|
|
const nsIntSize& aTexSize,
|
2010-11-12 20:02:20 +00:00
|
|
|
GLenum aWrapMode)
|
2010-07-22 20:29:37 +00:00
|
|
|
{
|
|
|
|
GLuint vertAttribIndex =
|
|
|
|
aProg->AttribLocation(LayerProgram::VertexAttrib);
|
|
|
|
GLuint texCoordAttribIndex =
|
|
|
|
aProg->AttribLocation(LayerProgram::TexCoordAttrib);
|
|
|
|
NS_ASSERTION(texCoordAttribIndex != GLuint(-1), "no texture coords?");
|
|
|
|
|
|
|
|
// clear any bound VBO so that glVertexAttribPointer() goes back to
|
|
|
|
// "pointer mode"
|
|
|
|
aGl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
|
|
|
|
|
2010-11-12 20:02:17 +00:00
|
|
|
// Given what we know about these textures and coordinates, we can
|
|
|
|
// compute fmod(t, 1.0f) to get the same texture coordinate out. If
|
|
|
|
// the texCoordRect dimension is < 0 or > width/height, then we have
|
|
|
|
// wraparound that we need to deal with by drawing multiple quads,
|
|
|
|
// because we can't rely on full non-power-of-two texture support
|
|
|
|
// (which is required for the REPEAT wrap mode).
|
|
|
|
|
|
|
|
GLContext::RectTriangles rects;
|
2010-11-12 20:02:20 +00:00
|
|
|
|
|
|
|
if (aWrapMode == LOCAL_GL_REPEAT) {
|
|
|
|
rects.addRect(/* dest rectangle */
|
|
|
|
0.0f, 0.0f, 1.0f, 1.0f,
|
|
|
|
/* tex coords */
|
|
|
|
aTexCoordRect.x / GLfloat(aTexSize.width),
|
|
|
|
aTexCoordRect.y / GLfloat(aTexSize.height),
|
|
|
|
aTexCoordRect.XMost() / GLfloat(aTexSize.width),
|
|
|
|
aTexCoordRect.YMost() / GLfloat(aTexSize.height));
|
|
|
|
} else {
|
|
|
|
GLContext::DecomposeIntoNoRepeatTriangles(aTexCoordRect, aTexSize, rects);
|
|
|
|
}
|
2010-11-12 20:02:17 +00:00
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
aGl->fVertexAttribPointer(vertAttribIndex, 2,
|
2010-09-21 19:41:24 +00:00
|
|
|
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
2010-11-12 20:02:17 +00:00
|
|
|
rects.vertexCoords);
|
2010-07-22 20:29:37 +00:00
|
|
|
|
|
|
|
aGl->fVertexAttribPointer(texCoordAttribIndex, 2,
|
|
|
|
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
2010-11-12 20:02:17 +00:00
|
|
|
rects.texCoords);
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
DEBUG_GL_ERROR_CHECK(aGl);
|
|
|
|
|
|
|
|
{
|
|
|
|
aGl->fEnableVertexAttribArray(texCoordAttribIndex);
|
|
|
|
{
|
|
|
|
aGl->fEnableVertexAttribArray(vertAttribIndex);
|
|
|
|
|
2010-11-12 20:02:17 +00:00
|
|
|
aGl->fDrawArrays(LOCAL_GL_TRIANGLES, 0, rects.numRects * 6);
|
2010-07-22 20:29:37 +00:00
|
|
|
DEBUG_GL_ERROR_CHECK(aGl);
|
|
|
|
|
|
|
|
aGl->fDisableVertexAttribArray(vertAttribIndex);
|
|
|
|
}
|
|
|
|
aGl->fDisableVertexAttribArray(texCoordAttribIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG_GL_ERROR_CHECK(aGl);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
class ThebesLayerBufferOGL
|
|
|
|
{
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(ThebesLayerBufferOGL)
|
|
|
|
public:
|
|
|
|
typedef TextureImage::ContentType ContentType;
|
|
|
|
typedef ThebesLayerBuffer::PaintState PaintState;
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
ThebesLayerBufferOGL(ThebesLayer* aLayer, LayerOGL* aOGLLayer)
|
2010-07-22 20:29:37 +00:00
|
|
|
: mLayer(aLayer)
|
2010-10-13 22:55:45 +00:00
|
|
|
, mOGLLayer(aOGLLayer)
|
2010-07-22 20:29:37 +00:00
|
|
|
{}
|
|
|
|
virtual ~ThebesLayerBufferOGL() {}
|
|
|
|
|
|
|
|
virtual PaintState BeginPaint(ContentType aContentType) = 0;
|
|
|
|
|
2010-11-08 09:06:15 +00:00
|
|
|
void RenderTo(const nsIntPoint& aOffset, LayerManagerOGL* aManager);
|
2010-07-22 20:29:37 +00:00
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
nsIntSize GetSize() {
|
|
|
|
if (mTexImage)
|
|
|
|
return mTexImage->GetSize();
|
|
|
|
return nsIntSize(0, 0);
|
|
|
|
}
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
protected:
|
2010-09-21 19:41:24 +00:00
|
|
|
virtual nsIntPoint GetOriginOffset() = 0;
|
2010-07-22 20:29:37 +00:00
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
GLContext* gl() const { return mOGLLayer->gl(); }
|
2010-07-22 20:29:37 +00:00
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
ThebesLayer* mLayer;
|
|
|
|
LayerOGL* mOGLLayer;
|
2010-07-22 20:29:37 +00:00
|
|
|
nsRefPtr<TextureImage> mTexImage;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
ThebesLayerBufferOGL::RenderTo(const nsIntPoint& aOffset,
|
2010-11-08 09:06:15 +00:00
|
|
|
LayerManagerOGL* aManager)
|
2010-07-22 20:29:37 +00:00
|
|
|
{
|
2010-09-21 19:41:24 +00:00
|
|
|
if (!mTexImage)
|
|
|
|
return;
|
|
|
|
|
2010-09-09 23:41:02 +00:00
|
|
|
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
if (!mTexImage->InUpdate() || !mTexImage->EndUpdate()) {
|
|
|
|
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexImage->Texture());
|
|
|
|
}
|
|
|
|
|
2010-12-17 07:29:23 +00:00
|
|
|
// Note BGR: Cairo's image surfaces are always in what
|
|
|
|
// OpenGL and our shaders consider BGR format.
|
|
|
|
ColorTextureLayerProgram *program =
|
|
|
|
aManager->GetColorTextureLayerProgram(mTexImage->GetShaderProgramType());
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
float xres = mLayer->GetXResolution();
|
|
|
|
float yres = mLayer->GetYResolution();
|
|
|
|
|
2011-01-04 15:37:22 +00:00
|
|
|
program->Activate();
|
|
|
|
program->SetLayerOpacity(mLayer->GetEffectiveOpacity());
|
|
|
|
program->SetLayerTransform(mLayer->GetEffectiveTransform());
|
|
|
|
program->SetRenderOffset(aOffset);
|
|
|
|
program->SetTextureUnit(0);
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
nsIntRegionRectIterator iter(mLayer->GetEffectiveVisibleRegion());
|
2010-10-13 22:55:45 +00:00
|
|
|
while (const nsIntRect *iterRect = iter.Next()) {
|
2010-09-22 18:17:01 +00:00
|
|
|
nsIntRect quadRect = *iterRect;
|
|
|
|
program->SetLayerQuadRect(quadRect);
|
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
|
|
|
|
|
|
|
quadRect.MoveBy(-GetOriginOffset());
|
2010-10-13 22:55:45 +00:00
|
|
|
|
|
|
|
// The buffer rect and rotation are resolution-neutral; with a
|
|
|
|
// non-1.0 resolution, only the texture size is scaled by the
|
|
|
|
// resolution. So map the quadrent rect into the space scaled to
|
|
|
|
// the texture size and let GL do the rest.
|
|
|
|
gfxRect sqr(quadRect.x, quadRect.y, quadRect.width, quadRect.height);
|
|
|
|
sqr.Scale(xres, yres);
|
2011-01-08 05:05:35 +00:00
|
|
|
sqr.Round();
|
2010-10-13 22:55:45 +00:00
|
|
|
nsIntRect scaledQuadRect(sqr.pos.x, sqr.pos.y, sqr.size.width, sqr.size.height);
|
|
|
|
|
2010-11-12 20:02:20 +00:00
|
|
|
BindAndDrawQuadWithTextureRect(gl(), program, scaledQuadRect,
|
|
|
|
mTexImage->GetSize(),
|
|
|
|
mTexImage->GetWrapMode());
|
2010-09-22 18:17:01 +00:00
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
|
|
|
}
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This implementation is the fast-path for when our TextureImage is
|
|
|
|
// permanently backed with a server-side ASurface. We can simply
|
|
|
|
// reuse the ThebesLayerBuffer logic in its entirety and profit.
|
|
|
|
class SurfaceBufferOGL : public ThebesLayerBufferOGL, private ThebesLayerBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef ThebesLayerBufferOGL::ContentType ContentType;
|
|
|
|
typedef ThebesLayerBufferOGL::PaintState PaintState;
|
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
SurfaceBufferOGL(ThebesLayerOGL* aLayer)
|
2010-10-13 22:55:45 +00:00
|
|
|
: ThebesLayerBufferOGL(aLayer, aLayer)
|
2010-07-22 20:29:37 +00:00
|
|
|
, ThebesLayerBuffer(SizedToVisibleBounds)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual ~SurfaceBufferOGL() {}
|
|
|
|
|
|
|
|
// ThebesLayerBufferOGL interface
|
|
|
|
virtual PaintState BeginPaint(ContentType aContentType)
|
|
|
|
{
|
|
|
|
// Let ThebesLayerBuffer do all the hard work for us! :D
|
2010-09-03 20:10:46 +00:00
|
|
|
return ThebesLayerBuffer::BeginPaint(mLayer, aContentType, 1.0, 1.0);
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ThebesLayerBuffer interface
|
|
|
|
virtual already_AddRefed<gfxASurface>
|
|
|
|
CreateBuffer(ContentType aType, const nsIntSize& aSize)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(gfxASurface::CONTENT_ALPHA != aType,"ThebesBuffer has color");
|
|
|
|
|
2010-11-12 20:02:20 +00:00
|
|
|
mTexImage = CreateClampOrRepeatTextureImage(gl(), aSize, aType);
|
2010-07-22 20:29:37 +00:00
|
|
|
return mTexImage ? mTexImage->GetBackingSurface() : nsnull;
|
|
|
|
}
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
protected:
|
2010-09-21 19:41:24 +00:00
|
|
|
virtual nsIntPoint GetOriginOffset() {
|
|
|
|
return BufferRect().TopLeft() - BufferRotation();
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
2010-07-22 20:29:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// This implementation is (currently) the slow-path for when we can't
|
|
|
|
// implement pixel retaining using thebes. This implementation and
|
|
|
|
// the above could be unified by abstracting buffer-copy operations
|
|
|
|
// and implementing them here using GL hacketry.
|
|
|
|
class BasicBufferOGL : public ThebesLayerBufferOGL
|
|
|
|
{
|
|
|
|
public:
|
2010-09-21 19:41:24 +00:00
|
|
|
BasicBufferOGL(ThebesLayerOGL* aLayer)
|
2010-10-13 22:55:45 +00:00
|
|
|
: ThebesLayerBufferOGL(aLayer, aLayer)
|
2010-09-21 19:41:24 +00:00
|
|
|
, mBufferRect(0,0,0,0)
|
|
|
|
, mBufferRotation(0,0)
|
2010-07-22 20:29:37 +00:00
|
|
|
{}
|
|
|
|
virtual ~BasicBufferOGL() {}
|
|
|
|
|
|
|
|
virtual PaintState BeginPaint(ContentType aContentType);
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
protected:
|
2010-09-21 19:41:24 +00:00
|
|
|
enum XSide {
|
|
|
|
LEFT, RIGHT
|
|
|
|
};
|
|
|
|
enum YSide {
|
|
|
|
TOP, BOTTOM
|
|
|
|
};
|
|
|
|
nsIntRect GetQuadrantRectangle(XSide aXSide, YSide aYSide);
|
|
|
|
|
|
|
|
virtual nsIntPoint GetOriginOffset() {
|
|
|
|
return mBufferRect.TopLeft() - mBufferRotation;
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
private:
|
|
|
|
nsIntRect mBufferRect;
|
2010-09-21 19:41:24 +00:00
|
|
|
nsIntPoint mBufferRotation;
|
2010-07-22 20:29:37 +00:00
|
|
|
};
|
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
static void
|
|
|
|
WrapRotationAxis(PRInt32* aRotationPoint, PRInt32 aSize)
|
|
|
|
{
|
|
|
|
if (*aRotationPoint < 0) {
|
|
|
|
*aRotationPoint += aSize;
|
|
|
|
} else if (*aRotationPoint >= aSize) {
|
|
|
|
*aRotationPoint -= aSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect
|
|
|
|
BasicBufferOGL::GetQuadrantRectangle(XSide aXSide, YSide aYSide)
|
|
|
|
{
|
|
|
|
// quadrantTranslation is the amount we translate the top-left
|
|
|
|
// of the quadrant by to get coordinates relative to the layer
|
|
|
|
nsIntPoint quadrantTranslation = -mBufferRotation;
|
|
|
|
quadrantTranslation.x += aXSide == LEFT ? mBufferRect.width : 0;
|
|
|
|
quadrantTranslation.y += aYSide == TOP ? mBufferRect.height : 0;
|
|
|
|
return mBufferRect + quadrantTranslation;
|
|
|
|
}
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
BasicBufferOGL::PaintState
|
|
|
|
BasicBufferOGL::BeginPaint(ContentType aContentType)
|
|
|
|
{
|
2010-09-21 19:41:24 +00:00
|
|
|
PaintState result;
|
|
|
|
|
|
|
|
result.mRegionToDraw.Sub(mLayer->GetVisibleRegion(), mLayer->GetValidRegion());
|
|
|
|
|
|
|
|
if (!mTexImage || mTexImage->GetContentType() != aContentType) {
|
|
|
|
// We're effectively clearing the valid region, so we need to draw
|
|
|
|
// the entire visible region now.
|
|
|
|
//
|
|
|
|
// XXX/cjones: a possibly worthwhile optimization to keep in mind
|
|
|
|
// is to re-use buffers when the resolution and visible region
|
|
|
|
// have changed in such a way that the buffer size stays the same.
|
|
|
|
// It might make even more sense to allocate buffers from a
|
|
|
|
// recyclable pool, so that we could keep this logic simple and
|
|
|
|
// still get back the same buffer.
|
|
|
|
result.mRegionToDraw = mLayer->GetVisibleRegion();
|
|
|
|
result.mRegionToInvalidate = mLayer->GetValidRegion();
|
|
|
|
mTexImage = nsnull;
|
|
|
|
mBufferRect.SetRect(0, 0, 0, 0);
|
|
|
|
mBufferRotation.MoveTo(0, 0);
|
|
|
|
}
|
2010-07-22 20:29:37 +00:00
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
if (result.mRegionToDraw.IsEmpty())
|
|
|
|
return result;
|
|
|
|
|
|
|
|
nsIntRect visibleBounds = mLayer->GetVisibleRegion().GetBounds();
|
2011-01-18 01:32:40 +00:00
|
|
|
if (visibleBounds.width > gl()->GetMaxTextureSize() ||
|
|
|
|
visibleBounds.height > gl()->GetMaxTextureSize()) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect drawBounds = result.mRegionToDraw.GetBounds();
|
2010-09-21 19:41:24 +00:00
|
|
|
nsRefPtr<TextureImage> destBuffer;
|
|
|
|
nsIntRect destBufferRect;
|
|
|
|
|
|
|
|
if (visibleBounds.Size() <= mBufferRect.Size()) {
|
|
|
|
// The current buffer is big enough to hold the visible area.
|
|
|
|
if (mBufferRect.Contains(visibleBounds)) {
|
|
|
|
// We don't need to adjust mBufferRect.
|
|
|
|
destBufferRect = mBufferRect;
|
|
|
|
} else {
|
|
|
|
// The buffer's big enough but doesn't contain everything that's
|
|
|
|
// going to be visible. We'll move it.
|
|
|
|
destBufferRect = nsIntRect(visibleBounds.TopLeft(), mBufferRect.Size());
|
|
|
|
}
|
|
|
|
nsIntRect keepArea;
|
|
|
|
if (keepArea.IntersectRect(destBufferRect, mBufferRect)) {
|
|
|
|
// Set mBufferRotation so that the pixels currently in mBuffer
|
|
|
|
// will still be rendered in the right place when mBufferRect
|
|
|
|
// changes to destBufferRect.
|
|
|
|
nsIntPoint newRotation = mBufferRotation +
|
|
|
|
(destBufferRect.TopLeft() - mBufferRect.TopLeft());
|
|
|
|
WrapRotationAxis(&newRotation.x, mBufferRect.width);
|
|
|
|
WrapRotationAxis(&newRotation.y, mBufferRect.height);
|
|
|
|
NS_ASSERTION(nsIntRect(nsIntPoint(0,0), mBufferRect.Size()).Contains(newRotation),
|
|
|
|
"newRotation out of bounds");
|
|
|
|
PRInt32 xBoundary = destBufferRect.XMost() - newRotation.x;
|
|
|
|
PRInt32 yBoundary = destBufferRect.YMost() - newRotation.y;
|
|
|
|
if ((drawBounds.x < xBoundary && xBoundary < drawBounds.XMost()) ||
|
|
|
|
(drawBounds.y < yBoundary && yBoundary < drawBounds.YMost())) {
|
|
|
|
// The stuff we need to redraw will wrap around an edge of the
|
|
|
|
// buffer, so we will need to do a self-copy
|
|
|
|
// If mBufferRotation == nsIntPoint(0,0) we could do a real
|
|
|
|
// self-copy but we're not going to do that in GL yet.
|
|
|
|
// We can't do a real self-copy because the buffer is rotated.
|
|
|
|
// So allocate a new buffer for the destination.
|
|
|
|
destBufferRect = visibleBounds;
|
2010-11-12 20:02:20 +00:00
|
|
|
destBuffer = CreateClampOrRepeatTextureImage(gl(), visibleBounds.Size(), aContentType);
|
2010-09-21 19:41:24 +00:00
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
|
|
|
if (!destBuffer)
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
mBufferRect = destBufferRect;
|
|
|
|
mBufferRotation = newRotation;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// No pixels are going to be kept. The whole visible region
|
|
|
|
// will be redrawn, so we don't need to copy anything, so we don't
|
|
|
|
// set destBuffer.
|
|
|
|
mBufferRect = destBufferRect;
|
|
|
|
mBufferRotation = nsIntPoint(0,0);
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
|
|
|
} else {
|
2010-09-21 19:41:24 +00:00
|
|
|
// The buffer's not big enough, so allocate a new one
|
|
|
|
destBufferRect = visibleBounds;
|
2010-11-12 20:02:20 +00:00
|
|
|
destBuffer = CreateClampOrRepeatTextureImage(gl(), visibleBounds.Size(), aContentType);
|
2010-09-21 19:41:24 +00:00
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
|
|
|
if (!destBuffer)
|
|
|
|
return result;
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
2010-09-21 19:41:24 +00:00
|
|
|
|
|
|
|
if (!destBuffer && !mTexImage) {
|
|
|
|
return result;
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
if (destBuffer) {
|
|
|
|
if (mTexImage) {
|
2010-10-02 03:56:56 +00:00
|
|
|
// BlitTextureImage depends on the FBO texture target being
|
|
|
|
// TEXTURE_2D. This isn't the case on some older X1600-era Radeons.
|
2010-10-13 22:55:45 +00:00
|
|
|
if (mOGLLayer->OGLManager()->FBOTextureTarget() == LOCAL_GL_TEXTURE_2D) {
|
2010-10-02 03:56:56 +00:00
|
|
|
nsIntRect overlap;
|
|
|
|
overlap.IntersectRect(mBufferRect, destBufferRect);
|
2010-09-21 19:41:24 +00:00
|
|
|
|
2010-10-02 03:56:56 +00:00
|
|
|
nsIntRect srcRect(overlap), dstRect(overlap);
|
|
|
|
srcRect.MoveBy(- mBufferRect.TopLeft() + mBufferRotation);
|
|
|
|
dstRect.MoveBy(- destBufferRect.TopLeft());
|
2010-07-22 20:29:37 +00:00
|
|
|
|
2010-10-02 03:56:56 +00:00
|
|
|
destBuffer->Resize(destBufferRect.Size());
|
2010-09-21 19:41:24 +00:00
|
|
|
|
2010-10-02 03:56:56 +00:00
|
|
|
gl()->BlitTextureImage(mTexImage, srcRect,
|
|
|
|
destBuffer, dstRect);
|
|
|
|
} else {
|
|
|
|
// can't blit, just draw everything
|
|
|
|
destBufferRect = visibleBounds;
|
2010-11-12 20:02:20 +00:00
|
|
|
destBuffer = CreateClampOrRepeatTextureImage(gl(), visibleBounds.Size(), aContentType);
|
2010-10-02 03:56:56 +00:00
|
|
|
}
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mTexImage = destBuffer.forget();
|
|
|
|
mBufferRect = destBufferRect;
|
|
|
|
mBufferRotation = nsIntPoint(0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRegion invalidate;
|
|
|
|
invalidate.Sub(mLayer->GetValidRegion(), destBufferRect);
|
|
|
|
result.mRegionToInvalidate.Or(result.mRegionToInvalidate, invalidate);
|
|
|
|
|
|
|
|
// Figure out which quadrant to draw in
|
|
|
|
PRInt32 xBoundary = mBufferRect.XMost() - mBufferRotation.x;
|
|
|
|
PRInt32 yBoundary = mBufferRect.YMost() - mBufferRotation.y;
|
|
|
|
XSide sideX = drawBounds.XMost() <= xBoundary ? RIGHT : LEFT;
|
|
|
|
YSide sideY = drawBounds.YMost() <= yBoundary ? BOTTOM : TOP;
|
|
|
|
nsIntRect quadrantRect = GetQuadrantRectangle(sideX, sideY);
|
|
|
|
NS_ASSERTION(quadrantRect.Contains(drawBounds), "Messed up quadrants");
|
|
|
|
|
|
|
|
nsIntPoint offset = -nsIntPoint(quadrantRect.x, quadrantRect.y);
|
|
|
|
|
|
|
|
// Make the region to draw relative to the buffer, before
|
|
|
|
// passing to BeginUpdate.
|
|
|
|
result.mRegionToDraw.MoveBy(offset);
|
2010-07-22 20:29:37 +00:00
|
|
|
// BeginUpdate is allowed to modify the given region,
|
|
|
|
// if it wants more to be repainted than we request.
|
2011-01-18 07:21:12 +00:00
|
|
|
result.mContext = new gfxContext(mTexImage->BeginUpdate(result.mRegionToDraw));
|
2010-09-21 19:41:24 +00:00
|
|
|
if (!result.mContext) {
|
2010-07-22 20:29:37 +00:00
|
|
|
NS_WARNING("unable to get context for update");
|
2010-09-21 19:41:24 +00:00
|
|
|
return result;
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
2011-01-17 21:47:18 +00:00
|
|
|
result.mContext->Translate(-gfxPoint(quadrantRect.x, quadrantRect.y));
|
2010-07-22 20:29:37 +00:00
|
|
|
// Move rgnToPaint back into position so that the thebes callback
|
|
|
|
// gets the right coordintes.
|
2010-09-21 19:41:24 +00:00
|
|
|
result.mRegionToDraw.MoveBy(-offset);
|
|
|
|
|
|
|
|
return result;
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
|
|
|
|
2010-04-27 02:09:47 +00:00
|
|
|
ThebesLayerOGL::ThebesLayerOGL(LayerManagerOGL *aManager)
|
2010-07-01 16:30:38 +00:00
|
|
|
: ThebesLayer(aManager, nsnull)
|
2010-04-27 02:09:47 +00:00
|
|
|
, LayerOGL(aManager)
|
2010-07-22 20:29:37 +00:00
|
|
|
, mBuffer(nsnull)
|
2010-03-30 04:48:52 +00:00
|
|
|
{
|
|
|
|
mImplData = static_cast<LayerOGL*>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ThebesLayerOGL::~ThebesLayerOGL()
|
|
|
|
{
|
2010-08-07 05:09:18 +00:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThebesLayerOGL::Destroy()
|
|
|
|
{
|
|
|
|
if (!mDestroyed) {
|
|
|
|
mBuffer = nsnull;
|
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
|
|
|
|
|
|
|
mDestroyed = PR_TRUE;
|
|
|
|
}
|
2010-03-30 04:48:52 +00:00
|
|
|
}
|
|
|
|
|
2010-06-23 14:01:29 +00:00
|
|
|
PRBool
|
2010-07-22 20:29:37 +00:00
|
|
|
ThebesLayerOGL::CreateSurface()
|
2010-03-30 04:48:52 +00:00
|
|
|
{
|
2010-07-22 20:29:37 +00:00
|
|
|
NS_ASSERTION(!mBuffer, "buffer already created?");
|
|
|
|
|
|
|
|
if (mVisibleRegion.IsEmpty()) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
if (gl()->TextureImageSupportsGetBackingSurface()) {
|
2010-07-22 20:29:37 +00:00
|
|
|
// use the ThebesLayerBuffer fast-path
|
2010-09-21 19:41:24 +00:00
|
|
|
mBuffer = new SurfaceBufferOGL(this);
|
2010-07-22 20:29:37 +00:00
|
|
|
} else {
|
2010-09-21 19:41:24 +00:00
|
|
|
mBuffer = new BasicBufferOGL(this);
|
2010-07-01 16:30:38 +00:00
|
|
|
}
|
2010-07-22 20:29:37 +00:00
|
|
|
return PR_TRUE;
|
2010-06-23 14:01:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThebesLayerOGL::SetVisibleRegion(const nsIntRegion &aRegion)
|
|
|
|
{
|
|
|
|
if (aRegion.IsEqual(mVisibleRegion))
|
|
|
|
return;
|
|
|
|
ThebesLayer::SetVisibleRegion(aRegion);
|
2010-03-30 04:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThebesLayerOGL::InvalidateRegion(const nsIntRegion &aRegion)
|
|
|
|
{
|
2010-07-01 16:30:38 +00:00
|
|
|
mValidRegion.Sub(mValidRegion, aRegion);
|
2010-03-30 04:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-09-21 19:41:24 +00:00
|
|
|
ThebesLayerOGL::RenderLayer(int aPreviousFrameBuffer,
|
2010-11-08 09:06:15 +00:00
|
|
|
const nsIntPoint& aOffset)
|
2010-03-30 04:48:52 +00:00
|
|
|
{
|
2010-07-22 20:29:37 +00:00
|
|
|
if (!mBuffer && !CreateSurface()) {
|
2010-06-23 14:01:29 +00:00
|
|
|
return;
|
2010-07-22 20:29:37 +00:00
|
|
|
}
|
|
|
|
NS_ABORT_IF_FALSE(mBuffer, "should have a buffer here");
|
2010-06-23 14:01:29 +00:00
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
mOGLManager->MakeCurrent();
|
|
|
|
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
TextureImage::ContentType contentType =
|
2010-07-29 19:15:13 +00:00
|
|
|
CanUseOpaqueSurface() ? gfxASurface::CONTENT_COLOR :
|
2010-07-22 20:29:37 +00:00
|
|
|
gfxASurface::CONTENT_COLOR_ALPHA;
|
|
|
|
Buffer::PaintState state = mBuffer->BeginPaint(contentType);
|
|
|
|
mValidRegion.Sub(mValidRegion, state.mRegionToInvalidate);
|
2010-05-21 03:20:48 +00:00
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
if (state.mContext) {
|
|
|
|
state.mRegionToInvalidate.And(state.mRegionToInvalidate, mVisibleRegion);
|
2010-05-25 06:35:35 +00:00
|
|
|
|
2010-07-22 20:29:37 +00:00
|
|
|
LayerManager::DrawThebesLayerCallback callback =
|
|
|
|
mOGLManager->GetThebesLayerCallback();
|
|
|
|
void* callbackData = mOGLManager->GetThebesLayerCallbackData();
|
|
|
|
callback(this, state.mContext, state.mRegionToDraw,
|
|
|
|
state.mRegionToInvalidate, callbackData);
|
2011-01-16 10:38:45 +00:00
|
|
|
// Everything that's visible has been validated. Do this instead of
|
|
|
|
// OR-ing with aRegionToDraw, since that can lead to a very complex region
|
|
|
|
// here (OR doesn't automatically simplify to the simplest possible
|
|
|
|
// representation of a region.)
|
|
|
|
mValidRegion.Or(mValidRegion, mVisibleRegion);
|
2010-05-21 03:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
|
|
|
|
|
|
|
gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer);
|
2010-11-08 09:06:15 +00:00
|
|
|
mBuffer->RenderTo(aOffset, mOGLManager);
|
2010-05-25 06:35:35 +00:00
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
2010-03-30 04:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Layer*
|
|
|
|
ThebesLayerOGL::GetLayer()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
ThebesLayerOGL::IsEmpty()
|
|
|
|
{
|
2010-07-22 20:29:37 +00:00
|
|
|
return !mBuffer;
|
2010-03-30 04:48:52 +00:00
|
|
|
}
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_IPC
|
|
|
|
|
|
|
|
class ShadowBufferOGL : public ThebesLayerBufferOGL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShadowBufferOGL(ShadowThebesLayerOGL* aLayer)
|
|
|
|
: ThebesLayerBufferOGL(aLayer, aLayer)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual PaintState BeginPaint(ContentType aContentType) {
|
|
|
|
NS_RUNTIMEABORT("can't BeginPaint for a shadow layer");
|
|
|
|
return PaintState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CreateTexture(ContentType aType, const nsIntSize& aSize)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(gfxASurface::CONTENT_ALPHA != aType,"ThebesBuffer has color");
|
|
|
|
|
2010-11-12 20:02:20 +00:00
|
|
|
mTexImage = CreateClampOrRepeatTextureImage(gl(), aSize, aType);
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Upload(gfxASurface* aUpdate, const nsIntRegion& aUpdated,
|
|
|
|
const nsIntRect& aRect, const nsIntPoint& aRotation);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual nsIntPoint GetOriginOffset() {
|
|
|
|
return mBufferRect.TopLeft() - mBufferRotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsIntRect mBufferRect;
|
|
|
|
nsIntPoint mBufferRotation;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowBufferOGL::Upload(gfxASurface* aUpdate, const nsIntRegion& aUpdated,
|
|
|
|
const nsIntRect& aRect, const nsIntPoint& aRotation)
|
|
|
|
{
|
2010-12-31 07:40:31 +00:00
|
|
|
gfxIntSize size = aUpdate->GetSize();
|
|
|
|
if (GetSize() != nsIntSize(size.width, size.height)) {
|
|
|
|
CreateTexture(aUpdate->GetContentType(),
|
|
|
|
nsIntSize(size.width, size.height));
|
|
|
|
}
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
nsIntRegion destRegion(aUpdated);
|
|
|
|
// aUpdated is in screen coordinates. Move it so that the layer's
|
|
|
|
// top-left is 0,0
|
|
|
|
nsIntPoint visTopLeft = mLayer->GetVisibleRegion().GetBounds().TopLeft();
|
|
|
|
destRegion.MoveBy(-visTopLeft);
|
2010-12-09 22:26:13 +00:00
|
|
|
|
|
|
|
// |aUpdated|, |aRect|, and |aRotation| are in thebes-layer space,
|
|
|
|
// unadjusted for resolution. The texture is in device space, so
|
|
|
|
// first we need to map the update params to device space.
|
|
|
|
//
|
|
|
|
// XXX this prematurely commits us to updating rects instead of
|
|
|
|
// regions here. This will be a perf penalty on platforms that
|
|
|
|
// support region updates. This is OK for now because the
|
|
|
|
// TextureImage backends we care about need to update contiguous
|
|
|
|
// rects anyway, and would do this conversion internally. To fix
|
|
|
|
// this, we would need to scale the region instead of its bounds
|
|
|
|
// here.
|
|
|
|
nsIntRect destBounds = destRegion.GetBounds();
|
|
|
|
gfxRect destRect(destBounds.x, destBounds.y, destBounds.width, destBounds.height);
|
|
|
|
destRect.Scale(mLayer->GetXResolution(), mLayer->GetYResolution());
|
|
|
|
destRect.RoundOut();
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
// NB: this gfxContext must not escape EndUpdate() below
|
2010-12-09 22:26:13 +00:00
|
|
|
nsIntRegion scaledDestRegion(nsIntRect(destRect.pos.x, destRect.pos.y,
|
|
|
|
destRect.size.width, destRect.size.height));
|
2010-12-17 07:50:26 +00:00
|
|
|
mTexImage->DirectUpdate(aUpdate, scaledDestRegion);
|
2010-10-13 22:55:45 +00:00
|
|
|
|
|
|
|
mBufferRect = aRect;
|
|
|
|
mBufferRotation = aRotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShadowThebesLayerOGL::ShadowThebesLayerOGL(LayerManagerOGL *aManager)
|
|
|
|
: ShadowThebesLayer(aManager, nsnull)
|
|
|
|
, LayerOGL(aManager)
|
|
|
|
{
|
|
|
|
mImplData = static_cast<LayerOGL*>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ShadowThebesLayerOGL::~ShadowThebesLayerOGL()
|
|
|
|
{}
|
|
|
|
|
|
|
|
void
|
2010-12-31 07:40:31 +00:00
|
|
|
ShadowThebesLayerOGL::SetFrontBuffer(const OptionalThebesBuffer& aNewFront,
|
2010-10-13 22:55:45 +00:00
|
|
|
const nsIntRegion& aValidRegion,
|
|
|
|
float aXResolution, float aYResolution)
|
|
|
|
{
|
|
|
|
if (mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mBuffer) {
|
|
|
|
mBuffer = new ShadowBufferOGL(this);
|
|
|
|
}
|
|
|
|
|
2010-12-31 07:40:31 +00:00
|
|
|
NS_ASSERTION(OptionalThebesBuffer::Tnull_t == aNewFront.type(),
|
|
|
|
"Only one system-memory buffer expected");
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowThebesLayerOGL::Swap(const ThebesBuffer& aNewFront,
|
|
|
|
const nsIntRegion& aUpdatedRegion,
|
|
|
|
ThebesBuffer* aNewBack,
|
|
|
|
nsIntRegion* aNewBackValidRegion,
|
2010-11-05 07:17:07 +00:00
|
|
|
float* aNewXResolution, float* aNewYResolution,
|
|
|
|
OptionalThebesBuffer* aReadOnlyFront,
|
|
|
|
nsIntRegion* aFrontUpdatedRegion)
|
2010-10-13 22:55:45 +00:00
|
|
|
{
|
|
|
|
if (!mDestroyed && mBuffer) {
|
|
|
|
nsRefPtr<gfxASurface> surf = ShadowLayerForwarder::OpenDescriptor(aNewFront.buffer());
|
|
|
|
mBuffer->Upload(surf, aUpdatedRegion, aNewFront.rect(), aNewFront.rotation());
|
|
|
|
}
|
|
|
|
|
|
|
|
*aNewBack = aNewFront;
|
|
|
|
*aNewBackValidRegion = mValidRegion;
|
2010-11-11 05:44:42 +00:00
|
|
|
*aNewXResolution = mXResolution;
|
|
|
|
*aNewYResolution = mYResolution;
|
2010-11-05 07:17:07 +00:00
|
|
|
*aReadOnlyFront = null_t();
|
|
|
|
aFrontUpdatedRegion->SetEmpty();
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowThebesLayerOGL::DestroyFrontBuffer()
|
|
|
|
{
|
|
|
|
mBuffer = nsnull;
|
|
|
|
}
|
|
|
|
|
2011-01-06 04:54:47 +00:00
|
|
|
void
|
|
|
|
ShadowThebesLayerOGL::Disconnect()
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
void
|
|
|
|
ShadowThebesLayerOGL::Destroy()
|
|
|
|
{
|
|
|
|
if (!mDestroyed) {
|
|
|
|
mDestroyed = PR_TRUE;
|
|
|
|
mBuffer = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Layer*
|
|
|
|
ShadowThebesLayerOGL::GetLayer()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
ShadowThebesLayerOGL::IsEmpty()
|
|
|
|
{
|
|
|
|
return !mBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowThebesLayerOGL::RenderLayer(int aPreviousFrameBuffer,
|
2010-11-08 09:06:15 +00:00
|
|
|
const nsIntPoint& aOffset)
|
2010-10-13 22:55:45 +00:00
|
|
|
{
|
|
|
|
if (!mBuffer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
NS_ABORT_IF_FALSE(mBuffer, "should have a buffer here");
|
|
|
|
|
|
|
|
mOGLManager->MakeCurrent();
|
|
|
|
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
|
|
|
|
|
|
|
gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer);
|
2010-11-08 09:06:15 +00:00
|
|
|
mBuffer->RenderTo(aOffset, mOGLManager);
|
2010-10-13 22:55:45 +00:00
|
|
|
DEBUG_GL_ERROR_CHECK(gl());
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MOZ_IPC
|
|
|
|
|
|
|
|
|
2010-03-30 04:48:52 +00:00
|
|
|
} /* layers */
|
|
|
|
} /* mozilla */
|