2010-05-27 20:04:26 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2010-05-25 06:35:35 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2010-05-18 04:04:22 +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) 2010
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
|
|
|
*
|
|
|
|
* 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 ***** */
|
|
|
|
|
2011-07-04 13:15:05 +00:00
|
|
|
#include "mozilla/layers/PLayers.h"
|
|
|
|
#include "mozilla/layers/ShadowLayers.h"
|
|
|
|
|
2011-04-03 02:14:00 +00:00
|
|
|
#include "gfxSharedImageSurface.h"
|
2010-10-13 22:55:45 +00:00
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
#include "CanvasLayerOGL.h"
|
|
|
|
|
|
|
|
#include "gfxImageSurface.h"
|
|
|
|
#include "gfxContext.h"
|
2010-06-23 14:02:32 +00:00
|
|
|
#include "GLContextProvider.h"
|
2010-05-18 04:04:22 +00:00
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
#include "gfxWindowsSurface.h"
|
|
|
|
#include "WGLLibrary.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include <OpenGL/OpenGL.h>
|
|
|
|
#endif
|
|
|
|
|
2011-04-20 21:45:57 +00:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
#include "gfxXlibSurface.h"
|
|
|
|
#endif
|
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
void
|
|
|
|
CanvasLayerOGL::Destroy()
|
2010-05-18 04:04:22 +00:00
|
|
|
{
|
2010-08-07 05:09:18 +00:00
|
|
|
if (!mDestroyed) {
|
|
|
|
if (mTexture) {
|
|
|
|
GLContext *cx = mOGLManager->glForResources();
|
|
|
|
cx->MakeCurrent();
|
|
|
|
cx->fDeleteTextures(1, &mTexture);
|
|
|
|
}
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
mDestroyed = PR_TRUE;
|
2010-06-18 09:21:42 +00:00
|
|
|
}
|
2010-05-18 04:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CanvasLayerOGL::Initialize(const Data& aData)
|
|
|
|
{
|
2010-05-25 06:35:35 +00:00
|
|
|
NS_ASSERTION(mCanvasSurface == nsnull, "BasicCanvasLayer::Initialize called twice!");
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
if (aData.mGLContext != nsnull &&
|
|
|
|
aData.mSurface != nsnull)
|
|
|
|
{
|
|
|
|
NS_WARNING("CanvasLayerOGL can't have both surface and GLContext");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-08 21:41:10 +00:00
|
|
|
mOGLManager->MakeCurrent();
|
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
if (aData.mSurface) {
|
2010-05-25 06:35:35 +00:00
|
|
|
mCanvasSurface = aData.mSurface;
|
|
|
|
mNeedsYFlip = PR_FALSE;
|
2011-03-08 21:41:10 +00:00
|
|
|
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
2011-08-05 01:13:25 +00:00
|
|
|
if (aData.mSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
|
|
|
|
gfxXlibSurface *xsurf = static_cast<gfxXlibSurface*>(aData.mSurface);
|
|
|
|
mPixmap = xsurf->GetGLXPixmap();
|
|
|
|
if (mPixmap) {
|
|
|
|
if (aData.mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
|
|
|
|
mLayerProgram = gl::RGBALayerProgramType;
|
|
|
|
} else {
|
|
|
|
mLayerProgram = gl::RGBXLayerProgramType;
|
|
|
|
}
|
|
|
|
MakeTexture();
|
2011-03-08 21:41:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2010-05-18 04:04:22 +00:00
|
|
|
} else if (aData.mGLContext) {
|
2010-07-19 05:01:14 +00:00
|
|
|
if (!aData.mGLContext->IsOffscreen()) {
|
|
|
|
NS_WARNING("CanvasLayerOGL with a non-offscreen GL context given");
|
2010-05-18 04:04:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
mCanvasGLContext = aData.mGLContext;
|
2010-05-18 04:04:22 +00:00
|
|
|
mGLBufferIsPremultiplied = aData.mGLBufferIsPremultiplied;
|
2010-07-19 05:01:14 +00:00
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
mNeedsYFlip = PR_TRUE;
|
2010-05-18 04:04:22 +00:00
|
|
|
} else {
|
|
|
|
NS_WARNING("CanvasLayerOGL::Initialize called without surface or GL context!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
|
2010-12-17 07:19:28 +00:00
|
|
|
|
|
|
|
// Check the maximum texture size supported by GL. glTexImage2D supports
|
|
|
|
// images of up to 2 + GL_MAX_TEXTURE_SIZE
|
|
|
|
GLint texSize = gl()->GetMaxTextureSize();
|
|
|
|
if (mBounds.width > (2 + texSize) || mBounds.height > (2 + texSize)) {
|
|
|
|
mDelayedUpdates = PR_TRUE;
|
|
|
|
MakeTexture();
|
|
|
|
// This should only ever occur with 2d canvas, WebGL can't already have a texture
|
|
|
|
// of this size can it?
|
|
|
|
NS_ABORT_IF_FALSE(mCanvasSurface,
|
|
|
|
"Invalid texture size when WebGL surface already exists at that size?");
|
|
|
|
}
|
2010-05-18 04:04:22 +00:00
|
|
|
}
|
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
void
|
|
|
|
CanvasLayerOGL::MakeTexture()
|
|
|
|
{
|
|
|
|
if (mTexture != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gl()->fGenTextures(1, &mTexture);
|
|
|
|
|
|
|
|
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
|
|
|
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
|
|
|
|
|
|
|
gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
|
|
|
|
gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
|
|
|
|
gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
}
|
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
void
|
2011-03-27 23:59:46 +00:00
|
|
|
CanvasLayerOGL::UpdateSurface()
|
2010-05-18 04:04:22 +00:00
|
|
|
{
|
2011-03-27 23:59:46 +00:00
|
|
|
if (!mDirty)
|
|
|
|
return;
|
|
|
|
mDirty = PR_FALSE;
|
|
|
|
|
2010-12-17 07:19:28 +00:00
|
|
|
if (mDestroyed || mDelayedUpdates) {
|
2010-08-07 05:09:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-08 21:41:10 +00:00
|
|
|
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
|
|
|
if (mPixmap) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
mOGLManager->MakeCurrent();
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
if (mCanvasGLContext &&
|
|
|
|
mCanvasGLContext->GetContextType() == gl()->GetContextType())
|
|
|
|
{
|
2010-07-19 05:01:14 +00:00
|
|
|
if (gl()->BindOffscreenNeedsTexture(mCanvasGLContext) &&
|
|
|
|
mTexture == 0)
|
|
|
|
{
|
|
|
|
MakeTexture();
|
2010-06-23 14:02:32 +00:00
|
|
|
}
|
2010-08-07 05:09:18 +00:00
|
|
|
} else {
|
2010-12-17 07:28:30 +00:00
|
|
|
nsRefPtr<gfxASurface> updatedAreaSurface;
|
2010-08-07 05:09:18 +00:00
|
|
|
if (mCanvasSurface) {
|
2010-12-17 07:28:30 +00:00
|
|
|
updatedAreaSurface = mCanvasSurface;
|
2010-08-07 05:09:18 +00:00
|
|
|
} else if (mCanvasGLContext) {
|
2010-12-17 07:28:30 +00:00
|
|
|
nsRefPtr<gfxImageSurface> updatedAreaImageSurface =
|
2011-03-27 23:59:46 +00:00
|
|
|
new gfxImageSurface(gfxIntSize(mBounds.width, mBounds.height),
|
2010-05-25 06:35:35 +00:00
|
|
|
gfxASurface::ImageFormatARGB32);
|
2011-03-27 23:59:46 +00:00
|
|
|
mCanvasGLContext->ReadPixelsIntoImageSurface(0, 0,
|
|
|
|
mBounds.width,
|
|
|
|
mBounds.height,
|
2010-08-07 05:09:18 +00:00
|
|
|
updatedAreaImageSurface);
|
2010-12-17 07:28:30 +00:00
|
|
|
updatedAreaSurface = updatedAreaImageSurface;
|
2010-05-18 04:04:22 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 07:28:30 +00:00
|
|
|
mLayerProgram =
|
|
|
|
gl()->UploadSurfaceToTexture(updatedAreaSurface,
|
2011-03-27 23:59:46 +00:00
|
|
|
mBounds,
|
2010-12-17 07:28:30 +00:00
|
|
|
mTexture,
|
2011-01-18 01:32:40 +00:00
|
|
|
false,
|
2011-03-27 23:59:46 +00:00
|
|
|
nsIntPoint(0, 0));
|
2010-05-18 04:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-05-21 03:20:48 +00:00
|
|
|
CanvasLayerOGL::RenderLayer(int aPreviousDestination,
|
2010-11-08 09:06:15 +00:00
|
|
|
const nsIntPoint& aOffset)
|
2010-05-18 04:04:22 +00:00
|
|
|
{
|
2011-03-27 23:59:46 +00:00
|
|
|
UpdateSurface();
|
2011-03-27 23:59:46 +00:00
|
|
|
FireDidTransactionCallback();
|
2011-03-27 23:59:46 +00:00
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
mOGLManager->MakeCurrent();
|
2010-05-18 04:04:22 +00:00
|
|
|
|
|
|
|
// XXX We're going to need a different program depending on if
|
|
|
|
// mGLBufferIsPremultiplied is TRUE or not. The RGBLayerProgram
|
|
|
|
// assumes that it's true.
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
if (mTexture) {
|
|
|
|
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
|
|
|
}
|
|
|
|
|
2010-12-17 07:28:30 +00:00
|
|
|
ColorTextureLayerProgram *program = nsnull;
|
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
bool useGLContext = mCanvasGLContext &&
|
|
|
|
mCanvasGLContext->GetContextType() == gl()->GetContextType();
|
|
|
|
|
2010-12-17 07:19:28 +00:00
|
|
|
nsIntRect drawRect = mBounds;
|
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
if (useGLContext) {
|
2010-09-29 22:46:22 +00:00
|
|
|
mCanvasGLContext->MakeCurrent();
|
|
|
|
mCanvasGLContext->fFlush();
|
|
|
|
|
|
|
|
gl()->MakeCurrent();
|
2010-07-19 05:01:14 +00:00
|
|
|
gl()->BindTex2DOffscreen(mCanvasGLContext);
|
2010-12-17 07:28:30 +00:00
|
|
|
program = mOGLManager->GetBasicLayerProgram(CanUseOpaqueSurface(), PR_TRUE);
|
2010-12-17 07:19:28 +00:00
|
|
|
} else if (mDelayedUpdates) {
|
|
|
|
NS_ABORT_IF_FALSE(mCanvasSurface, "WebGL canvases should always be using full texture upload");
|
|
|
|
|
|
|
|
drawRect.IntersectRect(drawRect, GetEffectiveVisibleRegion().GetBounds());
|
|
|
|
|
2010-12-17 07:28:30 +00:00
|
|
|
mLayerProgram =
|
|
|
|
gl()->UploadSurfaceToTexture(mCanvasSurface,
|
2011-02-14 23:23:50 +00:00
|
|
|
nsIntRect(0, 0, drawRect.width, drawRect.height),
|
2010-12-17 07:28:30 +00:00
|
|
|
mTexture,
|
2011-02-14 23:23:50 +00:00
|
|
|
true,
|
|
|
|
drawRect.TopLeft());
|
2010-12-17 07:28:30 +00:00
|
|
|
}
|
|
|
|
if (!program) {
|
|
|
|
program = mOGLManager->GetColorTextureLayerProgram(mLayerProgram);
|
2010-05-18 04:04:22 +00:00
|
|
|
}
|
|
|
|
|
2011-03-08 21:41:10 +00:00
|
|
|
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
|
|
|
if (mPixmap && !mDelayedUpdates) {
|
|
|
|
sGLXLibrary.BindTexImage(mPixmap);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-10-17 02:31:15 +00:00
|
|
|
gl()->ApplyFilterToBoundTexture(mFilter);
|
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
program->Activate();
|
2010-12-17 07:19:28 +00:00
|
|
|
program->SetLayerQuadRect(drawRect);
|
2010-11-08 09:06:15 +00:00
|
|
|
program->SetLayerTransform(GetEffectiveTransform());
|
|
|
|
program->SetLayerOpacity(GetEffectiveOpacity());
|
2010-05-25 06:35:35 +00:00
|
|
|
program->SetRenderOffset(aOffset);
|
|
|
|
program->SetTextureUnit(0);
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
mOGLManager->BindAndDrawQuad(program, mNeedsYFlip ? true : false);
|
2010-05-18 04:04:22 +00:00
|
|
|
|
2011-03-08 21:41:10 +00:00
|
|
|
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
|
|
|
if (mPixmap && !mDelayedUpdates) {
|
|
|
|
sGLXLibrary.ReleaseTexImage(mPixmap);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
if (useGLContext) {
|
2010-07-19 05:01:14 +00:00
|
|
|
gl()->UnbindTex2DOffscreen(mCanvasGLContext);
|
2010-05-18 04:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-13 22:55:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
ShadowCanvasLayerOGL::ShadowCanvasLayerOGL(LayerManagerOGL* aManager)
|
|
|
|
: ShadowCanvasLayer(aManager, nsnull)
|
|
|
|
, LayerOGL(aManager)
|
2011-06-10 01:17:02 +00:00
|
|
|
, mNeedsYFlip(PR_FALSE)
|
2010-10-13 22:55:45 +00:00
|
|
|
{
|
|
|
|
mImplData = static_cast<LayerOGL*>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ShadowCanvasLayerOGL::~ShadowCanvasLayerOGL()
|
|
|
|
{}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowCanvasLayerOGL::Initialize(const Data& aData)
|
|
|
|
{
|
2011-04-20 21:45:57 +00:00
|
|
|
NS_RUNTIMEABORT("Incompatibe surface type");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-27 22:19:28 +00:00
|
|
|
ShadowCanvasLayerOGL::Init(const CanvasSurface& aNewFront, bool needYFlip)
|
2011-04-20 21:45:57 +00:00
|
|
|
{
|
2011-09-27 22:19:28 +00:00
|
|
|
nsRefPtr<gfxASurface> surf = ShadowLayerForwarder::OpenDescriptor(aNewFront);
|
2011-04-20 21:45:57 +00:00
|
|
|
|
2011-09-27 22:19:28 +00:00
|
|
|
mTexImage = gl()->CreateTextureImage(surf->GetSize(),
|
2011-04-20 21:45:57 +00:00
|
|
|
surf->GetContentType(),
|
2010-10-13 22:55:45 +00:00
|
|
|
LOCAL_GL_CLAMP_TO_EDGE);
|
2011-06-10 01:17:02 +00:00
|
|
|
mNeedsYFlip = needYFlip;
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
|
|
|
|
2011-04-20 21:45:57 +00:00
|
|
|
void
|
2011-09-27 22:19:28 +00:00
|
|
|
ShadowCanvasLayerOGL::Swap(const CanvasSurface& aNewFront,
|
|
|
|
bool needYFlip,
|
|
|
|
CanvasSurface* aNewBack)
|
2010-10-13 22:55:45 +00:00
|
|
|
{
|
2011-09-27 22:19:28 +00:00
|
|
|
if (!mDestroyed) {
|
2011-04-20 21:45:57 +00:00
|
|
|
nsRefPtr<gfxASurface> surf = ShadowLayerForwarder::OpenDescriptor(aNewFront);
|
2011-09-27 22:19:28 +00:00
|
|
|
gfxIntSize sz = surf->GetSize();
|
|
|
|
if (!mTexImage || mTexImage->GetSize() != sz) {
|
|
|
|
Init(aNewFront, needYFlip);
|
|
|
|
}
|
2010-10-13 22:55:45 +00:00
|
|
|
nsIntRegion updateRegion(nsIntRect(0, 0, sz.width, sz.height));
|
2011-04-20 21:45:57 +00:00
|
|
|
mTexImage->DirectUpdate(surf, updateRegion);
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
|
|
|
|
2011-04-20 21:45:57 +00:00
|
|
|
*aNewBack = aNewFront;
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowCanvasLayerOGL::DestroyFrontBuffer()
|
|
|
|
{
|
|
|
|
mTexImage = nsnull;
|
|
|
|
}
|
|
|
|
|
2011-01-06 04:54:47 +00:00
|
|
|
void
|
|
|
|
ShadowCanvasLayerOGL::Disconnect()
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
void
|
|
|
|
ShadowCanvasLayerOGL::Destroy()
|
|
|
|
{
|
|
|
|
if (!mDestroyed) {
|
|
|
|
mDestroyed = PR_TRUE;
|
|
|
|
mTexImage = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Layer*
|
|
|
|
ShadowCanvasLayerOGL::GetLayer()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowCanvasLayerOGL::RenderLayer(int aPreviousFrameBuffer,
|
2010-11-08 09:06:15 +00:00
|
|
|
const nsIntPoint& aOffset)
|
2010-10-13 22:55:45 +00:00
|
|
|
{
|
|
|
|
mOGLManager->MakeCurrent();
|
|
|
|
|
2010-11-05 06:40:19 +00:00
|
|
|
ColorTextureLayerProgram *program =
|
2010-12-17 07:29:23 +00:00
|
|
|
mOGLManager->GetColorTextureLayerProgram(mTexImage->GetShaderProgramType());
|
2010-10-13 22:55:45 +00:00
|
|
|
|
2011-10-14 20:16:19 +00:00
|
|
|
|
|
|
|
gfx3DMatrix effectiveTransform = GetEffectiveTransform();
|
|
|
|
#ifdef ANDROID
|
|
|
|
// Bug 691354
|
|
|
|
// Using the LINEAR filter we get unexplained artifacts.
|
|
|
|
// Use NEAREST when no scaling is required.
|
|
|
|
gfxMatrix matrix;
|
|
|
|
bool is2D = GetEffectiveTransform().Is2D(&matrix);
|
|
|
|
if (is2D && !matrix.HasNonTranslationOrFlip()) {
|
|
|
|
mTexImage->SetFilter(gfxPattern::FILTER_NEAREST);
|
|
|
|
} else {
|
|
|
|
mTexImage->SetFilter(mFilter);
|
|
|
|
}
|
|
|
|
#else
|
2011-10-05 18:20:33 +00:00
|
|
|
mTexImage->SetFilter(mFilter);
|
2011-10-14 20:16:19 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
|
|
|
|
program->Activate();
|
2011-10-14 20:16:19 +00:00
|
|
|
program->SetLayerTransform(effectiveTransform);
|
2010-11-08 09:06:15 +00:00
|
|
|
program->SetLayerOpacity(GetEffectiveOpacity());
|
2010-10-13 22:55:45 +00:00
|
|
|
program->SetRenderOffset(aOffset);
|
|
|
|
program->SetTextureUnit(0);
|
|
|
|
|
2011-07-06 18:00:47 +00:00
|
|
|
mTexImage->BeginTileIteration();
|
|
|
|
do {
|
2011-10-05 18:20:33 +00:00
|
|
|
TextureImage::ScopedBindTextureAndApplyFilter texBind(mTexImage, LOCAL_GL_TEXTURE0);
|
2011-07-06 18:00:47 +00:00
|
|
|
program->SetLayerQuadRect(mTexImage->GetTileRect());
|
|
|
|
mOGLManager->BindAndDrawQuad(program, mNeedsYFlip); // FIXME flip order of tiles?
|
|
|
|
} while (mTexImage->NextTile());
|
2010-10-13 22:55:45 +00:00
|
|
|
}
|