Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#include "CompositorOGL.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stddef.h> // for size_t
|
|
|
|
#include <stdint.h> // for uint32_t, uint8_t
|
|
|
|
#include <stdlib.h> // for free, malloc
|
|
|
|
#include "GLContextProvider.h" // for GLContextProvider
|
2013-09-04 16:14:52 +04:00
|
|
|
#include "GLContext.h" // for GLContext
|
2013-12-03 22:44:38 +04:00
|
|
|
#include "GLUploadHelpers.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "Layers.h" // for WriteSnapshotToDumpFile
|
2013-11-29 08:11:49 +04:00
|
|
|
#include "LayerScope.h" // for LayerScope
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfx2DGlue.h" // for ThebesFilter
|
|
|
|
#include "gfx3DMatrix.h" // for gfx3DMatrix
|
|
|
|
#include "gfxCrashReporterUtils.h" // for ScopedGfxFeatureReporter
|
|
|
|
#include "gfxMatrix.h" // for gfxMatrix
|
2013-10-02 01:01:19 +04:00
|
|
|
#include "GraphicsFilter.h" // for GraphicsFilter
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
2014-02-27 06:53:27 +04:00
|
|
|
#include "gfxPrefs.h" // for gfxPrefs
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxRect.h" // for gfxRect
|
|
|
|
#include "gfxUtils.h" // for NextPowerOfTwo, gfxUtils, etc
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h" // for ArrayLength
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/Preferences.h" // for Preferences
|
|
|
|
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
|
|
|
#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix
|
2014-03-27 05:01:15 +04:00
|
|
|
#include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
#include "mozilla/layers/CompositingRenderTargetOGL.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/Effects.h" // for EffectChain, TexturedEffect, etc
|
|
|
|
#include "mozilla/layers/TextureHost.h" // for TextureSource, etc
|
|
|
|
#include "mozilla/layers/TextureHostOGL.h" // for TextureSourceOGL, etc
|
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
|
|
|
#include "nsAString.h"
|
|
|
|
#include "nsIConsoleService.h" // for nsIConsoleService, etc
|
|
|
|
#include "nsIWidget.h" // for nsIWidget
|
|
|
|
#include "nsLiteralString.h" // for NS_LITERAL_STRING
|
|
|
|
#include "nsMathUtils.h" // for NS_roundf
|
|
|
|
#include "nsRect.h" // for nsIntRect
|
|
|
|
#include "nsServiceManagerUtils.h" // for do_GetService
|
|
|
|
#include "nsString.h" // for nsString, nsAutoCString, etc
|
2013-12-09 08:07:18 +04:00
|
|
|
#include "ScopedGLHelpers.h"
|
2014-01-02 19:17:29 +04:00
|
|
|
#include "GLReadTexImageHelper.h"
|
2014-03-27 05:01:15 +04:00
|
|
|
#include "TiledLayerBuffer.h" // for TiledLayerComposer
|
2014-05-09 05:03:37 +04:00
|
|
|
#include "HeapCopyOfStackArray.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
#if MOZ_ANDROID_OMTC
|
|
|
|
#include "TexturePoolOGL.h"
|
|
|
|
#endif
|
2014-03-08 01:34:04 +04:00
|
|
|
|
2013-09-10 23:56:49 +04:00
|
|
|
#include "GeckoProfiler.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-03-18 05:36:56 +04:00
|
|
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
|
|
|
#include "libdisplay/GonkDisplay.h" // for GonkDisplay
|
|
|
|
#include <ui/Fence.h>
|
|
|
|
#endif
|
|
|
|
|
2013-11-27 02:15:17 +04:00
|
|
|
#define BUFFER_OFFSET(i) ((char *)nullptr + (i))
|
2013-11-29 08:11:49 +04:00
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2013-11-08 10:22:05 +04:00
|
|
|
using namespace std;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
using namespace gfx;
|
|
|
|
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
2013-12-10 10:50:52 +04:00
|
|
|
static void
|
|
|
|
BindMaskForProgram(ShaderProgramOGL* aProgram, TextureSourceOGL* aSourceMask,
|
|
|
|
GLenum aTexUnit, const gfx::Matrix4x4& aTransform)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(LOCAL_GL_TEXTURE0 <= aTexUnit && aTexUnit <= LOCAL_GL_TEXTURE31);
|
2014-03-13 04:37:17 +04:00
|
|
|
aSourceMask->BindTexture(aTexUnit, gfx::Filter::LINEAR);
|
2013-12-10 10:50:52 +04:00
|
|
|
aProgram->SetMaskTextureUnit(aTexUnit - LOCAL_GL_TEXTURE0);
|
|
|
|
aProgram->SetMaskLayerTransform(aTransform);
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
CompositorOGL::CompositorOGL(nsIWidget *aWidget, int aSurfaceWidth,
|
2013-04-30 07:16:04 +04:00
|
|
|
int aSurfaceHeight, bool aUseExternalSurfaceSize)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
: mWidget(aWidget)
|
|
|
|
, mWidgetSize(-1, -1)
|
|
|
|
, mSurfaceSize(aSurfaceWidth, aSurfaceHeight)
|
|
|
|
, mHasBGRA(0)
|
2013-04-30 07:16:04 +04:00
|
|
|
, mUseExternalSurfaceSize(aUseExternalSurfaceSize)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
, mFrameInProgress(false)
|
|
|
|
, mDestroyed(false)
|
2014-01-08 00:02:18 +04:00
|
|
|
, mHeight(0)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CompositorOGL);
|
2014-02-13 20:53:50 +04:00
|
|
|
SetBackend(LayersBackend::LAYERS_OPENGL);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CompositorOGL::~CompositorOGL()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CompositorOGL);
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<mozilla::gl::GLContext>
|
|
|
|
CompositorOGL::CreateContext()
|
|
|
|
{
|
|
|
|
nsRefPtr<GLContext> context;
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
if (PR_GetEnv("MOZ_LAYERS_PREFER_EGL")) {
|
|
|
|
printf_stderr("Trying GL layers...\n");
|
|
|
|
context = gl::GLContextProviderEGL::CreateForWindow(mWidget);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-06-03 22:41:00 +04:00
|
|
|
// Allow to create offscreen GL context for main Layer Manager
|
|
|
|
if (!context && PR_GetEnv("MOZ_LAYERS_PREFER_OFFSCREEN")) {
|
|
|
|
SurfaceCaps caps = SurfaceCaps::ForRGB();
|
|
|
|
caps.preserve = false;
|
|
|
|
caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == gfxImageFormat::RGB16_565;
|
|
|
|
context = GLContextProvider::CreateOffscreen(gfxIntSize(mSurfaceSize.width,
|
|
|
|
mSurfaceSize.height), caps);
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
if (!context)
|
|
|
|
context = gl::GLContextProvider::CreateForWindow(mWidget);
|
|
|
|
|
|
|
|
if (!context) {
|
|
|
|
NS_WARNING("Failed to create CompositorOGL context");
|
|
|
|
}
|
2013-11-15 20:28:43 +04:00
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
return context.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::Destroy()
|
|
|
|
{
|
2014-03-12 20:28:47 +04:00
|
|
|
if (mTexturePool) {
|
|
|
|
mTexturePool->Clear();
|
|
|
|
mTexturePool = nullptr;
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
if (!mDestroyed) {
|
|
|
|
mDestroyed = true;
|
|
|
|
CleanupResources();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::CleanupResources()
|
|
|
|
{
|
|
|
|
if (!mGLContext)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsRefPtr<GLContext> ctx = mGLContext->GetSharedContext();
|
|
|
|
if (!ctx) {
|
|
|
|
ctx = mGLContext;
|
|
|
|
}
|
|
|
|
|
2013-11-08 10:22:05 +04:00
|
|
|
for (std::map<ShaderConfigOGL, ShaderProgramOGL *>::iterator iter = mPrograms.begin();
|
|
|
|
iter != mPrograms.end();
|
|
|
|
iter++) {
|
|
|
|
delete iter->second;
|
|
|
|
}
|
|
|
|
mPrograms.clear();
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2013-12-03 14:44:46 +04:00
|
|
|
if (!ctx->MakeCurrent()) {
|
|
|
|
mQuadVBO = 0;
|
|
|
|
mGLContext = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
ctx->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
|
|
|
|
|
|
|
|
if (mQuadVBO) {
|
|
|
|
ctx->fDeleteBuffers(1, &mQuadVBO);
|
|
|
|
mQuadVBO = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mGLContext = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CompositorOGL::Initialize()
|
|
|
|
{
|
|
|
|
ScopedGfxFeatureReporter reporter("GL Layers", true);
|
|
|
|
|
|
|
|
// Do not allow double initialization
|
|
|
|
NS_ABORT_IF_FALSE(mGLContext == nullptr, "Don't reinitialize CompositorOGL");
|
|
|
|
|
|
|
|
mGLContext = CreateContext();
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
if (!mGLContext)
|
|
|
|
NS_RUNTIMEABORT("We need a context on Android");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!mGLContext)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
MakeCurrent();
|
|
|
|
|
|
|
|
mHasBGRA =
|
|
|
|
mGLContext->IsExtensionSupported(gl::GLContext::EXT_texture_format_BGRA8888) ||
|
|
|
|
mGLContext->IsExtensionSupported(gl::GLContext::EXT_bgra);
|
|
|
|
|
|
|
|
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
|
|
|
|
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
|
|
|
mGLContext->fEnable(LOCAL_GL_BLEND);
|
|
|
|
|
|
|
|
// initialise a common shader to check that we can actually compile a shader
|
2013-11-08 10:22:05 +04:00
|
|
|
RefPtr<EffectSolidColor> effect = new EffectSolidColor(Color(0, 0, 0, 0));
|
|
|
|
ShaderConfigOGL config = GetShaderConfigFor(effect);
|
|
|
|
if (!GetShaderProgramFor(config)) {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mGLContext->WorkAroundDriverBugs()) {
|
|
|
|
/**
|
|
|
|
* We'll test the ability here to bind NPOT textures to a framebuffer, if
|
|
|
|
* this fails we'll try ARB_texture_rectangle.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GLenum textureTargets[] = {
|
|
|
|
LOCAL_GL_TEXTURE_2D,
|
|
|
|
LOCAL_GL_NONE
|
|
|
|
};
|
|
|
|
|
2014-03-31 13:10:49 +04:00
|
|
|
if (!mGLContext->IsGLES()) {
|
2014-03-26 22:23:44 +04:00
|
|
|
// No TEXTURE_RECTANGLE_ARB available on ES2
|
|
|
|
textureTargets[1] = LOCAL_GL_TEXTURE_RECTANGLE_ARB;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mFBOTextureTarget = LOCAL_GL_NONE;
|
|
|
|
|
|
|
|
GLuint testFBO = 0;
|
|
|
|
mGLContext->fGenFramebuffers(1, &testFBO);
|
|
|
|
GLuint testTexture = 0;
|
|
|
|
|
2013-06-13 05:26:59 +04:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(textureTargets); i++) {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
GLenum target = textureTargets[i];
|
|
|
|
if (!target)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mGLContext->fGenTextures(1, &testTexture);
|
|
|
|
mGLContext->fBindTexture(target, testTexture);
|
|
|
|
mGLContext->fTexParameteri(target,
|
|
|
|
LOCAL_GL_TEXTURE_MIN_FILTER,
|
|
|
|
LOCAL_GL_NEAREST);
|
|
|
|
mGLContext->fTexParameteri(target,
|
|
|
|
LOCAL_GL_TEXTURE_MAG_FILTER,
|
|
|
|
LOCAL_GL_NEAREST);
|
|
|
|
mGLContext->fTexImage2D(target,
|
|
|
|
0,
|
|
|
|
LOCAL_GL_RGBA,
|
|
|
|
5, 3, /* sufficiently NPOT */
|
|
|
|
0,
|
|
|
|
LOCAL_GL_RGBA,
|
|
|
|
LOCAL_GL_UNSIGNED_BYTE,
|
2013-07-20 12:48:55 +04:00
|
|
|
nullptr);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
// unbind this texture, in preparation for binding it to the FBO
|
|
|
|
mGLContext->fBindTexture(target, 0);
|
|
|
|
|
|
|
|
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, testFBO);
|
|
|
|
mGLContext->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
target,
|
|
|
|
testTexture,
|
|
|
|
0);
|
|
|
|
|
|
|
|
if (mGLContext->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER) ==
|
|
|
|
LOCAL_GL_FRAMEBUFFER_COMPLETE)
|
|
|
|
{
|
|
|
|
mFBOTextureTarget = target;
|
|
|
|
mGLContext->fDeleteTextures(1, &testTexture);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mGLContext->fDeleteTextures(1, &testTexture);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (testFBO) {
|
|
|
|
mGLContext->fDeleteFramebuffers(1, &testFBO);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mFBOTextureTarget == LOCAL_GL_NONE) {
|
|
|
|
/* Unable to find a texture target that works with FBOs and NPOT textures */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// not trying to work around driver bugs, so TEXTURE_2D should just work
|
|
|
|
mFBOTextureTarget = LOCAL_GL_TEXTURE_2D;
|
|
|
|
}
|
|
|
|
|
|
|
|
// back to default framebuffer, to avoid confusion
|
|
|
|
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
|
|
|
|
|
|
|
|
if (mFBOTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB) {
|
|
|
|
/* If we're using TEXTURE_RECTANGLE, then we must have the ARB
|
|
|
|
* extension -- the EXT variant does not provide support for
|
|
|
|
* texture rectangle access inside GLSL (sampler2DRect,
|
|
|
|
* texture2DRect).
|
|
|
|
*/
|
|
|
|
if (!mGLContext->IsExtensionSupported(gl::GLContext::ARB_texture_rectangle))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a simple quad VBO */
|
|
|
|
|
|
|
|
mGLContext->fGenBuffers(1, &mQuadVBO);
|
|
|
|
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mQuadVBO);
|
|
|
|
|
2014-05-28 18:15:31 +04:00
|
|
|
// 4 quads, with the number of the quad (vertexID) encoded in w.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
GLfloat vertices[] = {
|
2014-05-28 18:15:31 +04:00
|
|
|
0.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
1.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 0.0f,
|
2014-05-31 06:34:14 +04:00
|
|
|
1.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 0.0f,
|
2014-05-28 18:15:31 +04:00
|
|
|
1.0f, 1.0f, 0.0f, 0.0f,
|
2014-05-31 06:34:14 +04:00
|
|
|
|
2014-05-28 18:15:31 +04:00
|
|
|
0.0f, 0.0f, 0.0f, 1.0f,
|
|
|
|
1.0f, 0.0f, 0.0f, 1.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 1.0f,
|
2014-05-31 06:34:14 +04:00
|
|
|
1.0f, 0.0f, 0.0f, 1.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 1.0f,
|
2014-05-28 18:15:31 +04:00
|
|
|
1.0f, 1.0f, 0.0f, 1.0f,
|
2014-05-31 06:34:14 +04:00
|
|
|
|
2014-05-28 18:15:31 +04:00
|
|
|
0.0f, 0.0f, 0.0f, 2.0f,
|
|
|
|
1.0f, 0.0f, 0.0f, 2.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 2.0f,
|
2014-05-31 06:34:14 +04:00
|
|
|
1.0f, 0.0f, 0.0f, 2.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 2.0f,
|
2014-05-28 18:15:31 +04:00
|
|
|
1.0f, 1.0f, 0.0f, 2.0f,
|
2014-05-31 06:34:14 +04:00
|
|
|
|
2014-05-28 18:15:31 +04:00
|
|
|
0.0f, 0.0f, 0.0f, 3.0f,
|
|
|
|
1.0f, 0.0f, 0.0f, 3.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 3.0f,
|
2014-05-31 06:34:14 +04:00
|
|
|
1.0f, 0.0f, 0.0f, 3.0f,
|
|
|
|
0.0f, 1.0f, 0.0f, 3.0f,
|
2014-05-28 18:15:31 +04:00
|
|
|
1.0f, 1.0f, 0.0f, 3.0f,
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
};
|
2014-05-09 05:03:37 +04:00
|
|
|
HeapCopyOfStackArray<GLfloat> verticesOnHeap(vertices);
|
|
|
|
mGLContext->fBufferData(LOCAL_GL_ARRAY_BUFFER,
|
|
|
|
verticesOnHeap.ByteLength(),
|
|
|
|
verticesOnHeap.Data(),
|
|
|
|
LOCAL_GL_STATIC_DRAW);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIConsoleService>
|
|
|
|
console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
|
|
|
|
if (console) {
|
|
|
|
nsString msg;
|
|
|
|
msg +=
|
2013-10-04 16:03:09 +04:00
|
|
|
NS_LITERAL_STRING("OpenGL compositor Initialized Succesfully.\nVersion: ");
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
msg += NS_ConvertUTF8toUTF16(
|
|
|
|
nsDependentCString((const char*)mGLContext->fGetString(LOCAL_GL_VERSION)));
|
|
|
|
msg += NS_LITERAL_STRING("\nVendor: ");
|
|
|
|
msg += NS_ConvertUTF8toUTF16(
|
|
|
|
nsDependentCString((const char*)mGLContext->fGetString(LOCAL_GL_VENDOR)));
|
|
|
|
msg += NS_LITERAL_STRING("\nRenderer: ");
|
|
|
|
msg += NS_ConvertUTF8toUTF16(
|
|
|
|
nsDependentCString((const char*)mGLContext->fGetString(LOCAL_GL_RENDERER)));
|
|
|
|
msg += NS_LITERAL_STRING("\nFBO Texture Target: ");
|
|
|
|
if (mFBOTextureTarget == LOCAL_GL_TEXTURE_2D)
|
|
|
|
msg += NS_LITERAL_STRING("TEXTURE_2D");
|
|
|
|
else
|
|
|
|
msg += NS_LITERAL_STRING("TEXTURE_RECTANGLE");
|
|
|
|
console->LogStringMessage(msg.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
reporter.SetSuccessful();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-22 14:29:56 +04:00
|
|
|
static GLfloat
|
|
|
|
WrapTexCoord(GLfloat v)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2014-05-22 14:29:56 +04:00
|
|
|
// fmodf gives negative results for negative numbers;
|
|
|
|
// that is, fmodf(0.75, 1.0) == 0.75, but
|
|
|
|
// fmodf(-0.75, 1.0) == -0.75. For the negative case,
|
|
|
|
// the result we need is 0.25, so we add 1.0f.
|
|
|
|
if (v < 0.0f) {
|
|
|
|
return 1.0f + fmodf(v, 1.0f);
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-05-22 14:29:56 +04:00
|
|
|
return fmodf(v, 1.0f);
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-05-22 14:29:56 +04:00
|
|
|
static void
|
|
|
|
SetRects(int n,
|
|
|
|
Rect* aLayerRects,
|
|
|
|
Rect* aTextureRects,
|
|
|
|
GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
|
|
|
|
GLfloat tx0, GLfloat ty0, GLfloat tx1, GLfloat ty1,
|
|
|
|
bool flip_y /* = false */)
|
|
|
|
{
|
|
|
|
if (flip_y) {
|
|
|
|
std::swap(ty0, ty1);
|
2014-05-22 05:05:15 +04:00
|
|
|
}
|
2014-05-22 14:29:56 +04:00
|
|
|
aLayerRects[n] = Rect(x0, y0, x1 - x0, y1 - y0);
|
|
|
|
aTextureRects[n] = Rect(tx0, ty0, tx1 - tx0, ty1 - ty0);
|
|
|
|
}
|
2014-05-22 02:23:21 +04:00
|
|
|
|
2014-05-24 04:49:41 +04:00
|
|
|
static inline bool
|
|
|
|
FuzzyEqual(float a, float b)
|
|
|
|
{
|
|
|
|
return fabs(a - b) < 0.0001f;
|
|
|
|
}
|
|
|
|
|
2014-05-22 14:29:56 +04:00
|
|
|
static int
|
|
|
|
DecomposeIntoNoRepeatRects(const Rect& aRect,
|
|
|
|
const Rect& aTexCoordRect,
|
|
|
|
Rect* aLayerRects,
|
|
|
|
Rect* aTextureRects)
|
|
|
|
{
|
|
|
|
Rect texCoordRect = aTexCoordRect;
|
|
|
|
|
|
|
|
// If the texture should be flipped, it will have negative height. Detect that
|
|
|
|
// here and compensate for it. We will flip each rect as we emit it.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
bool flipped = false;
|
|
|
|
if (texCoordRect.height < 0) {
|
|
|
|
flipped = true;
|
2014-05-24 04:49:41 +04:00
|
|
|
texCoordRect.y += texCoordRect.height;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
texCoordRect.height = -texCoordRect.height;
|
|
|
|
}
|
|
|
|
|
2014-05-24 04:49:41 +04:00
|
|
|
// Wrap the texture coordinates so they are within [0,1] and cap width/height
|
|
|
|
// at 1. We rely on this below.
|
|
|
|
texCoordRect = Rect(Point(WrapTexCoord(texCoordRect.x),
|
|
|
|
WrapTexCoord(texCoordRect.y)),
|
|
|
|
Size(std::min(texCoordRect.width, 1.0f),
|
|
|
|
std::min(texCoordRect.height, 1.0f)));
|
|
|
|
|
|
|
|
NS_ASSERTION(texCoordRect.x >= 0.0f && texCoordRect.x <= 1.0f &&
|
|
|
|
texCoordRect.y >= 0.0f && texCoordRect.y <= 1.0f &&
|
|
|
|
texCoordRect.width >= 0.0f && texCoordRect.width <= 1.0f &&
|
|
|
|
texCoordRect.height >= 0.0f && texCoordRect.height <= 1.0f &&
|
|
|
|
texCoordRect.XMost() >= 0.0f && texCoordRect.XMost() <= 2.0f &&
|
|
|
|
texCoordRect.YMost() >= 0.0f && texCoordRect.YMost() <= 2.0f,
|
|
|
|
"We just wrapped the texture coordinates, didn't we?");
|
|
|
|
|
|
|
|
// Get the top left and bottom right points of the rectangle. Note that
|
|
|
|
// tl.x/tl.y are within [0,1] but br.x/br.y are within [0,2].
|
2014-05-22 14:29:56 +04:00
|
|
|
Point tl = texCoordRect.TopLeft();
|
|
|
|
Point br = texCoordRect.BottomRight();
|
|
|
|
|
|
|
|
NS_ASSERTION(tl.x >= 0.0f && tl.x <= 1.0f &&
|
|
|
|
tl.y >= 0.0f && tl.y <= 1.0f &&
|
2014-05-24 04:49:41 +04:00
|
|
|
br.x >= tl.x && br.x <= 2.0f &&
|
|
|
|
br.y >= tl.y && br.y <= 2.0f &&
|
|
|
|
br.x - tl.x <= 1.0f &&
|
|
|
|
br.y - tl.y <= 1.0f,
|
2014-05-22 14:29:56 +04:00
|
|
|
"Somehow generated invalid texture coordinates");
|
|
|
|
|
2014-05-24 04:49:41 +04:00
|
|
|
// Then check if we wrap in either the x or y axis.
|
|
|
|
bool xwrap = br.x > 1.0f;
|
|
|
|
bool ywrap = br.y > 1.0f;
|
2014-05-22 14:29:56 +04:00
|
|
|
|
2014-05-24 04:49:41 +04:00
|
|
|
// If xwrap is false, the texture will be sampled from tl.x .. br.x.
|
|
|
|
// If xwrap is true, then it will be split into tl.x .. 1.0, and
|
|
|
|
// 0.0 .. WrapTexCoord(br.x). Same for the Y axis. The destination
|
|
|
|
// rectangle is also split appropriately, according to the calculated
|
|
|
|
// xmid/ymid values.
|
2014-05-22 14:29:56 +04:00
|
|
|
if (!xwrap && !ywrap) {
|
|
|
|
SetRects(0, aLayerRects, aTextureRects,
|
|
|
|
aRect.x, aRect.y, aRect.XMost(), aRect.YMost(),
|
|
|
|
tl.x, tl.y, br.x, br.y,
|
|
|
|
flipped);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-05-24 04:49:41 +04:00
|
|
|
// If we are dealing with wrapping br.x and br.y are greater than 1.0 so
|
|
|
|
// wrap them here as well.
|
|
|
|
br = Point(xwrap ? WrapTexCoord(br.x) : br.x,
|
|
|
|
ywrap ? WrapTexCoord(br.y) : br.y);
|
|
|
|
|
|
|
|
// If we wrap around along the x axis, we will draw first from
|
|
|
|
// tl.x .. 1.0 and then from 0.0 .. br.x (which we just wrapped above).
|
|
|
|
// The same applies for the Y axis. The midpoints we calculate here are
|
|
|
|
// only valid if we actually wrap around.
|
|
|
|
GLfloat xmid = aRect.x + (1.0f - tl.x) / texCoordRect.width * aRect.width;
|
|
|
|
GLfloat ymid = aRect.y + (1.0f - tl.y) / texCoordRect.height * aRect.height;
|
|
|
|
|
|
|
|
NS_ASSERTION(!xwrap ||
|
|
|
|
(xmid > aRect.x &&
|
|
|
|
xmid < aRect.XMost() &&
|
|
|
|
FuzzyEqual((xmid - aRect.x) + (aRect.XMost() - xmid), aRect.width)),
|
|
|
|
"xmid should be within [x,XMost()] and the wrapped rect should have the same width");
|
|
|
|
NS_ASSERTION(!ywrap ||
|
|
|
|
(ymid > aRect.y &&
|
|
|
|
ymid < aRect.YMost() &&
|
|
|
|
FuzzyEqual((ymid - aRect.y) + (aRect.YMost() - ymid), aRect.height)),
|
|
|
|
"ymid should be within [y,YMost()] and the wrapped rect should have the same height");
|
2014-05-22 14:29:56 +04:00
|
|
|
|
|
|
|
if (!xwrap && ywrap) {
|
|
|
|
SetRects(0, aLayerRects, aTextureRects,
|
|
|
|
aRect.x, aRect.y, aRect.XMost(), ymid,
|
|
|
|
tl.x, tl.y, br.x, 1.0f,
|
|
|
|
flipped);
|
|
|
|
SetRects(1, aLayerRects, aTextureRects,
|
|
|
|
aRect.x, ymid, aRect.XMost(), aRect.YMost(),
|
|
|
|
tl.x, 0.0f, br.x, br.y,
|
|
|
|
flipped);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xwrap && !ywrap) {
|
|
|
|
SetRects(0, aLayerRects, aTextureRects,
|
|
|
|
aRect.x, aRect.y, xmid, aRect.YMost(),
|
|
|
|
tl.x, tl.y, 1.0f, br.y,
|
|
|
|
flipped);
|
|
|
|
SetRects(1, aLayerRects, aTextureRects,
|
|
|
|
xmid, aRect.y, aRect.XMost(), aRect.YMost(),
|
|
|
|
0.0f, tl.y, br.x, br.y,
|
|
|
|
flipped);
|
|
|
|
return 2;
|
2014-05-22 02:23:21 +04:00
|
|
|
}
|
|
|
|
|
2014-05-22 14:29:56 +04:00
|
|
|
SetRects(0, aLayerRects, aTextureRects,
|
|
|
|
aRect.x, aRect.y, xmid, ymid,
|
|
|
|
tl.x, tl.y, 1.0f, 1.0f,
|
|
|
|
flipped);
|
|
|
|
SetRects(1, aLayerRects, aTextureRects,
|
|
|
|
xmid, aRect.y, aRect.XMost(), ymid,
|
|
|
|
0.0f, tl.y, br.x, 1.0f,
|
|
|
|
flipped);
|
|
|
|
SetRects(2, aLayerRects, aTextureRects,
|
|
|
|
aRect.x, ymid, xmid, aRect.YMost(),
|
|
|
|
tl.x, 0.0f, 1.0f, br.y,
|
|
|
|
flipped);
|
|
|
|
SetRects(3, aLayerRects, aTextureRects,
|
|
|
|
xmid, ymid, aRect.XMost(), aRect.YMost(),
|
|
|
|
0.0f, 0.0f, br.x, br.y,
|
|
|
|
flipped);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// |aRect| is the rectangle we want to draw to. We will draw it with
|
|
|
|
// up to 4 draw commands if necessary to avoid wrapping.
|
|
|
|
// |aTexCoordRect| is the rectangle from the texture that we want to
|
|
|
|
// draw using the given program.
|
|
|
|
// |aTexture| is the texture we are drawing. Its actual size can be
|
|
|
|
// larger than the rectangle given by |texCoordRect|.
|
|
|
|
void
|
|
|
|
CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
|
|
|
|
const Rect& aRect,
|
|
|
|
const Rect& aTexCoordRect,
|
|
|
|
TextureSource *aTexture)
|
|
|
|
{
|
|
|
|
Rect layerRects[4];
|
|
|
|
Rect textureRects[4];
|
|
|
|
int rects = DecomposeIntoNoRepeatRects(aRect,
|
|
|
|
aTexCoordRect,
|
|
|
|
layerRects,
|
|
|
|
textureRects);
|
2014-05-28 18:15:31 +04:00
|
|
|
BindAndDrawQuads(aProg, rects, layerRects, textureRects);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
|
2014-01-28 00:25:20 +04:00
|
|
|
const Matrix& aWorldTransform)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
|
|
|
// Set the viewport correctly.
|
|
|
|
mGLContext->fViewport(0, 0, aSize.width, aSize.height);
|
|
|
|
|
2014-01-08 00:02:18 +04:00
|
|
|
mHeight = aSize.height;
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
// We flip the view matrix around so that everything is right-side up; we're
|
|
|
|
// drawing directly into the window's back buffer, so this keeps things
|
|
|
|
// looking correct.
|
|
|
|
// XXX: We keep track of whether the window size changed, so we could skip
|
|
|
|
// this update if it hadn't changed since the last call. We will need to
|
|
|
|
// track changes to aTransformPolicy and aWorldTransform for this to work
|
|
|
|
// though.
|
|
|
|
|
|
|
|
// Matrix to transform (0, 0, aWidth, aHeight) to viewport space (-1.0, 1.0,
|
|
|
|
// 2, 2) and flip the contents.
|
2014-01-28 00:25:20 +04:00
|
|
|
Matrix viewMatrix;
|
2014-06-03 22:41:00 +04:00
|
|
|
if (mGLContext->IsOffscreen()) {
|
|
|
|
// In case of rendering via GL Offscreen context, disable Y-Flipping
|
|
|
|
viewMatrix.Translate(-1.0, -1.0);
|
|
|
|
viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
|
|
|
|
} else {
|
|
|
|
viewMatrix.Translate(-1.0, 1.0);
|
|
|
|
viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
|
|
|
|
viewMatrix.Scale(1.0f, -1.0f);
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
viewMatrix = aWorldTransform * viewMatrix;
|
|
|
|
|
2014-01-28 00:25:20 +04:00
|
|
|
Matrix4x4 matrix3d = Matrix4x4::From2D(viewMatrix);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
matrix3d._33 = 0.0f;
|
|
|
|
|
2013-11-08 10:22:05 +04:00
|
|
|
mProjMatrix = matrix3d;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<CompositingRenderTarget>
|
|
|
|
CompositorOGL::CreateRenderTarget(const IntRect &aRect, SurfaceInitMode aInit)
|
|
|
|
{
|
|
|
|
GLuint tex = 0;
|
|
|
|
GLuint fbo = 0;
|
2013-11-07 13:53:07 +04:00
|
|
|
CreateFBOWithTexture(aRect, false, 0, &fbo, &tex);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
RefPtr<CompositingRenderTargetOGL> surface
|
2013-11-07 13:53:08 +04:00
|
|
|
= new CompositingRenderTargetOGL(this, aRect.TopLeft(), tex, fbo);
|
2013-11-07 13:53:07 +04:00
|
|
|
surface->Initialize(aRect.Size(), mFBOTextureTarget, aInit);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
return surface.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<CompositingRenderTarget>
|
|
|
|
CompositorOGL::CreateRenderTargetFromSource(const IntRect &aRect,
|
2013-11-07 13:53:07 +04:00
|
|
|
const CompositingRenderTarget *aSource,
|
|
|
|
const IntPoint &aSourcePoint)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
|
|
|
GLuint tex = 0;
|
|
|
|
GLuint fbo = 0;
|
|
|
|
const CompositingRenderTargetOGL* sourceSurface
|
|
|
|
= static_cast<const CompositingRenderTargetOGL*>(aSource);
|
2013-11-07 13:53:07 +04:00
|
|
|
IntRect sourceRect(aSourcePoint, aRect.Size());
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
if (aSource) {
|
2013-11-07 13:53:07 +04:00
|
|
|
CreateFBOWithTexture(sourceRect, true, sourceSurface->GetFBO(),
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
&fbo, &tex);
|
|
|
|
} else {
|
2013-11-07 13:53:07 +04:00
|
|
|
CreateFBOWithTexture(sourceRect, true, 0,
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
&fbo, &tex);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<CompositingRenderTargetOGL> surface
|
2013-11-07 13:53:08 +04:00
|
|
|
= new CompositingRenderTargetOGL(this, aRect.TopLeft(), tex, fbo);
|
2013-11-07 13:53:07 +04:00
|
|
|
surface->Initialize(aRect.Size(),
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
mFBOTextureTarget,
|
2013-11-07 13:53:07 +04:00
|
|
|
INIT_MODE_NONE);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
return surface.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::SetRenderTarget(CompositingRenderTarget *aSurface)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aSurface);
|
|
|
|
CompositingRenderTargetOGL* surface
|
|
|
|
= static_cast<CompositingRenderTargetOGL*>(aSurface);
|
|
|
|
if (mCurrentRenderTarget != surface) {
|
|
|
|
surface->BindRenderTarget();
|
|
|
|
mCurrentRenderTarget = surface;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CompositingRenderTarget*
|
2014-04-02 11:27:42 +04:00
|
|
|
CompositorOGL::GetCurrentRenderTarget() const
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
|
|
|
return mCurrentRenderTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GLenum
|
|
|
|
GetFrameBufferInternalFormat(GLContext* gl,
|
|
|
|
GLuint aFrameBuffer,
|
|
|
|
nsIWidget* aWidget)
|
|
|
|
{
|
|
|
|
if (aFrameBuffer == 0) { // default framebuffer
|
|
|
|
return aWidget->GetGLFrameBufferFormat();
|
|
|
|
}
|
|
|
|
return LOCAL_GL_RGBA;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns a size that is larger than and closest to aSize where both
|
|
|
|
* width and height are powers of two.
|
|
|
|
* If the OpenGL setup is capable of using non-POT textures, then it
|
|
|
|
* will just return aSize.
|
|
|
|
*/
|
|
|
|
static IntSize
|
|
|
|
CalculatePOTSize(const IntSize& aSize, GLContext* gl)
|
|
|
|
{
|
2013-12-03 22:44:38 +04:00
|
|
|
if (CanUploadNonPowerOfTwo(gl))
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
return aSize;
|
|
|
|
|
|
|
|
return IntSize(NextPowerOfTwo(aSize.width), NextPowerOfTwo(aSize.height));
|
|
|
|
}
|
|
|
|
|
2014-01-18 06:55:30 +04:00
|
|
|
void
|
2014-03-28 07:38:32 +04:00
|
|
|
CompositorOGL::ClearRect(const gfx::Rect& aRect)
|
2014-01-18 06:55:30 +04:00
|
|
|
{
|
2014-03-05 06:07:32 +04:00
|
|
|
// Map aRect to OGL coordinates, origin:bottom-left
|
2014-03-28 07:38:32 +04:00
|
|
|
GLint y = mHeight - (aRect.y + aRect.height);
|
2014-03-05 06:07:32 +04:00
|
|
|
|
2014-02-27 23:07:34 +04:00
|
|
|
ScopedGLState scopedScissorTestState(mGLContext, LOCAL_GL_SCISSOR_TEST, true);
|
2014-03-28 07:38:32 +04:00
|
|
|
ScopedScissorRect autoScissorRect(mGLContext, aRect.x, y, aRect.width, aRect.height);
|
2014-01-18 06:55:30 +04:00
|
|
|
mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0);
|
|
|
|
mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
void
|
2013-11-21 23:25:16 +04:00
|
|
|
CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
|
|
|
|
const Rect *aClipRectIn,
|
2014-01-16 11:22:19 +04:00
|
|
|
const gfx::Matrix& aTransform,
|
2013-11-21 23:25:16 +04:00
|
|
|
const Rect& aRenderBounds,
|
|
|
|
Rect *aClipRectOut,
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
Rect *aRenderBoundsOut)
|
|
|
|
{
|
2014-05-24 01:12:29 +04:00
|
|
|
PROFILER_LABEL("CompositorOGL", "BeginFrame",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
MOZ_ASSERT(!mFrameInProgress, "frame still in progress (should have called EndFrame or AbortFrame");
|
|
|
|
|
2013-11-29 08:11:49 +04:00
|
|
|
LayerScope::BeginFrame(mGLContext, PR_Now());
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
mFrameInProgress = true;
|
2014-01-16 11:22:19 +04:00
|
|
|
gfx::Rect rect;
|
2013-04-30 07:16:04 +04:00
|
|
|
if (mUseExternalSurfaceSize) {
|
2014-01-16 11:22:19 +04:00
|
|
|
rect = gfx::Rect(0, 0, mSurfaceSize.width, mSurfaceSize.height);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
} else {
|
2014-01-16 11:22:19 +04:00
|
|
|
rect = gfx::Rect(aRenderBounds.x, aRenderBounds.y, aRenderBounds.width, aRenderBounds.height);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
// If render bounds is not updated explicitly, try to infer it from widget
|
|
|
|
if (rect.width == 0 || rect.height == 0) {
|
|
|
|
// FIXME/bug XXXXXX this races with rotation changes on the main
|
|
|
|
// thread, and undoes all the care we take with layers txns being
|
|
|
|
// sent atomically with rotation changes
|
|
|
|
nsIntRect intRect;
|
|
|
|
mWidget->GetClientBounds(intRect);
|
2014-01-16 11:22:19 +04:00
|
|
|
rect = gfx::Rect(0, 0, intRect.width, intRect.height);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rect = aTransform.TransformBounds(rect);
|
|
|
|
if (aRenderBoundsOut) {
|
2014-01-16 11:22:19 +04:00
|
|
|
*aRenderBoundsOut = rect;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GLint width = rect.width;
|
|
|
|
GLint height = rect.height;
|
|
|
|
|
|
|
|
// We can't draw anything to something with no area
|
|
|
|
// so just return
|
|
|
|
if (width == 0 || height == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If the widget size changed, we have to force a MakeCurrent
|
|
|
|
// to make sure that GL sees the updated widget size.
|
|
|
|
if (mWidgetSize.width != width ||
|
|
|
|
mWidgetSize.height != height)
|
|
|
|
{
|
|
|
|
MakeCurrent(ForceMakeCurrent);
|
|
|
|
|
|
|
|
mWidgetSize.width = width;
|
|
|
|
mWidgetSize.height = height;
|
|
|
|
} else {
|
|
|
|
MakeCurrent();
|
|
|
|
}
|
|
|
|
|
2013-09-12 01:57:23 +04:00
|
|
|
mPixelsPerFrame = width * height;
|
|
|
|
mPixelsFilled = 0;
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
#if MOZ_ANDROID_OMTC
|
|
|
|
TexturePoolOGL::Fill(gl());
|
|
|
|
#endif
|
|
|
|
|
2014-05-27 16:31:01 +04:00
|
|
|
// Make sure the render offset is respected. We ignore this when we have a
|
|
|
|
// target to stop tests failing - this is only used by the Android browser
|
|
|
|
// UI for its dynamic toolbar.
|
|
|
|
IntPoint origin;
|
|
|
|
if (!mTarget) {
|
|
|
|
origin.x = -mRenderOffset.x;
|
|
|
|
origin.y = -mRenderOffset.y;
|
|
|
|
}
|
|
|
|
|
2014-05-29 18:19:37 +04:00
|
|
|
mCurrentRenderTarget =
|
|
|
|
CompositingRenderTargetOGL::RenderTargetForWindow(this,
|
|
|
|
origin,
|
|
|
|
IntSize(width, height),
|
|
|
|
aTransform);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
mCurrentRenderTarget->BindRenderTarget();
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWindowRenderTarget = mCurrentRenderTarget;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Default blend function implements "OVER"
|
|
|
|
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
|
|
|
|
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
|
|
|
mGLContext->fEnable(LOCAL_GL_BLEND);
|
|
|
|
|
2014-03-13 04:37:17 +04:00
|
|
|
mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
|
|
|
|
|
2014-01-08 00:02:19 +04:00
|
|
|
if (aClipRectOut && !aClipRectIn) {
|
|
|
|
aClipRectOut->SetRect(0, 0, width, height);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the Android compositor is being used, this clear will be done in
|
|
|
|
// DrawWindowUnderlay. Make sure the bits used here match up with those used
|
|
|
|
// in mobile/android/base/gfx/LayerRenderer.java
|
|
|
|
#ifndef MOZ_ANDROID_OMTC
|
|
|
|
mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0);
|
|
|
|
mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-11-07 13:53:07 +04:00
|
|
|
CompositorOGL::CreateFBOWithTexture(const IntRect& aRect, bool aCopyFromSource,
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
GLuint aSourceFrameBuffer,
|
|
|
|
GLuint *aFBO, GLuint *aTexture)
|
|
|
|
{
|
|
|
|
GLuint tex, fbo;
|
|
|
|
|
|
|
|
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
|
|
|
|
mGLContext->fGenTextures(1, &tex);
|
|
|
|
mGLContext->fBindTexture(mFBOTextureTarget, tex);
|
|
|
|
|
2013-11-07 13:53:07 +04:00
|
|
|
if (aCopyFromSource) {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
GLuint curFBO = mCurrentRenderTarget->GetFBO();
|
|
|
|
if (curFBO != aSourceFrameBuffer) {
|
|
|
|
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aSourceFrameBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We're going to create an RGBA temporary fbo. But to
|
|
|
|
// CopyTexImage() from the current framebuffer, the framebuffer's
|
|
|
|
// format has to be compatible with the new texture's. So we
|
|
|
|
// check the format of the framebuffer here and take a slow path
|
|
|
|
// if it's incompatible.
|
|
|
|
GLenum format =
|
|
|
|
GetFrameBufferInternalFormat(gl(), aSourceFrameBuffer, mWidget);
|
|
|
|
|
|
|
|
bool isFormatCompatibleWithRGBA
|
2014-03-31 13:10:49 +04:00
|
|
|
= gl()->IsGLES() ? (format == LOCAL_GL_RGBA)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
: true;
|
|
|
|
|
|
|
|
if (isFormatCompatibleWithRGBA) {
|
|
|
|
mGLContext->fCopyTexImage2D(mFBOTextureTarget,
|
|
|
|
0,
|
|
|
|
LOCAL_GL_RGBA,
|
2014-01-31 19:59:14 +04:00
|
|
|
aRect.x, FlipY(aRect.y + aRect.height),
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
aRect.width, aRect.height,
|
|
|
|
0);
|
|
|
|
} else {
|
|
|
|
// Curses, incompatible formats. Take a slow path.
|
|
|
|
|
|
|
|
// RGBA
|
|
|
|
size_t bufferSize = aRect.width * aRect.height * 4;
|
|
|
|
nsAutoArrayPtr<uint8_t> buf(new uint8_t[bufferSize]);
|
|
|
|
|
|
|
|
mGLContext->fReadPixels(aRect.x, aRect.y,
|
|
|
|
aRect.width, aRect.height,
|
|
|
|
LOCAL_GL_RGBA,
|
|
|
|
LOCAL_GL_UNSIGNED_BYTE,
|
|
|
|
buf);
|
|
|
|
mGLContext->fTexImage2D(mFBOTextureTarget,
|
|
|
|
0,
|
|
|
|
LOCAL_GL_RGBA,
|
|
|
|
aRect.width, aRect.height,
|
|
|
|
0,
|
|
|
|
LOCAL_GL_RGBA,
|
|
|
|
LOCAL_GL_UNSIGNED_BYTE,
|
|
|
|
buf);
|
|
|
|
}
|
2013-07-16 23:56:10 +04:00
|
|
|
GLenum error = mGLContext->GetAndClearError();
|
|
|
|
if (error != LOCAL_GL_NO_ERROR) {
|
|
|
|
nsAutoCString msg;
|
|
|
|
msg.AppendPrintf("Texture initialization failed! -- error 0x%x, Source %d, Source format %d, RGBA Compat %d",
|
|
|
|
error, aSourceFrameBuffer, format, isFormatCompatibleWithRGBA);
|
|
|
|
NS_ERROR(msg.get());
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
} else {
|
|
|
|
mGLContext->fTexImage2D(mFBOTextureTarget,
|
|
|
|
0,
|
|
|
|
LOCAL_GL_RGBA,
|
|
|
|
aRect.width, aRect.height,
|
|
|
|
0,
|
|
|
|
LOCAL_GL_RGBA,
|
|
|
|
LOCAL_GL_UNSIGNED_BYTE,
|
2013-07-20 12:48:55 +04:00
|
|
|
nullptr);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
mGLContext->fTexParameteri(mFBOTextureTarget, LOCAL_GL_TEXTURE_MIN_FILTER,
|
|
|
|
LOCAL_GL_LINEAR);
|
|
|
|
mGLContext->fTexParameteri(mFBOTextureTarget, LOCAL_GL_TEXTURE_MAG_FILTER,
|
|
|
|
LOCAL_GL_LINEAR);
|
|
|
|
mGLContext->fTexParameteri(mFBOTextureTarget, LOCAL_GL_TEXTURE_WRAP_S,
|
|
|
|
LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
mGLContext->fTexParameteri(mFBOTextureTarget, LOCAL_GL_TEXTURE_WRAP_T,
|
|
|
|
LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
mGLContext->fBindTexture(mFBOTextureTarget, 0);
|
|
|
|
|
|
|
|
mGLContext->fGenFramebuffers(1, &fbo);
|
|
|
|
|
|
|
|
*aFBO = fbo;
|
|
|
|
*aTexture = tex;
|
|
|
|
}
|
|
|
|
|
2013-11-08 10:22:05 +04:00
|
|
|
ShaderConfigOGL
|
2014-05-09 14:06:18 +04:00
|
|
|
CompositorOGL::GetShaderConfigFor(Effect *aEffect,
|
|
|
|
MaskType aMask,
|
|
|
|
gfx::CompositionOp aOp) const
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2013-11-08 10:22:05 +04:00
|
|
|
ShaderConfigOGL config;
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
switch(aEffect->mType) {
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::SOLID_COLOR:
|
2013-11-08 10:22:05 +04:00
|
|
|
config.SetRenderColor(true);
|
|
|
|
break;
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::YCBCR:
|
2013-11-08 10:22:05 +04:00
|
|
|
config.SetYCbCr(true);
|
|
|
|
break;
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::COMPONENT_ALPHA:
|
2014-02-24 19:09:55 +04:00
|
|
|
{
|
2013-11-08 10:22:05 +04:00
|
|
|
config.SetComponentAlpha(true);
|
2014-02-24 19:09:55 +04:00
|
|
|
EffectComponentAlpha* effectComponentAlpha =
|
|
|
|
static_cast<EffectComponentAlpha*>(aEffect);
|
|
|
|
gfx::SurfaceFormat format = effectComponentAlpha->mOnWhite->GetFormat();
|
|
|
|
config.SetRBSwap(format == gfx::SurfaceFormat::B8G8R8A8 ||
|
|
|
|
format == gfx::SurfaceFormat::B8G8R8X8);
|
2013-11-08 10:22:05 +04:00
|
|
|
break;
|
2014-02-24 19:09:55 +04:00
|
|
|
}
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::RENDER_TARGET:
|
2013-11-08 10:22:05 +04:00
|
|
|
config.SetTextureTarget(mFBOTextureTarget);
|
|
|
|
break;
|
|
|
|
default:
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2014-04-26 06:34:06 +04:00
|
|
|
MOZ_ASSERT(aEffect->mType == EffectTypes::RGB);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
TexturedEffect* texturedEffect =
|
|
|
|
static_cast<TexturedEffect*>(aEffect);
|
|
|
|
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
|
2013-11-08 10:22:05 +04:00
|
|
|
MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_EXTERNAL,
|
|
|
|
source->GetFormat() == gfx::SurfaceFormat::R8G8B8A8);
|
|
|
|
MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_RECTANGLE_ARB,
|
|
|
|
source->GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ||
|
|
|
|
source->GetFormat() == gfx::SurfaceFormat::R8G8B8X8 ||
|
|
|
|
source->GetFormat() == gfx::SurfaceFormat::R5G6B5);
|
|
|
|
config = ShaderConfigFromTargetAndFormat(source->GetTextureTarget(),
|
|
|
|
source->GetFormat());
|
2014-05-09 14:06:18 +04:00
|
|
|
if (aOp == gfx::CompositionOp::OP_MULTIPLY &&
|
|
|
|
!texturedEffect->mPremultiplied) {
|
|
|
|
// We can do these blend modes just using glBlendFunc but we need the data
|
|
|
|
// to be premultiplied first.
|
|
|
|
config.SetPremultiply(true);
|
|
|
|
}
|
2013-11-08 10:22:05 +04:00
|
|
|
break;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
}
|
2014-04-26 06:34:06 +04:00
|
|
|
config.SetMask2D(aMask == MaskType::Mask2d);
|
|
|
|
config.SetMask3D(aMask == MaskType::Mask3d);
|
2013-11-08 10:22:05 +04:00
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShaderProgramOGL*
|
|
|
|
CompositorOGL::GetShaderProgramFor(const ShaderConfigOGL &aConfig)
|
|
|
|
{
|
|
|
|
std::map<ShaderConfigOGL, ShaderProgramOGL *>::iterator iter = mPrograms.find(aConfig);
|
|
|
|
if (iter != mPrograms.end())
|
|
|
|
return iter->second;
|
|
|
|
|
|
|
|
ProgramProfileOGL profile = ProgramProfileOGL::GetProfileFor(aConfig);
|
|
|
|
ShaderProgramOGL *shader = new ShaderProgramOGL(gl(), profile);
|
|
|
|
if (!shader->Initialize()) {
|
|
|
|
delete shader;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
mPrograms[aConfig] = shader;
|
|
|
|
return shader;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
2014-05-09 14:06:18 +04:00
|
|
|
static bool SetBlendMode(GLContext* aGL, gfx::CompositionOp aBlendMode, bool aIsPremultiplied = true)
|
|
|
|
{
|
|
|
|
if (aBlendMode == gfx::CompositionOp::OP_OVER && aIsPremultiplied) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLenum srcBlend;
|
|
|
|
GLenum dstBlend;
|
|
|
|
|
|
|
|
switch (aBlendMode) {
|
|
|
|
case gfx::CompositionOp::OP_OVER:
|
|
|
|
MOZ_ASSERT(!aIsPremultiplied);
|
|
|
|
srcBlend = LOCAL_GL_SRC_ALPHA;
|
|
|
|
dstBlend = LOCAL_GL_ONE_MINUS_SRC_ALPHA;
|
|
|
|
break;
|
|
|
|
case gfx::CompositionOp::OP_SCREEN:
|
|
|
|
srcBlend = aIsPremultiplied ? LOCAL_GL_ONE : LOCAL_GL_SRC_ALPHA;
|
|
|
|
dstBlend = LOCAL_GL_ONE_MINUS_SRC_COLOR;
|
|
|
|
break;
|
|
|
|
case gfx::CompositionOp::OP_MULTIPLY:
|
|
|
|
// If the source data was un-premultiplied we should have already
|
|
|
|
// asked the fragment shader to fix that.
|
|
|
|
srcBlend = LOCAL_GL_DST_COLOR;
|
|
|
|
dstBlend = LOCAL_GL_ONE_MINUS_SRC_ALPHA;
|
|
|
|
break;
|
|
|
|
default:
|
2014-05-16 11:35:13 +04:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Unsupported blend mode!");
|
|
|
|
return false;
|
2014-05-09 14:06:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
aGL->fBlendFuncSeparate(srcBlend, dstBlend,
|
|
|
|
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-02 00:54:46 +04:00
|
|
|
void
|
2014-05-22 01:26:38 +04:00
|
|
|
CompositorOGL::DrawQuad(const Rect& aRect,
|
|
|
|
const Rect& aClipRect,
|
|
|
|
const EffectChain &aEffectChain,
|
|
|
|
Float aOpacity,
|
|
|
|
const gfx::Matrix4x4 &aTransform)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2014-05-24 01:12:29 +04:00
|
|
|
PROFILER_LABEL("CompositorOGL", "DrawQuad",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
MOZ_ASSERT(mFrameInProgress, "frame not started");
|
|
|
|
|
|
|
|
IntRect intClipRect;
|
2014-05-27 16:31:01 +04:00
|
|
|
aClipRect.ToIntRect(&intClipRect);
|
2014-06-09 19:53:35 +04:00
|
|
|
if (!mTarget) {
|
|
|
|
intClipRect.MoveBy(mRenderOffset.x, mRenderOffset.y);
|
|
|
|
}
|
2014-01-09 20:59:32 +04:00
|
|
|
|
2014-03-13 04:37:17 +04:00
|
|
|
gl()->fScissor(intClipRect.x, FlipY(intClipRect.y + intClipRect.height),
|
|
|
|
intClipRect.width, intClipRect.height);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2013-11-29 08:11:49 +04:00
|
|
|
LayerScope::SendEffectChain(mGLContext, aEffectChain,
|
|
|
|
aRect.width, aRect.height);
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
MaskType maskType;
|
|
|
|
EffectMask* effectMask;
|
|
|
|
TextureSourceOGL* sourceMask = nullptr;
|
|
|
|
gfx::Matrix4x4 maskQuadTransform;
|
2014-04-26 06:34:06 +04:00
|
|
|
if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
|
|
|
|
effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
sourceMask = effectMask->mMaskTexture->AsSourceOGL();
|
|
|
|
|
|
|
|
// NS_ASSERTION(textureMask->IsAlpha(),
|
|
|
|
// "OpenGL mask layers must be backed by alpha surfaces");
|
|
|
|
|
|
|
|
// We're assuming that the gl backend won't cheat and use NPOT
|
|
|
|
// textures when glContext says it can't (which seems to happen
|
|
|
|
// on a mac when you force POT textures)
|
|
|
|
IntSize maskSize = CalculatePOTSize(effectMask->mSize, mGLContext);
|
|
|
|
|
|
|
|
const gfx::Matrix4x4& maskTransform = effectMask->mMaskTransform;
|
|
|
|
NS_ASSERTION(maskTransform.Is2D(), "How did we end up with a 3D transform here?!");
|
|
|
|
Rect bounds = Rect(Point(), Size(maskSize));
|
|
|
|
bounds = maskTransform.As2D().TransformBounds(bounds);
|
|
|
|
|
|
|
|
maskQuadTransform._11 = 1.0f/bounds.width;
|
|
|
|
maskQuadTransform._22 = 1.0f/bounds.height;
|
|
|
|
maskQuadTransform._41 = float(-bounds.x)/bounds.width;
|
|
|
|
maskQuadTransform._42 = float(-bounds.y)/bounds.height;
|
|
|
|
|
|
|
|
maskType = effectMask->mIs3D
|
2014-04-26 06:34:06 +04:00
|
|
|
? MaskType::Mask3d
|
|
|
|
: MaskType::Mask2d;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
} else {
|
2014-04-26 06:34:06 +04:00
|
|
|
maskType = MaskType::MaskNone;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
2013-09-12 01:57:23 +04:00
|
|
|
mPixelsFilled += aRect.width * aRect.height;
|
|
|
|
|
2013-11-08 10:22:05 +04:00
|
|
|
// Determine the color if this is a color shader and fold the opacity into
|
|
|
|
// the color since color shaders don't have an opacity uniform.
|
|
|
|
Color color;
|
2014-04-26 06:34:06 +04:00
|
|
|
if (aEffectChain.mPrimaryEffect->mType == EffectTypes::SOLID_COLOR) {
|
2013-11-08 10:22:05 +04:00
|
|
|
EffectSolidColor* effectSolidColor =
|
|
|
|
static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get());
|
|
|
|
color = effectSolidColor->mColor;
|
|
|
|
|
|
|
|
Float opacity = aOpacity * color.a;
|
|
|
|
color.r *= opacity;
|
|
|
|
color.g *= opacity;
|
|
|
|
color.b *= opacity;
|
|
|
|
color.a = opacity;
|
|
|
|
|
|
|
|
// We can fold opacity into the color, so no need to consider it further.
|
|
|
|
aOpacity = 1.f;
|
|
|
|
}
|
|
|
|
|
2014-05-09 14:06:18 +04:00
|
|
|
gfx::CompositionOp blendMode = gfx::CompositionOp::OP_OVER;
|
|
|
|
if (aEffectChain.mSecondaryEffects[EffectTypes::BLEND_MODE]) {
|
|
|
|
EffectBlendMode *blendEffect =
|
|
|
|
static_cast<EffectBlendMode*>(aEffectChain.mSecondaryEffects[EffectTypes::BLEND_MODE].get());
|
|
|
|
blendMode = blendEffect->mBlendMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShaderConfigOGL config = GetShaderConfigFor(aEffectChain.mPrimaryEffect, maskType, blendMode);
|
2013-11-08 10:22:05 +04:00
|
|
|
config.SetOpacity(aOpacity != 1.f);
|
|
|
|
ShaderProgramOGL *program = GetShaderProgramFor(config);
|
2013-11-01 17:29:20 +04:00
|
|
|
program->Activate();
|
2013-11-08 10:22:05 +04:00
|
|
|
program->SetProjectionMatrix(mProjMatrix);
|
|
|
|
program->SetLayerTransform(aTransform);
|
2014-06-04 18:05:24 +04:00
|
|
|
IntPoint offset = mCurrentRenderTarget->GetOrigin();
|
2013-11-08 10:22:05 +04:00
|
|
|
program->SetRenderOffset(offset.x, offset.y);
|
|
|
|
if (aOpacity != 1.f)
|
|
|
|
program->SetLayerOpacity(aOpacity);
|
|
|
|
if (config.mFeatures & ENABLE_TEXTURE_RECT) {
|
2013-11-01 19:51:32 +04:00
|
|
|
TexturedEffect* texturedEffect =
|
|
|
|
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
|
|
|
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
|
|
|
|
// This is used by IOSurface that use 0,0...w,h coordinate rather then 0,0..1,1.
|
|
|
|
program->SetTexCoordMultiplier(source->GetSize().width, source->GetSize().height);
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-05-09 14:06:18 +04:00
|
|
|
bool didSetBlendMode = false;
|
|
|
|
|
2013-11-01 17:29:20 +04:00
|
|
|
switch (aEffectChain.mPrimaryEffect->mType) {
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::SOLID_COLOR: {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
program->SetRenderColor(color);
|
|
|
|
|
2014-04-26 06:34:06 +04:00
|
|
|
if (maskType != MaskType::MaskNone) {
|
2013-12-10 10:50:52 +04:00
|
|
|
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE0, maskQuadTransform);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
2014-05-09 14:06:18 +04:00
|
|
|
didSetBlendMode = SetBlendMode(gl(), blendMode);
|
|
|
|
|
2014-05-22 01:36:56 +04:00
|
|
|
BindAndDrawQuad(program, aRect);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::RGB: {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
TexturedEffect* texturedEffect =
|
|
|
|
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
|
|
|
TextureSource *source = texturedEffect->mTexture;
|
|
|
|
|
2014-05-09 14:06:18 +04:00
|
|
|
didSetBlendMode = SetBlendMode(gl(), blendMode, texturedEffect->mPremultiplied);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-03-13 04:37:17 +04:00
|
|
|
gfx::Filter filter = texturedEffect->mFilter;
|
2014-01-25 05:49:02 +04:00
|
|
|
gfx3DMatrix textureTransform;
|
|
|
|
gfx::To3DMatrix(source->AsSourceOGL()->GetTextureTransform(), textureTransform);
|
2014-01-08 14:36:13 +04:00
|
|
|
|
2013-11-13 14:56:11 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2014-01-08 16:00:04 +04:00
|
|
|
gfxMatrix textureTransform2D;
|
2014-03-13 04:37:17 +04:00
|
|
|
if (filter != gfx::Filter::POINT &&
|
2013-11-13 14:56:11 +04:00
|
|
|
aTransform.Is2DIntegerTranslation() &&
|
|
|
|
textureTransform.Is2D(&textureTransform2D) &&
|
|
|
|
textureTransform2D.HasOnlyIntegerTranslation()) {
|
|
|
|
// On Android we encounter small resampling errors in what should be
|
|
|
|
// pixel-aligned compositing operations. This works around them. This
|
|
|
|
// code should not be needed!
|
2014-03-13 04:37:17 +04:00
|
|
|
filter = gfx::Filter::POINT;
|
2013-11-13 14:56:11 +04:00
|
|
|
}
|
|
|
|
#endif
|
2014-03-13 04:37:17 +04:00
|
|
|
source->AsSourceOGL()->BindTexture(LOCAL_GL_TEXTURE0, filter);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
program->SetTextureUnit(0);
|
2014-05-22 14:29:56 +04:00
|
|
|
Matrix4x4 transform;
|
|
|
|
ToMatrix4x4(textureTransform, transform);
|
|
|
|
program->SetTextureTransform(transform);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-04-26 06:34:06 +04:00
|
|
|
if (maskType != MaskType::MaskNone) {
|
2013-12-10 10:50:52 +04:00
|
|
|
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE1, maskQuadTransform);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
2014-05-22 14:29:56 +04:00
|
|
|
BindAndDrawQuadWithTextureRect(program, aRect, texturedEffect->mTextureCoords, source);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
break;
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::YCBCR: {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
EffectYCbCr* effectYCbCr =
|
|
|
|
static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
|
|
|
|
TextureSource* sourceYCbCr = effectYCbCr->mTexture;
|
|
|
|
const int Y = 0, Cb = 1, Cr = 2;
|
|
|
|
TextureSourceOGL* sourceY = sourceYCbCr->GetSubSource(Y)->AsSourceOGL();
|
|
|
|
TextureSourceOGL* sourceCb = sourceYCbCr->GetSubSource(Cb)->AsSourceOGL();
|
|
|
|
TextureSourceOGL* sourceCr = sourceYCbCr->GetSubSource(Cr)->AsSourceOGL();
|
|
|
|
|
|
|
|
if (!sourceY && !sourceCb && !sourceCr) {
|
|
|
|
NS_WARNING("Invalid layer texture.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-13 04:37:17 +04:00
|
|
|
sourceY->BindTexture(LOCAL_GL_TEXTURE0, effectYCbCr->mFilter);
|
|
|
|
sourceCb->BindTexture(LOCAL_GL_TEXTURE1, effectYCbCr->mFilter);
|
|
|
|
sourceCr->BindTexture(LOCAL_GL_TEXTURE2, effectYCbCr->mFilter);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
program->SetYCbCrTextureUnits(Y, Cb, Cr);
|
2014-05-22 14:29:56 +04:00
|
|
|
program->SetTextureTransform(Matrix4x4());
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-04-26 06:34:06 +04:00
|
|
|
if (maskType != MaskType::MaskNone) {
|
2013-12-10 10:50:52 +04:00
|
|
|
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE3, maskQuadTransform);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
2014-05-09 14:06:18 +04:00
|
|
|
didSetBlendMode = SetBlendMode(gl(), blendMode);
|
2014-01-08 16:00:04 +04:00
|
|
|
BindAndDrawQuadWithTextureRect(program,
|
2014-05-22 01:36:56 +04:00
|
|
|
aRect,
|
2014-01-08 16:00:04 +04:00
|
|
|
effectYCbCr->mTextureCoords,
|
|
|
|
sourceYCbCr->GetSubSource(Y));
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
break;
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::RENDER_TARGET: {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
EffectRenderTarget* effectRenderTarget =
|
|
|
|
static_cast<EffectRenderTarget*>(aEffectChain.mPrimaryEffect.get());
|
|
|
|
RefPtr<CompositingRenderTargetOGL> surface
|
|
|
|
= static_cast<CompositingRenderTargetOGL*>(effectRenderTarget->mRenderTarget.get());
|
|
|
|
|
|
|
|
surface->BindTexture(LOCAL_GL_TEXTURE0, mFBOTextureTarget);
|
|
|
|
|
2014-04-02 17:02:07 +04:00
|
|
|
// Drawing is always flipped, but when copying between surfaces we want to avoid
|
|
|
|
// this, so apply a flip here to cancel the other one out.
|
|
|
|
Matrix transform;
|
|
|
|
transform.Translate(0.0, 1.0);
|
|
|
|
transform.Scale(1.0f, -1.0f);
|
|
|
|
program->SetTextureTransform(Matrix4x4::From2D(transform));
|
2013-11-08 10:22:05 +04:00
|
|
|
program->SetTextureUnit(0);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2014-04-26 06:34:06 +04:00
|
|
|
if (maskType != MaskType::MaskNone) {
|
2014-03-13 04:37:17 +04:00
|
|
|
sourceMask->BindTexture(LOCAL_GL_TEXTURE1, gfx::Filter::LINEAR);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
program->SetMaskTextureUnit(1);
|
|
|
|
program->SetMaskLayerTransform(maskQuadTransform);
|
|
|
|
}
|
|
|
|
|
2013-11-08 10:22:05 +04:00
|
|
|
if (config.mFeatures & ENABLE_TEXTURE_RECT) {
|
2013-11-01 19:51:32 +04:00
|
|
|
// 2DRect case, get the multiplier right for a sampler2DRect
|
|
|
|
program->SetTexCoordMultiplier(aRect.width, aRect.height);
|
|
|
|
}
|
|
|
|
|
2014-03-06 23:14:52 +04:00
|
|
|
// Drawing is always flipped, but when copying between surfaces we want to avoid
|
|
|
|
// this. Pass true for the flip parameter to introduce a second flip
|
|
|
|
// that cancels the other one out.
|
2014-05-09 14:06:18 +04:00
|
|
|
didSetBlendMode = SetBlendMode(gl(), blendMode);
|
2014-05-22 01:36:56 +04:00
|
|
|
BindAndDrawQuad(program, aRect);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
break;
|
2014-04-26 06:34:06 +04:00
|
|
|
case EffectTypes::COMPONENT_ALPHA: {
|
2014-02-27 06:53:27 +04:00
|
|
|
MOZ_ASSERT(gfxPrefs::ComponentAlphaEnabled());
|
2014-05-09 14:06:18 +04:00
|
|
|
MOZ_ASSERT(blendMode == gfx::CompositionOp::OP_OVER, "Can't support blend modes with component alpha!");
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
EffectComponentAlpha* effectComponentAlpha =
|
|
|
|
static_cast<EffectComponentAlpha*>(aEffectChain.mPrimaryEffect.get());
|
|
|
|
TextureSourceOGL* sourceOnWhite = effectComponentAlpha->mOnWhite->AsSourceOGL();
|
|
|
|
TextureSourceOGL* sourceOnBlack = effectComponentAlpha->mOnBlack->AsSourceOGL();
|
|
|
|
|
|
|
|
if (!sourceOnBlack->IsValid() ||
|
|
|
|
!sourceOnWhite->IsValid()) {
|
|
|
|
NS_WARNING("Invalid layer texture for component alpha");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-13 04:37:17 +04:00
|
|
|
sourceOnBlack->BindTexture(LOCAL_GL_TEXTURE0, effectComponentAlpha->mFilter);
|
|
|
|
sourceOnWhite->BindTexture(LOCAL_GL_TEXTURE1, effectComponentAlpha->mFilter);
|
2013-11-01 17:29:20 +04:00
|
|
|
|
2013-11-08 10:22:05 +04:00
|
|
|
program->SetBlackTextureUnit(0);
|
|
|
|
program->SetWhiteTextureUnit(1);
|
2014-05-22 14:29:56 +04:00
|
|
|
program->SetTextureTransform(Matrix4x4());
|
2013-11-08 10:22:05 +04:00
|
|
|
|
2014-04-26 06:34:06 +04:00
|
|
|
if (maskType != MaskType::MaskNone) {
|
2013-11-08 10:22:05 +04:00
|
|
|
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE2, maskQuadTransform);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
2013-11-08 10:22:05 +04:00
|
|
|
// Pass 1.
|
|
|
|
gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_ONE_MINUS_SRC_COLOR,
|
|
|
|
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
|
|
|
program->SetTexturePass2(false);
|
|
|
|
BindAndDrawQuadWithTextureRect(program,
|
2014-05-22 01:36:56 +04:00
|
|
|
aRect,
|
2013-11-08 10:22:05 +04:00
|
|
|
effectComponentAlpha->mTextureCoords,
|
|
|
|
effectComponentAlpha->mOnBlack);
|
|
|
|
|
|
|
|
// Pass 2.
|
|
|
|
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE,
|
|
|
|
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
|
|
|
program->SetTexturePass2(true);
|
|
|
|
BindAndDrawQuadWithTextureRect(program,
|
2014-05-22 01:36:56 +04:00
|
|
|
aRect,
|
2013-11-08 10:22:05 +04:00
|
|
|
effectComponentAlpha->mTextureCoords,
|
|
|
|
effectComponentAlpha->mOnBlack);
|
|
|
|
|
|
|
|
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
|
|
|
|
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false, "Unhandled effect type");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-05-09 14:06:18 +04:00
|
|
|
if (didSetBlendMode) {
|
|
|
|
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
|
|
|
|
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
// in case rendering has used some other GL context
|
|
|
|
MakeCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::EndFrame()
|
|
|
|
{
|
2014-05-24 01:12:29 +04:00
|
|
|
PROFILER_LABEL("CompositorOGL", "EndFrame",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
MOZ_ASSERT(mCurrentRenderTarget == mWindowRenderTarget, "Rendering target not properly restored");
|
|
|
|
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
if (gfxUtils::sDumpPainting) {
|
|
|
|
nsIntRect rect;
|
2013-04-30 07:16:04 +04:00
|
|
|
if (mUseExternalSurfaceSize) {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
rect = nsIntRect(0, 0, mSurfaceSize.width, mSurfaceSize.height);
|
|
|
|
} else {
|
|
|
|
mWidget->GetBounds(rect);
|
|
|
|
}
|
2014-01-10 23:06:16 +04:00
|
|
|
RefPtr<DrawTarget> target = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(rect.width, rect.height), SurfaceFormat::B8G8R8A8);
|
2014-05-28 05:21:32 +04:00
|
|
|
CopyToTarget(target, nsIntPoint(), mCurrentRenderTarget->GetTransform());
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2013-09-27 04:37:19 +04:00
|
|
|
WriteSnapshotToDumpFile(this, target);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mFrameInProgress = false;
|
|
|
|
|
2013-11-29 08:11:49 +04:00
|
|
|
LayerScope::EndFrame(mGLContext);
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
if (mTarget) {
|
2014-05-28 05:21:32 +04:00
|
|
|
CopyToTarget(mTarget, mTargetBounds.TopLeft(), mCurrentRenderTarget->GetTransform());
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
|
|
|
|
mCurrentRenderTarget = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mCurrentRenderTarget = nullptr;
|
|
|
|
|
2014-03-12 20:28:47 +04:00
|
|
|
if (mTexturePool) {
|
|
|
|
mTexturePool->EndFrame();
|
2014-03-08 01:34:04 +04:00
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
mGLContext->SwapBuffers();
|
|
|
|
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
|
2014-03-13 04:37:17 +04:00
|
|
|
|
|
|
|
// Unbind all textures
|
|
|
|
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
|
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, 0);
|
2014-03-31 13:10:49 +04:00
|
|
|
if (!mGLContext->IsGLES()) {
|
2014-03-26 22:23:44 +04:00
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
|
|
|
|
}
|
|
|
|
|
2014-03-13 04:37:17 +04:00
|
|
|
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE1);
|
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, 0);
|
2014-03-31 13:10:49 +04:00
|
|
|
if (!mGLContext->IsGLES()) {
|
2014-03-26 22:23:44 +04:00
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
|
|
|
|
}
|
|
|
|
|
2014-03-13 04:37:17 +04:00
|
|
|
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE2);
|
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, 0);
|
2014-03-31 13:10:49 +04:00
|
|
|
if (!mGLContext->IsGLES()) {
|
2014-03-26 22:23:44 +04:00
|
|
|
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
2014-03-18 05:36:56 +04:00
|
|
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
|
|
|
void
|
|
|
|
CompositorOGL::SetFBAcquireFence(Layer* aLayer)
|
|
|
|
{
|
2014-03-27 05:01:15 +04:00
|
|
|
// OpenGL does not provide ReleaseFence for rendering.
|
|
|
|
// Instead use FBAcquireFence as layer buffer's ReleaseFence
|
|
|
|
// to prevent flickering and tearing.
|
|
|
|
// FBAcquireFence is FramebufferSurface's AcquireFence.
|
|
|
|
// AcquireFence will be signaled when a buffer's content is available.
|
|
|
|
// See Bug 974152.
|
|
|
|
|
2014-03-18 05:36:56 +04:00
|
|
|
if (!aLayer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsIntRegion& visibleRegion = aLayer->GetEffectiveVisibleRegion();
|
|
|
|
if (visibleRegion.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-27 05:01:15 +04:00
|
|
|
// Set FBAcquireFence on ContainerLayer's childs
|
2014-03-18 05:36:56 +04:00
|
|
|
ContainerLayer* container = aLayer->AsContainerLayer();
|
|
|
|
if (container) {
|
|
|
|
for (Layer* child = container->GetFirstChild(); child; child = child->GetNextSibling()) {
|
|
|
|
SetFBAcquireFence(child);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-27 05:01:15 +04:00
|
|
|
// Set FBAcquireFence as tiles' ReleaseFence on TiledLayerComposer.
|
|
|
|
TiledLayerComposer* composer = nullptr;
|
|
|
|
LayerComposite* shadow = aLayer->AsLayerComposite();
|
|
|
|
if (shadow) {
|
|
|
|
composer = shadow->GetTiledLayerComposer();
|
|
|
|
if (composer) {
|
|
|
|
composer->SetReleaseFence(new android::Fence(GetGonkDisplay()->GetPrevFBAcquireFd()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set FBAcquireFence as layer buffer's ReleaseFence
|
2014-03-18 05:36:56 +04:00
|
|
|
LayerRenderState state = aLayer->GetRenderState();
|
|
|
|
if (!state.mTexture) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TextureHostOGL* texture = state.mTexture->AsHostOGL();
|
|
|
|
if (!texture) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
texture->SetReleaseFence(new android::Fence(GetGonkDisplay()->GetPrevFBAcquireFd()));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void
|
|
|
|
CompositorOGL::SetFBAcquireFence(Layer* aLayer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
void
|
2014-01-16 11:22:19 +04:00
|
|
|
CompositorOGL::EndFrameForExternalComposition(const gfx::Matrix& aTransform)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
|
|
|
// This lets us reftest and screenshot content rendered externally
|
|
|
|
if (mTarget) {
|
|
|
|
MakeCurrent();
|
2014-05-28 05:21:32 +04:00
|
|
|
CopyToTarget(mTarget, mTargetBounds.TopLeft(), aTransform);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
|
|
|
|
}
|
2014-03-25 20:14:48 +04:00
|
|
|
if (mTexturePool) {
|
|
|
|
mTexturePool->EndFrame();
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::AbortFrame()
|
|
|
|
{
|
|
|
|
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
|
|
|
|
mFrameInProgress = false;
|
|
|
|
mCurrentRenderTarget = nullptr;
|
2014-03-26 19:56:30 +04:00
|
|
|
|
|
|
|
if (mTexturePool) {
|
|
|
|
mTexturePool->EndFrame();
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::SetDestinationSurfaceSize(const gfx::IntSize& aSize)
|
|
|
|
{
|
|
|
|
mSurfaceSize.width = aSize.width;
|
|
|
|
mSurfaceSize.height = aSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-28 05:21:32 +04:00
|
|
|
CompositorOGL::CopyToTarget(DrawTarget* aTarget, const nsIntPoint& aTopLeft, const gfx::Matrix& aTransform)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2013-09-27 04:37:19 +04:00
|
|
|
IntRect rect;
|
2013-04-30 07:16:04 +04:00
|
|
|
if (mUseExternalSurfaceSize) {
|
2013-09-27 04:37:19 +04:00
|
|
|
rect = IntRect(0, 0, mSurfaceSize.width, mSurfaceSize.height);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
} else {
|
2013-09-27 04:37:19 +04:00
|
|
|
rect = IntRect(0, 0, mWidgetSize.width, mWidgetSize.height);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
GLint width = rect.width;
|
|
|
|
GLint height = rect.height;
|
|
|
|
|
2013-10-20 11:25:20 +04:00
|
|
|
if ((int64_t(width) * int64_t(height) * int64_t(4)) > INT32_MAX) {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
NS_ERROR("Widget size too big - integer overflow!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
|
|
|
|
|
2014-03-31 13:10:49 +04:00
|
|
|
if (!mGLContext->IsGLES()) {
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
// GLES2 promises that binding to any custom FBO will attach
|
|
|
|
// to GL_COLOR_ATTACHMENT0 attachment point.
|
|
|
|
mGLContext->fReadBuffer(LOCAL_GL_BACK);
|
|
|
|
}
|
|
|
|
|
2014-01-02 19:17:29 +04:00
|
|
|
RefPtr<DataSourceSurface> source =
|
2014-01-10 23:06:16 +04:00
|
|
|
Factory::CreateDataSourceSurface(rect.Size(), gfx::SurfaceFormat::B8G8R8A8);
|
2014-06-17 03:47:28 +04:00
|
|
|
if (!source) {
|
|
|
|
NS_WARNING("Failed to create SourceSurface.");
|
|
|
|
return;
|
|
|
|
}
|
2014-01-16 16:17:23 +04:00
|
|
|
|
2014-04-29 03:26:54 +04:00
|
|
|
ReadPixelsIntoDataSurface(mGLContext, source);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
// Map from GL space to Cairo space and reverse the world transform.
|
2014-01-28 00:25:21 +04:00
|
|
|
Matrix glToCairoTransform = aTransform;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
glToCairoTransform.Invert();
|
|
|
|
glToCairoTransform.Scale(1.0, -1.0);
|
2013-09-27 04:37:19 +04:00
|
|
|
glToCairoTransform.Translate(0.0, -height);
|
|
|
|
|
2014-05-28 05:21:32 +04:00
|
|
|
glToCairoTransform.PostTranslate(-aTopLeft.x, -aTopLeft.y);
|
|
|
|
|
2013-09-27 04:37:19 +04:00
|
|
|
Matrix oldMatrix = aTarget->GetTransform();
|
|
|
|
aTarget->SetTransform(glToCairoTransform);
|
|
|
|
Rect floatRect = Rect(rect.x, rect.y, rect.width, rect.height);
|
2014-01-10 23:06:17 +04:00
|
|
|
aTarget->DrawSurface(source, floatRect, floatRect, DrawSurfaceOptions(), DrawOptions(1.0f, CompositionOp::OP_SOURCE));
|
2013-09-27 04:37:19 +04:00
|
|
|
aTarget->SetTransform(oldMatrix);
|
|
|
|
aTarget->Flush();
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::Pause()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2014-01-22 02:45:35 +04:00
|
|
|
if (!gl() || gl()->IsDestroyed())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// ReleaseSurface internally calls MakeCurrent.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
gl()->ReleaseSurface();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CompositorOGL::Resume()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2014-01-22 02:45:35 +04:00
|
|
|
if (!gl() || gl()->IsDestroyed())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// RenewSurface internally calls MakeCurrent.
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
return gl()->RenewSurface();
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
TemporaryRef<DataTextureSource>
|
|
|
|
CompositorOGL::CreateDataTextureSource(TextureFlags aFlags)
|
|
|
|
{
|
|
|
|
RefPtr<DataTextureSource> result =
|
2014-01-07 20:20:11 +04:00
|
|
|
new TextureImageTextureSourceOGL(mGLContext, aFlags);
|
2013-07-30 13:59:51 +04:00
|
|
|
return result;
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
bool
|
|
|
|
CompositorOGL::SupportsPartialTextureUpdate()
|
|
|
|
{
|
2013-12-03 22:44:38 +04:00
|
|
|
return CanUploadSubTextures(mGLContext);
|
2013-09-04 16:14:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
CompositorOGL::GetMaxTextureSize() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mGLContext);
|
|
|
|
GLint texSize = 0;
|
|
|
|
mGLContext->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE,
|
|
|
|
&texSize);
|
|
|
|
MOZ_ASSERT(texSize != 0);
|
|
|
|
return texSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositorOGL::MakeCurrent(MakeCurrentFlags aFlags) {
|
|
|
|
if (mDestroyed) {
|
|
|
|
NS_WARNING("Call on destroyed layer manager");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mGLContext->MakeCurrent(aFlags & ForceMakeCurrent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-28 18:15:31 +04:00
|
|
|
CompositorOGL::BindAndDrawQuads(ShaderProgramOGL *aProg,
|
|
|
|
int aQuads,
|
|
|
|
const Rect* aLayerRects,
|
|
|
|
const Rect* aTextureRects)
|
2013-09-04 16:14:52 +04:00
|
|
|
{
|
2014-05-22 01:26:38 +04:00
|
|
|
NS_ASSERTION(aProg->HasInitialized(), "Shader program not correctly initialized");
|
|
|
|
|
2014-06-02 00:16:44 +04:00
|
|
|
const GLuint coordAttribIndex = 0;
|
|
|
|
|
|
|
|
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mQuadVBO);
|
|
|
|
mGLContext->fVertexAttribPointer(coordAttribIndex, 4,
|
|
|
|
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
|
|
|
(GLvoid*) 0);
|
|
|
|
mGLContext->fEnableVertexAttribArray(coordAttribIndex);
|
|
|
|
|
2014-05-29 18:19:37 +04:00
|
|
|
aProg->SetLayerRects(aLayerRects);
|
|
|
|
if (aProg->GetTextureCount() > 0) {
|
2014-05-28 18:15:31 +04:00
|
|
|
aProg->SetTextureRects(aTextureRects);
|
2013-09-04 16:14:52 +04:00
|
|
|
}
|
|
|
|
|
2014-05-31 06:34:14 +04:00
|
|
|
// We are using GL_TRIANGLES here because the Mac Intel drivers fail to properly
|
|
|
|
// process uniform arrays with GL_TRIANGLE_STRIP. Go figure.
|
|
|
|
mGLContext->fDrawArrays(LOCAL_GL_TRIANGLES, 0, 6 * aQuads);
|
2013-09-04 16:14:52 +04:00
|
|
|
}
|
|
|
|
|
2014-03-12 20:28:47 +04:00
|
|
|
GLuint
|
2014-03-21 16:54:13 +04:00
|
|
|
CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit)
|
2014-03-12 20:28:47 +04:00
|
|
|
{
|
|
|
|
if (!mTexturePool) {
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
mTexturePool = new PerFrameTexturePoolOGL(gl());
|
|
|
|
#else
|
|
|
|
mTexturePool = new PerUnitTexturePoolOGL(gl());
|
|
|
|
#endif
|
|
|
|
}
|
2014-03-21 16:54:13 +04:00
|
|
|
return mTexturePool->GetTexture(aTarget, aUnit);
|
2014-03-12 20:28:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GLuint
|
2014-03-21 16:54:13 +04:00
|
|
|
PerUnitTexturePoolOGL::GetTexture(GLenum aTarget, GLenum aTextureUnit)
|
2014-03-12 20:28:47 +04:00
|
|
|
{
|
2014-03-21 16:54:13 +04:00
|
|
|
if (mTextureTarget == 0) {
|
|
|
|
mTextureTarget = aTarget;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mTextureTarget == aTarget);
|
|
|
|
|
2014-03-12 20:28:47 +04:00
|
|
|
size_t index = aTextureUnit - LOCAL_GL_TEXTURE0;
|
|
|
|
// lazily grow the array of temporary textures
|
|
|
|
if (mTextures.Length() <= index) {
|
|
|
|
size_t prevLength = mTextures.Length();
|
|
|
|
mTextures.SetLength(index + 1);
|
|
|
|
for(unsigned int i = prevLength; i <= index; ++i) {
|
|
|
|
mTextures[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// lazily initialize the temporary textures
|
|
|
|
if (!mTextures[index]) {
|
|
|
|
if (!mGL->MakeCurrent()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
mGL->fGenTextures(1, &mTextures[index]);
|
2014-03-21 16:54:13 +04:00
|
|
|
mGL->fBindTexture(aTarget, mTextures[index]);
|
|
|
|
mGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
mGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
2014-03-12 20:28:47 +04:00
|
|
|
}
|
|
|
|
return mTextures[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PerUnitTexturePoolOGL::DestroyTextures()
|
|
|
|
{
|
|
|
|
if (mGL && mGL->MakeCurrent()) {
|
|
|
|
if (mTextures.Length() > 0) {
|
|
|
|
mGL->fDeleteTextures(mTextures.Length(), &mTextures[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mTextures.SetLength(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PerFrameTexturePoolOGL::DestroyTextures()
|
|
|
|
{
|
|
|
|
if (!mGL->MakeCurrent()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mUnusedTextures.Length() > 0) {
|
|
|
|
mGL->fDeleteTextures(mUnusedTextures.Length(), &mUnusedTextures[0]);
|
|
|
|
mUnusedTextures.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mCreatedTextures.Length() > 0) {
|
|
|
|
mGL->fDeleteTextures(mCreatedTextures.Length(), &mCreatedTextures[0]);
|
|
|
|
mCreatedTextures.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint
|
2014-03-21 16:54:13 +04:00
|
|
|
PerFrameTexturePoolOGL::GetTexture(GLenum aTarget, GLenum)
|
2014-03-12 20:28:47 +04:00
|
|
|
{
|
2014-03-21 16:54:13 +04:00
|
|
|
if (mTextureTarget == 0) {
|
|
|
|
mTextureTarget = aTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The pool should always use the same texture target because it is illegal
|
|
|
|
// to change the target of an already exisiting gl texture.
|
|
|
|
// If we need to use several targets, a pool with several sub-pools (one per
|
|
|
|
// target) will have to be implemented.
|
|
|
|
// At the moment this pool is only used with tiling on b2g so we always need
|
|
|
|
// the same target.
|
|
|
|
MOZ_ASSERT(mTextureTarget == aTarget);
|
|
|
|
|
2014-03-12 20:28:47 +04:00
|
|
|
GLuint texture = 0;
|
|
|
|
|
|
|
|
if (!mUnusedTextures.IsEmpty()) {
|
|
|
|
// Try to reuse one from the unused pile first
|
|
|
|
texture = mUnusedTextures[0];
|
|
|
|
mUnusedTextures.RemoveElementAt(0);
|
|
|
|
} else if (mGL->MakeCurrent()) {
|
|
|
|
// There isn't one to reuse, create one.
|
|
|
|
mGL->fGenTextures(1, &texture);
|
2014-03-21 16:54:13 +04:00
|
|
|
mGL->fBindTexture(aTarget, texture);
|
|
|
|
mGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
mGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
|
2014-03-12 20:28:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (texture) {
|
|
|
|
mCreatedTextures.AppendElement(texture);
|
|
|
|
}
|
|
|
|
|
|
|
|
return texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PerFrameTexturePoolOGL::EndFrame()
|
|
|
|
{
|
|
|
|
if (!mGL->MakeCurrent()) {
|
|
|
|
// this means the context got destroyed underneith us somehow, and the driver
|
|
|
|
// already has destroyed the textures.
|
|
|
|
mCreatedTextures.Clear();
|
|
|
|
mUnusedTextures.Clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some platforms have issues unlocking Gralloc buffers even when they're
|
|
|
|
// rebound.
|
|
|
|
if (gfxPrefs::OverzealousGrallocUnlocking()) {
|
|
|
|
mUnusedTextures.AppendElements(mCreatedTextures);
|
|
|
|
mCreatedTextures.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete unused textures
|
|
|
|
for (size_t i = 0; i < mUnusedTextures.Length(); i++) {
|
|
|
|
GLuint texture = mUnusedTextures[i];
|
|
|
|
mGL->fDeleteTextures(1, &texture);
|
|
|
|
}
|
|
|
|
mUnusedTextures.Clear();
|
|
|
|
|
|
|
|
// Move all created textures into the unused pile
|
|
|
|
mUnusedTextures.AppendElements(mCreatedTextures);
|
|
|
|
mCreatedTextures.Clear();
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
} /* layers */
|
|
|
|
} /* mozilla */
|